Sampling WITH replacement

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

Sampling WITH replacement

MariaPetsch
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
Reply | Threaded
Open this post in threaded view
|

Re: Sampling WITH replacement

David Marso
Administrator
"Like bootstrap, but bootstrap is not working for me. "
Please elaborate and provide more context regarding this request.
In particular how is it that "bootstrap is not working for me"?
What do you wish to do with the samples?
In lieu of further info I suggest you to search this group for XSAVE.

MariaPetsch wrote
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
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 WITH replacement

Bruce Weaver
Administrator
I assume Maria means she doesn't have the Bootstrapping option as part of her license.  See Help > Bootstrapping Option at the link below.

   http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp

It that's the problem, she could always use this code written by some old-timer from SPSS.  ;-)

  https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1

HTH.


David Marso wrote
"Like bootstrap, but bootstrap is not working for me. "
Please elaborate and provide more context regarding this request.
In particular how is it that "bootstrap is not working for me"?
What do you wish to do with the samples?
In lieu of further info I suggest you to search this group for XSAVE.

MariaPetsch wrote
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Sampling WITH replacement

David Marso
Administrator
Yeah, that 'old timer' code will work but it lacks a certain degree of *subtlety* ;-).
If I were to rewrite that today I would avoid explicit construction of the file, the 2 potentially huge SORTs and MATCH and just crank out the stats using MATRIX.  
OTOH:  such depends entirely upon the nature of the research question and what needs be done downstream of the sampling.
----
Bruce Weaver wrote
I assume Maria means she doesn't have the Bootstrapping option as part of her license.  See Help > Bootstrapping Option at the link below.

   http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp

It that's the problem, she could always use this code written by some old-timer from SPSS.  ;-)

  https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1

HTH.


David Marso wrote
"Like bootstrap, but bootstrap is not working for me. "
Please elaborate and provide more context regarding this request.
In particular how is it that "bootstrap is not working for me"?
What do you wish to do with the samples?
In lieu of further info I suggest you to search this group for XSAVE.

MariaPetsch wrote
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
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 WITH replacement

David Marso
Administrator
Surely the following is in a somewhat different class WRT code and efficiency.
OTOH:  It is a mere skeleton, deficient algorithm-wise and leaves a great deal to the consumer to build from.  If one has a problem rolling their own stat functions then don't pass go, don't collect $200 ..
This simply creates an array of NSAMP bootstrapped means and holds one copy of the data and NSAMP stats.
DELETE DELETE DELETE...
---
DATA LIST FREE / X.
BEGIN DATA
6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
3 67 1 3 6 7
END DATA.

DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)).
PRESERVE.
SET MXLOOPS=100000.
MATRIX.
GET DATA / VARIABLES !VAR / FILE *.
COMPUTE N=NROW(DATA).
COMPUTE Means=MAKE(!NSAMP,1,0).
LOOP SAMPLE=1 TO !NSAMP.
+  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
+  LOOP CASEID=1 TO N.
+    COMPUTE MEANS(SAMPLE)=MEANS(SAMPLE)+DATA(RARRAY(CASEID)).
+  END LOOP.
END LOOP.
COMPUTE MEANS=MEANS/N.
PRINT MEANS.
END MATRIX.
RESTORE.
!ENDDEFINE.
BOOT VAR=X NSAMP=100.
PRINT CASEID.

David Marso wrote
Yeah, that 'old timer' code will work but it lacks a certain degree of *subtlety* ;-).
If I were to rewrite that today I would avoid explicit construction of the file, the 2 potentially huge SORTs and MATCH and just crank out the stats using MATRIX.  
OTOH:  such depends entirely upon the nature of the research question and what needs be done downstream of the sampling.
----
Bruce Weaver wrote
I assume Maria means she doesn't have the Bootstrapping option as part of her license.  See Help > Bootstrapping Option at the link below.

   http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp

It that's the problem, she could always use this code written by some old-timer from SPSS.  ;-)

  https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1

HTH.


David Marso wrote
"Like bootstrap, but bootstrap is not working for me. "
Please elaborate and provide more context regarding this request.
In particular how is it that "bootstrap is not working for me"?
What do you wish to do with the samples?
In lieu of further info I suggest you to search this group for XSAVE.

