sampling distribution of the mean

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

sampling distribution of the mean

Salbod
I'm looking for a class demonstration of the sampling distribution of the mean.

I thought I ran across this some time back. But when I checked the list I couldn't find it.

I have a population of 20 heights. I want to randomly select with replacement four heights and compute their mean. I want to do this a 1000 times. At the end I want a file with 1000 means.

Any help or suggestions will be greatly appreciated.

TIA, Steve (Pace University, NYC)

 
Reply | Threaded
Open this post in threaded view
|

Re: sampling distribution of the mean

David Marso
Administrator

Here is a QAD I wrote in 5 minutes ;-)
--
DATA LIST FREE / X.
BEGIN DATA
1 2 4 3 7 6 8 7 9 6 5 4 5
END DATA.
SET MXLOOPS=100000000.

MATRIX.
GET DATA /VARIABLES x.
COMPUTE means=MAKE(1000,1,0).
COMPUTE N=NROW(data).
LOOP #=1 TO 1000.
+  LOOP i=1 TO 4.
+    COMPUTE means(#,1)=Means(#,1) + data((TRUNC(UNIFORM(1,1)*N)+1),1).
+  END LOOP.
END LOOP.
COMPUTE Means=Means/4.
SAVE Means / OUTFILE */VARIABLES=Mean.


END MATRIX.
Salbod wrote
I'm looking for a class demonstration of the sampling distribution of the mean.

I thought I ran across this some time back. But when I checked the list I couldn't find it.

I have a population of 20 heights. I want to randomly select with replacement four heights and compute their mean. I want to do this a 1000 times. At the end I want a file with 1000 means.

Any help or suggestions will be greatly appreciated.

TIA, Steve (Pace University, NYC)
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?"
Reply | Threaded
Open this post in threaded view
|

Re: sampling distribution of the mean

Salbod
David, THANK YOU.

I will definitely put this in the vault.

I now understand why I couldn't solve it with plain syntax. Your solution is neat and informative.

Warm regards, Steve  

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Thursday, February 25, 2016 11:57 PM
To: [hidden email]
Subject: Re: sampling distribution of the mean

Here is a QAD I wrote in 5 minutes ;-)
--
DATA LIST FREE / X.
BEGIN DATA
1 2 4 3 7 6 8 7 9 6 5 4 5
END DATA.
SET MXLOOPS=100000000.

MATRIX.
GET DATA /VARIABLES x.
COMPUTE means=MAKE(1000,1,0).
COMPUTE N=NROW(data).
LOOP #=1 TO 1000.
+  LOOP i=1 TO 4.
+    COMPUTE means(#,1)=Means(#,1) + data((TRUNC(UNIFORM(1,1)*N)+1),1).
+  END LOOP.
END LOOP.
COMPUTE Means=Means/4.
SAVE Means / OUTFILE */VARIABLES=Mean.


END MATRIX.
Salbod wrote

> I'm looking for a class demonstration of the sampling distribution of
> the mean.
>
> I thought I ran across this some time back. But when I checked the
> list I couldn't find it.
>
> I have a population of 20 heights. I want to randomly select with
> replacement four heights and compute their mean. I want to do this a
> 1000 times. At the end I want a file with 1000 means.
>
> Any help or suggestions will be greatly appreciated.
>
> TIA, Steve (Pace University, NYC)





-----
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?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/sampling-distribution-of-the-mean-tp5731618p5731619.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: sampling distribution of the mean

David Marso
Administrator
Here is a plain syntax version.  I prefer the MATRIX solution for a number of reasons (no need to flip the data, no external file, no need to hack the N ) for starters.
--
DATA LIST FREE / X.
BEGIN DATA
1 2 4 3 7 6 8 7 9 6 5 4 5
END DATA.

FLIP.
DATASET Name Source.
COMPUTE @=$SYSMIS.
COMPUTE N=NVALID(var001 TO @).
VECTOR V=var001 TO @.
LOOP Sample=1 TO 1000.
+  COMPUTE M=0.
+  LOOP #=1 TO 4.
+    COMPUTE #draw=TRUNC(RV.UNIFORM(1,N+1)).
+    COMPUTE M=M+V(#draw).
+  END LOOP.
+  COMPUTE Mean=M/4.
+  XSAVE OUTFILE 'C:\TEMP\temp.sav' / KEEP Sample Mean.
END LOOP.
EXECUTE.
GET FILE 'C:\TEMP\temp.sav' .


Salbod wrote
David, THANK YOU.

I will definitely put this in the vault.

I now understand why I couldn't solve it with plain syntax. Your solution is neat and informative.

Warm regards, Steve  

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Thursday, February 25, 2016 11:57 PM
To: [hidden email]
Subject: Re: sampling distribution of the mean

Here is a QAD I wrote in 5 minutes ;-)
--
DATA LIST FREE / X.
BEGIN DATA
1 2 4 3 7 6 8 7 9 6 5 4 5
END DATA.
SET MXLOOPS=100000000.

MATRIX.
GET DATA /VARIABLES x.
COMPUTE means=MAKE(1000,1,0).
COMPUTE N=NROW(data).
LOOP #=1 TO 1000.
+  LOOP i=1 TO 4.
+    COMPUTE means(#,1)=Means(#,1) + data((TRUNC(UNIFORM(1,1)*N)+1),1).
+  END LOOP.
END LOOP.
COMPUTE Means=Means/4.
SAVE Means / OUTFILE */VARIABLES=Mean.


END MATRIX.
Salbod wrote
> I'm looking for a class demonstration of the sampling distribution of
> the mean.
>
> I thought I ran across this some time back. But when I checked the
> list I couldn't find it.
>
> I have a population of 20 heights. I want to randomly select with
> replacement four heights and compute their mean. I want to do this a
> 1000 times. At the end I want a file with 1000 means.
>
> Any help or suggestions will be greatly appreciated.
>
> TIA, Steve (Pace University, NYC)





-----
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?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/sampling-distribution-of-the-mean-tp5731618p5731619.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
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?"