0

I am trying to calibrate parameters in a probabilistic cost-effective model I built. The model is a discrete state-transition (Markov) model. Before building models in R, I used the software TreeAge Pro. There one could set the model to run using the distribution means for each parameter, instead of drawing random values from the distributions. This made it easy see how varying single input parameters affected certain outcome variables.

My model uses many different distribution draws with Beta, Gamma and Normal distributions (rbeta, rgamma, rnorm). I would like to be able to set them to take their mean value using one command and setting them back to draw values with another. Does something like this exist?

E.g. the Beta distribution rbeta(1, 45, 55) would then take the value 0.45, when it is called, as long as it is set to take the mean.

I tried temporarily replacing the rbeta(1,, rgamma(1, etc. and parts of the distributions with qbeta(0.5 and qgamma(0.5 but this does not give me the means. For qbeta(0.5, 45,55) it gave me 0.4496653 instead of 0.45; for qbeta(0.5, 1,99) it gave me 0.006977 instead of 0.01.

The question is if there is a function in R that tells all distributions that draw random values to return the mean instead of random values, thereby avoiding having to replace every single distribution manually with its mean value.

I appreciate any hint on how to set the distributions to take their mean values. Does anyone know of any package that would be able to help?

  • Generally we would expect to see the name of a package, some sample data, and some code to set this up. So at the moment the burning questions is "why not use `qbeta` rather than `rbeta`"? – IRTFM Sep 22 '14 at 18:14
  • The answer to this question is that `qbeta` does not return the mean of the beta distribution as the example shows. The packages are the basic R packages, sample data is not used, code is in the question. ;-) – user3738925 Sep 22 '14 at 18:20
  • If the question is how to get the formula for means of the beta distribution you should go to a stats book or to Wikipedia. – IRTFM Sep 22 '14 at 18:26
  • This is not the question. The question is if there is a function in R that tells all distributions that draw random values to return the mean instead of random values. (Added this plus clarification to the question). – user3738925 Sep 22 '14 at 18:30
  • NO. There is no such function. (It would not makes sense to have such a function in my opinion.) Please see first comment which remains unaddressed and failing to respond to it in meaningful way is causing to vote to close. Packages can have their own special purpose functions but if you don't already have a package in mind then this is a "please recommend a package" question and we close them. – IRTFM Sep 22 '14 at 18:38
  • First part was driven by astonishment that a statistical language would have some sort of switch to convert a random number generator into something else. Second part: I'm explaining why I think your question is not appropriate for SO. SO asks for (and I was repeating) that questioners to offer code and package names. – IRTFM Sep 22 '14 at 18:42
  • What does SO mean? (No packages used above from basic packages that come with R install) – user3738925 Sep 22 '14 at 18:44
  • 1
    Where do you think you are posting? – IRTFM Sep 22 '14 at 19:46

0 Answers0