Title: | Stepwise Procedure for Beta, Beta-Binomial and Negative Binomial Regression Models |
---|---|
Description: | Starting from a Regression Model, it provides a stepwise procedure to select the linear predictor. |
Authors: | Sergio Garofalo |
Maintainer: | Sergio Garofalo <[email protected]> |
License: | GPL-3 |
Version: | 2.1.0 |
Built: | 2025-02-19 04:43:55 UTC |
Source: | https://github.com/cran/StepBeta |
StepBeta and StepBetaBinomial internal object
check_formula_terms(model)
check_formula_terms(model)
model |
Beta regression model |
It returns the complete formula in a standard form
StepBetaBinomial internal object
Combination_Terms(Terms, interaction = F)
Combination_Terms(Terms, interaction = F)
Terms |
Variables from the starting model |
interaction |
Parameter to define which part of linear predictor to operate |
The function create alle possible combination of the linear predictor
StepBeta internal object
dispersion_formula_terms(object)
dispersion_formula_terms(object)
object |
full model |
The function updates the formula for the dispersion component of the model
StepBeta internal object
keep_formula_terms(the_formula, var_name)
keep_formula_terms(the_formula, var_name)
the_formula |
Formula of Beta Regression model |
var_name |
Names of the variables to keep |
The function updates the formula, it keeps the variables defined by the user
StepBeta internal object
remove_formula_interactions(the_formula)
remove_formula_interactions(the_formula)
the_formula |
Formula of Beta Regression model |
The function returns a reduced form of the formula. It excludes the interactive effects.
This function performs a stepwise algorithm to define the best linear predictor according to an user defined criterion (defeault is the Akaike Information Criterion aka AIC, but it is also possible to perform the corrected version AICc). It works only for object from betabin function (class "glimML" from "aod" package). If the object is different from "glimMl" class, the function performs the classical step function in "stats" package.
Step_glimML(object, k = 2, overdispersion = T, correctAIC = T)
Step_glimML(object, k = 2, overdispersion = T, correctAIC = T)
object |
Object of class "glimML". If the class is different the function apply step function in "stats" package |
k |
The penalty parameter used for the criterion, e.g. default is k = 2 which identify the classical AIC. BIC can be obtained as k = log(n) |
overdispersion |
Provide the stepwise procedure also for the overdispersion component of the model (defined as random) Default is TRUE |
correctAIC |
Use AICc instead of AIC. Default TRUE is for AICc |
Step_glimML is different from step (stats) and stepAIC (MASS) functions; for an object of class betabin is impossible to use an algorithm which uses the function extractAIC. Starting from a full model it provides a backaward procedure where the scope model is the reduced one.
First, Step_glimML operates with all the principal effects included in the model; starting from the full model, the algorithm computes all the possible models, it calculates the measure (default is AIC) and it defines as a good predictor the model with lower AIC.
Then, based on the previous results, Step_glimML operates adding all the possible interactive effects. As in the first passage, the model choosen by the algorithm is the one whose AIC is the lowest.
During the procedure, Step_glimML considers all the possible models which betabin can fit. There are many cases where betabin function falls into error, in these cases the algorithm does not consider the linear predictor which causes the error and it goes forward.
The algorithm returns an object of class "glimML"
Sergio Garofalo
Crowder, M.J., 1978. Beta-binomial anova for proportions. Appl. Statist. 27, 34-37.
Lawless, J.F., 1987. Negative binomial and mixed Poisson regression. The Canadian Journal of Statistics, 15(3): 209-225.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. (has iris3 as iris.)
## Starting from a "betabinom" model ## Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. ## Wadsworth & Brooks/Cole. (has iris3 as iris.) ## Prepare the data library(aod) data(iris) ############ Beta Binomial model ## Not run: n <- round(runif(dim(iris)[1],1,50)) y <- round(runif(length(n), 1,n)) data <- cbind(iris,y,n) fullModel <- betabin(cbind(y, n - y) ~ Sepal.Width * Petal.Length + Petal.Width, ~ Species, data = data) reducedModel <- Step_glimML(fullModel) summary(reducedModel) ## End(Not run) ############ Negative Binomial model ## Not run: data <- iris data$Sepal.Length <- round(Sepal.length + runif(dim(data)[1],0,1) * 100) fullModel <- negbin(Sepal.Length ~ Sepal.Width * Petal.Length + Petal.Width, ~ Species, data = data) reducedModel <-Step_glimML(fullModel) summary(reducedModel) ## End(Not run)
## Starting from a "betabinom" model ## Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. ## Wadsworth & Brooks/Cole. (has iris3 as iris.) ## Prepare the data library(aod) data(iris) ############ Beta Binomial model ## Not run: n <- round(runif(dim(iris)[1],1,50)) y <- round(runif(length(n), 1,n)) data <- cbind(iris,y,n) fullModel <- betabin(cbind(y, n - y) ~ Sepal.Width * Petal.Length + Petal.Width, ~ Species, data = data) reducedModel <- Step_glimML(fullModel) summary(reducedModel) ## End(Not run) ############ Negative Binomial model ## Not run: data <- iris data$Sepal.Length <- round(Sepal.length + runif(dim(data)[1],0,1) * 100) fullModel <- negbin(Sepal.Length ~ Sepal.Width * Petal.Length + Petal.Width, ~ Species, data = data) reducedModel <-Step_glimML(fullModel) summary(reducedModel) ## End(Not run)
This function performs a stepwise algorithm to define the best linear predictor according to an user defined criterion (defeault is the Akaike Information Criterion aka AIC). It works for objects of class "betareg" from betareg function. If the object is different from "betareg" class, the function performs the classical step function in "stats" package.
StepBeta(object, k = 2, dispersion = T)
StepBeta(object, k = 2, dispersion = T)
object |
Object of class "betareg". If the class is different the function apply the step function in "stats" package |
k |
The penalty parameter used for the criterion, e.g. default is k = 2 which identify the classical AIC. BIC can be obtained as k = log(n) |
dispersion |
Provide the stepwise procedure also for dispersion parameter. Default is TRUE |
StepBeta is different from step (stats) and stepAIC (MASS) functions; for an object of class "betareg" is impossible to use an algorithm which uses the function extractAIC Starting from a full model it provides a backaward procedure where the scope model is the reduced one.
First, StepBeta operates with all the principal effects included in the model; starting from the full model, the algorithm computes all the possible models, it calculates the measure (default is AIC) and it defines as a good predictor the model with lower AIC.
Then, based on the previous results, StepBeta operates adding all the possible interactive effects. As in the first passage, the model choosen by the algorithm is the one whose AIC is the lowest.
During the procedure, StepBeta considers all the possible models which betareg can fit. There are many cases where betareg function falls into error, in these cases the algorithm does not consider the linear predictor which causes the error and it goes forward.
The algorithm returns an object of class "betareg"
Sergio Garofalo
Cribari-Neto, F., and Zeileis, A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1–24. 10.18637/jss.v034.i02
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. (has iris3 as iris.)
## Starting from a "betareg" model ## Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. ## Wadsworth & Brooks/Cole. (has iris3 as iris.) ## Prepare the data library(betareg) data <- iris data$Sepal.Length <- data$Sepal.Length/(max(data$Sepal.Length) + 0.01) ###### Mean parameters fullModel <- betareg(Sepal.Length ~ Sepal.Width * Petal.Length * Petal.Width * Species, data = data) reducedModel <- StepBeta(fullModel) summary(reducedModel) ##### Mean and precision parameters fullModel <- betareg(Sepal.Length ~ Sepal.Width * Petal.Length * Petal.Width * Species| Sepal.Width + Petal.Length, data = data) reducedModel <- StepBeta(fullModel, dispersion = TRUE) summary(reducedModel)
## Starting from a "betareg" model ## Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. ## Wadsworth & Brooks/Cole. (has iris3 as iris.) ## Prepare the data library(betareg) data <- iris data$Sepal.Length <- data$Sepal.Length/(max(data$Sepal.Length) + 0.01) ###### Mean parameters fullModel <- betareg(Sepal.Length ~ Sepal.Width * Petal.Length * Petal.Width * Species, data = data) reducedModel <- StepBeta(fullModel) summary(reducedModel) ##### Mean and precision parameters fullModel <- betareg(Sepal.Length ~ Sepal.Width * Petal.Length * Petal.Width * Species| Sepal.Width + Petal.Length, data = data) reducedModel <- StepBeta(fullModel, dispersion = TRUE) summary(reducedModel)