Create a generalized linear model that can be used in the PatientLevelPrediction package.
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.
Examples
coefficients <- data.frame(
covariateId = c(1002),
coefficient = c(0.05))
model <- createGlmModel(coefficients, intercept = -2.5)
data("simulationProfile")
plpData <- simulatePlpData(simulationProfile, n=50)
#> Generating covariates
#> Generating cohorts
#> Generating outcomes
prediction <- predictPlp(model, plpData, plpData$cohorts)
#> did FE
#> did tidy
#> predict risk probabilities using predictGlm
#> Prediction took 0.0901 secs
#> Prediction done in: 0.0922 secs
# see the predicted risk values
prediction$value
#> [1] 0.3775407 0.3775407 0.3658644 0.3543437 0.3208213 0.3775407 0.4013123
#> [8] 0.3893608 0.3429895 0.3100255 0.3893608 0.4133824 0.3658644 0.4133824
#> [15] 0.3775407 0.3775407 0.3100255 0.3318122 0.3775407 0.3208213 0.3543437
#> [22] 0.3775407 0.3658644 0.3429895 0.4013123 0.3893608 0.3543437 0.3318122
#> [29] 0.3100255 0.3208213 0.3658644 0.3543437 0.3775407 0.4013123 0.3208213
#> [36] 0.3100255 0.3893608 0.4013123 0.4013123 0.3543437 0.4013123 0.3429895
#> [43] 0.3429895 0.3429895 0.2994329 0.3318122 0.3543437 0.3775407 0.3658644
#> [50] 0.4013123