Date: Fri, 15 Jul 2011 15:10:41 -0700
Reply-To: David Marso <david.marso@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: David Marso <david.marso@gmail.com>
Subject: Re: Syntax for SAMPLE
In-Reply-To: <1310763965048-4592216.post@n5.nabble.com>
Content-Type: text/plain; charset=us-ascii
If one just wants say a mean then something like this works without creating
a large case level file.
*SIMULATE SOME DATA.
NEW FILE.
INPUT PROGRAM.
LOOP #ID=1 TO 1000.
+ COMPUTE VAR= RV.Normal(5,10).
+ END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXE.
DESC VAR.
FLIP.
VECTOR V=VAR001 TO VAR1000.
LOOP SAMPLE=1 TO 500.
+ COMPUTE MEAN=0.
+ LOOP #PULL=1 TO 100.
+ COMPUTE #=TRUNC(UNIFORM(1000)+1).
+ COMPUTE MEAN=MEAN+V(#).
+ END LOOP.
+ COMPUTE MEAN=MEAN/100.
+ XSAVE OUTFILE "BOOTTEMP.SAV" / KEEP SAMPLE MEAN.
END LOOP.
EXECUTE.
GET FILE "BOOTTEMP.SAV" .
DESC MEAN.
Bruce Weaver wrote:
>
> When I found that old post, I was looking for a quick & dirty way of
> generating bootstrap samples (with replacement), and as I recall, there
> was not much else out there. Anyway, it worked out quite well for what I
> was doing at the time. ;-)
>
>
>
>
> David Marso wrote:
>>
>> GACK Bruce!
>> That old thing???
>> It is from 1996 right about the time I bailed from SPSS TekSport and
>> transferred to the consulting group.
>> Almost 15 years to the day... How time flies!!!!!!!!!!!!!!!!
>> The SPSS-X Archives are truncated at 1996 and everything before that has
>> been bit-bucketted.
>> Hey, ever wonder what ever happened to all the gems which I posted
>> between 1992 and 1996?
>> There were some pretty twisted Rube-Goldbergesque monstrosities I
>> inflicted upon the world in those days. Self modifying SPSS code,
>> unintelligible one liners, programs to read data configured like they
>> came from the brain of H.P. Lovecraft or some other dark place (almost
>> lost my mind doing that job).
>>
>> I used to have those all on my old dead PC (HD is fine but the box is
>> dead, need to pull data some day).
>> *BUT* I think I like what I posted earlier today much more than that old
>> one.
>> Note also that what you reference does BOOTSTRAP sampling (with
>> replacement).
>> The current does sampling without replacement (slightly oversample beyond
>> the desired ratio, XSAVE cases which are 'sampled', then do the random
>> scramble and nuke the extra cases at the end).
>> Thanks for the blast from the past (I think-- cringe--)
>>
>>
>>
>> Bruce Weaver wrote:
>>>
>>> Hi John. I've sent you something off-list that you may be able to
>>> cobble into the kind of demo/tutorial you want. It uses some code
>>> written by David Marso, but posted by his then colleague David Nichols.
>>> Here's the link:
>>>
>>>
>>> http://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source
>>>
>>> HTH.
>>>
>>>
>>>
>>> John F Hall wrote:
>>>>
>>>> David
>>>>
>>>> It was just a thought, and I was only trying to help!
>>>>
>>>> I once had a similar problem when trying to introduce students to
>>>> inferential statistics. I'd have say 24 students and a survey with
>>>> 1800
>>>> cases for a lab session. Each student was asked to sample n from N
>>>> with a
>>>> different SET SEED starting point. This was in the days of 16 VDU's
>>>> connected to a remote Vax mainframe (12 working if you were lucky and
>>>> severe
>>>> time constraints if we didn't want to get locked in the building, or
>>>> get
>>>> away before the Arsenal match finished up the road) not modern PCs and
>>>> distance learning. The idea was to get 3 samples each to yield 72
>>>> statistics (mean lifesat, % happy or whatever) which we then plotted
>>>> (on the
>>>> chalk-board) hopefully to demonstrate a distribution with an
>>>> approximately
>>>> normal distribution. Sometimes it worked, sometimes it didn't (usually
>>>> because sampling 30 from 3000 isn't as stable as 300 from 3000) but the
>>>> students learned a lot from the attempt and understood what we were
>>>> trying
>>>> to do, especially that the sampling distribution of the mean was
>>>> approximately normal even if the variable itself was not (eg age)
>>>>
>>>> Now, how about some syntax to do what I need for a new tutorial for the
>>>> website?
>>>>
>>>> Assume data set is BSA89.sav, N is 3000 and I want 100 samples of size
>>>> 300:
>>>> then to save mean lifesat, mean age and % very happy (code 3 on happy)
>>>> as
>>>> variables in a separate file with 100 cases (one for each sample).
>>>>
>>>> Have a nice weekend.
>>>>
>>>> John
>>>>
>>>> johnfhall@orange.fr
>>>> www.surveyresearch.weebly.com
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf
>>>> Of
>>>> David Marso
>>>> Sent: 15 July 2011 19:33
>>>> To: SPSSX-L@LISTSERV.UGA.EDU
>>>> Subject: Re: Syntax for SAMPLE
>>>>
>>>> It makes *NO* sense at all to use SAMPLE within a DO REPEAT.
>>>> Think about that for a moment ;-)
>>>>
>>>> When you do something like
>>>> DO REPEAT X= a b c d / Y = e f g h / Z= ae be cg dh.
>>>> COMPUTE Z=X/Y.
>>>> END REPEAT.
>>>>
>>>> what do you end up with?
>>>> 4 new variables on *EACH* case...
>>>> i.e. DO REPEAT handles TRANSFORMATIONS and applies to each case.
>>>> How would SAMPLE fit into a DO REPEAT?
>>>>
>>>> --
>>>> View this message in context:
>>>> http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-SAMPLE-tp4591268p45
>>>> 91568.html
>>>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>>>
>>>> =====================
>>>> To manage your subscription to SPSSX-L, send a message to
>>>> LISTSERV@LISTSERV.UGA.EDU (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
>>>> LISTSERV@LISTSERV.UGA.EDU (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
>>>>
>>>
>>
>
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-SAMPLE-tp4591268p4592495.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
|