# load data
data(dataHigherMoments)
y <- dataHigherMoments[,1]
X <- cbind(dataHigherMoments[,2],dataHigherMoments[,3])
colnames(X) <- c("X1","X2")
P <- dataHigherMoments[,4]
# build an instrument gp = (G - mean(G))(P - mean(P)) using the internalIV() function
# with G = "x3" meaning G(X) = X^3
eiv <- internalIV(y,X,P, G ="x3", IIV = "gp")
Run the code above in your browser using DataLab