Learn R Programming

memisc (version 0.11-9)

prediction.frame: Data frame of model predictions and independent variables

Description

prediction.frame is a convenience function that produces a data frame of independent variables and predictions of a fitted model.

Usage

## S3 method for class 'default':
prediction.frame(object,newdata=NULL,...,residuals=NULL)

Arguments

object
a model object from which predictions are generated.
newdata
an optional data frame for out-of-sample predictions.
...
further arguments passed to predict.
residuals
a character vector that specifies residuals that are added to the resulting data frame.

Value

  • A data frame.

Examples

Run this code
lm1 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
lm2 <- lm(sr ~ pop15 + pop75 + dpi + ddpi + pop15*dpi, data = LifeCycleSavings)

str(prediction.frame(lm1))
str(prediction.frame(lm1, se.fit=TRUE))
str(prediction.frame(lm1, interval="prediction"))
str(prediction.frame(lm1, type="terms"))
str(prediction.frame(lm1,
                  se.fit=TRUE,
                  type="terms"))

str(prediction.frame(lm1,
                  se.fit=TRUE,
                  type="terms",
                  residuals="working"))

str(prediction.frame(lm1,
                  se.fit=TRUE,
                  type="terms",
                  residuals="partial"))

str(prediction.frame(lm2,
                  se.fit=TRUE,
                  type="terms",
                  residuals="partial"))

berkeley <- aggregate(wtable(Admit,Freq)~.,data=UCBAdmissions)
berk2 <- glm(cbind(Admitted,Rejected)~Gender+Dept,data=berkeley,family="binomial")

str(prediction.frame(berk2,
                  se.fit=TRUE,
                  type="terms",
                  residuals="partial"))

Run the code above in your browser using DataLab