Friday, December 16, 2011

Doing bootstrap/jackknife in Stata


Doing Repeated Replication Methods (Bootstrap/Jackknife) for complex survey data
  • Bootstrap sampling and estimation, Survey data analysis in Stata
  • Starting from Stata 10, you can just use -svy jackknife- instead of creating jackknife weight at first.
    • By using information on PSUs and strata, -svy jackknife:- will automatically adjust the sampling weights to produce the replicates using the delete-1 jackknife method
    • if you want do delete-k jackknife, you need provide the replicate weight variables using -svyset-
    • by default jackknife variance is computed by using deviations of the replicates from their mean. If you want to variance from the observed value of statistics based on the entire dataset, you need use -svy jackknife, mse- (mean square error)option. The -mse- method providea larger variance estimation because of the addition of the familiar sqared bias tern in the mean square error
  • The Stata 14 has "strata()" and "cluster()" options and sounds like for the complex survey data, but seemingly it cannot deal with the sampling weight correctly.
  • Jackknife for simple random sampling data:
    • jknife r(mean): summarize mpg
  • Jackknife for complex survey data
    • webuse nhanes2, replace
    • svyset psu [pw=finalwgt], strata(strata)
    • svy jackknife slope=_b[height] constant=_b[_cons]: regress weight height
  • Jackknife for complex survey data using a user-written program:
    • svy jackknfie _b[, options]: intcens
  • User-written program using Jackknife for complex survey data.
    • Notes: 
    • -svy jackknife- is allowed as long as they follow standard Stata -syntax-, allow the 
    • -if- qualifier, and allow -pweights- and -iweights-.
    • Notes: "anything", "namelist", "name", "weight, "if", "in", "varlist", "using", "exp", etc. are special macros. "anything" is used to tell the -syntax- command what can appear immediately after the name of the command. "anythingcould be anything like SILLY in this example, which passes an arguement into the program. Things between "[" and "]" are optional. In order to use -margins-, -set buildfvinfo- needs set as -on-.
  • Here is a modified example in the manual: with replication-based variance estimators
    • program mymargins, eclass
        syntax anything [if] [iw pw]
        if "`weight'" != "" {
          local wgtexp "[`weight' `exp']"
        }
        set buildfvinfo on
        `anything' `if' `wgtexp'
        margins race, post
      end
      global myanything "logistic highbp height weight i.race c.age##c.age" //!!! using `anything' with caution !!!
      svy jackknife _b: mymargins $myanything
  • UCLA: How do I write my own bootstrap program?
  • SSCC: Bootstrapping in Stata
  • Stata Journal(2003): Bootstrapped standard errors
  • Schmidheiny(2016): The Bootstrap
  • How can I analyze multiple mediators in Stata? 
  • Stata Journal(2004): From the help desk: Some bootstrapping techniques
  • 'svr' is a module/package to compute estimates with survey replication (SVR) based standard errors written by Nick Winter. -survwgt-, one of commands of 'svr' creates sets of replicate weights for complex sampling data including balanced repeated replication (BRR) and several version of the survey jackknife (JK*). In addition, survwgt performs oststratification, raking, and non-response adjustments to survey weights. Starting from Stata 10, you can just use -svy jackknife- instead of creating jackknife weight at first.
  • The jackknife (n-1) estimate of the standard error is equal to , where n is the total number of observations (or clusters). The factor in the jackknife's standard error is about n times (inflation factor) larger than bootstrap [1/(B-1)].
  • The delete-d jackknife estimate of the standard error is using (n-d)/C(n,d) instead of (n-1)/n
  • Efron (1981). Nonparametric Estimates of Standard Error: The Jackknife, the Bootstrap and OtherMethods
  • McIntosh."The Jackknife Estimation Method"
  • UCLA:How can I sample from a dataset with frequency weights?

1 comment:

Anonymous said...

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Bootstrap, kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Virtual Instructor led training on Bootstrap. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us.
Nitesh Kumar
MaxMunus
E-mail: nitesh@maxmunus.com
Skype id: nitesh_maxmunus
Ph:(+91) 8553912023
http://www.maxmunus.com/