# How do I apply weights to a Cox Regression Model in R? [closed]

I am trying to answer the question of whether service in a certain organization has an effect on age of first marriage, and am interested in using the Cox model to understand the difference in the hazard rates.

Because I have observational data, I'm using a pre-processing technique to achieve covariate balance between the two groups (to account for selection bias), and then trying to estimate the treatment effect of service. Using the WeightIt package, each observation is given a weight, and I would now like to add these to the observations when conducting the Cox regression.

I was introduced to the coxphw package, but am unsure if I am putting the weights in the correct place. Currently, I am putting them in caseweights, where W1 is the object from the WeightIt package.

fit1 <- coxphw(Surv(time1mar, censor) ~ milserve,
data = com,
template = "ARE",
caseweights=get.w(W1))


Thanks for the help!

## closed as off-topic by Nick Cox, user158565, mdewey, Michael Chernick, Jeremy MilesJun 4 at 18:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – user158565, mdewey, Michael Chernick, Jeremy Miles
If this question can be reworded to fit the rules in the help center, please edit the question.