Learn R Programming

gmm (version 1.0-2)

get_dat: Extracting data from a formula

Description

It extract the data from a formula y~z with instrument h and put everything in a matrix. It helps redefine the function $g(\theta,x)$ that is required by gmm and gel.

Usage

get_dat(formula,h,intercept=TRUE)

Arguments

formula
A formula that defines the linear model to be estimated (see details).
h
A $n\times nh$ matrix of intruments(see details).
intercept
Should the model include a constant? It should always be the case but the choice is yours.

Value

  • x: A $n \times l$ matrix, where $l = ncol(y)+ncol(z)+ncol(h)+2$ if "intercept" is TRUE and $ncol(y)+ncol(z)+xcol(h)$ if "intercept" is FALSE.

    nh: dimension of h

    k: dimension of z

    ny: dimension of y

Details

The model to be estimated is based on the moment conditions $=0$. It adds a column of ones to z and h if "intercept" is TRUE.

Examples

Run this code
n = 500
phi<-c(.2,.7)
thet <- 0.2
sd <- .2
x <- matrix(arima.sim(n=n,list(order=c(2,0,1),ar=phi,ma=thet,sd=sd)),ncol=1)
y <- x[7:n]
ym1 <- x[6:(n-1)]
ym2 <- x[5:(n-2)]
H <- cbind(x[4:(n-3)],x[3:(n-4)],x[2:(n-5)],x[1:(n-6)])

x <- get_dat(y~ym1+ym2,H)

Run the code above in your browser using DataLab