3

I'm trying to use instrument variables for the following three variables: pwtopen, inc, incsqr with the following three instruments: elhsfs, incf, incfsqr. polity is an exegenous variable.

    answer<- ivreg(sulfdm ~ polity + pwtopen + inc + incsqr|polity + elhsfs + incf + incfsqr, 
    mydata)

I am then getting the error message:
Error in ivreg(sulfdm ~ polity + pwtopen + inc + incsqr | polity + elhsfs + : length(formula)[1] == 1L is not TRUE

Any thoughts? Thanks

Marco
  • 2,368
  • 6
  • 22
  • 48
DJF
  • 103
  • 1
  • 9

2 Answers2

0

You should use the arguments in this case:

ivreg(formula, instruments, data, subset, na.action, weights, offset, contrasts = NULL, model = TRUE, y = TRUE, x = FALSE, …)

As you didn't specify the arguments, the function tried to use your data as "instrument".

So, this should solve your problem:

answer<- ivreg(sulfdm ~ polity + pwtopen + inc + incsqr|polity + elhsfs + incf + incfsqr, 
data = mydata)
0

I faced the same issue. Rewriting the command as below solved it:

 answer <- ivreg(sulfdm ~ polity + pwtopen + inc + incsqr, ~polity + elhsfs + incf + incfsqr, mydata)
ju_pi_car
  • 1
  • 1