Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Replication of panel-RE/FE Models with SEM
From
"Florian Christian Esser" <[email protected]>
To
[email protected]
Subject
st: Replication of panel-RE/FE Models with SEM
Date
Wed, 18 Sep 2013 09:15:01 +0200
Hi everyone,
first, I am still using Stata 12.1
I want to reproduce Random and Fixed Effects Models for panel data with
structural equation models as described e.g. by Bollen/Brand (2008 -
http://www.escholarship.org/uc/item/3sr461nd). Unfortunately I do not
manage to get the same results from regular models with -xtreg (, fe)- and
sem. Are there any additional lines of code that I have to use in order to
make the sem command work or are there mistakes?
It would be great to hear back from you!
Florian
I have attached the Stata output from my .do-file:
* Regressionmodel: enter panel information
. xtset id year
panel variable: id (strongly balanced)
time variable: year, 10 to 12
delta: 1 unit
.
. * Regression: REM
. xtreg height food
Random-effects GLS regression Number of obs =
15
Group variable: id Number of groups =
5
R-sq: within = 0.4167 Obs per group: min =
3
between = 0.6194 avg =
3.0
overall = 0.4316 max =
3
Wald chi2(1) =
5.70
corr(u_i, X) = 0 (assumed) Prob > chi2 =
0.0169
------------------------------------------------------------------------------
height | Coef. Std. Err. z P>|z| [95% Conf.
Interval]
-------------+----------------------------------------------------------------
food | 1.311973 .5493459 2.39 0.017 .2352746
2.388671
_cons | 159.782 5.932372 26.93 0.000 148.1548
171.4092
-------------+----------------------------------------------------------------
sigma_u | 10.279583
sigma_e | .80507649
rho | .99390368 (fraction of variance due to u_i)
------------------------------------------------------------------------------
.
. * Regression: FEM
. xtreg height food, fe
Fixed-effects (within) regression Number of obs =
15
Group variable: id Number of groups =
5
R-sq: within = 0.4167 Obs per group: min =
3
between = 0.6194 avg =
3.0
overall = 0.4316 max =
3
F(1,9) =
6.43
corr(u_i, Xb) = 0.6159 Prob > F =
0.0319
------------------------------------------------------------------------------
height | Coef. Std. Err. t P>|t| [95% Conf.
Interval]
-------------+----------------------------------------------------------------
food | 1.25 .4930066 2.54 0.032 .1347415
2.365259
_cons | 160.1167 2.670339 59.96 0.000 154.0759
166.1574
-------------+----------------------------------------------------------------
sigma_u | 13.822611
sigma_e | .80507649
rho | .99661917 (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(4, 9) = 548.90 Prob > F =
0.0000
.
. * Reshapen in Wide Format
. reshape wide height food, i(id) j(year)
(note: j = 10 11 12)
Data long -> wide
-----------------------------------------------------------------------------
Number of obs. 15 -> 5
Number of variables 4 -> 7
j variable (3 values) year -> (dropped)
xij variables:
height -> height10 height11 height12
food -> food10 food11 food12
-----------------------------------------------------------------------------
.
. * Calculate SEM RE
. sem (food10@B -> height10) (food11@B -> height11) (food12@B -> height12)
(eta@1 -> height10) (eta@1 -> height11) (eta@1 -
> > height12), ///
> covstruct(_lexogenous,diagonal) cov(_lexogenous*_oexogenous@0) nolog
iterate(200) latent(eta ) cov( food10*food11 food10*
> food12 food11*food12 ///
> e.height10@E e.height11@E e.height12@E) nocapslatent
Endogenous variables
Observed: height10 height11 height12
Exogenous variables
Observed: food10 food11 food12
Latent: eta
Structural equation model Number of obs =
5
Estimation method = ml
Log likelihood = -38.399032
( 1) [height10]food10 - [height12]food12 = 0
( 2) [height10]eta = 1
( 3) [height11]food11 - [height12]food12 = 0
( 4) [height11]eta = 1
( 5) [height12]eta = 1
( 6) [var(e.height10)]_cons - [var(e.height12)]_cons = 0
( 7) [var(e.height11)]_cons - [var(e.height12)]_cons = 0
( 8) [cov(food10,eta)]_cons = 0
( 9) [cov(food11,eta)]_cons = 0
(10) [cov(food12,eta)]_cons = 0
-------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf.
Interval]
--------------+----------------------------------------------------------------
Structural |
height10 <- |
food10 | .1816882 .569775 0.32 0.750 -.9350502
1.298427
eta | 1 1.51e-15 6.6e+14 0.000 1
1
_cons | 165.0916 6.412771 25.74 0.000 152.5228
177.6604
------------+----------------------------------------------------------------
height11 <- |
food11 | .1816882 .569775 0.32 0.750 -.9350502
1.298427
eta | 1 (constrained)
_cons | 166.0189 6.51722 25.47 0.000 153.2454
178.7924
------------+----------------------------------------------------------------
height12 <- |
food12 | .1816882 .569775 0.32 0.750 -.9350502
1.298427
eta | 1 (constrained)
_cons | 166.5462 6.627862 25.13 0.000 153.5558
179.5366
--------------+----------------------------------------------------------------
Mean |
food10 | 5 .2828427 17.68 0.000 4.445638
5.554362
food11 | 5.4 .3577709 15.09 0.000 4.698782
6.101218
food12 | 5.8 .1788854 32.42 0.000 5.449391
6.150609
--------------+----------------------------------------------------------------
Variance |
e.height10 | .3453428 .1545956 .143616
.8304203
e.height11 | .3453428 .1545956 .143616
.8304203
e.height12 | .3453428 .1545956 .143616
.8304203
food10 | .4 .2529822 .1158011
1.381679
food11 | .64 .4047715 .1852818
2.210686
food12 | .16 .1011929 .0463205
.5526715
eta | 164.6924 104.4409 47.52018
570.7805
--------------+----------------------------------------------------------------
Covariance |
food10 |
food11 | .4 .2884441 1.39 0.166 -.1653401
.9653401
food12 | .2 .1442221 1.39 0.166 -.08267
.48267
eta | 0 (constrained)
------------+----------------------------------------------------------------
food11 |
food12 | .28 .1901578 1.47 0.141 -.0927025
.6527025
eta | 0 (constrained)
------------+----------------------------------------------------------------
food12 |
eta | 0 (constrained)
-------------------------------------------------------------------------------
.
. * Calculate SEM FE
. sem (food10@B -> height10) (food11@B -> height11) (food12@B -> height12)
(eta@1 -> height10) (eta@1 -> height11) (eta@1 -
> > height12), ///
> covstruct(_lexogenous,diagonal) cov(_lexogenous*_oexogenous@0) nolog
iterate(200) latent(eta ) ///
> cov( food10*food11 food10*food12 food10*eta food11*food12 food11*eta
food12*eta e.height10@E e.height11@E e.height12@E) n
> ocapslatent
Endogenous variables
Observed: height10 height11 height12
Exogenous variables
Observed: food10 food11 food12
Latent: eta
Structural equation model Number of obs =
5
Estimation method = ml
Log likelihood = -31.552533
( 1) [height10]food10 - [height12]food12 = 0
( 2) [height10]eta = 1
( 3) [height11]food11 - [height12]food12 = 0
( 4) [height11]eta = 1
( 5) [height12]eta = 1
( 6) [var(e.height10)]_cons - [var(e.height12)]_cons = 0
( 7) [var(e.height11)]_cons - [var(e.height12)]_cons = 0
-------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf.
Interval]
--------------+----------------------------------------------------------------
Structural |
height10 <- |
food10 | .125 .5687157 0.22 0.826 -.9896622
1.239662
eta | 1 1.51e-15 6.6e+14 0.000 1
1
_cons | 165.375 6.420632 25.76 0.000 152.7908
177.9592
------------+----------------------------------------------------------------
height11 <- |
food11 | .125 .5687157 0.22 0.826 -.9896622
1.239662
eta | 1 (constrained)
_cons | 166.325 6.524571 25.49 0.000 153.5371
179.1129
------------+----------------------------------------------------------------
height12 <- |
food12 | .125 .5687157 0.22 0.826 -.9896622
1.239662
eta | 1 (constrained)
_cons | 166.875 6.634683 25.15 0.000 153.8713
179.8787
--------------+----------------------------------------------------------------
Mean |
food10 | 5 .2828427 17.68 0.000 4.445638
5.554362
food11 | 5.4 .3577709 15.09 0.000 4.698782
6.101218
food12 | 5.8 .1788854 32.42 0.000 5.449391
6.150609
--------------+----------------------------------------------------------------
Variance |
e.height10 | .345 .1542887 .1435986
.828873
e.height11 | .345 .1542887 .1435986
.828873
e.height12 | .345 .1542887 .1435986
.828873
food10 | .4 .2529822 .1158011
1.381679
food11 | .64 .4047715 .1852818
2.210686
food12 | .16 .1011929 .0463205
.5526715
eta | 165.3479 104.855 47.71022
573.0415
--------------+----------------------------------------------------------------
Covariance |
food10 |
food11 | .4 .2884441 1.39 0.166 -.1653401
.9653401
food12 | .2 .1442221 1.39 0.166 -.08267
.48267
eta | 6.891667 4.772 1.44 0.149 -2.461282
16.24461
------------+----------------------------------------------------------------
food11 |
food12 | .28 .1901578 1.47 0.141 -.0927025
.6527025
eta | 6.198333 5.378265 1.15 0.249 -4.342873
16.73954
------------+----------------------------------------------------------------
food12 |
eta | 4.28 2.995532 1.43 0.153 -1.591135
10.15114
-------------------------------------------------------------------------------
.
end of do-file
.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/