ols.predict | R Documentation |
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.
ols.predict(mod, data = list(), xnew, antilog = FALSE, details = FALSE)
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 |
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) |
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.