| predict20x | R Documentation |
predict20x() gives predictions and intervals for a fitted model. It is
an S3 generic, so the same function works for linear models, generalised
linear models and tslm fits.
predict20x(object, ...)
## Default S3 method:
predict20x(object, ...)
## S3 method for class 'lm'
predict20x(
object,
newdata,
conf.level = 0.95,
digits = 3,
print.out = TRUE,
cilevel = conf.level,
...
)
## S3 method for class 'glm'
predict20x(
object,
newdata,
conf.level = 0.95,
digits = 3,
print.out = TRUE,
cilevel = conf.level,
type = c("response", "link", "odds"),
quasit = FALSE,
...
)
## S3 method for class 'tslm'
predict20x(object, newdata, ...)
object |
a fitted model, such as the output from |
... |
optional arguments that are passed to the model's prediction
method, or for other methods to |
newdata |
prediction data frame. |
conf.level |
confidence level for the intervals. |
digits |
number of decimal places to print. |
print.out |
if |
cilevel |
the older name for |
type |
for a |
quasit |
if |
For an lm fit the table holds fitted values, confidence intervals for
the mean response, and prediction intervals for new observations. For a
glm fit the intervals are confidence intervals, calculated on the link
scale and then transformed according to type.
The columns of newdata are matched to the model variables by name when
every variable is present. Otherwise they are taken in order, either one
column per variable or one column per model term.
This is not a method for predict, so it does not change what
predict() does for these models.
Invisibly returns an object of class s20xPrediction, which
prints as the prediction table. It is a list with components
data frame containing the predictions and intervals.
prediction values, on the link scale for a glm fit.
standard errors of predictions.
residual standard deviation, for an lm fit.
residual degrees of freedom, for an lm fit.
the scale of the results, for a glm fit.
confidence level of the interval.
predict, predict.lm, predict.glm.
# 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)
# A generalised linear model: predictions on the response scale
peru.glm = glm(BP ~ log(weight), data = peru.df, family = poisson)
predict20x(peru.glm, data.frame(weight = c(60, 70)))
predict20x(peru.glm, data.frame(weight = c(60, 70)), type = "link")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.