OMS/FREQUENCIES

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OMS/FREQUENCIES

Beckstead, Jason

 

Hello Listers,

I have a bit of a problem.

I am running a small Monte Carlo simulation.

I am generating samples from a bivariate normal distribtion (X,Y).

For each sample I can control the sample size and the correlation bt X & Y.

I am rescaling both X & Y to have mean of 42 and st dev of 5 in order to mimic

the distribution of human age (18yrs to 64yrs). This part works fine.

 

I am interested in calculating entropy (uncertainty) in each distribution and

the contingent uncertainty bt the distributions.

I am using OMS with the CROSSTAB command to get the likelihood ratio chi-square

which I can easily transform into contingent uncertainty, Uc = chisq/(2*LN(2)*N).

 

PROBLEM: I want to use OMS with FREQUENCIES command to get the number of times each value

is generated in each distribution from the FREQUENCIES output.

This works BUT as the range of values can be different

from sample to sample, FREQUENCIES/OMS creates a new variable for each value listed

in the output table. This means that the variable names created are not always the same from

one sample to the next. As I am appending the FREQUENCIES output from each sample as new rows

in the same destination file this is creating a problem when I try to automate the reading-in

of the destination file.

 

below is the relevant code I am using. Any help would be appreciated.

 

CD 'C:\SPSS STUFF'.

OMS/SELECT TABLES /IF COMMANDS=[' Frequencies'] SUBTYPES=[' Frequencies']

 /DESTINATION FORMAT=SAV OUTFILE='BIVAR5_1.SAV' /COLUMNS SEQUENCE=[CALL RALL LALL].

OMS/SELECT TABLES /IF COMMANDS=[' Means'] SUBTYPES=[' Report']

 /DESTINATION FORMAT=SAV OUTFILE='BIVAR5_1.SAV' /COLUMNS SEQUENCE=[CALL RALL LALL].

*-------------------------.

OMS/DESTINATION VIEWER=NO.

*-------------------------.

DEFINE !rCATS  (!POS !TOKENS(1)).

!DO !I = 1 !TO !1.

NEW FILE.

INPUT PROGRAM.

 COMPUTE SMPLE=!I.

 LOOP #i = 1 to 30       /*set sample size*/.

   COMPUTE #r    = .5    /*set correlation of X & Y*/.

   COMPUTE X     = RV.NORMAL(0,1).

   COMPUTE #Y    = RV.NORMAL(0,1).

   COMPUTE Y     = X*#r + #Y*(1-#r**2)**.5.

   END CASE.

 END LOOP.

 END FILE.

END INPUT PROGRAM.

COMPUTE X=RND(X*5 + 42)  /*rescaling X*/.

COMPUTE Y=RND(Y*5 + 42)  /*rescaling Y*/.

FORMAT X Y SMPLE (F4.0).

MEANS SMPLE/CELL=MEAN    /*used to id samples*/.

FREQUENCIES X Y.

!DOEND.

!ENDDEFINE.

*--------.

!RCATS 10  /*set number of samples generated*/.

*--------.

OMSEND.

GET FILE 'BIVAR5_1.SAV'.

IF NMISS(SMPLE_Mean)=1 SMPLE_Mean=LAG(SMPLE_Mean,1).

EXE.

 

_____________________________________________________________

 Jason W. Beckstead, Ph.D.       

  Associate Professor/Quantitative Methodologist

  University of South Florida College of Nursing

  12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.5418          

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: OMS/FREQUENCIES

kwame woei
RECODE the values INTO categories and get a FREQUENCY for each category created?


Op 16 apr. 2013 om 21:57 heeft "Beckstead, Jason" <[hidden email]> het volgende geschreven:

 

Hello Listers,

I have a bit of a problem.

I am running a small Monte Carlo simulation.

I am generating samples from a bivariate normal distribtion (X,Y).

For each sample I can control the sample size and the correlation bt X & Y.

I am rescaling both X & Y to have mean of 42 and st dev of 5 in order to mimic

the distribution of human age (18yrs to 64yrs). This part works fine.

 

I am interested in calculating entropy (uncertainty) in each distribution and

the contingent uncertainty bt the distributions.

I am using OMS with the CROSSTAB command to get the likelihood ratio chi-square

which I can easily transform into contingent uncertainty, Uc = chisq/(2*LN(2)*N).

 

PROBLEM: I want to use OMS with FREQUENCIES command to get the number of times each value

is generated in each distribution from the FREQUENCIES output.

This works BUT as the range of values can be different

from sample to sample, FREQUENCIES/OMS creates a new variable for each value listed

in the output table. This means that the variable names created are not always the same from

one sample to the next. As I am appending the FREQUENCIES output from each sample as new rows

in the same destination file this is creating a problem when I try to automate the reading-in

of the destination file.

 

below is the relevant code I am using. Any help would be appreciated.

 

CD 'C:\SPSS STUFF'.

OMS/SELECT TABLES /IF COMMANDS=[' Frequencies'] SUBTYPES=[' Frequencies']

 /DESTINATION FORMAT=SAV OUTFILE='BIVAR5_1.SAV' /COLUMNS SEQUENCE=[CALL RALL LALL].

OMS/SELECT TABLES /IF COMMANDS=[' Means'] SUBTYPES=[' Report']

 /DESTINATION FORMAT=SAV OUTFILE='BIVAR5_1.SAV' /COLUMNS SEQUENCE=[CALL RALL LALL].

*-------------------------.

OMS/DESTINATION VIEWER=NO.

*-------------------------.

DEFINE !rCATS  (!POS !TOKENS(1)).

!DO !I = 1 !TO !1.

NEW FILE.

