【问题标题】:Visual Graph of Regression in RR中回归的可视化图
【发布时间】:2012-12-15 07:12:08
【问题描述】:

我正在尝试在 R 中运行基本的时间序列回归。

reg<-lm(y~x)
summary(reg)
Call:lm(formula = y ~ x)

Residuals:
     Min       1Q   Median       3Q      Max 
-100.188  -21.600    0.503   21.999   97.296 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 102.53835    4.66296  21.990   <2e-16 ***
x            -0.03687    0.04524  -0.815    0.415   

但是,我还想要 y 变量、模型投影和下方残差的可视化图。 R中是否有能力进行这种回归?谢谢!

【问题讨论】:

  • 你试过plot(reg)吗?

标签: r regression


【解决方案1】:

我不完全确定你想要绘制什么。 以下为您提供了两张图 - 一张包含数据和模型预测,另一张包含残差。

par(mfrow=c(2,1))  # Two plots in one window

plot(x,y)                # Your datapoints
lines(x,predict(reg))    # The model prediction

plot(x, residuals(reg), ylab='Residuals')    # x vs. residuals

R 的线性模型绘图工具相当不错。我强烈建议您查看plot(reg) 的输出,如果解释正确,它可能会为您提供比您的图更多的信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-04
    • 2021-06-17
    • 1970-01-01
    • 2020-07-05
    • 1970-01-01
    • 2013-08-27
    • 2018-04-23
    • 2020-03-20
    相关资源
    最近更新 更多