Learn R Programming

betaselectr (version 0.1.3)

predict.lm_betaselect: Predict Method for an 'lm_betaselect' Object

Description

Compute the predicted values in a model fitted by lm_betaselect().

Usage

# S3 method for lm_betaselect
predict(
  object,
  model_type = c("beta", "standardized", "raw", "unstandardized"),
  newdata,
  ...
)

Value

It returns the output of stats::predict.lm().

Arguments

object

An lm_betaselect-class object.

model_type

The model from which the the predicted values are computed. For "beta" or "standardized", the model is the one after selected variables standardized. For "raw" or "unstandardized", the model is the one before standardization was done.

newdata

If set to a data frame, the predicted values are computed using this data frame. The data must be unstandardized. That is, the variables are of the same units as in the data frame used in lm_betaselect(). If model_type is "beta" or "standardized", it will be standardized using the setting of to_standardize when object is created in lm_betaselect().

...

Arguments to be passed to stats::predict.lm(). Please refer to the help page of stats::predict.lm().

Details

It simply passes the model before or after selected variables are standardized to the predict-method of an lm object.

IMPORTANT

Some statistics, such as prediction or confidence interval, which make use of the sampling variances and covariances of coefficient estimates may not be applicable to the models with one or more variables standardized. Therefore, they should only be used for exploratory purpose.

See Also

lm_betaselect() and stats::predict.lm()

Examples

Run this code

data(data_test_mod_cat)

lm_beta_x <- lm_betaselect(dv ~ iv*mod + cov1 + cat1,
                           data = data_test_mod_cat,
                           to_standardize = "iv")
predict(lm_beta_x)
predict(lm_beta_x, model_type = "raw")

Run the code above in your browser using DataLab