A function to calculate the surrogate R-squared measure.Source:
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
A reduced model that needs to be investigated. The reported surrogate R-square is for this reduced 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.
The number of replication for the averaging of surrogate R-square.
Additional optional arguments.
An object of class
"surr_rsq" is a list containing the following components:
the surrogate R-square value;
the reduced model under investigation. It should be a subset of the 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);
the dataset contains the response variable and all the predictors.
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
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) #>  0.408