I analyze ethnic differences in risk of cardiovascular events (CVD) in a cohort study of patients with coronary heart disease. It is known that immigrants have higher risk of CVD and I intend to show this via Cox regression. However, my results fail to prove what is both plausible and well known, i.e immigrants do not have significantly higher risk. I suspect the reason for this is that groups are not comparable, not even with Cox model, because immigrants are 10–20 years younger at baseline (age is an important risk factor). There might be insufficient number of individuals with overlapping age to compare immigrants to natives.

So I thought the comparison would be more appropriate if each immigrant would be matched to a sex and age matched control.

I used the MatchIt package (I have some basic understanding of prop scores and the fact that they are primarily intended for treatment exposures). I reasoned that, as treatment is an exposure, so is immigrant status, which is dichotomized (yes/no immigrant status). I obtained (adjustments for age, sex and duration of coronary heart disease) the probability of being native. I used the weights in coxph function as follows:

coxph(Surv(start, stop, event==1) ~  var1 + var2 + var3 + var4, data=dataset, weights=weights)

Results are now more plausible. Immigrants are now at higher risk.

Was this correct or just a incorrect effort to prove an hypothesis?



1 Answer 1


There is no need to use matching, as the variables you are matching on are exceedingly easy to handle as covariates. You can easily allow for nonlinearity in age and non-additivity in age and sex by expanding age into a spline and interacting all spline terms with sex, and likewise for duration.

Ways to check that the matching method worked in a good and reproducible fashion include

  1. randomly reorder the dataset and see if the same matches are produced
  2. check that the matched ages are within one year of each other and likewise for duration of disease
  3. show that the matching did not discard any observations that could have possibly matched

It is unlikely that all three of these conditions are satisfied, hence matching has problems.

To obtain the Cox model analysis I suggested above:

dd <- datadist(mydata); options(datadist='dd')
f <- cph(Surv( ) ~ (rcs(age,5) + rcs(duration,5)) * sex + immigrant,
anova(f)     # all meaningful hypothesis tests
summary(f)   # hazard ratios 
  • 1
    $\begingroup$ Many thanks prof Harrell. It all worked out until i typed "summary(f)", which resulted in the following error: Error in summary.rms(f) : adjustment values not defined here or with datadist for age duration sex Ethnicity. I'll try to figure it out. $\endgroup$ Aug 21, 2014 at 12:58
  • 1
    $\begingroup$ Update: it worked better not using summary-function. Just typing the object name (f) returned the results, as well as using the stargazer package. Perhaps it had something to do with confidence intervals, because stargazer returned the same error when i requested confidence limits. Nevertheless, thanks. $\endgroup$ Aug 21, 2014 at 13:07
  • $\begingroup$ I have no idea whether stargazer respects the conventions used by rms. I added code above that will fix the error you got. Just typing the fit object only helps you in the special case where the variable being tested does not interact with anything and is represented by only a single term in the model. $\endgroup$ Aug 21, 2014 at 15:21
  • $\begingroup$ Thank you. It executes without error now. I'll give you feedback (regarding the effect of the suggested regression on hazard ratios) in short. $\endgroup$ Aug 21, 2014 at 15:34
  • $\begingroup$ UPDATE: I redid the analysis and fit the following: 'f <- cph(Surv( ) ~ rcs(age,5) + rcs(duration,5) + sex + immigrant, data=mydata)' I.e separate splines for age and duration and no interaction with sex. That raised the HR for immigrants markedly, but still in a plausible fashion. Since HR went from 1.2 to almost 4 for some groups (which I, however, find plausible) I wonder if I broke the law by my formula? $\endgroup$ Aug 22, 2014 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.