I am very new to R, and trying to reproduce a Stata Output. I have the following Regression
formula2 <- as.formula(paste("lnwd ~ dreformd + ", paste("", PredictorVar2, collapse='+'), "+", paste("", PredictorYr, collapse='+')))
with dreformd being endogenous. I want to run a 2SLS by regressing dreformd on three instruments
datatwo$qz1 <- factor (with (datatwo, ifelse ((q1 == 1), 1, 0)))
datatwo$qz2 <- factor (with (datatwo, ifelse ((q1 == 2), 1, 0)))
datatwo$qz3 <- factor (with (datatwo, ifelse ((q1 == 0|q1 == 3), 1, 0)))
This would be my code:
library(car)
iv = ivregress(formula2, dreformd ~ qz1 + z2 + qz3, datatwo)
And all I get as Output is
Error in ivregress(formula2, dreformd ~ qz1 + qz2 + qz3, datatwo) :
could not find function "linearHypothesis"
I am lost here, I've tried everything and have no clue where the problem is. I've also tried using the ivreg function, but R cannot find that one either. The AER and CAR packages are installed. What am I missing ?
EDIT: tried installing CAR and AER with dependencies, still get the same error. The car package cannot load, and there is no pbkrtest package. Tried installing it, I get this error:
Warning in install.packages :
package ‘pbkrtest’ is not available (for R version 3.2.1)