我已經設置了一個線性 model 我希望創建一個 qq plot 。我可以在標准 R 控制台中使用plot(mymodel)然后再次按回車鍵,但是我怎樣才能在 Markdown 中生成這個 plot?
1 個解決方案
解決方案1
0 已采納 2021-01-31 19:57:13
您需要使用rstandard(mymodel)顯式訪問 model 的殘差,然后制作 qqplot。這是一個例子:
# simulate some data
dat <- as.data.frame(rmultinom(2, 1000, 1:50))
# build linear model
mymodel <- lm(dat$V1 ~ dat$V2)
# make qqplot of residuals
qqnorm(rstandard(mymodel))