簡體   English   中英

R 中的固定效果回歸

[英]Fixed effects regression in R

我正在嘗試使用 R 和 package plm中的面板數據運行固定效果回歸,並且我不斷收到錯誤消息,說我的向量“未找到固定”,因此我無法運行我的回歸。

這是我的腳本

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

刪除公式中的逗號並將其移到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")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM