[R] 2SLS with Fixed Effects and Control Variables

Achim Zeileis Ach|m@Ze||e|@ @end|ng |rom u|bk@@c@@t
Sun Jan 28 23:33:48 CET 2024


Kelis,

thanks for your interest. It's hard to say what exactly goes wrong based 
on the information you provide. However, I would recommend that you first 
process the data:

- Store all variables as the appropriate types (numeric, factor, etc.) 
in the data frame. Then you don't have to put these things into the model 
formula.

- Employ variable names without spaces, then you don't have to use 
backquotes.

Hopefully, this helps you to resolve the problem.

If the problem persists and you believe that this is an error within 
ivreg, please provide a minimal self-contained and reproducible example.

Best regards,
Achim


On Sun, 28 Jan 2024, Kelis Wong wrote:

> Dear John Fox, Christian Kleiber, and Achim Zeileis,
> 
> I am attempting to run various independent variable parameters to assess
> their suitability. Unfortunately, I hit a snag and couldn't get the tests to
> run properly. When I used ivreg, I got an error message saying: "Error in
> eval(predvars, data, env) : object 'WageInequality' not found." 
> Can you please help?
> Model: numeric(WageInequality) = numeric(EffectiveMinimum) +
> numeric(EffectiveMinimum2)
> (whereas EffectiveMinimum2 is the quadratic form of EffectiveMinimum)
> 
> Instruments: numeric(`Log Real Minimum Wage`) + numeric(`Log Real Minimum
> Wage2`) + numeric(IVinteration)
> (whereas Real Minimum Wage2 is the quadratic form of Real Minimum Wage)
> 
> Time and Region Fixed Effects: factor(Region) + numeric(Year) + Region:Year
> (whereas Region:Year is and interaction term of Region and Year)
> 
> Control Variables: factor(Region), numeric(`Woman Percentage`),
> numeric(`Noneducated Percentage`)
> 
> Parameter 1:
> ivreg(WageInequality ~ EffectiveMinimum + EffectiveMinimum2 + Region | `Log
> Real Minimum Wage` + `Log Real Minimum Wage2` + IVinteration + Region,
> dataset))
> 
> Parameter 2:
> ivreg(WageInequality ~ EffectiveMinimum + EffectiveMinimum2 + Region + Year
> + Region:Year | `Log Real Minimum Wage` + `Log Real Minimum Wage2` +
> IVinteration + Region + Year + Region:Year, dataset))
> 
> Parameter 3:
> ivreg(WageInequality ~ EffectiveMinimum + EffectiveMinimum2 + Region + Year
> + Region:Year + `Woman Percentage` + `Noneducated Percentage` | `Log Real
> Minimum Wage` + `Log Real Minimum Wage2` + IVinteration + Region + Year +
> Region:Year + `Woman Percentage` + `Noneducated Percentage`, dataset))
> 
> --
> Peace,
> 
> Kelis Wong
> 
>


More information about the R-help mailing list