GLM.Formulas: Develop formulas for GLM models

View source: R/Index_functions.R

GLM.FormulasR Documentation

Develop formulas for GLM models

Description

GLM.Formulas generates a character vector that can be used to represent formulas for use in individual GLM model runs. The intent is to quickly generate a GLM model formula that incorporates information from several potential covariates and the type of covariate utilized.

Usage

GLM.Formulas(Predictors, Response, offset = NULL, VarType, names)

Arguments

Predictors

numeric vector representing 'value' for each co-variate included in the model, where the definition of 'value' is different depending on the type of covariate in question. For discrete covariates, a value of 0 indicates that co-variate should not be included in the model; all other values indicate the variable will be included. For continuous covariates, a value of 0 indicates that co-variate should not be included in the model; positive values indicate the polynomial order for that co-variate.

Response

Character string specifying the name of the response variable. This should match a specific column name in your data frame.

offset

character vector representing an "offset" variable to be used in the formula.

VarType

character string denoting the type of co-variate (continuous ("C") or discrete ("F")) for each co-varaite listed in *predictors*. This character string must be the same length as the character string specified by *predictors*. If a value other than "C" or "F" is provided, the function will return an error.

names

character vector representing the names of unique co-variates you want to include in your GLM model. These should match specific column names in your data frame.

Value

Character string representing a potential GLM model formula which represents the proposed model structure defined by the function inputs.

See Also

Other Model Formulas: GAM.Formulas(), Model.Formulas(), ZI.Formulas()

Examples

data(iris)
form <- GLM.Formulas(Response = "Sepal.Length", Predictors = c(1, 2, 0, 3),
names = c("Petal.Length", "Petal.Width", "Sepal.Width", "Species"), VarType =
c(rep("C", 3), "F"))
form
m1 <- glm(as.formula(form), data = iris, family="gaussian")
summary(m1)
plot(m1, all.terms = TRUE, seWithMean = TRUE)

ballengerj/FishyR documentation built on June 17, 2022, 10:33 p.m.