简体   繁体   English

R中的回归(vs Eviews)

[英]Regression in R (vs Eviews)

When you do a regression in Eviews, you get a panel of statistics like this: 当您在Eviews中进行回归时,您会获得如下统计信息的面板:

在此输入图像描述

Is there a way in R in which I can get all/most of these statistics about a regression in R in one list as well? 在R中是否有一种方法可以在一个列表中获得关于R中的回归的所有/大部分统计数据?

See summary , which will produce summaries for most classes of regression object. 请参阅summary ,它将为大多数类的回归对象生成摘要。

For example, from help(glm) : 例如,来自help(glm)

> clotting <- data.frame(
+          u = c(5,10,15,20,30,40,60,80,100),
+          lot1 = c(118,58,42,35,27,25,21,19,18),
+          lot2 = c(69,35,26,21,18,16,13,12,12))
>      summary(glm(lot1 ~ log(u), data = clotting, family = Gamma))

Call:
glm(formula = lot1 ~ log(u), family = Gamma, data = clotting)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-0.04008  -0.03756  -0.02637   0.02905   0.08641  

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.0165544  0.0009275  -17.85 4.28e-07 ***
log(u)       0.0153431  0.0004150   36.98 2.75e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for Gamma family taken to be 0.002446059)

    Null deviance: 3.51283  on 8  degrees of freedom
Residual deviance: 0.01673  on 7  degrees of freedom
AIC: 37.99

Number of Fisher Scoring iterations: 3

The big win of R over GUI programs is generally that the output from functions is available. R对GUI程序的重大胜利通常是函数的输出可用。 So you can do: 所以你可以这样做:

> s =  summary(glm(lot1 ~ log(u), data = clotting, family = Gamma))
> s$coefficients[1,]
     Estimate    Std. Error       t value      Pr(>|t|) 
-1.655438e-02  9.275466e-04 -1.784749e+01  4.279149e-07 
> s$cov.scaled
              (Intercept)        log(u)
(Intercept)  8.603427e-07 -3.606457e-07
log(u)      -3.606457e-07  1.721915e-07

To get the t's and p's and all that for parameters, or the scaled covariance matrix. 获取t和p以及参数或缩放协方差矩阵的所有内容。 But always read the docs for the summary method to make sure you are getting what you think you are getting. 但是,请务必阅读摘要方法的文档,以确保获得您认为的结果。 Sometimes things in the returned object may be calculated on transformed scales, and presented on untransformed scales when the object is printed. 有时返回对象中的事物可以在变换后的尺度上计算,并且在打印对象时呈现在未变换的尺度上。

Note however that what you seem to have shown as an example is an ARIMA model, and there's no nice summary function for arima objects in R: 但请注意,您似乎作为示例显示的是ARIMA模型,并且R中的arima对象没有很好的summary函数:

> m = arima(lh, order = c(1,0,1))
> summary(m)
          Length Class  Mode     
coef       3     -none- numeric  
sigma2     1     -none- numeric  
var.coef   9     -none- numeric  
mask       3     -none- logical  
loglik     1     -none- numeric  
aic        1     -none- numeric  
arma       7     -none- numeric  
residuals 48     ts     numeric  
call       3     -none- call     
series     1     -none- character
code       1     -none- numeric  
n.cond     1     -none- numeric  
model     10     -none- list     

this is just the default summary for a list object with those elements. 这只是包含这些元素的列表对象的默认摘要。 Simply printing it gets you a few things: 只需打印它就可以获得以下几点:

> m

Call:
arima(x = lh, order = c(1, 0, 1))

Coefficients:
         ar1     ma1  intercept
      0.4522  0.1982     2.4101
s.e.  0.1769  0.1705     0.1358

sigma^2 estimated as 0.1923:  log likelihood = -28.76,  aic = 65.52

如果m是你的lm生成模型,只需执行: summary(m)来获取所有这些模型统计数据和数字。

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

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