tidypredict_interval

It parses a model or uses an already parsed model to return a Tidy Eval formula that can then be used inside a dplyr command.

tidypredict_interval(model, interval = 0.95)

Arguments

model

An R model or a tibble with a parsed model. It currently supports lm() models only.

interval

The prediction interval, defaults to 0.95

Details

The result still has to be added to the fit to obtain the upper bound, and subtracted from fit to obtain the lower bound.

Examples

library(dplyr) df <- mutate(mtcars, cyl = paste0("cyl", cyl)) model <- lm(mpg ~ wt + cyl * disp, offset = am, data = df) tidypredict_interval(model)
#> (2.0595385527533) * sqrt(((((((((-0.176776695296637) * (-0.176776695296637) * #> (5.4148660732425)) + (((-0.590557271637747) + ((wt) * (0.183559646169165))) * #> ((-0.590557271637747) + ((wt) * (0.183559646169165))) * (5.4148660732425))) + #> ((((-0.126215672528828) + ((wt) * (0.0101118696567173))) + #> ((ifelse((cyl) == ("cyl6"), 1, 0)) * (0.428266330860589))) * #> (((-0.126215672528828) + ((wt) * (0.0101118696567173))) + #> ((ifelse((cyl) == ("cyl6"), 1, 0)) * (0.428266330860589))) * #> (5.4148660732425))) + (((((0.386215468111418) + ((wt) * #> (-0.230516217152034))) + ((ifelse((cyl) == ("cyl6"), 1, 0)) * #> (0.332336511639638))) + ((ifelse((cyl) == ("cyl8"), 1, 0)) * #> (0.646203930513815))) * ((((0.386215468111418) + ((wt) * #> (-0.230516217152034))) + ((ifelse((cyl) == ("cyl6"), 1, 0)) * #> (0.332336511639638))) + ((ifelse((cyl) == ("cyl8"), 1, 0)) * #> (0.646203930513815))) * (5.4148660732425))) + ((((((-0.153656347809448) + #> ((wt) * (0.30544122969658))) + ((ifelse((cyl) == ("cyl6"), #> 1, 0)) * (0.1509332046154))) + ((ifelse((cyl) == ("cyl8"), #> 1, 0)) * (0.76082884204827))) + ((disp) * (-0.00517897882607625))) * #> (((((-0.153656347809448) + ((wt) * (0.30544122969658))) + #> ((ifelse((cyl) == ("cyl6"), 1, 0)) * (0.1509332046154))) + #> ((ifelse((cyl) == ("cyl8"), 1, 0)) * (0.76082884204827))) + #> ((disp) * (-0.00517897882607625))) * (5.4148660732425))) + #> (((((((-0.0223589233233276) + ((wt) * (-0.0955117420011905))) + #> ((ifelse((cyl) == ("cyl6"), 1, 0)) * (1.88382983909738))) + #> ((ifelse((cyl) == ("cyl8"), 1, 0)) * (-0.403967380709359))) + #> ((disp) * (0.00228914819342199))) + (((disp) * (ifelse((cyl) == #> ("cyl6"), 1, 0))) * (-0.0108195644963774))) * ((((((-0.0223589233233276) + #> ((wt) * (-0.0955117420011905))) + ((ifelse((cyl) == ("cyl6"), #> 1, 0)) * (1.88382983909738))) + ((ifelse((cyl) == ("cyl8"), #> 1, 0)) * (-0.403967380709359))) + ((disp) * (0.00228914819342199))) + #> (((disp) * (ifelse((cyl) == ("cyl6"), 1, 0))) * (-0.0108195644963774))) * #> (5.4148660732425))) + ((((((((1.04062152259755) + ((wt) * #> (0.156526972089146))) + ((ifelse((cyl) == ("cyl6"), 1, 0)) * #> (-1.41229176936981))) + ((ifelse((cyl) == ("cyl8"), 1, 0)) * #> (-1.64546937617655))) + ((disp) * (-0.0133008166085693))) + #> (((disp) * (ifelse((cyl) == ("cyl6"), 1, 0))) * (0.0126666778900692))) + #> (((disp) * (ifelse((cyl) == ("cyl8"), 1, 0))) * (0.0132409552398366))) * #> (((((((1.04062152259755) + ((wt) * (0.156526972089146))) + #> ((ifelse((cyl) == ("cyl6"), 1, 0)) * (-1.41229176936981))) + #> ((ifelse((cyl) == ("cyl8"), 1, 0)) * (-1.64546937617655))) + #> ((disp) * (-0.0133008166085693))) + (((disp) * (ifelse((cyl) == #> ("cyl6"), 1, 0))) * (0.0126666778900692))) + (((disp) * #> (ifelse((cyl) == ("cyl8"), 1, 0))) * (0.0132409552398366))) * #> (5.4148660732425))) + (5.4148660732425))
Skip to content This repository Search Pull requests Issues Marketplace Explore @edgararuiz Sign out Unwatch 9 Star 5 Fork 5 rstudio/db.rstudio.com Code Issues 6 Pull requests 0 Projects 0 Wiki Insights Settings Tree: 7a7548589f Find file Copy pathdb.rstudio.com/themes/hugo-material-docs/layouts/partials/footer_js.html 7a75485 on Apr 22, 2017 @edgararuiz edgararuiz Fix to theme's scrollspy 1 contributor RawBlameHistory 84 lines (73 sloc) 2.83 KB © 2018 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About