I have some data similar to this
died age hospital
0 75 AA
0 88 AA
1 81 AA
0 77 AA
1 65 AA
0 41 AA
0 66 BA
1 81 BA
0 82 BA
1 64 BA
0 65 BA
1 52 BA
I was asked to calculate "age adjusted mortality rates" for each hospital. There are around 150 hospitals and approx 1000 patients (observations) per hospital. Each row in the data concerns a particular patient.
I was told how this could be done in Stata:
- Perform logistic regression of
died
onage
. - Use the
predict
function to get patient-level probabilities of death. - Summarise the patient-level probabilities by hospital to get the mortality rates for each hospital.
However, I am using R.
Is this the correct approach ? Are the alternatives ? Can I do the same thing in R with glm
and predict
?
Edit:
I should perhaps add that there are several other variables that are going to be adjusted for in the model. I have shown age above, just for simplicity.