| predict20x | R Documentation |
Teaching helper for linear-model predictions. It wraps
predict.lm and prints a compact table containing fitted values,
confidence intervals for the mean response, and prediction intervals for new
observations.
predict20x(object, newdata, cilevel = 0.95, digit = 3, print.out = TRUE, ...)
object |
an |
newdata |
prediction data frame. |
cilevel |
confidence level for the intervals. |
digit |
number of decimal places to print. |
print.out |
if |
... |
optional arguments that are passed to |
This is not an S3 predict() method and is not intended to be a
drop-in replacement for base R prediction methods. It is a compatibility
helper for older teaching material that expects confidence and prediction
intervals to be printed together. The standard predict
interface is preferred for new work.
Note: newdata must be a data frame with the same column order and
data types as those used in fitting the model. This is stricter than the usual
predict.lm() interface and is kept for compatibility with the original
teaching wrapper.
Invisibly returns a list with components
printed data frame containing predictions, confidence intervals, and prediction intervals.
prediction values.
standard errors of predictions.
residual standard deviation.
residual degrees of freedom.
confidence level of the interval.
This function is deprecated because it is no longer used in class.
Prefer the standard predict method for new work.
predict, predict.lm, as.data.frame.
# Zoo data
data(zoo.df)
zoo.df = within(zoo.df, {day.type = factor(day.type)})
zoo.fit = lm(log(attendance) ~ time + sun.yesterday + nice.day + day.type + tv.ads,
data = zoo.df)
pred.zoo = data.frame(time = 8, sun.yesterday = 10.8, nice.day = 0,
day.type = factor(3), tv.ads = 1.181)
predict20x(zoo.fit, pred.zoo)
# Peruvian Indians data
data(peru.df)
peru.fit = lm(BP ~ age + years + I(years^2) + weight + height, data = peru.df)
pred.peru = data.frame(age = 21, years = 2, `I(years^2)` = 2, weight = 71, height = 1629)
predict20x(peru.fit, pred.peru)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.