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

View source: R/lm_betaselect_methods.R

predict.lm_betaselectR Documentation

Predict Method for an 'lm_betaselect' Object

Description

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

Usage

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

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.

Value

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

Author(s)

Shu Fai Cheung https://orcid.org/0000-0002-9871-9448

See Also

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

Examples


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")


betaselectr documentation built on April 3, 2025, 8:51 p.m.