MariaPetsch wrote
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
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 WITH replacement

Bruce Weaver
Administrator
No doubt, this version is more efficient.  But IMO, the "old-timer" version is easier to understand (especially for users who are not well-versed in the matrix language).  So it's the usual trade-off.  ;-)


David Marso wrote
Surely the following is in a somewhat different class WRT code and efficiency.
OTOH:  It is a mere skeleton, deficient algorithm-wise and leaves a great deal to the consumer to build from.  If one has a problem rolling their own stat functions then don't pass go, don't collect $200 ..
This simply creates an array of NSAMP bootstrapped means and holds one copy of the data and NSAMP stats.
DELETE DELETE DELETE...
---
DATA LIST FREE / X.
BEGIN DATA
6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
3 67 1 3 6 7
END DATA.

DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)).
PRESERVE.
SET MXLOOPS=100000.
MATRIX.
GET DATA / VARIABLES !VAR / FILE *.
COMPUTE N=NROW(DATA).
COMPUTE Means=MAKE(!NSAMP,1,0).
LOOP SAMPLE=1 TO !NSAMP.
+  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
+  LOOP CASEID=1 TO N.
+    COMPUTE MEANS(SAMPLE)=MEANS(SAMPLE)+DATA(RARRAY(CASEID)).
+  END LOOP.
END LOOP.
COMPUTE MEANS=MEANS/N.
PRINT MEANS.
END MATRIX.
RESTORE.
!ENDDEFINE.
BOOT VAR=X NSAMP=100.
PRINT CASEID.

David Marso wrote
Yeah, that 'old timer' code will work but it lacks a certain degree of *subtlety* ;-).
If I were to rewrite that today I would avoid explicit construction of the file, the 2 potentially huge SORTs and MATCH and just crank out the stats using MATRIX.  
OTOH:  such depends entirely upon the nature of the research question and what needs be done downstream of the sampling.
----
Bruce Weaver wrote
I assume Maria means she doesn't have the Bootstrapping option as part of her license.  See Help > Bootstrapping Option at the link below.

   http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp

It that's the problem, she could always use this code written by some old-timer from SPSS.  ;-)

  https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1

HTH.


David Marso wrote
"Like bootstrap, but bootstrap is not working for me. "
Please elaborate and provide more context regarding this request.
In particular how is it that "bootstrap is not working for me"?
What do you wish to do with the samples?
In lieu of further info I suggest you to search this group for XSAVE.

MariaPetsch wrote
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

BOOTSTRAPPING was: Sampling WITH replacement

David Marso
Administrator
Seems OP has deleted her original question without further clarification.  OTOH, seems interesting thread beginning with Bruce and myself.  Would love to see others jump in.
--
I believe the MATRIX version to be more straightforward than the brute force "old-timer" version and is a rather cool example of several powerful concepts.  If one is bootstrapping simple statistics it is straightforward to adapt the code to implement them (see below).  
MATRIX language.
MACROS with arguments.
RollYourOwnStats
--
For example I have modified the MACRO to bootstrap the SD and Median.  
Maybe later I'll add correlations and OLS regression and capacity to SAVE the sample
statistics for further use.
Any other suggestions?
----
DATA LIST FREE / X.
BEGIN DATA
6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
3 67 1 3 6 7 50 2
END DATA.
DESC X.

DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)/SPRINT !TOKENS(1) !DEFAULT(F) ).
PRESERVE.
SET MXLOOPS=100000.
FREQ X /STAT ALL/FORMAT NOT.
MATRIX.
GET DATA / VARIABLES !VAR / FILE *.
COMPUTE N=NROW(DATA).
*Determine ranks of Median case(s)*.
COMPUTE CRIT={(N/2)+.5, (N/2)+.5 }.
DO IF N/2=TRUNC(N/2).
+  COMPUTE CRIT=CRIT + {-1.5,0.5}.
END IF.