INPUT PROGRAM.

 COMPUTE SMPLE=!I.

 LOOP #i = 1 to 30       /*set sample size*/.

   COMPUTE #r    = .5    /*set correlation of X & Y*/.

   COMPUTE X     = RV.NORMAL(0,1).

   COMPUTE #Y    = RV.NORMAL(0,1).

   COMPUTE Y     = X*#r + #Y*(1-#r**2)**.5.

   END CASE.

 END LOOP.

 END FILE.

END INPUT PROGRAM.

COMPUTE X=RND(X*5 + 42)  /*rescaling X*/.

COMPUTE Y=RND(Y*5 + 42)  /*rescaling Y*/.

FORMAT X Y SMPLE (F4.0).

MEANS SMPLE/CELL=MEAN    /*used to id samples*/.

FREQUENCIES X Y.

!DOEND.

!ENDDEFINE.

*--------.

!RCATS 10  /*set number of samples generated*/.

*--------.

OMSEND.

GET FILE 'BIVAR5_1.SAV'.

IF NMISS(SMPLE_Mean)=1 SMPLE_Mean=LAG(SMPLE_Mean,1).

EXE.

 

_____________________________________________________________

 Jason W. Beckstead, Ph.D.       

  Associate Professor/Quantitative Methodologist

  University of South Florida College of Nursing

  12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.5418          

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: OMS/FREQUENCIES

David Marso
Administrator
"> PROBLEM: I want to use OMS with FREQUENCIES command to get the number of times each value
> is generated in each distribution from the FREQUENCIES output."
Read up on VARSTOCASES and AGGREGATE.
The approach you are presently taking is tragically flawed!

kwame woei wrote
RECODE the values INTO categories and get a FREQUENCY for each category created?


Op 16 apr. 2013 om 21:57 heeft "Beckstead, Jason" <[hidden email]> het volgende geschreven:

>  
> Hello Listers,
> I have a bit of a problem.
> I am running a small Monte Carlo simulation.
> I am generating samples from a bivariate normal distribtion (X,Y).
> For each sample I can control the sample size and the correlation bt X & Y.
> I am rescaling both X & Y to have mean of 42 and st dev of 5 in order to mimic
> the distribution of human age (18yrs to 64yrs). This part works fine.
>  
> I am interested in calculating entropy (uncertainty) in each distribution and
> the contingent uncertainty bt the distributions.
> I am using OMS with the CROSSTAB command to get the likelihood ratio chi-square
> which I can easily transform into contingent uncertainty, Uc = chisq/(2*LN(2)*N).
>  
> PROBLEM: I want to use OMS with FREQUENCIES command to get the number of times each value
> is generated in each distribution from the FREQUENCIES output.
> This works BUT as the range of values can be different
> from sample to sample, FREQUENCIES/OMS creates a new variable for each value listed
> in the output table. This means that the variable names created are not always the same from
> one sample to the next. As I am appending the FREQUENCIES output from each sample as new rows
> in the same destination file this is creating a problem when I try to automate the reading-in
> of the destination file.
>  
> below is the relevant code I am using. Any help would be appreciated.
>  
> CD 'C:\SPSS STUFF'.
> OMS/SELECT TABLES /IF COMMANDS=[' Frequencies'] SUBTYPES=[' Frequencies']
>  /DESTINATION FORMAT=SAV OUTFILE='BIVAR5_1.SAV' /COLUMNS SEQUENCE=[CALL RALL LALL].
> OMS/SELECT TABLES /IF COMMANDS=[' Means'] SUBTYPES=[' Report']
>  /DESTINATION FORMAT=SAV OUTFILE='BIVAR5_1.SAV' /COLUMNS SEQUENCE=[CALL RALL LALL].
> *-------------------------.
> OMS/DESTINATION VIEWER=NO.
> *-------------------------.
> DEFINE !rCATS  (!POS !TOKENS(1)).
> !DO !I = 1 !TO !1.
> NEW FILE.
> INPUT PROGRAM.
>  COMPUTE SMPLE=!I.
>  LOOP #i = 1 to 30       /*set sample size*/.
>    COMPUTE #r    = .5    /*set correlation of X & Y*/.
>    COMPUTE X     = RV.NORMAL(0,1).
>    COMPUTE #Y    = RV.NORMAL(0,1).
>    COMPUTE Y     = X*#r + #Y*(1-#r**2)**.5.
>    END CASE.
>  END LOOP.
>  END FILE.
> END INPUT PROGRAM.
> COMPUTE X=RND(X*5 + 42)  /*rescaling X*/.
> COMPUTE Y=RND(Y*5 + 42)  /*rescaling Y*/.
> FORMAT X Y SMPLE (F4.0).
> MEANS SMPLE/CELL=MEAN    /*used to id samples*/.
> FREQUENCIES X Y.
> !DOEND.
> !ENDDEFINE.
> *--------.
> !RCATS 10  /*set number of samples generated*/.
> *--------.
> OMSEND.
> GET FILE 'BIVAR5_1.SAV'.
> IF NMISS(SMPLE_Mean)=1 SMPLE_Mean=LAG(SMPLE_Mean,1).
> EXE.
>  
> _____________________________________________________________
>  Jason W. Beckstead, Ph.D.      
>   Associate Professor/Quantitative Methodologist
>   University of South Florida College of Nursing
>   12901 Bruce B. Downs Blvd., MDC22, Tampa, FL 33612, USA
>   Statistical Editor, International Journal of Nursing Studies
>   phone: +1.813.974.7667  fax: +1.813.974.5418          
>   personal website:  http://personal.health.usf.edu/jbeckste/
>   International Journal of Nursing Studies  http://www.elsevier.com/ijns
>  
>  
>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"