This vignette applies the models developed in [Reference to Paper] to simulated data. We begin by validating our inferential framework for modelling the impact of malaria on haemoglobin levels during pregnancy, including the effect of acquired immunity over successive pregnancies. We then demonstrate the biases introduced by excluding women diagnosed with severe anaemia at enrolment and validate our approach for adjusting the framework to account for these biases, enabling us to correctly capture underlying trends.
Our study involved data from pregnant women enrolled into a number of trials evaluating interventions to combat malaria in pregnancy. This comprised the following variables at first ANC visit: HB concentrations, infection status by PCR, gestational age and gravidity. We also use ANC prevalence in primigravidae as a marker to determine our model-based estimates of patterns of prior exposure during pregnancy. The function generate_country_data_list_censor creates a list that involves both the data (here the synthetic data from data_generation.Rmd) and pre-calculated aggregated number of PCR samples and PCR positives in primigravidae within the dataset (to reduce computational time)
# Generate the uncensored data list
uncensored_data_list <- generate_country_data_list_noncensor(data_df = synthetic_data_df$data_df)
# Display the first few rows of the data
knitr::kable(head(uncensored_data_list$country_df))| gravidity | gestage | adj_gestage | malaria | hb_level |
|---|---|---|---|---|
| 1 | 120 | 41 | 0 | 14.844876 |
| 1 | 179 | 100 | 1 | 6.822151 |
| 1 | 139 | 60 | 1 | 8.534953 |
| 1 | 170 | 91 | 0 | 8.939274 |
| 1 | 176 | 97 | 1 | 6.326073 |
| 1 | 88 | 9 | 0 | 13.769398 |
## and the additional prevalence data added to the list
knitr::kable((uncensored_data_list$prev_data))| positive | total |
|---|---|
| 2805 | 5501 |
Our approach uses the drjacoby package which requires specific templates for parameters. Here we use the function ‘generate_df_params_non_censor’ to set up a template of parameters required for this package. These parameters include:
# Generate parameter file for uncensored data
df_params_non_censor <- generate_df_params_non_censor()
# Display the parameter file
knitr::kable(df_params_non_censor)| name | min | max | |
|---|---|---|---|
| 1 | HB_sigma | 0.100 | 10.000 |
| 2 | shape_hill | 0.010 | 10.000 |
| 3 | scale_hill | 0.010 | 10.000 |
| name1 | G2_non_infect | -5.000 | 5.000 |
| name2 | G3_non_infect | -5.000 | 5.000 |
| name3 | G4_non_infect | -5.000 | 5.000 |
| name4 | G5_non_infect | -5.000 | 5.000 |
| name5 | G6_non_infect | -5.000 | 5.000 |
| name11 | y_knot_1 | 5.000 | 15.000 |
| name21 | y_knot_2 | 5.000 | 15.000 |
| name31 | y_knot_3 | 5.000 | 15.000 |
| name12 | mal_knot_1 | -10.000 | 10.000 |
| name22 | mal_knot_2 | -10.000 | 10.000 |
| name32 | mal_knot_3 | -10.000 | 10.000 |
| name | log_odds_malaria_prevalence_G1 | -4.595 | 1.736 |
With the data prepared and parameters defined, we now run our model on the uncensored dataset. This will help us validate our model’s ability to capture the true underlying patterns without any biases introduced by data censorship.
run_noncensored_data <- run_mcmc(
data = uncensored_data_list,
df_params = df_params_non_censor,
misc = list(
gestage_min = 80,
gestage_max = 200,
cutoff = NULL,
inf_history = selected_inf_history
),
loglike = r_loglike,
logprior = r_logprior_noncensor,
burnin = 1000,
samples = 10000,
chains = 1
)
#> MCMC chain 1
#> burn-in
#> | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
#> acceptance rate: 42%
#> sampling phase
#> | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
#> acceptance rate: 44%
#> chain completed in 851.212754 seconds
#> total MCMC run-time: 851 secondsAfter running the model, we can visualise the results to compare the model’s predictions with the true synthetic data. This helps us ensure that the model correctly infers the impact of malaria on haemoglobin levels.
# Generate combined plot for non-censored data
combined_noncensored_plot <- generate_combined_plot(
model = run_noncensored_data,
fitted_data = uncensored_data_list$country_df,
true_data = synthetic_data_df,
site_inf_history = selected_inf_history
)In the left-hand plot dots show datapoints, the dashed lines show true underlying mean Hb by gestation and gravidity and thin equivalent lines show draws from the joint posterior for these means. On the right-hand plots thick orange lines show the simulated values and thin purple lines equivalent posterior draws.
Here we have run the mcmc for a much shorter duration than would be required for a final version but even in this shorter run we can the inferred and simulated relationships look reassuringly aligned.
In some of the studies used in the analysis, women with severe anaemia (HB < 7) are excluded from enrolment, introducing biases. Here, we demonstrate the issue by simulating this scenario by censoring our synthetic data and then running the model without adjusting for this bias.
# Censor women with HB < 7
cutoff <- 7
censored_data_list <- generate_country_data_list_noncensor(
synthetic_data_df$data_df %>% filter(hb_level > cutoff)
)# Run the model on censored data without adjustment
run_censored_data_incorrect <- run_mcmc(
data = censored_data_list,
df_params = df_params_non_censor,
misc = list(
gestage_min = 80,
gestage_max = 200,
cutoff = NULL,
inf_history = selected_inf_history
),
loglike = r_loglike,
logprior = r_logprior_noncensor,
burnin = 1000,
samples = 10000,
chains = 1
)
#> MCMC chain 1
#> burn-in
#> | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
#> acceptance rate: 42.3%
#> sampling phase
#> | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
#> acceptance rate: 44%
#> chain completed in 794.923501 seconds
#> total MCMC run-time: 795 secondsWe now visualise the results to see the impact of not adjusting for the bias introduced by excluding women with severe anaemia. The true impact of malaria upon haemoglobin is substantially under-estimated.
# Generate combined plot for censored data without adjustment
combined_incorrect_censored_plot <- generate_combined_plot(
model = run_censored_data_incorrect,
site_inf_history = selected_inf_history,
fitted_data = censored_data_list$country_df,
true_data = synthetic_data_df
)# Display the combined plot
combined_incorrect_censored_plot
#> `geom_smooth()` using formula = 'y ~ x'To account for the bias introduced by censoring, we adjust our model and re-run the analysis. Our approach assumes we know the number of individuals censored due to being anaemic at enrolment but not their gravidity distribution, nor their infection status. As a result, we have to make joint inference on the underlying true prevalence within each gravidity category, the true distribution of gravidity within our sample and the true underlying distribution of gestational age at enrollment. This requires we develop a new parameter file to reflect this.
# Generate parameter file for censored data
df_params_censor <- generate_df_params_censor()
knitr::kable(df_params_censor)| name | min | max | |
|---|---|---|---|
| 1 | HB_sigma | 0.200 | 10.000 |
| 2 | shape_hill | 0.010 | 10.000 |
| 3 | scale_hill | 0.010 | 10.000 |
| name1 | G2_non_infect | -5.000 | 5.000 |
| name2 | G3_non_infect | -5.000 | 5.000 |
| name3 | G4_non_infect | -5.000 | 5.000 |
| name4 | G5_non_infect | -5.000 | 5.000 |
| name5 | G6_non_infect | -5.000 | 5.000 |
| name11 | y_knot_1 | 5.000 | 15.000 |
| name21 | y_knot_2 | 5.000 | 15.000 |
| name31 | y_knot_3 | 5.000 | 15.000 |
| name12 | mal_knot_1 | -5.000 | 5.000 |
| name22 | mal_knot_2 | -5.000 | 5.000 |
| name32 | mal_knot_3 | -5.000 | 5.000 |
| name13 | log_odds_malaria_prevalence_G1 | -4.595 | 1.736 |
| name23 | log_odds_malaria_prevalence_G2 | -4.595 | 1.736 |
| name33 | log_odds_malaria_prevalence_G3 | -4.595 | 1.736 |
| name41 | log_odds_malaria_prevalence_G4 | -4.595 | 1.736 |
| name51 | log_odds_malaria_prevalence_G5 | -4.595 | 1.736 |
| name6 | log_odds_malaria_prevalence_G6 | -4.595 | 1.736 |
| name14 | log_RR_G2 | -5.000 | 5.000 |
| name24 | log_RR_G3 | -5.000 | 5.000 |
| name34 | log_RR_G4 | -5.000 | 5.000 |
| name42 | log_RR_G5 | -5.000 | 5.000 |
| name52 | log_RR_G6 | -5.000 | 5.000 |
| 11 | shape_1_GA | 0.010 | 10.000 |
| 21 | shape_2_GA | 0.010 | 10.000 |
As our approach involves integrating over all of these factors to estimate the # of women who were anaemic at enrollment we need to do a great deal more pre-calculation to reduce computational intensity - in particular we need to calculate the observed distribution of gestational age
# Generate data list for the censored data, including correction for bias
censored_data_list <- generate_country_data_list_censor(
synthetic_data_df$data_df,
cutoff = cutoff
)
#> `summarise()` has grouped output by 'adj_gestage', 'malaria'. You can override
#> using the `.groups` argument.
#> `summarise()` has grouped output by 'gravidity'. You can override using the
#> `.groups` argument.
knitr::kable(head(censored_data_list$country_df))| gravidity | gestage | adj_gestage | malaria | hb_level |
|---|---|---|---|---|
| 1 | 120 | 41 | 0 | 14.844876 |
| 1 | 139 | 60 | 1 | 8.534953 |
| 1 | 170 | 91 | 0 | 8.939274 |
| 1 | 88 | 9 | 0 | 13.769398 |
| 1 | 135 | 56 | 1 | 7.916735 |
| 1 | 153 | 74 | 1 | 13.809401 |
# This frequency of each unique day of gestational age, gravidity and malaria status within the dataset and an index variable to avoid having to loop over all possible combinations
knitr::kable(head(censored_data_list$counts_df))| adj_gestage | malaria | gravidity | count | index |
|---|---|---|---|---|
| 1 | 0 | 1 | 21 | 1 |
| 1 | 0 | 2 | 22 | 2 |
| 1 | 0 | 3 | 26 | 3 |
| 1 | 0 | 4 | 22 | 4 |
| 1 | 0 | 5 | 24 | 5 |
| 1 | 0 | 6 | 57 | 6 |
| positive | total |
|---|---|
| 2805 | 5501 |
# the distribution of counts by malaria status and gravidity
knitr::kable(censored_data_list$grav_mal_counts)| gravidity | malaria | total | prop |
|---|---|---|---|
| 1 | 0 | 2607 | 0.0900269 |
| 1 | 1 | 2463 | 0.0850542 |
| 2 | 0 | 2746 | 0.0948270 |
| 2 | 1 | 2117 | 0.0731059 |
| 3 | 0 | 2721 | 0.0939637 |
| 3 | 1 | 1810 | 0.0625043 |
| 4 | 0 | 2597 | 0.0896816 |
| 4 | 1 | 1436 | 0.0495891 |
| 5 | 0 | 2576 | 0.0889564 |
| 5 | 1 | 1118 | 0.0386076 |
| 6 | 0 | 4943 | 0.1706955 |
| 6 | 1 | 1824 | 0.0629878 |
# the number censored due to being anaemic (Hb g/dL) of counts by malaria status and gravidity
knitr::kable(censored_data_list$censored_data)| censored_number | total_number |
|---|---|
| 1042 | 30000 |
#We now run the model
# Run the model on censored data with bias correction
run_censored_data_correct <- run_mcmc(
data = censored_data_list,
df_params = df_params_censor,
misc = list(
gestage_min = 80,
gestage_max = 200,
cutoff = cutoff,
inf_history = selected_inf_history
),
loglike = r_loglike_w_censoring,
logprior = r_logprior_censor,
burnin = 1000,
samples = 10000,
chains = 1
)
#> MCMC chain 1
#> burn-in
#> | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
#> acceptance rate: 42%
#> sampling phase
#> | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================= | 41% | |============================= | 42% | |============================== | 43% | |=============================== | 44% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 48% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |======================================= | 55% | |======================================= | 56% | |======================================== | 57% | |========================================= | 58% | |========================================= | 59% | |========================================== | 60% | |=========================================== | 61% | |=========================================== | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 74% | |===================================================== | 75% | |===================================================== | 76% | |====================================================== | 77% | |======================================================= | 78% | |======================================================= | 79% | |======================================================== | 80% | |========================================================= | 81% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 84% | |============================================================ | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |============================================================== | 89% | |=============================================================== | 90% | |================================================================ | 91% | |================================================================ | 92% | |================================================================= | 93% | |================================================================== | 94% | |=================================================================== | 95% | |=================================================================== | 96% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
#> acceptance rate: 44%
#> chain completed in 4667.804495 seconds
#> total MCMC run-time: 4670 secondsFinally, we visualise the results from the corrected model to confirm that it accurately captures the true underlying patterns, even when women with severe anaemia are excluded.
# Generate combined plot for censored data with adjustment
combined_correct_censored_plot <- generate_combined_plot(
model = run_censored_data_correct,
site_inf_history = selected_inf_history,
fitted_data = censored_data_list$country_df,
true_data = synthetic_data_df
)# Display the combined plot
combined_correct_censored_plot
#> `geom_smooth()` using formula = 'y ~ x'