50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


dlsem (version 1.5)

dlsem: Distributed-lag structural equation modelling

Description

Estimation of a structural equation model with second-order polynomial and gamma lag shapes.

Usage

dlsem(model.code, group = NULL, exogenous = NULL, data, log = FALSE, control = NULL, imputation = TRUE, uniroot.check = TRUE, test = "adf", combine = "choi", k = 0, lshort = TRUE, maxdiff = 5, tol = 0.0001, maxit = 500, selection = "aic", plotDir = NULL)

Arguments

model.code
A list of objects of class formula, each describing a single regression model. See Details.
group
The name of the group factor (optional). If NULL, no groups are considered.
exogenous
The name of exogenous variables (optional). Exogenous variables never appear on the left side of an equation and are not lagged.
data
An object of class data.frame containing data.
log
Logical. If TRUE, logarithmic transformation is applied to quantitative variables. Default is FALSE.
control
A list containing options for estimation. See Details.
imputation
Logical. If TRUE, missing values will be imputed using the EM algorithm. Default is FALSE.
uniroot.check
Logical. If TRUE, unit root test is performed for each variable, and appropriate differentation is applied. Default is FALSE.
test
The unit root test to use, that can be either "adf" or "kpss" (see unirootTest). Ignored if uniroot.check=FALSE. Default is "adf".
combine
The method to combine p-values of different groups, that can be either "choi" or "demetrescu" (see unirootTest). Ignored if uniroot.check=FALSE or group is NULL. Default is "choi".
k
The lag order to calculate the statistic of the Augmented Dickey-Fuller test. Ignored if uniroot.check=FALSE or if test="kpss". Default is 0.
lshort
Logical. If TRUE, the short version of the truncation lag parameter is used for the KPSS test. Ignored if uniroot.check=FALSE or if test="adf". Default is TRUE.
maxdiff
The maximum differentiation order to apply. Ignored if uniroot.check=FALSE. Default is 5.
maxit
The maximum number of iterations for the EM algorithm (see EM.imputation). Ignored if imputation=FALSE. Default is 500.
tol
The tolerance threshold of the EM algorithm (see EM.imputation). Ignored if imputation=FALSE. Default is 0.0001.
selection
The criterion to be used for the adaptation of lag shapes, that can be one among "aic" to minimise the Akaike Information Criterion, "bic" to minimise the Bayesian Information Criterion (AIC), and "mdl" to minimise the Minimum Description Length. Default is "aic".
plotDir
A directory where to save the plots of the lag shapes (optional). If NULL, no plots will be produced.

Value

dlsem, with the following components:S3 methods available for class dlsem are:

Details

Formulas cannot contain interaction terms (no ':' or '*' symbols), and may contain the following operators for lag specification:
  • quec: quadratic (2nd order polynomial) lag shape with endpoint constraints;
  • qdec: quadratic (2nd order polynomial) decreasing lag shape.
  • gamma: gamma lag shape.

Each operator must have the following three arguments (provided within brackets):

  1. the name of the covariate to which the lag is applied;
  2. the minimum lag with a non-zero coefficient (for 2nd order polynomial lag shapes), or the delta parameter (for the gamma lag shape)
  3. the maximum lag with a non-zero coefficient (for 2nd order polynomial lag shapes), or the lambda parameter (for the gamma lag shape).

For example, quec(X1,3,15) indicates that a quadratic lag shape with endpoint constraints must be applied to variable X1 in the interval (3,15), and gamma(X1,0.75,0.8) indicates that a gamma lag shape with delta=0.75 and lambda=0.8 must be applied to variable X1. The formula of regression models with no covariates excepting exogenous variables can be omitted from argument model.code. Variables appearing in any formula are treated as quantitative. The group factor and exogenous variables must not appear in any formula.

Argument control must be a named list containing one or more among the following components:

  • L: a named vector of non-negative integer values including the highest lag with non-zero autocorrelation for one or more response variables. If greater than 0, the Newey-West correction of the covariance matrix of estimates (Newey and West, 1987) is used. Default is 0 for all response variables.
  • adapt: a named vector of logical values indicating if adaptation of lag shapes must be performed for one or more response variables. Default is FALSE for all response variables.
  • max.gestation: a named list. Each component of the list must refer to one response variable and contain a named vector, including the maximum gestation lag for one or more covariates. If not provided, it is taken as equal to max.width (see below). Ignored if adapt=FALSE for a certain covariate.
  • min.width: a named list. Each component of the list must refer to one response variable and contain a named vector, including the minimum lag width for one or more covariates. If not provided, it is taken as 0. Ignored if adapt=FALSE for a certain covariate.
  • max.width: a named list. Each component of the list must refer to one response variable and contain a named vector, including the maximum lag width for one or more covariates. If not provided, it is computed accordingly to the sample size. Ignored if adapt=FALSE for a certain covariate.
  • sign: a named list. Each component of the list must refer to one response variable and contain a named vector, including the sign (either '+' for non-negative, or '-' for non-positive) of the coefficients of one or more covariates. If not provided, adaptation will disregard the sign of coefficients. Ignored if adapt=FALSE for a certain covariate.

Variables appearing in the model code but not included in data will be considered as unobserved. If there is at least one unobserved variable, imputation using EM will be performed whatever the value of argument imputation.

References

A. Magrini, F. Bartolini, A. Coli, and B. Pacini (2016). Distributed-Lag Structural Equation Modelling: An Application to Impact Assessment of Research Activity on European Agriculture. Proceedings of the 48th Meeting of the Italian Statistical Society, 8-10 June 2016, Salerno, IT.

W. K. Newey, and K. D. West (1978). A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55(3), 703-708.

See Also

unirootTest, applyDiff, EM.imputation

Examples

Run this code
data(industry)

# estimation without control options
mycode <- list(
  Consum~quec(Job,0,6),
  Pollution~quec(Job,1,11)+quec(Consum,1,6)
  )
myfit <- dlsem(mycode,group="Region",exogenous=c("Population","GDP"),
  data=industry,uniroot.check=TRUE,log=TRUE)


### adaptation of lag shapes (may take some seconds more)
## model code
#mycode <- list(
#  Consum~quec(Job,0,15),
#  Pollution~quec(Job,0,15)+quec(Consum,0,15)
#  )
#                      
#mycontrol <- list(
#  adapt=c(Consum=T,Pollution=T),
#  max.gestation=list(Consum=c(Job=3),Pollution=c(Consum=3,Job=3)),
#  min.width=list(Consum=c(Job=5),Pollution=c(Consum=5,Job=5)),
#  max.width=list(Consum=c(Job=15),Pollution=c(Consum=15,Job=15)),
#  sign=list(Consum=c(Job="+"),Pollution=c(Consum="+",Job="+"))
#  )
#myfit <- dlsem(mycode,group="Region",exogenous=c("Population","GDP"),data=industry,
#  control=mycontrol,uniroot.check=TRUE,log=TRUE)


# summaries of estimation
summary(myfit)

# display the directed acyclic graph
plot(myfit)

Run the code above in your browser using DataLab