COMPUTE Stats=MAKE(!NSAMP,3,0).
COMPUTE SAMPLES=MAKE(N,1,0).
LOOP SAMPLE=1 TO !NSAMP.
* Construct array of random Indexes (Data pointers).
+  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
+  LOOP CASEID=1 TO N.
+    COMPUTE SAMPLES(CASEID)=DATA(RARRAY(CASEID)).
+  END LOOP.
** Calculate Median **.
+  COMPUTE MEDSTAT=GRADE(SAMPLES).
+  COMPUTE Stats(SAMPLE,3) =0.
+  LOOP I=1 TO N.
+    LOOP J=1 TO 2.
+      DO IF MEDSTAT(I)=CRIT(J).
+        COMPUTE Stats(SAMPLE,3) =Stats(SAMPLE,3)+SAMPLES(I).
+      END IF.
+    END LOOP.
+  END LOOP.
+  COMPUTE Stats(SAMPLE,3)=Stats(SAMPLE,3)/2.
*  Generate Sum(X) and SUM(X**2).
+  COMPUTE Stats(SAMPLE,1)=CSUM(Samples)/N.
+  COMPUTE Stats(SAMPLE,2)=T(Samples)*Samples).
END LOOP.
* Calculate StdDev *.
COMPUTE Stats(:,2)=SQRT((Stats(:,2)-N*Stats(:,1))/(N-1)).
!IF (!SPRINT !EQ T) !THEN
PRINT Stats
     /TITLE "Individual Bootstrapped Sample Statistics"
     /CLABELS "Mean","SD","Median".
!IFEND
* Calculate Averages of Bootsrapped statistics *.
PRINT (CSUM(Stats)/!NSAMP)
     /TITLE="Averaged Bootstrapped Statistics"
     /CLABELS "Mean","StdDev","Median".
END MATRIX.
!ENDDEFINE.
BOOT Var=X NSAMP=100 SPRINT=T.
BOOT Var=X NSAMP=1000.
Bruce Weaver wrote
No doubt, this version is more efficient.  But IMO, the "old-timer" version is easier to understand (especially for users who are not well-versed in the matrix language).  So it's the usual trade-off.  ;-)


David Marso wrote
Surely the following is in a somewhat different class WRT code and efficiency.
OTOH:  It is a mere skeleton, deficient algorithm-wise and leaves a great deal to the consumer to build from.  If one has a problem rolling their own stat functions then don't pass go, don't collect $200 ..
This simply creates an array of NSAMP bootstrapped means and holds one copy of the data and NSAMP stats.
DELETE DELETE DELETE...
---
DATA LIST FREE / X.
BEGIN DATA
6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
3 67 1 3 6 7
END DATA.

DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)).
PRESERVE.
SET MXLOOPS=100000.
MATRIX.
GET DATA / VARIABLES !VAR / FILE *.
COMPUTE N=NROW(DATA).
COMPUTE Means=MAKE(!NSAMP,1,0).
LOOP SAMPLE=1 TO !NSAMP.
+  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
+  LOOP CASEID=1 TO N.
+    COMPUTE MEANS(SAMPLE)=MEANS(SAMPLE)+DATA(RARRAY(CASEID)).
+  END LOOP.
END LOOP.
COMPUTE MEANS=MEANS/N.
PRINT MEANS.
END MATRIX.
RESTORE.
!ENDDEFINE.
BOOT VAR=X NSAMP=100.
PRINT CASEID.

David Marso wrote
Yeah, that 'old timer' code will work but it lacks a certain degree of *subtlety* ;-).
If I were to rewrite that today I would avoid explicit construction of the file, the 2 potentially huge SORTs and MATCH and just crank out the stats using MATRIX.  
OTOH:  such depends entirely upon the nature of the research question and what needs be done downstream of the sampling.
----
Bruce Weaver wrote
I assume Maria means she doesn't have the Bootstrapping option as part of her license.  See Help > Bootstrapping Option at the link below.

   http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp

It that's the problem, she could always use this code written by some old-timer from SPSS.  ;-)

  https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1

HTH.


David Marso wrote
"Like bootstrap, but bootstrap is not working for me. "
Please elaborate and provide more context regarding this request.
In particular how is it that "bootstrap is not working for me"?
What do you wish to do with the samples?
In lieu of further info I suggest you to search this group for XSAVE.

