bayesplot icon indicating copy to clipboard operation
bayesplot copied to clipboard

Visual Predictive Check

Open wds15 opened this issue 7 years ago • 9 comments

It would be great to have a so-called visual predictive check. To exemplify it I include an example in the form of a simple R script.

This plot is very useful for models which have continuous regressors which are given by the design of the experiemnt at the same value for all the subjects in a data-set. For example, imagine I have many subjects in a clinical study and one measures at pre-defined time-points for all patients whatever is of interest. The plot then allows to compare the raw quantiles of the data at each time-point vs what the model predicts for these quantiles (with its uncertainty).

vpc_example_R.txt

vpc_mtcars.pdf

wds15 avatar Jan 26 '17 17:01 wds15

@wds15 are you aware of https://github.com/ronkeizer/vpc

dpastoor avatar Jan 26 '17 22:01 dpastoor

Don't know about @wds15, but I hadn't seen that package. Thanks.

Although the vpc suggested here seems easy enough to add, so we might as well do our own version to maintain a consistent style across plot types and also limit dependencies. Especially since one of the goals for bayesplot is to allow other packages to call it in order to not have to use different packages and styles for each kind of plot.

jgabry avatar Jan 27 '17 00:01 jgabry

yeah, the basic functionality is really easy to implement, and could be nice stylistically.

The 3 'extras' this package offers are:

  • binning for non-uniform/nominal sampling times
  • prediction corrections - useful when data has wide range, eg ascending dose studies (more details here: https://www.ncbi.nlm.nih.gov/pubmed/21302010)
  • VPC's for categorical data

Happy to answer any questions, or help in some capacity. I think a 'built-in' VPC would be a valuable addition, and is a go-to plot in the pharmacometrics community.

dpastoor avatar Jan 27 '17 02:01 dpastoor

Cool, thanks. I don't do much pharma stuff so it will definitely be good to get some feedback on the plots when I have a chance to add it to a branch.

On Thu, Jan 26, 2017 at 9:33 PM Devin Pastoor [email protected] wrote:

yeah, the basic functionality is really easy to implement, and could be nice stylistically.

The 3 'extras' this package offers are:

  • binning for non-uniform/nominal sampling times

  • prediction corrections - useful when data has wide range, eg ascending dose studies (more details here: https://www.ncbi.nlm.nih.gov/pubmed/21302010)

  • VPC's for categorical data

Happy to answer any questions, or help in some capacity. I think a 'built-in' VPC would be a valuable addition, and is a go-to plot in the pharmacometrics community.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/stan-dev/bayesplot/issues/66#issuecomment-275575324, or mute the thread https://github.com/notifications/unsubscribe-auth/AHb4Qz5AKZ3iUBhSrL62U475C49Xohr1ks5rWVdtgaJpZM4Lu4NM .

jgabry avatar Jan 27 '17 04:01 jgabry

@dpastoor no, I don't know that package, looks interesting.

However, having this plot in bayesplot would be great for the reasons Jonah raises. The plot is one of the standards in PK/PD modeling. However, I think this is useful elsewhere certainly. Given with what is there in bayesplot it should be straightforward; at least it looks like.

I am happy to review the feature branch (or even write one should I think adapting code from other plotting functions looks easily adaptable to me in a coherent design).

wds15 avatar Jan 27 '17 10:01 wds15

@wds15 In the example you sent which parts of the data processing (e.g. binning) do you envision the user performing before calling a bayesplot function?

jgabry avatar Feb 01 '17 15:02 jgabry

Also, we should find a good way to write the code without using the plyr package. dplyr and reshape2 are ok since bayesplot already uses them.

jgabry avatar Feb 01 '17 16:02 jgabry

The user should be doing the binning himself. bayesplot should only need to know what refers to the bins. I suppose this can be mapped to the grouping facilities which are already there.

What would be useful is to allow the user to specify extra strata which are used to split things, e.g. by facets. So the bins always define the x-axis and a variable like sex may put male and female subjects on different facets.

Let me know if I should look at some branch and try things.

wds15 avatar Feb 06 '17 18:02 wds15

Ok cool. I think that makes sense. I'll try to put together a prototype soon.

jgabry avatar Feb 06 '17 20:02 jgabry