alexpkeil1 / qgcomp

QGcomp (quantile g-computation): estimating the effects of exposure mixtures. Works for continuous, binary, and right-censored survival outcomes. Flexible, unconstrained, fast and guided by modern causal inference principles
27 stars 6 forks source link

use qgcomp to plot exposure-response curve #30

Closed lifeng-zhu closed 1 year ago

lifeng-zhu commented 1 year ago

qc.survfit1 <- qgcomp.cox.boot(Surv(disease_time, disease_state) ~ arsenic+barium+cadmium,expnms=Xnm, deg=3,data=metals[,c(Xnm, 'disease_time', 'disease_state')], q=100,B=500,MCsize=500) df<-pointwisebound.boot(qc.survfit1 , alpha=0.05, pointwiseref=1) df<-as.data.frame(df) names(df) ggplot(df,aes(quantile,rr))+geom_line()+ geom_ribbon(aes(ymin=ll.rr,ymax=ul.rr),alpha=0.3)

I want to use this to plot exposure-response curve, but it does run.

Error in pointwisebound.boot(qc.survfit1, alpha = 0.05, pointwiseref = 1) : This function does not work with this type of qgcomp fit

alexpkeil1 commented 1 year ago

The error is correct. This functionality is not part of the package. This is not something that would be easy to add in, but I am open to pull requests if you can get something working! Best wishes.

lifeng-zhu commented 1 year ago

I have been studying this package recently. Thank you for your reply. Best wishes.

lifeng-zhu commented 1 year ago

Sorry to bother you. I want to know what function can be used to extract the exposure-response curve plot data for qgcomp.cox.boot. I found a Lancet article in which he achieved in figure 4. https://www.thelancet.com/journals/lanwpc/article/PIIS2666-6065(23)00094-9/fulltext

alexpkeil1 commented 1 year ago

Thanks. I hadn't see that paper. Those plots don't look like they were created with the qgcomp plot functions. It does seem useful, but I can see a couple of issues with trying to implement it in the package.

Here is a bit of sample code that should give you what you are looking for: https://gist.github.com/alexpkeil1/cda13891bf224921b6b2ac48cc0f2f41

lifeng-zhu commented 1 year ago

Thank you very much, this is very useful