MariaPetsch wrote
Hi! I really need help! How can I do sampling with replacement in spss? Like bootstrap, but bootstrap is not working for me.
Thanks for the help!
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: BOOTSTRAPPING was: Sampling WITH replacement

Jon K Peck
Besides the built-in bootstrapping option in Statistics, there is a Python module, BootstrapTool, available in the Python Modules Collection on the SPSS Community site (www.ibm.com/developerworks/spssdevcentral).  Here's the description:

The bootstrap_object.py module will allow any SPSS commands to be bootstrapped, and will produce Bias-Corrected and Accelerated Confidence Intervals.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        David Marso <[hidden email]>
To:        [hidden email]
Date:        04/05/2012 09:43 AM
Subject:        [SPSSX-L] BOOTSTRAPPING was: Sampling WITH replacement
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Seems OP has deleted her original question without further clarification.
OTOH, seems interesting thread beginning with Bruce and myself.  Would love
to see others jump in.
--
I believe the MATRIX version to be more straightforward than the brute force
"old-timer" version and is a rather cool example of several powerful
concepts.  If one is bootstrapping simple statistics it is straightforward
to adapt the code to implement them (see below).
MATRIX language.
MACROS with arguments.
RollYourOwnStats
--
For example I have modified the MACRO to bootstrap the SD and Median.
Maybe later I'll add correlations and OLS regression and capacity to SAVE
the sample
statistics for further use.
Any other suggestions?
----
DATA LIST FREE / X.
BEGIN DATA
6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
3 67 1 3 6 7 50 2
END DATA.
DESC X.

DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)/SPRINT !TOKENS(1) !DEFAULT(F)
).
PRESERVE.
SET MXLOOPS=100000.
FREQ X /STAT ALL/FORMAT NOT.
MATRIX.
GET DATA / VARIABLES !VAR / FILE *.
COMPUTE N=NROW(DATA).
*Determine ranks of Median case(s)*.
COMPUTE CRIT={(N/2)+.5, (N/2)+.5 }.
DO IF N/2=TRUNC(N/2).
+  COMPUTE CRIT=CRIT + {-1.5,0.5}.
END IF.

COMPUTE Stats=MAKE(!NSAMP,3,0).
COMPUTE SAMPLES=MAKE(N,1,0).
LOOP SAMPLE=1 TO !NSAMP.
* Construct array of random Indexes (Data pointers).
+  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
+  LOOP CASEID=1 TO N.
+    COMPUTE SAMPLES(CASEID)=DATA(RARRAY(CASEID)).
+  END LOOP.
** Calculate Median **.
+  COMPUTE MEDSTAT=GRADE(SAMPLES).
+  COMPUTE Stats(SAMPLE,3) =0.
+  LOOP I=1 TO N.
+    LOOP J=1 TO 2.
+      DO IF MEDSTAT(I)=CRIT(J).
+        COMPUTE Stats(SAMPLE,3) =Stats(SAMPLE,3)+SAMPLES(I).
+      END IF.
+    END LOOP.
+  END LOOP.
+  COMPUTE Stats(SAMPLE,3)=Stats(SAMPLE,3)/2.
*  Generate Sum(X) and SUM(X**2).
+  COMPUTE Stats(SAMPLE,1)=CSUM(Samples)/N.
+  COMPUTE Stats(SAMPLE,2)=T(Samples)*Samples).
END LOOP.
* Calculate StdDev *.
COMPUTE Stats(:,2)=SQRT((Stats(:,2)-N*Stats(:,1))/(N-1)).
!IF (!SPRINT !EQ T) !THEN
PRINT Stats
    /TITLE "Individual Bootstrapped Sample Statistics"
    /CLABELS "Mean","SD","Median".
!IFEND
* Calculate Averages of Bootsrapped statistics *.
PRINT (CSUM(Stats)/!NSAMP)
    /TITLE="Averaged Bootstrapped Statistics"
    /CLABELS "Mean","StdDev","Median".
END MATRIX.
!ENDDEFINE.
BOOT Var=X NSAMP=100 SPRINT=T.
BOOT Var=X NSAMP=1000.

