面板数据修复了R,I不';在摘要中看不到我所有的虚拟变量
我正在用R运行一个数据面板回归。 我使用这些(第2页) 我想对面板数据使用固定效果。请在下面找到我的固定效果代码面板数据修复了R,I不';在摘要中看不到我所有的虚拟变量,r,regression,panel,plm,R,Regression,Panel,Plm,我正在用R运行一个数据面板回归。 我使用这些(第2页) 我想对面板数据使用固定效果。请在下面找到我的固定效果代码 FE_1 <- plm(GDP_per_capita_growth ~ log(GDP_per_capita) + GF_GDP + MA_GDP + start_business + Invest_GDP + second_schooling + Pop_growth + log(I
FE_1 <- plm(GDP_per_capita_growth ~
log(GDP_per_capita) + GF_GDP + MA_GDP +
start_business + Invest_GDP +
second_schooling + Pop_growth +
log(Inflation_CPI) + Trade +
GF_GDP * start_business +
factor(as.character(time_fixed_effect)) +
factor(as.character(regional)) +
factor(as.character(oil_exporting_countries)),
data = Temp_1,
index = c("country",
"year"),
na.action = na.omit,
model = "within")
我想知道,我需要做什么来显示我所有的虚拟变量。我的代码中有错误吗
我没有使用index=c(“国家”、“年份”),
,而是编写了index=c(“年份”、“国家”),
,得到了以下结果:
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
log(GDP_per_capita) -3.3627e+00 2.0642e+00 -1.6291 0.105013
GF_GDP 1.2334e+00 1.8129e+00 0.6804 0.497127
MA_GDP 5.2312e-01 6.4419e+00 0.0812 0.935366
start_business 1.4314e-08 3.0105e-08 0.4755 0.635022
Invest_GDP -9.8744e-10 1.5174e-09 -0.6507 0.516025
second_schooling 1.0860e+00 1.0806e+00 1.0050 0.316205
Pop_growth -6.3753e-01 2.2690e-01 -2.8097 0.005494 **
log(Inflation_CPI) 1.4547e-01 2.5011e-01 0.5816 0.561550
Trade 9.2730e-04 3.8306e-03 0.2421 0.808991
factor(as.character(regional))2 -1.0668e+00 8.3584e-01 -1.2763 0.203441
factor(as.character(regional))3 -2.6186e-01 6.6220e-01 -0.3954 0.692972
factor(as.character(regional))4 1.4760e-01 7.9347e-01 0.1860 0.852639
factor(as.character(regional))5 1.3558e+00 7.2400e-01 1.8727 0.062696 .
factor(as.character(oil_exporting_countries))1 -1.8890e-01 4.4884e-01 -0.4209 0.674344
GF_GDP:start_business -2.9751e-08 1.3526e-07 -0.2199 0.826157
---
我不知道为什么我会得到这个结果!你能帮我找出原因吗?请帮我显示我的“时间固定效应”变量
提前感谢您的宝贵帮助
这是完整的代码
# Rename column names
colnames(my_data)[4] <- "Invest_GDP" # percentage
colnames(my_data)[9] <- "Pr_sector_GDP" # percentage
colnames(my_data)[12] <- "start_business"
colnames(my_data)[16] <- "second_schooling"
colnames(my_data)[18] <- "GDP_per_capita_growth"
# Transform column "inflation" as numeric
my_data$Inflation_CPI <- as.numeric(my_data$Inflation_CPI)
my_data$second_schooling <- as.numeric(my_data$second_schooling)
Temp_1 <- my_data %>%
select(
-region,
-Pr_sector_GDP,
-Prop_rights,
-T_freedom,
-current_invest
)
#重命名列名
colnames(my_data)[4]由于多重共线性,变量没有显示——正如@AntoniosK建议的那样,它们被删除plm
并不冗长,也没有告诉您这一点,但如果您使用lm
估计同一型号,您可以更清楚地看到这一点(我对输出进行了一点简化):
第二个plm
模型会得到不同的结果,因为它是一个不同的模型——你告诉它year
是你的实体固定效应,因此它是用年份模型而不是国家模型来估计模型
Again, using `lm`, here's what you are estimating:
> summary(lm(GDP_per_capita_growth ~
+ log(GDP_per_capita) + GF_GDP + MA_GDP +
+ start_business + Invest_GDP +
+ second_schooling + Pop_growth +
+ log(Inflation_CPI) + Trade +
+ GF_GDP * start_business + factor(year) +
+ factor(time_fixed_effect) +
+ factor(regional) +
+ factor(oil_exporting_countries),
+ data = Temp_1))
Call:
lm(formula = GDP_per_capita_growth ~ log(GDP_per_capita) + GF_GDP +
MA_GDP + start_business + Invest_GDP + second_schooling +
Pop_growth + log(Inflation_CPI) + Trade + GF_GDP * start_business +
factor(year) + factor(time_fixed_effect) + factor(regional) +
factor(oil_exporting_countries), data = Temp_1)
Residuals:
Min 1Q Median 3Q Max
-6.7279 -1.2924 -0.1109 1.2808 10.6906
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.032e+00 2.442e+00 3.699 0.000286 ***
log(GDP_per_capita) -3.363e+00 2.064e+00 -1.629 0.105013
GF_GDP 1.233e+00 1.813e+00 0.680 0.497127
MA_GDP 5.231e-01 6.442e+00 0.081 0.935366
start_business 1.431e-08 3.011e-08 0.475 0.635022
Invest_GDP -9.874e-10 1.517e-09 -0.651 0.516025
second_schooling 1.086e+00 1.081e+00 1.005 0.316205
Pop_growth -6.375e-01 2.269e-01 -2.810 0.005494 **
log(Inflation_CPI) 1.455e-01 2.501e-01 0.582 0.561550
Trade 9.273e-04 3.831e-03 0.242 0.808991
factor(year)2008 -2010 -9.536e-01 5.308e-01 -1.796 0.074056 .
factor(year)2011-2013 -1.449e+00 5.336e-01 -2.714 0.007269 **
factor(year)2014-2016 -2.261e+00 5.554e-01 -4.071 6.93e-05 ***
factor(time_fixed_effect)1 NA NA NA NA
factor(regional)2 -1.067e+00 8.358e-01 -1.276 0.203441
factor(regional)3 -2.619e-01 6.622e-01 -0.395 0.692972
factor(regional)4 1.476e-01 7.935e-01 0.186 0.852639
factor(regional)5 1.356e+00 7.240e-01 1.873 0.062696 .
factor(oil_exporting_countries)1 -1.889e-01 4.488e-01 -0.421 0.674344
GF_GDP:start_business -2.975e-08 1.353e-07 -0.220 0.826157
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.56 on 184 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.3063, Adjusted R-squared: 0.2384
F-statistic: 4.513 on 18 and 184 DF, p-value: 4.363e-08
现在还不清楚你想做什么。如果你解释一下你想通过分析达到什么目的,可能会有所帮助
您想要国家/地区和年份固定效果吗?
时间固定效应
变量到底在做什么
如果希望国家和年份固定效果,则需要参数effect=“twoway”
。默认情况下,plm
指定了effect=“individual”
,它只估计实体固定效应模型
FE_1 <- plm(GDP_per_capita_growth ~
log(GDP_per_capita) + GF_GDP + MA_GDP +
start_business + Invest_GDP +
second_schooling + Pop_growth +
log(Inflation_CPI) + Trade +
GF_GDP * start_business +
factor(as.character(regional)) +
factor(as.character(oil_exporting_countries)),
data = Temp_1,
index = c("country", "year"),
model = "within", effect = "twoway")
FE_1由于与其他变量的强相关性,您看不到的变量似乎被模型删除了。更多信息请点击这里:谢谢你对mych Antoniosk的评论!这是我的第一个想法。。。但是,我只是更改了代码的索引部分。我没有使用“index=c(“国家”,“年份”),而是写了index=c(“年份”,“国家”)。这样做的时候,我的区域虚拟变量显示在摘要中。真的很奇怪。是不是区域虚拟变量添加到摘要中了?可能你以前使用的另一个变量现在已经过时了?是的,现在是“时间固定”效应“他出去了!不确定,但可能与更改index=。
参数时算法的工作方式有关。我假设如果您多次运行完全相同的东西,您会得到相同的输出(变量和系数),对吗?非常感谢!我想有一年作为我的分析固定的影响。太好了!请注意一个小的修正-应该是index=c(“国家”、“年份”)
。实体应该首先运行。在plm模型上运行summary
时,应该会得到大致相同的输出。此外,您还可以查看向量您的\u plm\u模型$aliased
。
Again, using `lm`, here's what you are estimating:
> summary(lm(GDP_per_capita_growth ~
+ log(GDP_per_capita) + GF_GDP + MA_GDP +
+ start_business + Invest_GDP +
+ second_schooling + Pop_growth +
+ log(Inflation_CPI) + Trade +
+ GF_GDP * start_business + factor(year) +
+ factor(time_fixed_effect) +
+ factor(regional) +
+ factor(oil_exporting_countries),
+ data = Temp_1))
Call:
lm(formula = GDP_per_capita_growth ~ log(GDP_per_capita) + GF_GDP +
MA_GDP + start_business + Invest_GDP + second_schooling +
Pop_growth + log(Inflation_CPI) + Trade + GF_GDP * start_business +
factor(year) + factor(time_fixed_effect) + factor(regional) +
factor(oil_exporting_countries), data = Temp_1)
Residuals:
Min 1Q Median 3Q Max
-6.7279 -1.2924 -0.1109 1.2808 10.6906
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.032e+00 2.442e+00 3.699 0.000286 ***
log(GDP_per_capita) -3.363e+00 2.064e+00 -1.629 0.105013
GF_GDP 1.233e+00 1.813e+00 0.680 0.497127
MA_GDP 5.231e-01 6.442e+00 0.081 0.935366
start_business 1.431e-08 3.011e-08 0.475 0.635022
Invest_GDP -9.874e-10 1.517e-09 -0.651 0.516025
second_schooling 1.086e+00 1.081e+00 1.005 0.316205
Pop_growth -6.375e-01 2.269e-01 -2.810 0.005494 **
log(Inflation_CPI) 1.455e-01 2.501e-01 0.582 0.561550
Trade 9.273e-04 3.831e-03 0.242 0.808991
factor(year)2008 -2010 -9.536e-01 5.308e-01 -1.796 0.074056 .
factor(year)2011-2013 -1.449e+00 5.336e-01 -2.714 0.007269 **
factor(year)2014-2016 -2.261e+00 5.554e-01 -4.071 6.93e-05 ***
factor(time_fixed_effect)1 NA NA NA NA
factor(regional)2 -1.067e+00 8.358e-01 -1.276 0.203441
factor(regional)3 -2.619e-01 6.622e-01 -0.395 0.692972
factor(regional)4 1.476e-01 7.935e-01 0.186 0.852639
factor(regional)5 1.356e+00 7.240e-01 1.873 0.062696 .
factor(oil_exporting_countries)1 -1.889e-01 4.488e-01 -0.421 0.674344
GF_GDP:start_business -2.975e-08 1.353e-07 -0.220 0.826157
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.56 on 184 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.3063, Adjusted R-squared: 0.2384
F-statistic: 4.513 on 18 and 184 DF, p-value: 4.363e-08
FE_1 <- plm(GDP_per_capita_growth ~
log(GDP_per_capita) + GF_GDP + MA_GDP +
start_business + Invest_GDP +
second_schooling + Pop_growth +
log(Inflation_CPI) + Trade +
GF_GDP * start_business +
factor(as.character(regional)) +
factor(as.character(oil_exporting_countries)),
data = Temp_1,
index = c("country", "year"),
model = "within", effect = "twoway")