flexOR {flexOR} | R Documentation |
flexOR: Flexible Odds Ratio Computation for GAM Models
Description
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.
Usage
flexOR(data, response = NULL, formula = NULL)
Arguments
data |
A data frame containing the variables. |
response |
The response variable as a character string. |
formula |
A formula specifying the model. |
Details
It accepts two different ways of specifying the model: by providing the data frame and response variable or by specifying the formula.
Value
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.
Examples
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)
[Package flexOR version 1.0.0 Index]