R 基于协变量的OLS预测图

R 基于协变量的OLS预测图,r,ggplot2,plot,R,Ggplot2,Plot,我正在拟合一个线性模型mpg~disp+vs+wt 这是我的输出 model1 <- lm(mpg ~ disp + vs + wt, data = mtcars) summary(model1) Call: lm(formula = mpg ~ disp + vs + wt, data = mtcars) Residuals: Min 1Q Median 3Q Max -3.701 -2.413 -0.105 1.471 5.953 Coeffi

我正在拟合一个线性模型
mpg~disp+vs+wt

这是我的输出

model1 <- lm(mpg ~ disp + vs + wt, data = mtcars)
summary(model1)

Call:
lm(formula = mpg ~ disp + vs + wt, data = mtcars)

Residuals:
   Min     1Q Median     3Q    Max 
-3.701 -2.413 -0.105  1.471  5.953 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 32.82909    2.39738   13.69  6.2e-14 ***
disp        -0.00669    0.01077   -0.62   0.5395    
vs           2.63718    1.46349    1.80   0.0823 .  
wt          -3.83847    1.15368   -3.33   0.0025 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.81 on 28 degrees of freedom
Multiple R-squared:  0.804, Adjusted R-squared:  0.783 
F-statistic: 38.2 on 3 and 28 DF,  p-value: 4.94e-10
model1 | t |)
(截距)32.82909 2.39738 13.69 6.2e-14***
disp-0.00669 0.01077-0.62 0.5395
对2.63718 1.46349 1.80 0.0823。
wt-3.83847 1.15368-3.33 0.0025**
---
签名。代码:0'***'0.001'***'0.01'*'0.05'.'0.1''1
剩余标准误差:28个自由度上的2.81
倍数R平方:0.804,调整后的R平方:0.783
F-统计值:38.2在3和28 DF上,p-值:4.94e-10
如何创建
的绘图 -预测值图(pred(mpg(y))~disp(x),其中vs=0wt=wt的平均值

-预测值图(pred(mpg(y))~disp(x),其中vs=0wt=wt的第10个百分位

一个选项是预测单独数据框中的感兴趣趋势,并将其用作单独Geom的数据参数

库(ggplot2)

fit@teubrand,有趣的teunbrand,我会进一步研究这个。谢谢。