首页 > 解决方案 > R中带有“ldpy”的多重线性回归问题

问题描述

我正在尝试用 R 计算多元线性回归,我想在数据框中获得结果。我必须使用过滤器,因为我需要计算对不同国家/地区的回归:

## No controls. ("unadjusted" pay gap.)
model1 <- dlply(data, 'Pais', function(df) 
lm(log_total ~ male, data = df)
## Apply coef to each model and return a data frame 
df1 <- ldply(model1, coef)
model2 <- dlply(data, 'Pais', function(df)  
lm(log_total ~ male + age_bin, data = df))
df2 <- ldply(model2, coef)
### Adding all controls. ("adjusted" pay gap.)
model3 <- dlply(data, 'Pais', function(df) 
lm(log_total ~ male + + age_bin + dept + seniority + jobTitle, data = df))
df3 <- ldply(model3, coef)

我在模型 3 中遇到问题,因为我没有获得 df3 并且我不知道如何解决问题..

非常感谢。

标签: rregression

解决方案


推荐阅读