简体   繁体   English

Stargazer-使用lapply进行多重线性回归模型并将其存储在R中的列表中

[英]Stargazer - using lapply to do mutliple linear regression models and store them in a list in R

df is data with values from 1-10 for 14 different variables formatted as a dataframe with n observations with lots of NA values for each variable which is why I couldn't do a regular lm with multiple predictors. df是14个不同变量的值从1到10的dataframe ,格式为n个观测值的dataframe ,每个变量具有很多NA值,这就是为什么我不能对多个预测变量进行常规lm

Then I used an lapply in order to do a linear regression for each variable because an MLR returns too many errors 然后,我使用了lapply以便对每个变量进行线性回归,因为MLR返回的错误太多

x = lapply(df[,-1], function(x) summary(lm(df$IV ~ x)))

this returns a large list made up of 13 elements that are all lists 这将返回一个由13个元素组成的大列表,这些元素都是列表

is.recursive(x) = TRUE

then I try to use stargazer 然后我尝试使用观星者

stargazer(x)

returns error 返回错误

Error in .summary.object$coefficients : $ operator is invalid for atomic vectors

how do i get rid of this error? 我如何摆脱这个错误?

尝试删除summary调用,以便xlm对象的列表,而不是summary.lm对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM