[R] COXPH: How should weights be entered in coxph, as the log of the weight or as the weight on its original scale?

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Thu May 20 07:23:35 CEST 2021


Perhaps this package could be considered

https://cran.r-project.org/web/packages/hrIPW/hrIPW.pdf

That packages author also has a 2016 article in Statistics in Medicine on the properties of estimates from such analyses that might be useful. 

— 
David Winsemius, MD, MPH

Sent from my iPhone

> On May 19, 2021, at 8:01 PM, Sorkin, John <jsorkin using 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]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list