createGlmModel: createGlmModel

View source: R/Glm.R

createGlmModelR Documentation

createGlmModel

Description

Create a generalized linear model that can be used in the PatientLevelPrediction package.

Usage

createGlmModel(coefficients, intercept = 0, mapping = "logistic")

Arguments

coefficients

A dataframe containing two columns, coefficients and covariateId, both of type numeric. The covariateId column must contain valid covariateIds that match those used in the FeatureExtraction package.

intercept

A numeric value representing the intercept of the model.

mapping

A string representing the mapping from the linear predictors to outcome probabilities. For generalized linear models this is the inverse of the link function. Supported values is only "logistic" for logistic regression model at the moment.

Value

A model object containing the model (Coefficients and intercept) and the prediction function.

Examples

coefficients <- data.frame(
  covariateId = c(1002),
  coefficient = c(0.05))
model <- createGlmModel(coefficients, intercept = -2.5)
data("simulationProfile")
plpData <- simulatePlpData(simulationProfile, n=50)
prediction <- predictPlp(model, plpData, plpData$cohorts)
# see the predicted risk values
prediction$value

OHDSI/PatientLevelPrediction documentation built on Feb. 14, 2025, 9:44 a.m.