On May 19, 2021, at 8:01 PM, Sorkin, John <jsorkin at som.umaryland.edu> wrote:
?When running a propensity score weighted analysis using coxph(), are the weights entered as the log of the weights, or as the weights on the original scale, i.e. coxph(Surv(time,status)~group,weights=weights ,data=mydata) or
coxph(Surv(time,status)~group,weights=log(weights),data=mydata)
I am creating weights using logistic regression as described below.
# Lalonde data from the MatchIt package is used in the pseudo code below
install.packages("MatchIt")
library("MatchIt")
#############################################
# Calculate propensity scores using logistic regression.#
#############################################
ps <- glm(treat ~ age + educ +nodegree +re74+ re75,data=lalonde,family=binomial())
summary(ps)
#PS on the scale of the dependent variable
# Add the propensity scores to the dataset
lalonde$psvalue <- predict(ps,type="response")
#################################################
# END Calculate propensity scores using logistic regression.#
#################################################
#################################
# Convert propensity scores to weights#
#################################
# Different weights for cases (1) and controls
lalonde$weight.ATE <- ifelse(lalonde$treat == 1, 1/lalonde$psvalue,1/(1-lalonde$psvalue))
summary(lalonde$weight.ATE)
#####################################
# END Convert propensity scores to weights#
#####################################
##########################################################
# Examples of two possible way to enter weights in the coxph model. #
##########################################################
fit1 <- coxph(Surv(time,status)~group,weights=lalonde$weight,data=lalonde)
or
fit2 <- coxph(Surv(time,status)~group,weights=log(lalonde$weight),data=lalonde)
##########################################################
# Examples of two possible way to enter weights in the coxph model. #
##########################################################
[[alternative HTML version deleted]]