全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 HLM专版
7349 9
2014-04-04

Consider a longitudinaldataset, used by both Ruppert, Wand, and Carroll (2003) and Diggle etal. (2002), consisting of weight measurements of 48 pigs on 9 successive weeks.Pigs are identified by the variable id. Below is a plot of the growth curvesfor the first 10 pigs.


. usehttp://www.stata-press.com/data/r13/pig (Longitudinalanalysis of pig weights)

. twowayconnected weight week if id<=10, connect(L)


It seems clear that each pig experiences a linear trend ingrowth and that overall weight measurements vary from pig to pig. Because weare not really interested in these particular 48 pigs per se, we instead treatthem as a random sample from a larger population and model the between-pigvariability as a random effect, or in the terminology of (2), as arandom-intercept term at the pig level. We thus wish to fit the model  

weightij= β0 + β1weekij + uj + Єij

states that we want one overall regression linerepresenting the population average. The random effect uj serves to shift thisregression line up or down according to each pig. Because the random effectsoccur at the pig level (id), we fit the model by typing

. mixedweight week || id:



Notes:



  • By typing weight week, we specified the response, weight, and thefixed portion of the model in the same way that we would if we were using regressor any other estimation command. Our fixed effects are a coefficient on  week and a constant term.
  • When we added || id:, wespecified random effects at the level identified by the group variable id, that is, the pig level (level two). Becausewe wanted only a random intercept, that is all we had to type.
  • The estimation log consists of three parts: (a)A set of EM iterations used to refine starting values. By default,the iterations themselves are not displayed, but you can display them with the emlogoption. (b)A set of gradient-based iterations. By default, these areNewton–Raphson iterations, but other methods are available by specifying theappropriate maximize option.(c)The message “Computing standard errors”. This is just to informyou that mixed has finished its iterative maximization and is nowreparameterizing from a matrix-based parameterization to the natural metric ofvariance components and their estimated standard errors.
  • The output title, “Mixed-effects ML regression”, informs us thatour model was fit using ML, the default. For  EML estimates, use the reml option. Becausethis model is a simple random-intercept model fit by ML, it would be equivalentto using xtreg with its mle option.
  • The first estimation tablereports the fixed effects. We estimate β0 = 19.36 and β1 = 6.21.
  • The second estimation table shows theestimated variance components. The first section of the table is labeled id:Identity, meaning that these are random effects at the id (pig) level and that theirvariance–covariance matrix is a multiple of the identity matrix. Because wehave only one random effect at this level, mixed knew that Identity is the onlypossible covariance structure. In any case, the variance of the level-twoerrors  is estimated as  4.82 with standard error 3.12.
  • The row labeled var(Residual) displays theestimated variance of the overall error term; the variance of the level-oneerrors is 4.38.
  • Finally,a likelihood-ratio test comparing the model with one-level ordinary linearregression, model (4) without uj , is provided and is highly significant forthese data.


ME294



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-4-4 01:43:25

Extending aboveexample to allow for a random slope on week yields the model

weightij = β0 + β1weekij + u0j + u1jweekij+ Єij

  • Because we did not specify a covariance structure for therandom effects, mixed used thedefault Independentstructure;
  • We can use lrtest andour two stored estimation results to verify this fact:

. lrtest randslope randint

  • The near-zero significance level favors the modelthat allows for a random pig-specific regression line over the model thatallows only for a pig-specific shift.



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-4 01:51:17
  • Specify covariance to be unstructured to allow u0j and u1j to be correlated
. mixed weight week || id: week, covariance(unstructured)
  • Conduct Likelihood-ratio test
. lrtest  randslope
  • Specify covariance to be identity, restricting u0j and u1j to not only be independent but also to have common variance,
  • specify covariance to be exchangeable, which imposes a common variance but allows for a nonzero correlation.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-4 02:01:54
  • Baltagi, Song, and Jung (2001) estimate a Cobb–Douglas production function examining the productivity of public capitalin each state’s private output. Originally provided by Munnell (1990), the data were recorded over 1970–1986 for 48 states groupedinto nine regions.

. use http://www.stata-press.com/data/r13/productivity(Public Capital Productivity)

. describe


  • Because the states are nested within regions,we fit a three-level mixed model with random intercepts at both the region andthe state-within-region levels.

. mixed gsp private emp hwy water otherunemp || region: || state:


  • Our model now has two random-effects equations, separatedby ||. The first is a random intercept (constant only) at the regionlevel(level three), and the second is a random intercept at the state level(level two). The order in which these are specified (from left to right) issignificant—mixed assumes that state isnested within region.
  • The information on groups is now displayed as a table, withone row for each grouping. You can suppress this table with the nogrouporthe noheader option, which will suppress the rest of the header, aswell.
  • The variance-component estimates are now organized andlabeled according to level. After adjusting for the nested-level errorstructure, we find that the highway and water components of public capital hadsignificant positive effects on private output, whereas the other publicbuildings component had a negative effect.
  • In the previous example, the states are coded 1–48 and are nested within nine regions. mixed treated the states as nested within regions, regardless of whether the codes for each state were unique between regions. That is, even if codes for states were duplicated between regions, mixed would have enforced the nesting and produced the same results.
  • The group information at the top of the mixed output and that produced by the postestimation command estat group take the nesting into account. The statistics are thus not necessarily what you would get if you instead tabulated each group variable individually.


