Estimate dynamic panel models with fixed effects via maximum likelihood estimation.
dpm(formula, data, error.inv = FALSE, const.inv = FALSE, alpha.free = FALSE, y.lag = 1, y.free = FALSE, x.free = FALSE, fixed.effects = TRUE, print.only = FALSE, id = NULL, wave = NULL, err.inv = NULL, ...)
Model formula. See details for instructions on specifying parameters properly.
Data frame in "long" format. Prefers a "panel_data" object.
Constrain the error variance to be equal across waves. Default is FALSE.
Constrain the dependent variable's variance to be equal across waves. This removes cross-sectional dependence. Default is FALSE.
Estimate each wave of the dependent variable's loading on the alpha latent variable. Default is FALSE, meaning each wave has a loading of 1.
Which lag(s) of the dependent variable to include in the regression. Default is 1, but any number of vector of numbers can be used.
If TRUE, allows the regression coefficient(s) for the lagged dependent variable to vary over time. Default is FALSE. You may alternately provide a number or vector of numbers corresponding to which lags should vary freely.
If TRUE, allows the regressions coefficient(s) for the predictor(s) to vary over time. Default is FALSE. If TRUE, the predictor regression coefficient(s) can vary over time. Alternately, you may provide a character vector of predictors to allow to vary if you only want a subset of predictors to vary.
Fit a fixed effects model? Default is TRUE. If FALSE, you get a random effects specification instead.
Instead of estimating the model, print the lavaan model string to the console instead.
Name of the data column that identifies which individual the
observation is. Not needed if
Name of the data column that identifies which wave the
observation is from. Not needed if
Deprecated, same purpose as
Extra parameters to pass to
An object of class
dpm which has its own
dpm object is an extension of the
lavaan class and has all
the capabilities of
lavaan objects, with some extras.
It contains extra slots for:
mod_string, the character object used to specify the model
to lavaan. This is helpful if you want to fit the model yourself or
wish to check that the specification is correct.
wide_data, the widened data frame necessary to fit the SEM.
The right-hand side of the formula has two parts, separated by a bar
|). The first part should include the time-varying predictors.
The second part, then, is for the time-invariant variables. If you put
a time-varying variable in the second part of the formula, by default
the first wave's value of that variable is treated as the constant.
You must include time-varying predictors. If you do not include a bar in the formula, all variables are treated as time-varying.
To set a variable as predetermined, or weakly exogenous, surround the
variable with a
pre function. For instance, if you want the variable
union to be predetermined, you could specify the formula like this:
wks ~ pre(union) + lwage | ed, where
wks is the dependent
lwage is a strictly exogenous time-varying predictor,
ed is a strictly exogenous time-invariant predictor.
To lag a predictor, surround the variable with a
lag function in
the same way. Note that the lag function used is specific to this package,
so it does not work the same way as the built-in lag function.
Allison, P. D., Williams, R., & Moral-Benito, E. (2017). Maximum likelihood for cross-lagged panel models with fixed effects. Socius, 3, 1–17. http://journals.sagepub.com/doi/10.1177/2378023117710578
# Load example data data("WageData", package = "panelr") # Convert data to panel_data format for ease of use wages <- panel_data(WageData, id = id, wave = t) # Replicates Allison, Williams, & Moral-Benito (2017) analysis fit <- dpm(wks ~ pre(lag(union)) + lag(lwage) | ed, data = wages, error.inv = TRUE, information = "observed") # Note: information = "observed" only needed to match Stata/SAS standard errors summary(fit)#> MODEL INFO: #> Dependent variable: wks #> Total observations: 595 #> Complete observations: 595 #> Time periods: 2 - 7 #> #> MODEL FIT: #> <U+0001D6D8>²(76) = 138.476 #> RMSEA = 0.037, 90% CI [0.027, 0.047] #> p(RMSEA < .05) = 0.986 #> SRMR = 0.025 #> #> | | Est. | S.E. | z val. | p | #> |:------------------|-------:|------:|-------:|------:| #> | union (t - 1) | -1.206 | 0.522 | -2.309 | 0.021 | #> | lwage (t - 1) | 0.588 | 0.488 | 1.204 | 0.229 | #> | ed | -0.107 | 0.056 | -1.893 | 0.058 | #> | wks (t - 1) | 0.188 | 0.020 | 9.586 | 0.000 | #> #> Model converged after 603 iterations