Bruce Weaver wrote
>
> No doubt, this version is more efficient.  But IMO, the "old-timer"
> version is easier to understand (especially for users who are not
> well-versed in the matrix language).  So it's the usual trade-off.  ;-)
>
>
>
> David Marso wrote
>>
>> Surely the following is in a somewhat different class WRT code and
>> efficiency.
>> OTOH:  It is a mere skeleton, deficient algorithm-wise and leaves a great
>> deal to the consumer to build from.  If one has a problem rolling their
>> own stat functions then don't pass go, don't collect $200 ..
>> This simply creates an array of NSAMP bootstrapped means and holds one
>> copy of the data and NSAMP stats.
>> DELETE DELETE DELETE...
>> ---
>> DATA LIST FREE / X.
>> BEGIN DATA
>> 6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
>> 3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
>> 3 67 1 3 6 7
>> END DATA.
>>
>> DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)).
>> PRESERVE.
>> SET MXLOOPS=100000.
>> MATRIX.
>> GET DATA / VARIABLES !VAR / FILE *.
>> COMPUTE N=NROW(DATA).
>> COMPUTE Means=MAKE(!NSAMP,1,0).
>> LOOP SAMPLE=1 TO !NSAMP.
>> +  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
>> +  LOOP CASEID=1 TO N.
>> +    COMPUTE MEANS(SAMPLE)=MEANS(SAMPLE)+DATA(RARRAY(CASEID)).
>> +  END LOOP.
>> END LOOP.
>> COMPUTE MEANS=MEANS/N.
>> PRINT MEANS.
>> END MATRIX.
>> RESTORE.
>> !ENDDEFINE.
>> BOOT VAR=X NSAMP=100.
>> PRINT CASEID.
>>
>>
>> David Marso wrote
>>>
>>> Yeah, that 'old timer' code will work but it lacks a certain degree of
>>> *subtlety* ;-).
>>> If I were to rewrite that today I would avoid explicit construction of
>>> the file, the 2 potentially huge SORTs and MATCH and just crank out the
>>> stats using MATRIX.
>>> OTOH:  such depends entirely upon the nature of the research question
>>> and what needs be done downstream of the sampling.
>>> ----
>>>
>>> Bruce Weaver wrote
>>>>
>>>> I assume Maria means she doesn't have the Bootstrapping option as part
>>>> of her license.  See Help > Bootstrapping Option at the link below.
>>>>
>>>>    
http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp
>>>>
>>>> It that's the problem, she could always use this code written by some
>>>> old-timer from SPSS.  ;-)
>>>>
>>>>
>>>>
https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1
>>>>
>>>> HTH.
>>>>
>>>>
>>>>
>>>> David Marso wrote
>>>>>
>>>>> "Like bootstrap, but bootstrap is not working for me. "
>>>>> Please elaborate and provide more context regarding this request.
>>>>> In particular how is it that "bootstrap is not working for me"?
>>>>> What do you wish to do with the samples?
>>>>> In lieu of further info I suggest you to search this group for XSAVE.
>>>>>
>>>>>
>>>>> MariaPetsch wrote
>>>>>>
>>>>>> Hi! I really need help! How can I do *sampling with replacement* in
>>>>>> spss? Like bootstrap, but bootstrap is not working for me.
>>>>>> Thanks for the help!
>>>>>>
>>>>>
>>>>
>>>
>>
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Sampling-WITH-replacement-tp5618318p5620719.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


Reply | Threaded
Open this post in threaded view
|

Re: BOOTSTRAPPING was: Sampling WITH replacement

David Marso
Administrator
Jon,
  It would be helpful if you were to post direct links to anything you wish anyone to be able to find.
The IBM site is such a flustercluck that it took me about 10 minutes to locate the resource you were referring to.
https://www.ibm.com/developerworks/mydeveloperworks/files/app/person/270002VCWN/file/341a7ede-6a08-4ea4-a31e-070279f9cae6
"bootstrap_object.py module will allow any SPSS commands to be bootstrapped".
WOW!  How are the sales reps EVER going to be able to talk ANYONE into buying the Bootstrap Option.  Sounds like it is now obsolete!  Anyway, my version doesn't support Python and I can do just about *ANYTHING* I need to do with MATRIX and my code will probably run a lot faster!!!

