R中的线性回归使每个记录成为回归

时间:2016-08-03 17:23:02

标签: r linear-regression

我正在尝试使用R中的lm()函数进行线性回归。当我运行它时,看起来R正在获取每条记录并使其成为一个独立变量。

fit3 <- lm(no_outliers$strat_count ~ no_outliers$CDS_emerg + no_outliers$weighted_volume_avg)
summary(fit3)

这是输出的一个示例(有118个自变量,但我不想把它全部放在帖子上):

Coefficients:
                                            Estimate Std. Error t value Pr(>|t|)  
(Intercept)                                -336.1017  1065.5530  -0.315   0.7652 
no_outliers$weighted_volume_avg941931862     12.2047    31.2349   0.391   0.7121  
no_outliers$weighted_volume_avg949989365.5    4.0453    33.3295   0.121   0.9081  
no_outliers$weighted_volume_avg955100055.4   10.4469    31.3577   0.333   0.7525  
no_outliers$weighted_volume_avg961033059.1  -17.2295    32.3160  -0.533   0.6168  
no_outliers$weighted_volume_avg973785580     85.1891    40.0488   2.127   0.0867 .
no_outliers$weighted_volume_avg976666189.1   48.1133    39.9253   1.205   0.2821  
no_outliers$weighted_volume_avg979529996     26.2521    31.2707   0.840   0.4395  
no_outliers$weighted_volume_avg985701661.4   35.3185    35.8381   0.986   0.3696  
no_outliers$weighted_volume_avg988019226.8   66.4781    31.3502   2.120   0.0875 .
no_outliers$weighted_volume_avg994324495.5  -13.4227    32.9220  -0.408   0.7004  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 29.2 on 5 degrees of freedom
Multiple R-squared:  0.9752,    Adjusted R-squared:  0.3894 
F-statistic: 1.665 on 118 and 5 DF,  p-value: 0.3005 

非常感谢任何帮助或指示。

1 个答案:

答案 0 :(得分:2)

我猜weighted_volume_avg是一个因素。试试class(no_outliers$weighted_volume_avg)。如果应该首先将其转换为数字。尝试:

no_outliers$weighted_volume_avg <- as.numeric(as.character(no_outliers$weighted_volume_avg))

然后再次尝试lm