Im trying to do a gmm using this data:
X <- cbind(rep(1,800), data$Prices,data$Efectivity)
delta <- data$delta_j_i
Z <- cbind(rep(1,800),data$Price_Active_Ingredient,data$Mean_Price_Secundary_Ingredients)
I'm performing the gmm in this way:
start <- inv(t(X)%*%X)%*%(t(X)%*%delta)
fusion <- cbind(delta,X,Z)
g <- function(tet,x) {
beta0 <- tet[1]
alpha <- tet[2]
beta1 <- tet[3]
xi <- matrix((x[,1])-beta0-(alpha*x[,2])-(beta1*x[,3]))
G <- (1/800)*(t(x[,5:7])%*%xi)
gmm <- t(G)%*%G
print(gmm)
return(gmm)
}
result_gmm <- gmm(g,x=fusion,t0=betas)
But after some iterations then give the error: Error in ar.ols(x, aic = aic, order.max = order.max, na.action = na.action, :
'order.max' must be < 'n.used'
Do you know what is happening?
question from:
https://stackoverflow.com/questions/65907708/error-in-using-gmm-function-error-in-ar-olsx-aic-aic-order-max-order-max 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…