Closed Rgui closed 9 years ago
Using hmLewbel97.R which i assume is the most recent hmlewbel function
The object returned by hmlewbel is the result of res <- AER::ivreg(y ~ X + P|X + IV, x=TRUE )
which was called with the forumla y ~ X + P|X + IV
. So the output is technically correct.
But I guess the the desired result would be:
obj<-hmlewbel(Data_hmlewbel$y1 ~ Data_hmlewbel$X1 + Data_hmlewbel$X2 + Data_hmlewbel$P1, IIV = "yp")
Call: hmlewbel(formula = Data_hmlewbel$y1 ~ Data_hmlewbel$X1 + Data_hmlewbel$X2 + Data_hmlewbel$P1, IIV = "yp")
This can be achieved by replacing the call of the result of "AER::ivreg" with the call of the function itself:
res <- AER::ivreg(y ~ X + P|X + IV, x=TRUE )
res$call <- match.call()
return(res)
Did I get the desired output right?
Yes, now it shows hmlewbel when I call the function (instead of AER:ivreg), Thanks. But still the names of the variables appear to be X and P (like in the call of ivreg), but I want to appear in the call of ivreg the names of the variables in the formula of hmlewbel().
hmlewbel(formula = Data_hmlewbel$y1 ~ Data_hmlewbel$X1 + Data_hmlewbel$X2 + Data_hmlewbel$P1, IIV = "yp")
Coefficients:
(Intercept) XData_hmlewbel$X1 XData_hmlewbel$X2 P
3.294 1.406 2.958 -1.008
The coefficients should appear to be Data_hmlewbel$X1, Data_hmlewbel$X2 and Data_hmlewbel$P1 and not XData_hmlewbel$X1 XData_hmlewbel$X2 and P
I found a solution to this. Thanks. You can see it in the updated files
in hmlewbel.R the names of the variables returned are not the ones given in "formula" - see example below (the formula was y1~ M + P1, where M has two columns X1 and X2):
AER::ivreg(formula = y~ X + P | X + IV, x = TRUE)
Coefficients: (Intercept) XX1 XX2 P
3.4331 0.9484 3.1407 0.5571
could you please indicate how could I change that.
Thanks!