# st: gllamm for IV modeling for longitudinal data

 From ZYD To statalist@hsphsun2.harvard.edu Subject st: gllamm for IV modeling for longitudinal data Date Sat, 6 Aug 2005 15:39:05 -0400

```Dear Statalisters:

I would like to perform a IV modeling for a longitudinal dataset with
endogenous right hand variables. I wonder if gllamm can be used here.
The details are listed below.  Your help is highly appreciated!

I am doing an analysis on spatial proximity between older parents and
their adult children. The outcome variable is categorical that is
dictated by data availability: (Y==1: living within 10 miles from
nearest child or Y==2: beyond 10 miles). The key explanatory variable
"Endogen" is older parents' subjective survival probability (SSP),
which is continuous and endogenous to the system. Instrument variable
"IV", for the moment, is the subjective evaluation of inflation rate.
Longitudinal data is available, which has been cleaned into long form,
where i=id and j=year. Other controlling variables including
social-demographics and health and wealth, named as x1, x2, x3….

I modified Dr Rabe-Hesketh's sample code for kenkel study in the book
"Generalized latent variable modeling: multilevel, longitudinal and
structural equation models" for my longitudinal dataset as listed
below.

I wonder whether gllamm is applicable to my study. Also whether my
specification will work.  Thanks a lot!

********************** modified code *****************************
rename Y resp1
gen resp2 = Endogen
reshape long resp, i(id year) j(type)

* create dummies d1 for type=1 and d2 for type=2
tab type, gen(d)

* create interactions between d1 and covariates in drining model
foreach var in endogen x1 x2 {
gen d1_`var' = d1*`var'
}

* create interactions between d2 and covariates in endog model
foreach var in x1 x2 iv {
gen d2_`var' = d2*`var'
}

* Endogenous treatment:
eq fac: d2 d1
gllamm resp d1_endog d1 d1_x1 d1_x2 d2 d2_x1 d2_x2  /*
*/ d2_iv, nocons i(hhidpn year) /*
*/ family(binom gauss) link(probit identity) fv(type) lv(type) /*
*/ eq(fac fac) adapt nip(15) trace
****************************************************

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```