Dear all,
My problem setup is as follows. I have a relatively simple survey data with a single strata and probability weights. My ultimate goal is to calculate an income inequality statistic (the share of income of the top 25%) and bootstrap the standard errors using a custom written program.
This has been a rather complicated procedure and I want to make sure my setup is correct. Let’s say we use the auto data set, with survey weights equal to weight and the stratification being foreign. My first step is generating the bootstrap weights using the rhsbsample command:
I then set the survey information:
Finally, I apply my user written command mdist to get the share of price held of the top 25% most expensive vehicles:
The program seems to run, but I’m not sure if it is producing the correct results. My questions are as follows:
(i) Does my program conform to all of the guidelines for a svy bootstrap program? In particular, note how I am not using any svy commands within the program! Do I need to use them?
(ii) Am I applying additional “if” statements correctly? In particular, note my “if addition” variable
(iii) Am I using the bootstrap weights correctly?
Many thanks,
Jake Robbins
P.S.: The references I have used in looking at this problem are:
http://repec.org/usug2013/vankerm.uk13.pdf
https://www.statalist.org/forums/for...or-survey-data
https://www.stata.com/statalist/arch.../msg01206.html
https://journals.sagepub.com/doi/pdf...867X1001000201
My problem setup is as follows. I have a relatively simple survey data with a single strata and probability weights. My ultimate goal is to calculate an income inequality statistic (the share of income of the top 25%) and bootstrap the standard errors using a custom written program.
This has been a rather complicated procedure and I want to make sure my setup is correct. Let’s say we use the auto data set, with survey weights equal to weight and the stratification being foreign. My first step is generating the bootstrap weights using the rhsbsample command:
Code:
clear all set seed 100 sysuse auto * Generating boot strap weight variables forvalues i=1/500 { qui gen brw`i' = . rhsbsample , strata(foreign) weight(brw`i') }
I then set the survey information:
Code:
svyset [pw=weight], strata(foreign) bsrweight(brw*) vce(bootstrap)
Finally, I apply my user written command mdist to get the share of price held of the top 25% most expensive vehicles:
Code:
cap program drop mdist svy bootstrap: mdist price, rankvar(price) program mdist, eclass properties(svyb) syntax anything [if] [in] [fw aw pw iw] [, rankvar(varlist)] marksample touse tempvar b tempvar rankprog * Rank individuals by the rankvar * Note that cumul doesn't work with svy! Thus this will be a problem * cumul `rankvar' [`weight'`exp'] `if', gen(`rankprog') _pctile `rankvar' [`weight'`exp'] `if', percentiles(75) local pct75 = r(r1) * Get the total for the variable total `anything' [`weight'`exp'] `if' local nobs = e(N) local stot = e(b)[1,1] * Get the total for the top 25% local iffaddition "" if "`if'"=="" { local iffaddition "if `rankvar' >= `pct75'" } else { local iffaddition "`if' & `rankvar' >= `pct75'" } total `anything' [`weight'`exp'] `iffaddition' local ttot = e(b)[1,1] * The share is the top total divided by the aggregate total matrix `b' = `ttot'/(`stot') ereturn post `b', esample(`touse') ereturn local cmd "meantest" ereturn scalar N = `nobs' ereturn display end
(i) Does my program conform to all of the guidelines for a svy bootstrap program? In particular, note how I am not using any svy commands within the program! Do I need to use them?
(ii) Am I applying additional “if” statements correctly? In particular, note my “if addition” variable
(iii) Am I using the bootstrap weights correctly?
Many thanks,
Jake Robbins
P.S.: The references I have used in looking at this problem are:
http://repec.org/usug2013/vankerm.uk13.pdf
https://www.statalist.org/forums/for...or-survey-data
https://www.stata.com/statalist/arch.../msg01206.html
https://journals.sagepub.com/doi/pdf...867X1001000201
Comment