#load data
data(dataHigherMoments)
y <- dataHigherMoments[,1]
X <- cbind(dataHigherMoments[,2],dataHigherMoments[,3])
colnames(X) <- c("X1","X2")
P <- dataHigherMoments[,4]
# call higherMomentsIV with internal instrument yp = (Y - mean(Y))(P - mean(P))
h <- higherMomentsIV(y,X,P, G = "x2", IIV = "yp")
# build an additional instrument p2 = (P - mean(P))^2 using the internalIV() function
eiv <- internalIV(y,X,P, G="x2", IIV = "p2")
# use the additional variable as external instrument in higherMomentsIV()
h1 <- higherMomentsIV(y,X,P,G = "x2",IIV = "yp", EIV=eiv)
summary(h1)
# get the robust standard errors using robust.se() function from package ivpack
# library(ivpack)
# sder <- robust.se(h1)
Run the code above in your browser using DataLab