ggvis scatter plot with 95% prediction interval

回眸只為那壹抹淺笑 提交于 2020-01-04 01:19:13

问题


library(ggvis)
mtcars %>% 
  ggvis(~wt, ~mpg) %>%
  layer_points() %>%
  layer_model_predictions(model = "lm", se = TRUE)

The above produces a scatter plot with a fitted regression line and 95% confidence limits on

.

Question: How to draw a scatter plot with a fitted regression line and 95% prediction limits on

?

回答1:


Here is an idea. It probably needs more work to get exactly what you're after though.

mtcars.pi = data.frame(mtcars, predict(lm(mpg~wt,data=mtcars), interval="prediction"))
mtcars.pi %>% 
ggvis(~wt, ~mpg) %>%
layer_points() %>%
layer_ribbons(y=~lwr, y2=~upr, opacity:=.5) %>%
layer_model_predictions(model = "lm", se = TRUE)


来源:https://stackoverflow.com/questions/25300094/ggvis-scatter-plot-with-95-prediction-interval

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!