Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在plotly或ggplot2中仅绘制残差?_R_Ggplot2_Plot_Plotly_Linear Regression - Fatal编程技术网

R 如何在plotly或ggplot2中仅绘制残差?

R 如何在plotly或ggplot2中仅绘制残差?,r,ggplot2,plot,plotly,linear-regression,R,Ggplot2,Plot,Plotly,Linear Regression,如果我只想画残差,我可以 plot(model$residuals) 我会得到一个很好的散点图。如何在ggplot2或plotly中执行相同操作? 我不想绘制剩余值与拟合值 谢谢, 也许是这样 模特也许是这样 模型与@AllanCameron类似,您可以使用broom软件包,该软件包还提供了关于df中模型变量结果的其他选项: 与@AllanCameron类似,您可以使用broom软件包,该软件包还提供了关于df中模型变量结果的其他选项: library(ggplot2) library(bro

如果我只想画残差,我可以

plot(model$residuals)
我会得到一个很好的散点图。如何在ggplot2或plotly中执行相同操作? 我不想绘制剩余值与拟合值

谢谢, 也许是这样

模特也许是这样


模型与@AllanCameron类似,您可以使用broom软件包,该软件包还提供了关于df中模型变量结果的其他选项:


与@AllanCameron类似,您可以使用broom软件包,该软件包还提供了关于df中模型变量结果的其他选项:

library(ggplot2)
library(broom)
#Data
data("iris")
#Model
m1 <- lm(Sepal.Length~Sepal.Width,data=iris)
df <- augment(m1)
ggplot(df, aes(x = 1:nrow(df), y = .resid)) + geom_point() + xlab('x')