getResidualScores {phers} | R Documentation |
Calculate residual phenotype risk scores
Description
The residual score indicates to what extent a person's phenotype risk score for a given disease deviates from the expected score, after adjusting for the person's characteristics in a linear model.
Usage
getResidualScores(demos, scores, lmFormula)
Arguments
demos |
A data.table of characteristics for each person in the cohort.
Must have column |
scores |
A data.table containing the phenotype risk score for each
person for each disease. Must have columns |
lmFormula |
A formula representing the linear model to use for
calculating residual scores. All terms in the formula must correspond to
columns in |
Value
A data.table, based on scores
, with an additional column
resid_score
. Residual scores for each disease are standardized to have
unit variance.
See Also
stats::rstandard()
, getScores()
Examples
library('data.table')
# map ICD codes to phecodes
phecodeOccurrences = getPhecodeOccurrences(icdSample)
# calculate weights (using the prevalence method)
weights = getWeights(demoSample, phecodeOccurrences)
# OMIM disease IDs for which to calculate phenotype risk scores
diseaseId = 154700
# map diseases to phecodes
diseasePhecodeMap = mapDiseaseToPhecode()
# calculate scores
scores = getScores(weights, diseasePhecodeMap[disease_id == diseaseId])
# calculate residual scores
rscores = getResidualScores(demoSample, scores, lmFormula = ~ sex)
[Package phers version 1.0.2 Index]