Jon K Peck wrote
Besides the built-in bootstrapping option in Statistics, there is a Python
module, BootstrapTool, available in the Python Modules Collection on the
SPSS Community site (www.ibm.com/developerworks/spssdevcentral).  Here's
the description:

The bootstrap_object.py module will allow any SPSS commands to be
bootstrapped, and will produce Bias-Corrected and Accelerated Confidence
Intervals.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:   David Marso <[hidden email]>
To:     [hidden email]
Date:   04/05/2012 09:43 AM
Subject:        [SPSSX-L] BOOTSTRAPPING was: Sampling WITH replacement
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Seems OP has deleted her original question without further clarification.
OTOH, seems interesting thread beginning with Bruce and myself.  Would
love
to see others jump in.
--
I believe the MATRIX version to be more straightforward than the brute
force
"old-timer" version and is a rather cool example of several powerful
concepts.  If one is bootstrapping simple statistics it is straightforward
to adapt the code to implement them (see below).
MATRIX language.
MACROS with arguments.
RollYourOwnStats
--
For example I have modified the MACRO to bootstrap the SD and Median.
Maybe later I'll add correlations and OLS regression and capacity to SAVE
the sample
statistics for further use.
Any other suggestions?
----
DATA LIST FREE / X.
BEGIN DATA
6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
3 67 1 3 6 7 50 2
END DATA.
DESC X.

DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)/SPRINT !TOKENS(1)
!DEFAULT(F)
).
PRESERVE.
SET MXLOOPS=100000.
FREQ X /STAT ALL/FORMAT NOT.
MATRIX.
GET DATA / VARIABLES !VAR / FILE *.
COMPUTE N=NROW(DATA).
*Determine ranks of Median case(s)*.
COMPUTE CRIT={(N/2)+.5, (N/2)+.5 }.
DO IF N/2=TRUNC(N/2).
+  COMPUTE CRIT=CRIT + {-1.5,0.5}.
END IF.

COMPUTE Stats=MAKE(!NSAMP,3,0).
COMPUTE SAMPLES=MAKE(N,1,0).
LOOP SAMPLE=1 TO !NSAMP.
* Construct array of random Indexes (Data pointers).
+  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
+  LOOP CASEID=1 TO N.
+    COMPUTE SAMPLES(CASEID)=DATA(RARRAY(CASEID)).
+  END LOOP.
** Calculate Median **.
+  COMPUTE MEDSTAT=GRADE(SAMPLES).
+  COMPUTE Stats(SAMPLE,3) =0.
+  LOOP I=1 TO N.
+    LOOP J=1 TO 2.
+      DO IF MEDSTAT(I)=CRIT(J).
+        COMPUTE Stats(SAMPLE,3) =Stats(SAMPLE,3)+SAMPLES(I).
+      END IF.
+    END LOOP.
+  END LOOP.
+  COMPUTE Stats(SAMPLE,3)=Stats(SAMPLE,3)/2.
*  Generate Sum(X) and SUM(X**2).
+  COMPUTE Stats(SAMPLE,1)=CSUM(Samples)/N.
+  COMPUTE Stats(SAMPLE,2)=T(Samples)*Samples).
END LOOP.
* Calculate StdDev *.
COMPUTE Stats(:,2)=SQRT((Stats(:,2)-N*Stats(:,1))/(N-1)).
!IF (!SPRINT !EQ T) !THEN
PRINT Stats
     /TITLE "Individual Bootstrapped Sample Statistics"
     /CLABELS "Mean","SD","Median".
!IFEND
* Calculate Averages of Bootsrapped statistics *.
PRINT (CSUM(Stats)/!NSAMP)
     /TITLE="Averaged Bootstrapped Statistics"
     /CLABELS "Mean","StdDev","Median".
END MATRIX.
!ENDDEFINE.
BOOT Var=X NSAMP=100 SPRINT=T.
BOOT Var=X NSAMP=1000.

