A simple class for ranges/intervals. Upon the S3 class range
, one
could define confidence/prediction intervals in a compact way, i.e. one
column instead of three (including lower, upper and level). It provides
the back-end for tbl_forecast
in the
tsibble package.
You could install the development version from Github using
# install.packages("devtools")
devtools::install_github("earowang/hilo")
library(hilo)
x <- rnorm(15)
y <- x + rnorm(15)
newdat <- data.frame(x = seq(-3, 3, length.out = 10))
pred <- as.data.frame(predict(lm(y ~ x), newdat, interval = "prediction"))
pred$PI <- bind_rng(lower = pred$lwr, upper = pred$upr, level = 95L)
pred
#> fit lwr upr PI
#> 1 -4.2 -6.76 -1.54 [-6.76, -1.54]95
#> 2 -3.2 -5.67 -0.80 [-5.67, -0.80]95
#> 3 -2.3 -4.61 -0.02 [-4.61, -0.02]95
#> 4 -1.4 -3.59 0.81 [-3.59, 0.81]95
#> 5 -0.5 -2.62 1.67 [-2.62, 1.67]95
#> 6 0.4 -1.70 2.59 [-1.70, 2.59]95
#> 7 1.4 -0.83 3.56 [-0.83, 3.56]95
#> 8 2.3 -0.01 4.58 [-0.01, 4.58]95
#> 9 3.2 0.77 5.64 [ 0.77, 5.64]95
#> 10 4.1 1.52 6.73 [ 1.52, 6.73]95
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.