I am fairly new to Stata so some of my questions may be pretty basic, but I appreciate any help I can get. An example of my data is below
I have survey data and I am trying to bootstrap the difference in mean wages for women ONLY. I want to find out the difference in mean outcome with [survey weights] and with [survey weights * constant] that is
Manual calculation:
I have written the following program, but I am not getting the results I want. In particular, my SE column turns up blank and my point estimates for the means and the difference in means do not match with what I get with manual calculation.
I have already svyset my data using bootstrap weights. My questions are as follows:
wage | survey weights | constant | sex |
32 | 14 | .56 | 1 |
56 | 45 | .96 | 1 |
77 | 88 | .25 | 0 |
Manual calculation:
Code:
mean x [pw=hhwt] if sex==1 mat x1=e(b) mean x [pw=wt*constant] if sex==1 mat x2=e(b) mat dd=x1-x2 **my outcome of interest is the point estimate and bootstrapped SE of DD
Code:
program define meandiff, eclass properties (svyb) args vars means 'vars' mat x1=e(b) mean `vars' [pw=constant] mat dd=x1-x2 ereturn scalar diff=el(dd,1,1) end local vars wage svy bootstrap e(diff), subpop(sex): mean `vars'
- When I type svy: mean 'vars' the program seems to start running bootstrap replications, and when I type svy bootstrap: means `vars' also the program seems to start replications. What is the difference between the two commands?
- When I do mean x with regular survey weights do I need to do [pw=wt] or will svy command automatically apply the survey weights?
- If I do have to write [pw=wt] in the first mean then do I need to create a variable called, say,gen wtxcons = wt * constant to do [pw=wtxcons] when I calculate the second mean?
- How do I calculate the bootstrap SE and point estimates for my outcome of interest, which is the difference in means. Why are my point estimates not matching my manual calculation?
Comment