ols.predict {desk} | R Documentation |
Predictions in a Linear Model
Description
Calculates the predicted values of a linear model based on specified values of the exogenous variables. Optionally the estimated variance of the prediction error is returned.
Usage
ols.predict(mod, data = list(), xnew, antilog = FALSE, details = FALSE)
Arguments
mod |
model object generated by |
data |
name of data frame to be specified if |
xnew |
(T x K) matrix of new values of the exogenous variables, for which a prediction should be made, where |
antilog |
logical value which indicates whether to re-transform the predicted value of a log transformed dependent variable back into original units. |
details |
logical value, if specified as |
Value
A list object including:
pred.val | the predicted values. |
xnew | values of predictor at which predictions should be evaluated. |
var.pe | estimated variance of prediction error. |
sig.squ | estimated variance of error term. |
smpl.err | estimated sampling error. |
mod | the model estimated (for internal purposes) |
Examples
## Estimate logarithmic model
fert.est <- ols(barley ~ phos + nit, data = log(data.fertilizer))
## Set new x data
my.mat = cbind(x1 = log(c(6,3,9)), x2 = log(c(5,3,10)))
## Returns fitted values
ols.predict(fert.est)
## Returns predicted values at new x-values
ols.predict(fert.est, xnew = my.mat)
## Returns re-transformed predicted values and est. var. of pred. error
ols.predict(fert.est, xnew = my.mat, antilog = TRUE, details = TRUE)