0

I'm trying to run a fixed effects regression using panel data in R with package plm and I keep getting an error saying that my vector "Fixed is not found", ergo I cannot run my regressions.

Here is my script

library(readr) 
library(plm)
eco_490_data <- read_csv("C:/Users/Steve's pc/Downloads/New folder (2)/Stephens eco class/eco 490 data.csv")
View(eco_490_data)
names(eco_490_data)
Fixed <- plm(Hom ~ LRM + Comp Employment  + beer + Poverty, + pop + Unemployment + Employment + Personal inc + prison pop data = eco_490_data, index = c("year", "msa"), model="within")
summary(Fixed)
### Here are the error's I'm getting  
 
Fixed <- plm(Hom ~ LRM + Comp Employment  + beer + Poverty, + pop + Unemployment + Employment + Personal inc + prison pop data = eco_490_data, index = c("year", "msa"), model="within")
# Error: unexpected symbol in "Fixed <- plm(Hom ~ LRM + Comp Employment"
summary(Fixed)
# Error in summary(Fixed) : object 'Fixed' not found


library(readr) 
library(plm)
eco_490_data <- read_csv("C:/Users/Steve's pc/Downloads/New folder (2)/Stephens eco class/eco 490 data.csv")
View(eco_490_data)
names(eco_490_data)
Fixed <- plm(Hom ~ LRM + Comp Employment  + beer + Poverty, + pop + Unemployment + Employment + Personal inc + prison pop data = eco_490_data, index = c("year", "msa"), model="within")
summary(Fixed)


Fixed <- plm(Hom ~ LRM + Comp Employment  + beer + Poverty, + pop + Unemployment + Employment + Personal inc + prison pop data = eco_490_data, index = c("year", "msa"), model="within")
# Error: unexpected symbol in "Fixed <- plm(Hom ~ LRM + Comp Employment"
summary(Fixed)
# Error in summary(Fixed) : object 'Fixed' not found
Helix123
  • 3,502
  • 2
  • 16
  • 36
  • It sounds like there was an issue with assigning the results of your `pml()` function into `Fixed`. What error do you get when you run just that assignment? – Eric Leung Jan 09 '21 at 19:20
  • Also, it would help us to help you if you shared a reproducible example when possible https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Eric Leung Jan 09 '21 at 19:24
  • the error's that im getting is unexpected symbol in my run of R – Steven cuomo Jan 09 '21 at 19:33
  • Is there any other piece of information from that error? Reading your code I'm still unable to figure out what may be wrong. The code looks fine to me. This is what I was using as a reference to double check your work https://www.econometrics-with-r.org/10-3-fixed-effects-regression.html. Maybe it'll help you debug as well. – Eric Leung Jan 09 '21 at 19:38
  • the error is unexpected symbol – Steven cuomo Jan 09 '21 at 19:52
  • You have a comma after `Poverty`. Remove that and your code should work (or at least give you a different error). – Eric Leung Jan 09 '21 at 20:12

1 Answers1

1

Remove the comma in your formula and move it before your data argument.

It also looks like some columns have spaces in them. You need to wrap those in back ticks for them to be processed correctly.

Fixed <- plm(Hom ~ LRM + Comp Employment  + beer + Poverty + pop + Unemployment + Employment + `Personal inc` + `prison pop`,
    data = eco_490_data,
    index = c("year", "msa"),
    model="within")
Eric Leung
  • 2,354
  • 12
  • 25