One thing that we need to do quite frequently in my area of research is to calculate the perioperative risk of a patient undergoing surgery based on baseline factors, such as patient age, type of surgery, and presence of medical co-morbidities, etc.
There are a whole constellation of risk scoring/stratification tools which are available in the literature. One of the risk tools that we most frequently use in our research group is the Physiological and Operative Severity Score for the enUmeration of Mortality and morbidity (POSSUM), and its Portsmouth variation (P-POSSUM).
I therefore wrote a couple of R functions to calculate these scores in my work, and I’ll talk about them here.
The first calculates POSSUM morbidity, and P-POSSUM mortality risks (or more precisely, the log-odds). It parses a dataframe and computes the POSSUM scores, and thens return a dataframe, which you can assign to an object name, with the following variables:
PhysScore The physiological score for POSSUM
OpScore The operative score for POSSUM
POSSUMLogit The log-odds for morbidity as calculated by POSSUM
pPOSSUMLogit The log-odds for mortatlity as calculated by P-POSSUM
To use the function, there is some pre-processing that needs to be done to manipulate the input dataframe to have columns with the names and structure as below:
Age continuous
JVP binary, whether the patient has raised JVP or not
Cardiomegaly binary, whether the patient has cardiomegaly on CXR or not
Oedema binary, whether the patient has peripheral oedema or not
Warfarin binary, whether the patient normally takes warfarin or not
Diuretics binary, whether the patient normally takes a diuretic medication or not
AntiAnginals binary, whether the patient normally takes anti-anginal medication or not
Digoxin binary, whether the patient normally takes digoxin or not
AntiHypertensives binary, whether the patient normally takes blood pressure meds or not
Dyspnoea categorical, can be: Non = None; OME = On exertion; L = Limiting activities; AR = At rest
Consolidation binary, whether the patient has consolidation on CXR
PulmonaryFibrosis binary, whether the patient has a history of pulmonary fibrosis or imaging findings of fibrosis
WCC continuous, pre-op White Cell Count (* 10^9cells/L)
Ur continuous, pre-op Urea (mmol/L)
Na continuous, pre-op Na (mmol/L)
K continuous, pre-op K (mmol/L)
ECG categorical, electrocardiogram, ND = Not done; NOR = Normal ECG; AF6090 = AF 60-90; AF>90 = AF>90; QW = Q-waves; 4E = >4 ectopics; ST = ST or T wave changes; O = Any other abnormal rhythm
OpSeverity categorical, severity of the procedure, Min = Minor; Int = Intermediate; Maj = Major; Xma = Xmajor; Com = Complex
OpUrgency categorical, NCEPOD operative urgency classifications. Ele = Elective; Exp = Expedited; U = Urgent; I = Immediate
The actual function uses dplyr as a dependency, and the code for the function is as follows:
Let’s see it in action:
Notice that I have set the binary variables in three different ways: as 0s and 1s, Ns and Ys, and FALSEs and TRUEs. The function should parse any of these correctly.
In order to convert the computed log-odds into probability risks, we can use the invlogit function from the arm package