RPubs - Panel Data Examples Using R&Quot
RPubs - Panel Data Examples Using R&Quot
summary(random)
How do we know when to use fixed or random effects? We can use the Hausman Test, where the null
hypothesis is that the model is random effects and the alternative is that fixed effects are better fit. In this
example, the p-value is above .05 so a random effects model is the better fit for this data.
phtest(random, fixed)
##
## Hausman Test
##
## data: y ~ x1
## chisq = 3.674, df = 1, p-value = 0.05527
## alternative hypothesis: one model is inconsistent
Another way to analyze longitudinal data is through Latent Growth Modeling (LGM). LGM models time as a
latent variable similar to a multi-level modeling approach. To analyze LGM in R we use the lavaan package. To
analyze LGM in lavaan we use an artificial data set provided by lavaan The first step is to define the model
https://rpubs.com/mhanauer/278903 1/1