Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

plm - Fixed effects regression in R

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
question from:https://stackoverflow.com/questions/65644100/fixed-effects-regression-in-r

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...