# Estimation of Taylor Rule

How to estimate the four parameters of the Augmented Taylor Rule
i_t=(1-ρ)α+(1-ρ)βπ_(t+n)+(1-ρ)γx_t+ρi_(t-1)+ε_t using Generalized Method of Moments (GMM)

### Load packages (using the library() or require() functions)

library("gmm")
library("momentfit")

### Define variables

dat <- ts(dat, start=c(2000,1), frequency=4)

# Exclude rows with missing entries.

dat <- dat[complete.cases(dat), ]
data1 = as.data.frame(dat)

### Create a function g(\theta; x) which returns an n * 3 matrix

gmm1 <- function(tet, data1)
{
m1 <- data1$R-(1-tet[2])*(tet[1]+tet[3]*data1$I+tet[4]*data1$G)+ tet[2]*lag(data1$R,-1)
f <- cbind(m1)
return(f)
}

### Compute the covariance matrix of parameters

Grand1 <- function(tet,data1)
{
h <- matrix(c( -(1-tet[2]),
(tet[1]+tet[3]*mean(data1$I)+tet[4]*mean(data1$G))+ mean(lag(data1$R,-1)), -(1-tet[2])*mean(data1$I),-(1-tet[2])*mean(data1\$G)),
nrow=1,ncol=4)
return(h)
}

### Run GMM using the starting values

print(res <- momentModel(gmm1, data1, theta0=c(beta0=1, beta1=1,beta3=2), grad = Grand1))
summary(res)

I have tried to create the R code above, but I get this error: Some moments are NA's. Make sure you remove missing values from x.