Skip to contents

Predict risk with a given plpModel containing a generalized linear model.

Usage

predictGlm(plpModel, data, cohort)

Arguments

plpModel

An object of type plpModel - a patient level prediction model

data

An object of type plpData - the patient level prediction data extracted from the CDM.

cohort

The population dataframe created using createStudyPopulation who will have their risks predicted or a cohort without the outcome known

Value

A dataframe containing the prediction for each person in the population

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 <- predictGlm(model, plpData, plpData$cohorts)
#> predict risk probabilities using predictGlm
#> Prediction took 0.0897 secs
# see the predicted risk values
head(prediction)
#>   rowId subjectId targetId cohortStartDate daysFromObsStart daysToCohortEnd
#> 1     1     2e+10        1      2012-07-18              586             710
#> 2     2     2e+10        1      2008-01-06               10             791
#> 3     3     2e+10        1      2012-08-15              833             981
#> 4     4     2e+10        1      2011-06-20              505             129
#> 5     5     2e+10        1      2010-06-22              942             726
#> 6     6     2e+10        1      2007-09-17              733             580
#>   daysToObsEnd ageYear gender     value
#> 1         1588      39   8507 0.3658644
#> 2          930      39   8532 0.3658644
#> 3         1429      42   8507 0.4013123
#> 4          370      33   8532 0.2994329
#> 5         1296      42   8507 0.4013123
#> 6         1294      39   8507 0.3658644