surr_rsq {SurrogateRsq} | R Documentation |
A function to calculate the surrogate R-squared measure.
Description
It can provide the surrogate R-squared for a user specified model.
This function will generate an S3 object of surrogate R-squared measure that will
be called from other functions of this package. The generic S3 function print
is also developed to present the surrogate R-squared measure.
Usage
surr_rsq(model, full_model, avg.num = 30, ...)
Arguments
model |
A reduced model that needs to be investigated. The reported surrogate R-square is for this reduced model. |
full_model |
A full model that contains all of the predictors in the data set. This model object should also contain the dataset for fitting the full model and the reduced model in the first argument. |
avg.num |
The number of replication for the averaging of surrogate R-square. |
... |
Additional optional arguments. |
Value
An object of class "surr_rsq"
is a list containing the following components:
surr_rsq |
the surrogate R-square value; |
reduced_model |
the reduced model under investigation. It should be a subset of the full model; |
full_model |
the full model used for generating the surrogate response. It should have passed initial variable screening and model diagnostics (see Paper for reference); |
data |
the dataset contains the response variable and all the predictors. |
References
Zhu, X., Liu, D., Lin, Z., Greenwell, B. (2022). SurrogateRsq: an R package for categorical data goodness-of-fit analysis using the surrogate R-squared
Examples
data("RedWine")
full_formula <- as.formula(quality ~ fixed.acidity + volatile.acidity +
citric.acid+ residual.sugar + chlorides + free.sulfur.dioxide +
total.sulfur.dioxide + density + pH + sulphates + alcohol)
full_mod <- polr(formula = full_formula,
data=RedWine, method = "probit")
select_model <- update(full_mod, formula. = ". ~ . - fixed.acidity -
citric.acid - residual.sugar - density")
surr_obj_sele_mod <- surr_rsq(model = select_model, full_model = full_mod,
data = RedWine, avg.num = 30)
print(surr_obj_sele_mod$surr_rsq, digits = 3)