Learn R Programming

betaselectr (version 0.1.3)

predict.glm_betaselect: Predict Method for a 'glm_betaselect' Object

Description

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

Usage

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

Value

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

Arguments

object

A glm_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 glm_betaselect(). If model_type is "beta" or "standardized", it will be standardized using the setting of to_standardize when object is created in glm_betaselect().

...

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

Details

It simply passes the model before or after selected variables are standardized to the predict-method of a glm 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

glm_betaselect() and stats::predict.glm()

Examples

Run this code

data_test_mod_cat$p <- scale(data_test_mod_cat$dv)[, 1]
data_test_mod_cat$p <- ifelse(data_test_mod_cat$p > 0,
                              yes = 1,
                              no = 0)
logistic_beta_x <- glm_betaselect(p ~ iv*mod + cov1 + cat1,
                                  data = data_test_mod_cat,
                                  family = binomial,
                                  to_standardize = "iv")

predict(logistic_beta_x)
predict(logistic_beta_x, model_type = "raw")

Run the code above in your browser using DataLab