Learn R Programming

plm (version 0.3-1)

dynformula: Dynamic Formula

Description

A function to create easily formula with lags

Usage

dynformula(formula, lag.form = NULL, diff.form = NULL, log.form = NULL)

Arguments

formula
a formula,
lag.form
a list containing the lag structure of each variable in the formula,
diff.form
a list of logical values indicating whether variables should be differenced,
log.form
a list of logical values indicating whether variables should be in logarithms.

Value

  • an object of class c("dynformula","formula"), which is a formula with four additional attributes : var, the names of the variables in the formula, lag, diff and log which store the information about lags, differences and logs.

Details

lag.form, diff.form and log.form should be lists of length equal to the total number variables. Each element of these lists is :
  • either a vector of length 2 (c(1,4)means lags 1,2,3 and 4) or a scalar (3means lags 0,1,2,3 except for the left--hand side variable for which it is 1,2,3) forlag.form.
  • logical values fordiff.formandlog.form.
  • It can also be an incomplete named list (to apply the transformation for only some variables) with eventually an unnamed element which then is the default value.

Examples

Run this code
# all variables in log, x1, x2 and x3 laged twice, y laged once and x3 differenced
dynformula(y ~ x1+x2+x3, lag.form = list(2,y=1),
    diff.form = list(x3=TRUE), log.form = TRUE)

Run the code above in your browser using DataLab