具有 95% 预测区间的 ggvis 散点图 [英] ggvis scatter plot with 95% prediction interval

查看:66
本文介绍了具有 95% 预测区间的 ggvis 散点图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

以上生成了一个散点图,带有拟合回归线和 95% 置信限 .

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

问题:如何在 预测限制的散点图/chart?cht=tx&chl=%5Cmu_%7BY%7Cx%7D" alt="f">?

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

推荐答案

这里有一个想法.可能需要做更多的工作才能准确地获得您想要的东西.

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)

这篇关于具有 95% 预测区间的 ggvis 散点图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