It seems like we should be able to avoid the for loops here by:
evaluating cdfs that come from distfromq at the vector of all endpoints in columns like truth_df_filtered[[paste0("crit", seq_len(num_cat - 1), sep="")]]
appending a 1 to the end of that vector (and maybe a 0 to the beginning)
taking the diff of the result to get from "cumulative category probabilities" to the pmf values
you may need to unnest the results at the end
It may be helpful to split all of that functionality out into a helper function
looking at this code: https://github.com/reichlab/idforecastutils/blob/b137497b0bbe8c59210dcecb37214ad133740d52/R/get_pmf_forecasts_from_quantile.R#L91-L120
It seems like we should be able to avoid the for loops here by:
truth_df_filtered[[paste0("crit", seq_len(num_cat - 1), sep="")]]
1
to the end of that vector (and maybe a0
to the beginning)diff
of the result to get from "cumulative category probabilities" to the pmf valuesunnest
the results at the endIt may be helpful to split all of that functionality out into a helper function