dLagM (version 1.0.19)

dlm: Implement finite distributed lag model

Description

Applies distributed lag models with one or multiple predictor(s).

Usage

dlm(formula , data , x , y , q , remove )

Arguments

formula

A formula object for the model to be fitted. In the case of multiple predictor series, the model should be entered via a formula object.

data

A data.frame including all dependent and independent series. In the case of multiple predictor series, the data should be entered via the data argument.

x

A vector including the observations of predictor time series. This is not restricted to ts objects. If the series are supplied by data

y

A vector including the observations of dependent time series. This is not restricted to ts objects.

q

An integer representing finite lag length.

remove

A list object showing the lags to be removed from the model for each independent series in its elements. Please see the details for the construction of this argument.

Value

model

An object of class lm.

designMatrix

The design matrix composed of transformed z-variables.

k

The number of independent series. This is returned if multiple independent series are entered.

q

The lag length.

removed

A list or vector showing the removed lags from the model for independent series. Returns NULL if the fitted model is full.

formula

Model formula of the fitted model. This is returned if multiple independent series are entered.

data

A data.frame including all dependent and independent series. This is returned if multiple independent series are entered.

Details

When a decision made on a variable, some of the related variables would be effected through time. For example, when income tax rate is increased, this would reduce expenditures of consumers on goods and services, which reduces profits of suppliers, which reduces the demand for productive inputs, which reduces the profits of the input suppliers, and so on (Judge and Griffiths, 2000). These effects occur over the future time periods; hence, they are distributed across the time.

In a distributed-lag model, the effect of an independent variable \(X\) on a dependent variable \(Y\) occurs over the time. Therefore, DLMs are dynamic models. A linear finite DLM with one independent variable is written as follows:

$$ Y_{t} = \alpha +\sum_{s = 0}^{q}\beta_{s}X_{t-s}+\epsilon_{t}, $$

where \(\epsilon_{t}\) is a stationary error term with \(E(\epsilon_{t})=0, Var(\epsilon_{t})=\sigma^{2},Cov(\epsilon_{t},\epsilon_{s})=0\).

When there is only one predictor series, both of model and formula objects can be used. But when they are supplied, both x and y arguments should be NULL.

The variable names in formula must match with the names of variables in data argument and it must be in the form of a generic formula for R functions.

The argument data contains dependent series and independent series. Required lags of dependent series are generated by the dlm function automatically.

The argument remove = list() is used to specify which lags will be removed from the full model. Each element of the list remove shows particular lags that will be removed from each independent series. Notice that it is possible to fit a model with different lag lengths for each independent series by removing the appropriate lags of independent series with remove argument. To remove the main series from the model include 0 within the elements of remove.

To remove the intercept from the model, if a formula is entered, just include "-1" in the model formula. Otherwise, include "-1" in the element remove of the list remove. See the examples below for implementation details.

The standard function summary() prints model summary for the model of interest.

References

B.H. Baltagi. Econometrics, Fifth Ed. Springer, 2011.

R.C. Hill, W.E. Griffiths, G.G. Judge. Undergraduate Econometrics. Wiley, 2000.

Examples

Run this code
# NOT RUN {
# Only one independent series
data(warming)
model.dlm = dlm(x = warming$NoMotorVehicles , 
                y = warming$Warming , q = 2)
summary(model.dlm)

removed = list(x = c(1,3))
model.dlm = dlm(x = warming$NoMotorVehicles , 
                y = warming$Warming , q = 5,
                remove = removed)
summary(model.dlm)

# Remove intercept as well
removed = list(x = c(1,3,-1))
model.dlm = dlm(x = warming$NoMotorVehicles , 
                y = warming$Warming , q = 5,
                remove = removed)
summary(model.dlm)

removed = list(x = c(0,1,3))
model.dlm = dlm(x = warming$NoMotorVehicles , 
                y = warming$Warming , q = 5,
                remove = removed)
summary(model.dlm)

model.dlm = dlm(formula = Warming ~ NoMotorVehicles , 
                data = warming , q = 2)
summary(model.dlm)

removed = list(x = c(0,3))
model.dlm = dlm(formula = Warming ~ NoMotorVehicles , 
                data = warming , q = 4,
                remove = removed)
summary(model.dlm)

# Remove intercept as well
removed = list(x = c(0,3,-1))
model.dlm = dlm(formula = Warming ~ NoMotorVehicles , 
                data = warming , q = 4,
                remove = removed)
summary(model.dlm)

# Multiple independent series
data(M1Germany)
data = M1Germany[1:144,]
model.dlm  = dlm(formula = logprice ~ interest + logm1, 
                 data = data.frame(data) , q = 4)
summary(model.dlm)

removed = list(interest = c(1,3), logm1 = c(2))
removed
model.dlm  = dlm(formula = logprice ~ interest + logm1, 
                 data = data.frame(data) , q = 4 , remove = removed)
summary(model.dlm)

removed = list(interest = c(0,1,3), logm1 = c(0,2))
removed
model.dlm  = dlm(formula = logprice ~ interest + logm1, 
                 data = data.frame(data) , q = 4 , remove = removed)
summary(model.dlm)

removed = list( logm1 = c(1,2))
removed
model.dlm  = dlm(formula = logprice ~ interest + logm1, 
                 data = data.frame(data) , q = 4 , remove = removed)
summary(model.dlm)
# }

Run the code above in your browser using DataCamp Workspace