Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

Re: st: how to do fixed effects with weights? (problem using svy: with xtreg, fe)

 From Steve Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: how to do fixed effects with weights? (problem using svy: with xtreg, fe) Date Mon, 12 Apr 2010 11:38:29 -0400

```"ah2574"

Here is my suggestion applied to -reg- with  the nhanes example
jackknife data used in the Manual.  Note the statement for creating
jackknife differences.  I use a constant 0.5 because in this data set
there were 31 pseudo strata and 2 PSUs in each(page 164, Stata 11
Survey Manual).   I presume that the proper multiplier for your data
is 1.0, as suggested by your consultant. While this works, I wouldn't
want to use it for a complete analysis.  Stas's suggestion is really
the way to go.

By the way,  real names are welcome in Statalist.

Steve
**************************CODE BEGINS**************************
capture log close
log using pjack, replace text

use http://www.stata-press.com/data/r11/nhanes2jknife, clear
svyset
svy jackknife slope = _b[height], nodots: regress weight height

***************************************************************
* Hand calculations of jackknife follow
***************************************************************
tempname memhold
postfile `memhold'  b_height using results, replace
quietly forvalues j  = 1/62 {
reg weight height [pw= jkw_`j']
post `memhold'  (_b[height])
}
postclose `memhold'
use results, clear
ds
foreach v in `r(varlist)'{
sum `v', meanonly
gen m`v'=r(mean)

gen t`v' = 0.5*(`v' - m`v')^2   // CHECK MULTIPLIER
egen se_`v' = total(t`v')
replace se_`v' =sqrt(se_`v')
}
list se_* in 1

log close
***************************CODE ENDS***************************

On Mon, Apr 12, 2010 at 12:46 AM, Stas Kolenikov <skolenik@gmail.com> wrote:
> In fact, -xtreg- satisfies the Stata's internal requirements needed
> for -vce(jackknife)- that -if- conditions and [pweights] be accepted
> and processed by the command, and the results be returned in e(b) and
> e(V) matrices (plus a little bit of extra details; see -help program
> properties-). So at your own risk you can write a very simple wrapper
> like this:
>
> program define myxtreg, eclass properties( svyj )
>
>   * transfer the whole call to -xtreg-
>   xtreg `0'
>
>   * pretend we wrote a full fledge estimator here
>   ereturn local cmd myxtreg
>
> end
>
> and try running your -svy, vce( jackknife ): myxtreg whatever- command
> with it. This eliminates the need to do the jackknife "by hand" as
> Steve S suggested, and if it does work, it will produce correct
> results (it falls short of a proper Stata estimation command in a
> number of ways, but I don't know whether that will be a problem since
> you only need it for a specific purpose and won't distribute as an
> estimation command that somebody else could use). This is a different
> workaround than Steve's, that's all -- you'd HAVE TO write some
> specialized code to make it work, and I would rather try to squeeze an
> estimator into the existing -svy- paradigm than to write my own cycles
> to process the jackknife weights.
>
> Another issue that might bite you is that you might come across
> weights that change from wave to wave for the same student. -xtreg-
> will issue an error message, and that is the most reasonable behavior
> in this situation.
>
> On Sun, Apr 11, 2010 at 2:43 PM,  <ah2574@columbia.edu> wrote:
>> I am analyzing longitudinal data on children's educational achievement using
>> the "xtreg, fe" command.  My challenge is that I can't seem to weight the
>> data with the "svy:" command when running a fixed effects model.  I am
>> working with Early Childhood Longitudinal Study-Kindergarten Cohort data
>> from the National Center for Education Statistics; the study employed a
>> multistage probability sample design (with three stages).
>>
>> As advised by a technical consultant at the American Institutes for
>> Reserach, I am currently "survey setting" the data using replicate weights
>> as follows:
>> svyset [pweight=c1_5fp0], jkrweight( c1_5fp1-c1_5fp90, multiplier(1))
>>
>> I then attempted to run the fixed effects model with this syntax:
>> svy jacknife: xtreg ztime incneed married momwork numchild, i(childid2) fe
>>
>> I receive the following error message:
>> xtreg is not supported by svy with vce(jackknife)

--
Steven Samuels
sjsamuels@gmail.com
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```