flexOR | R Documentation |
Computes odds ratios for predictors in GAM models. It provides flexibility in specifying predictors using either a data frame, a response variable, and a formula or a pre-fitted GAM model. The function is useful for understanding the impact of predictors on binary outcomes in GAMs.
flexOR(data, response = NULL, formula = NULL)
data |
A data frame containing the variables. |
response |
The response variable as a character string. |
formula |
A formula specifying the model. |
It accepts two different ways of specifying the model: by providing the data frame and response variable or by specifying the formula.
A list containing the following components:
dataset
: The dataset used for the analysis.
formula
: The formula used in the GAM model.
gamfit
: The fitted GAM model.
response
: The response variable used in the analysis.
library(gam);
# Load dataset
data(PimaIndiansDiabetes2, package="mlbench");
# Calculate odds ratios using flexOR
df_result <- flexOR(data = PimaIndiansDiabetes2, response = "diabetes",
formula=~ s(age) + s(mass) + s(pedigree) + pressure + glucose)
print(df_result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.