ME302

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-4 02:35:02
•        Returning to our productivity data, we now add random coefficients on hwy and unemp at the region level. This only slightly changes the estimates of the fixed effects, so we focus our attention on the variance components:
. mixed gsp private emp hwy water other unemp || region: hwy unemp || state:,nolog nogroup nofetable
•        The random-effects specification at the state level remains unchanged; that is, ∑2 is still treated as the scalar variance of the random intercepts at the state level.

•        An LR test comparing this model with that from example 4 favors the inclusion of the two random coefficients.
•        The estimated variance components, upon examination, reveal that the variances of the random coefficients on hwy and unemp could be treated as equal.
•        We construct block-diagonal covariances by repeating level specifications:
. mixed gsp private emp hwy water other unemp || region: hwy unemp,
> cov(identity) || region: || state:, nolog nogroup nofetable
•        We specified two equations for the region level: the first for the random coefficients on hwy and unemp with covariance set to Identity and the second for the random intercept cons, whose covariance defaults to Identity because it is of dimension 1. mixed labeled the estimate of ∑2  as var(hwy unemp) to designate that it is common to the random coefficients on both hwy and unemp.
•        An LR test shows that the constrained model fits equally well.
. lrtest . prodrc
•        Because the null hypothesis for this test is one of equality (H0 : σ2a = σ2b ), it is not on the boundary of the parameter space. As such, we can take the reported significance as precise rather than a conservative estimate
•        You can repeat level specifications as often as you like, defining successive blocks of a blockdiagonal covariance matrix. However, repeated-level equations must be listed consecutively; otherwise, mixed will give an error.
•        In the previous estimation output, there was no constant term included in the first region equation, even though we did not use the noconstant option. When you specify repeated-level equations, mixed knows not to put constant terms in each equation because such a model would be unidentified. By default, it places the constant in the last repeated-level equation, but you can use noconstant creatively to override this. Linear mixed-effects models can also be fit using meglm with the default gaussian family. Meglm provides two more covariance structures through which you can impose constraints on variance components.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-4 03:11:26
•        Following Rabe-Hesketh and Skrondal (2012, sec. 7.2), we analyze data from Asian children in a British community who were weighed up to four times, roughly between the ages of 6 weeks and 27 months. The dataset is a random sample of data previously analyzed by Goldstein (1986) and Prosser, Rasbash, and Goldstein (1991).
. use http://www.stata-press.com/data/r13/childweight
(Weight data on Asian children)
. describe
•        .
graph twoway (line weight age, connect(ascending)), by(girl)
> xtitle(Age in years) ytitle(Weight in kg)

•        Ignoring gender effects for the moment, we begin with the following model for the ith measurement on the jth child:
weightij = β0 + β1ageij + β2age2ij + uj0 + uj1ageij + Єij

•        This models overall mean growth as quadratic in age and allows for two child-specific random effects: a random intercept uj0, which represents each child’s vertical shift from the overall mean, and a random age slope uj1, which represents each child’s deviation in linear growth rate from the overall mean linear growth rate (_1). For simplicity, we do not consider child-specific changes in the quadratic component of growth.
. mixed weight age c.age#c.age || id: age, nolog
•        it is always a good idea to first fit a model with the covariance(unstructured) option.
•        Next we introduce gender effects into the fixed portion of the model by including a main gender effect and a gender–age interaction for overall mean growth:
. mixed weight i.girl i.girl#c.age c.age#c.age || id: age, nolog
•        The main gender effect is significant at the 5% level, but the gender–age interaction is not:
. test 0.girl#c.age = 1.girl#c.age

•        On average, boys are heavier than girls, but their average linear growth rates are not significantly different.
•        In the above model, we introduced a gender effect on average growth, but we still assumed that the variability in child-specific deviations from this average was the same for boys and girls. To check this assumption, we introduce gender into the random component of the model. Because support for factor-variable notation is limited in specifications of random we need to generate the interactions ourselves.
. gen boy = !girl
. gen boyXage = boy*age
. gen girlXage = girl*age
. mixed weight i.girl i.girl#c.age c.age#c.age || id: boy boyXage, noconstant
> || id: girl girlXage, noconstant nolog nofetable

•        Our previous model had the random-effects specification
|| id: age
which we have replaced with the dual repeated-level specification
|| id: boy boyXage, noconstant || id: girl girlXage, noconstant

•        The former models a random intercept and random slope on age, and does so treating all children as a random sample from one population. The latter also specifies a random intercept and random slope on age, but allows for the variability of the random intercepts and slopes to differ between boys and girls. In other words, it allows for heteroskedasticity in random effects due to gender. We use the noconstant option so that we can separate the overall random intercept (automatically provided by the former syntax) into one specific to boys and one specific to girls.
•        There seems to be a large gender effect in the variability of linear growth rates. We can compare both models with an LR test, recalling that we stored the previous estimation results under the name homoskedastic:
. lrtest homoskedastic heteroskedastic

•        Because the null hypothesis here is one of equality of variances and not that variances are 0, the above does not test on the boundary; thus we can treat the significance level as precise and not conservative. Either way, the results favor the new model with heteroskedastic random effects.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群