johnfergusonNUIG / graphPAF

Other
2 stars 2 forks source link

PAF_calc_continuous not accepting prev argument #4

Closed FatemehSafi closed 4 months ago

FatemehSafi commented 4 months ago

Hi,

Thanks for providing this package.

when I use PAF_calc_discrete, it works perfectly with my dataset. However, with PAF_calc_continuous it doesnt't work and I get the following error: Error in impact_fraction(model = model, data = data, new_data = new_data, : Prevalence weighted estimation not appropriate for survival data sets In addition: Warning message: In risk_quantiles(riskfactor = riskfactor_vec[i], data = data, model = model, : NAs introduced by coercion

I cant provide the dataset since it's not allowed by the third party, but here is part of my code:

`df_bmi <- fread("paf_mi_bmi5.csv")

model <- with(df_bmi , coxph(Surv(TTE, event) ~ age +sex+ height+ active_cat2+ active_cat3+alc_cat2+ alc_cat3+ alc_cat4+ alc_cat5+ alc_cat6+ veg_imp+ fruit_imp+ crc_screen_imp+ depriv_imp+ smostat_cat2+ smostat_cat3+ packyears+ redmeat_cat2+ redmeat_cat3+ redmeat_cat4+ educ_cat2+ educ_cat3+ ethnic_bin2+ fh_crc_imp+ nsaids_imp+ processedmeat_cat2+ processedmeat_cat3+ processedmeat_cat4+ BMI5))

PAF_calc_continuous( model=model, riskfactor_vec=c("BMI5"), q_vec = c(0.01), data=df_bmi, calculation_method = "D", prev= 0.013, ci = TRUE, boot_rep = 200, t_vector = c(14.8), ci_level = 0.95, ci_type = c("norm"), S = 1, weight_vec = NULL, verbose = TRUE )

prev here is the prevalence of the disease (event) which is colorectal cancer.`

I'd appreciate any suggestions.

johnfergusonNUIG commented 4 months ago

Hi,

Thanks for providing this package.

when I use PAF_calc_discrete, it works perfectly with my dataset. However, with PAF_calc_continuous it doesnt't work and I get the following error: Error in impact_fraction(model = model, data = data, new_data = new_data, : Prevalence weighted estimation not appropriate for survival data sets In addition: Warning message: In risk_quantiles(riskfactor = riskfactor_vec[i], data = data, model = model, : NAs introduced by coercion

I cant provide the dataset since it's not allowed by the third party, but here is part of my code:

`df_bmi <- fread("paf_mi_bmi5.csv")

model <- with(df_bmi , coxph(Surv(TTE, event) ~ age +sex+ height+ active_cat2+ active_cat3+alc_cat2+ alc_cat3+ alc_cat4+ alc_cat5+ alc_cat6+ veg_imp+ fruit_imp+ crc_screen_imp+ depriv_imp+ smostat_cat2+ smostat_cat3+ packyears+ redmeat_cat2+ redmeat_cat3+ redmeat_cat4+ educ_cat2+ educ_cat3+ ethnic_bin2+ fh_crc_imp+ nsaids_imp+ processedmeat_cat2+ processedmeat_cat3+ processedmeat_cat4+ BMI5))

PAF_calc_continuous( model=model, riskfactor_vec=c("BMI5"), q_vec = c(0.01), data=df_bmi, calculation_method = "D", prev= 0.013, ci = TRUE, boot_rep = 200, t_vector = c(14.8), ci_level = 0.95, ci_type = c("norm"), S = 1, weight_vec = NULL, verbose = TRUE )

prev here is the prevalence of the disease (event) which is colorectal cancer.`

I'd appreciate any suggestions.

Hi Fatemeh,

As the help file says, the prevalece setting is appropriate for case-control datasets where you'd like an estimate of the disease prevalence avoided if a risk factor were eliminated (if you are using the setting method="D"). For survival data, the PAF esitmates the proportion of events that would be avoided at a particular time, in the absense of the risk factor. Since the data itself can estimate the proportion of events that might happen over various time intervals, you don't need to specify the prev argument. Try running without the prev argument...

John

FatemehSafi commented 4 months ago

Hi John,

Thanks very much for your reply. I have tried running the code without the prev argument but when the results are generated I get the following: riskfactor q paf_q.est CI 14.80356 BMI5 0.01 0.144 (0.0222,0.403)

Type of statistical model originally fit: coxph Method used to produce estimate: Weighted Standardisation Assumed prevalence: 0.5 Type of Bootstrap confidence interval used: norm Confidence level: 0.95 Number of bootstrap draws: 200

which assumes the prevalence equals 0.5 which is not correct. should I change anything else in the code?

johnfergusonNUIG commented 4 months ago

Hi Fatemeh,

Apologies about this. The message is what's confusing (specifically when a coxph model is used in PAF_calc_continuous). I'll edit the package to remove that message

The results you got when you didn't specify the prevalence are correct (that the PAF at time 14.8 is estimated at 0.144, with a confidence interval (0.022,0.403)

John

johnfergusonNUIG commented 4 months ago

Just letting you know that the issue has been fixed with the package now.

FatemehSafi commented 4 months ago

Awesome. Thanks for your prompt reply and for fixing the package. I really appreciate it.

Kind regards, Fatemeh