Bruce Weaver wrote
>
> No doubt, this version is more efficient.  But IMO, the "old-timer"
> version is easier to understand (especially for users who are not
> well-versed in the matrix language).  So it's the usual trade-off.  ;-)
>
>
>
> David Marso wrote
>>
>> Surely the following is in a somewhat different class WRT code and
>> efficiency.
>> OTOH:  It is a mere skeleton, deficient algorithm-wise and leaves a
great
>> deal to the consumer to build from.  If one has a problem rolling their
>> own stat functions then don't pass go, don't collect $200 ..
>> This simply creates an array of NSAMP bootstrapped means and holds one
>> copy of the data and NSAMP stats.
>> DELETE DELETE DELETE...
>> ---
>> DATA LIST FREE / X.
>> BEGIN DATA
>> 6 3 1 35 5 7 1 53 17 6 37 3 76 3 56 7 1 2 3 6 71 2 5
>> 3 71 7 63 1 76 1 7 1 7 63 1 7 63 6 7 11 6 7 35 6 71
>> 3 67 1 3 6 7
>> END DATA.
>>
>> DEFINE BOOT (VAR !TOKENS(1) / NSAMP !TOKENS(1)).
>> PRESERVE.
>> SET MXLOOPS=100000.
>> MATRIX.
>> GET DATA / VARIABLES !VAR / FILE *.
>> COMPUTE N=NROW(DATA).
>> COMPUTE Means=MAKE(!NSAMP,1,0).
>> LOOP SAMPLE=1 TO !NSAMP.
>> +  COMPUTE RArray=TRUNC(UNIFORM(N,1)*N +1).
>> +  LOOP CASEID=1 TO N.
>> +    COMPUTE MEANS(SAMPLE)=MEANS(SAMPLE)+DATA(RARRAY(CASEID)).
>> +  END LOOP.
>> END LOOP.
>> COMPUTE MEANS=MEANS/N.
>> PRINT MEANS.
>> END MATRIX.
>> RESTORE.
>> !ENDDEFINE.
>> BOOT VAR=X NSAMP=100.
>> PRINT CASEID.
>>
>>
>> David Marso wrote
>>>
>>> Yeah, that 'old timer' code will work but it lacks a certain degree of
>>> *subtlety* ;-).
>>> If I were to rewrite that today I would avoid explicit construction of
>>> the file, the 2 potentially huge SORTs and MATCH and just crank out
the
>>> stats using MATRIX.
>>> OTOH:  such depends entirely upon the nature of the research question
>>> and what needs be done downstream of the sampling.
>>> ----
>>>
>>> Bruce Weaver wrote
>>>>
>>>> I assume Maria means she doesn't have the Bootstrapping option as
part
>>>> of her license.  See Help > Bootstrapping Option at the link below.
>>>>
>>>>
http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp
>>>>
>>>> It that's the problem, she could always use this code written by some
>>>> old-timer from SPSS.  ;-)
>>>>
>>>>
>>>>
https://groups.google.com/group/sci.stat.consult/msg/710ea4ab83ddf24a?dmode=source&pli=1

>>>>
>>>> HTH.
>>>>
>>>>
>>>>
>>>> David Marso wrote
>>>>>
>>>>> "Like bootstrap, but bootstrap is not working for me. "
>>>>> Please elaborate and provide more context regarding this request.
>>>>> In particular how is it that "bootstrap is not working for me"?
>>>>> What do you wish to do with the samples?
>>>>> In lieu of further info I suggest you to search this group for
XSAVE.
>>>>>
>>>>>
>>>>> MariaPetsch wrote
>>>>>>
>>>>>> Hi! I really need help! How can I do *sampling with replacement* in
>>>>>> spss? Like bootstrap, but bootstrap is not working for me.
>>>>>> Thanks for the help!
>>>>>>
>>>>>
>>>>
>>>
>>
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Sampling-WITH-replacement-tp5618318p5620719.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
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 WITH replacement

MariaPetsch
In reply to this post by MariaPetsch
Thank you guys! :) I did it! :) Now i have a new probelm with RIM weighting! I think I'm opening a new topic...
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Sampling WITH replacement

Jo Fennessey
I will be out of the office Friday 4/6/2012 and will check and respond to email Monday morning.

=====================
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