|
Dear all,
I'm trying to bootstrap a mean with (noninteger) caseweights in effect. I found some syntax for bootstrapping logistic regression results that used a macro to generate (by means of the oms) a dataset containing bootstrapped results. I'm not sure who the author of the original syntax is. I'm trying to adapt it to my needs but not entirely succesfully yet. It seems that the basic idea is to 'draw' the replacement samples by assigning random integer caseweights (I called those 'bootwei' in the syntax) which sum to (unweighted sample size) and weighting the sample with them. My idea was to multiply those weights with the normal weights (referred to as 'idealwei' in the syntax) as a workaround for the fact that only one single weighting variable can be in effect. I'm not sure whether this is a good idea but I was hoping that the bootstrapped results would tell me. However, the syntax doesn't run at all. It breaks down on the 'RV.BINOM' command. I can't see why because the first argument must be a positive integer and the second argument cannot be outside [0;1] if I understand correctly. I've no experience with macros whatsoever by the way. Any comments -either on the syntax breaking down or the basic idea of what I'm trying to do- are really more than welcome! TIA! Ruben ***Ruben van den Berg. ***Author of original syntax unknown (was meant for logistic regression bootstrapping). ***dataset 'data' is open containing grade (variable we're interested in) and idealwei (caseweights that correct for nonrandom nonresponse). datas act data. set tva nam. * OMS. DATASET DECLARE des. OMS /SELECT TABLES /IF COMMANDS = ["Descriptives"] SUBTYPES = ["Descriptive Statistics"] /DESTINATION FORMAT = SAV NUMBERED = TableNumber_ OUTFILE = des /TAG = "des". DEFINE bootstrap (samples=!TOKENS(1)/bootsvar=!TOKENS(1)) COMPUTE t1=1. AGGREGATE /OUTFILE = * MODE = ADDVARIABLES /BREAK=t1 /filesize=N. !DO !other=1 !TO !samples SET SEED RANDOM. WEIGHT OFF. FILTER OFF. DO IF $casenum=1. - COMPUTE #samplesize=filesize. - COMPUTE #filesize=filesize. END IF. DO IF (#samplesize>0 and #filesize>0). - COMPUTE bootwei=rv.binom(#samplesize, 1/#filesize). - COMPUTE #samplesize=#samplesize-bootwei. - COMPUTE #filesize=#filesize-1. ELSE. - COMPUTE bootwei=0. END IF. comp bootwei=bootwei*idealwei. WEIGHT BY bootwei. FILTER BY bootwei. des !bootsvar /sta mean. !DOEND !ENDDEFINE. bootstrap samples=100 bootsvar=grade. OMSEND tag=['des']. Express yourself instantly with MSN Messenger! MSN Messenger |
|
Hi Ruben
Sorry for the delay in answering. Unfortunately, my syntax uses MATRX, and the weights are ignored. I think that Ray Levesque had code for boostrapping the mean using OMS. Take a look t his pages (http://www.spsstools.net) and see if it can be adapted. Not a solution... yet, but PASW 18 has a bootstrapping module. You will have to wait less than a month to see it. Best regards, Marta Ruben van den Berg wrote: > Dear all, > > I'm trying to bootstrap a mean with (noninteger) caseweights in > effect. I found some syntax for bootstrapping logistic regression > results that used a macro to generate (by means of the oms) a > dataset containing bootstrapped results. I'm not sure who the author > of the original syntax is. I'm trying to adapt it to my needs but not > entirely succesfully yet. > > It seems that the basic idea is to 'draw' the replacement samples by > assigning random integer caseweights (I called those 'bootwei' in the > syntax) which sum to (unweighted sample size) and weighting the sample > with them. My idea was to multiply those weights with the normal > weights (referred to as 'idealwei' in the syntax) as a workaround for > the fact that only one single weighting variable can be in effect. I'm > not sure whether this is a good idea but I was hoping that the > bootstrapped results would tell me. > > However, the syntax doesn't run at all. It breaks down on the > 'RV.BINOM' command. I can't see why because the first argument must be > a positive integer and the second argument cannot be outside [0;1] if > I understand correctly. I've no experience with macros whatsoever by > the way. > > Any comments -either on the syntax breaking down or the basic idea of > what I'm trying to do- are really more than welcome! > > TIA! > > Ruben > > ***Ruben van den Berg. > ***Author of original syntax unknown (was meant for logistic > regression bootstrapping). > ***dataset 'data' is open containing grade (variable we're interested > in) and idealwei (caseweights that correct for nonrandom nonresponse). > > datas act data. > > set tva nam. > * OMS. > DATASET DECLARE des. > OMS > /SELECT TABLES > /IF COMMANDS = ["Descriptives"] > SUBTYPES = ["Descriptive Statistics"] > /DESTINATION FORMAT = SAV NUMBERED = TableNumber_ > OUTFILE = des > /TAG = "des". > > DEFINE bootstrap (samples=!TOKENS(1)/bootsvar=!TOKENS(1)) > > COMPUTE t1=1. > AGGREGATE > /OUTFILE = * MODE = ADDVARIABLES > /BREAK=t1 > /filesize=N. > > !DO !other=1 !TO !samples > > SET SEED RANDOM. > WEIGHT OFF. > FILTER OFF. > > DO IF $casenum=1. > - COMPUTE #samplesize=filesize. > - COMPUTE #filesize=filesize. > END IF. > > DO IF (#samplesize>0 and #filesize>0). > - COMPUTE bootwei=rv.binom(#samplesize, 1/#filesize). > - COMPUTE #samplesize=#samplesize-bootwei. > - COMPUTE #filesize=#filesize-1. > ELSE. > - COMPUTE bootwei=0. > END IF. > > comp bootwei=bootwei*idealwei. > > WEIGHT BY bootwei. > FILTER BY bootwei. > > des !bootsvar > /sta mean. > > !DOEND > > !ENDDEFINE. > > bootstrap samples=100 bootsvar=grade. > > OMSEND tag=['des']. > > > > > > > > > > > > ------------------------------------------------------------------------ > Express yourself instantly with MSN Messenger! MSN Messenger > <http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/> -- For miscellaneous SPSS related statistical stuff, visit: http://gjyp.nl/marta/ ===================== 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 |
|
Dear Marta and others,
The syntax by Levesque is the same that I found for logistic regression. I tried to adapt it all over again. In first instance it works but as soon as I multiply the idealweights with the bootstrapweights, it breaks down. The first warning is Warnings
They are all filtered out indeed but I don't see why. The newly adapted syntax is below. Kind regards, Ruben cd'C:\Test'. ins fil='Testdata_100_3.SPS'. set mpri on. ***Ruben van den Berg. ***Author of original syntax presumably R. Levesque. ***dataset 'data' open containing grade (variable we're interested in) and idealwei (caseweights that correct for nonrandom nonresponse). datas clo des. datas act data. SET TVARS NAMES. DATASET DECLARE des. OMS /SELECT TABLES /IF COMMANDS = ["Descriptives"] SUBTYPES = ["Descriptive Statistics"] /DESTINATION FORMAT = SAV NUMBERED = TableNumber_ OUTFILE = des /TAG = "des". DEFINE bootstr (samples=!TOKENS(1) /vars=!TOKENS(1) /idealweight=!TOKENS(1)) wei off. filt off. COMPUTE dummyvar=1. AGGREGATE /OUTFILE='c:\temp\aggrtemp.sav' /BREAK=dummyvar /filesize=N. MATCH FILES FILE=* /TABLE='c:\temp\aggrtemp.sav' /BY dummyvar. !DO !other=1 !TO !samples SET SEED RANDOM. WEIGHT OFF. FILTER OFF. DO IF $casenum=1. - COMPUTE #samplesize=filesize. - COMPUTE #filesize=filesize. END IF. DO IF (#samplesize>0 and #filesize>0). - COMPUTE sampleWeight=rv.binom(#samplesize, 1/#filesize). - COMPUTE #samplesize=#samplesize-sampleWeight. - COMPUTE #filesize=#filesize-1. ELSE. - COMPUTE sampleWeight=0. END IF. comp newweight=sampleWeight*!idealweight. exe. WEIGHT BY newweight. FILTER BY newweight. des !vars /sta mean. !DOEND !ENDDEFINE. bootstr samples=5 vars=grade idealweight=idealwei. OMSEND. > Date: Wed, 9 Sep 2009 15:27:44 +0200 > From: [hidden email] > Subject: Re: Bootstrap macro for weighted sample breaks down > To: [hidden email] > > Hi Ruben > > Sorry for the delay in answering. Unfortunately, my syntax uses MATRX, > and the weights are ignored. I think that Ray Levesque had code for > boostrapping the mean using OMS. Take a look t his pages > (http://www.spsstools.net) and see if it can be adapted. > > Not a solution... yet, but PASW 18 has a bootstrapping module. You will > have to wait less than a month to see it. > > Best regards, > Marta > > > Ruben van den Berg wrote: > > Dear all, > > > > I'm trying to bootstrap a mean with (noninteger) caseweights in > > effect. I found some syntax for bootstrapping logistic regression > > results that used a macro to generate (by means of the oms) a > > dataset containing bootstrapped results. I'm not sure who the author > > of the original syntax is. I'm trying to adapt it to my needs but not > > entirely succesfully yet. > > > > It seems that the basic idea is to 'draw' the replacement samples by > > assigning random integer caseweights (I called those 'bootwei' in the > > syntax) which sum to (unweighted sample size) and weighting the sample > > with them. My idea was to multiply those weights with the normal > > weights (referred to as 'idealwei' in the syntax) as a workaround for > > the fact that only one single weighting variable can be in effect. I'm > > not sure whether this is a good idea but I was hoping that the > > bootstrapped results would tell me. > > > > However, the syntax doesn't run at all. It breaks down on the > > 'RV.BINOM' command. I can't see why because the first argument must be > > a positive integer and the second argument cannot be outside [0;1] if > > I understand correctly. I've no experience with macros whatsoever by > > the way. > > > > Any comments -either on the syntax breaking down or the basic idea of > > what I'm trying to do- are really more than welcome! > > > > TIA! > > > > Ruben > > > > ***Ruben van den Berg. > > ***Author of original syntax unknown (was meant for logistic > > regression bootstrapping). > > ***dataset 'data' is open containing grade (variable we're interested > > in) and idealwei (caseweights that correct for nonrandom nonresponse). > > > > datas act data. > > > > set tva nam. > > * OMS. > > DATASET DECLARE des. > > OMS > > /SELECT TABLES > > /IF COMMANDS = ["Descriptives"] > > SUBTYPES = ["Descriptive Statistics"] > > /DESTINATION FORMAT = SAV NUMBERED = TableNumber_ > > OUTFILE = des > > /TAG = "des". > > > > DEFINE bootstrap (samples=!TOKENS(1)/bootsvar=!TOKENS(1)) > > > > COMPUTE t1=1. > > AGGREGATE > > /OUTFILE = * MODE = ADDVARIABLES > > /BREAK=t1 > > /filesize=N. > > > > !DO !other=1 !TO !samples > > > > SET SEED RANDOM. > > WEIGHT OFF. > > FILTER OFF. > > > > DO IF $casenum=1. > > - COMPUTE #samplesize=filesize. > > - COMPUTE #filesize=filesize. > > END IF. > > > > DO IF (#samplesize>0 and #filesize>0). > > - COMPUTE bootwei=rv.binom(#samplesize, 1/#filesize). > > - COMPUTE #samplesize=#samplesize-bootwei. > > - COMPUTE #filesize=#filesize-1. > > ELSE. > > - COMPUTE bootwei=0. > > END IF. > > > > comp bootwei=bootwei*idealwei. > > > > WEIGHT BY bootwei. > > FILTER BY bootwei. > > > > des !bootsvar > > /sta mean. > > > > !DOEND > > > > !ENDDEFINE. > > > > bootstrap samples=100 bootsvar=grade. > > > > OMSEND tag=['des']. > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > Express yourself instantly with MSN Messenger! MSN Messenger > > <http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/> > > > -- > For miscellaneous SPSS related statistical stuff, visit: > http://gjyp.nl/marta/ > > ===================== > 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 Express yourself instantly with MSN Messenger! MSN Messenger |
| Free forum by Nabble | Edit this page |
