Skip to contents

This wrapper function creates an FTM object from various types of model objects, including glm, glmnet, and lm, by extracting necessary components and adapting them into the FTM framework.

Usage

createFTM(modelObj, s = NULL, x = NULL, y = NULL, outcome_name = NULL)

Arguments

modelObj

A model object from glm, glmnet, or lm.

s

Optional value of the penalty parameter (lambda); applicable only for glmnet or lm models.

x

matrix of predictors used in the glmnet model.

y

vector of outcomes used in the glmnet model.

outcome_name

Optional name of the outcome variable; if not provided, it will be extracted from the model object.

Value

An FTM object either of type ftmglm or ftmlm depending on the input model.

Examples

if (FALSE) { # \dontrun{
data(mtcars)
lm_model <- lm(mpg ~ cyl + hp + wt, data = mtcars)
ftm_object <- createFTM(lm_model)

glm_model <- glm(am ~ hp + wt + cyl, data = mtcars, family = "binomial")
ftm_object <- createFTM(glm_model)

predictors <- as.matrix(mtcars[, c("hp", "wt", "cyl")])
glmnet_model <- glmnet::cv.glmnet(predictors, mtcars$am, family = "binomial")
ftm_object <- createFTM(glmnet_model)
} # }