Gundala Viswanath
2008-Jul-29 14:03 UTC
[R] Howto Draw Bimodal Gamma Curve with User Supplied Parameters
Hi, Suppose I have the following vector (data points):> x[1] 36.0 57.3 73.3 92.0 300.4 80.9 19.8 31.4 85.8 44.9 24.6 48.0 [13] 28.0 38.3 85.2 103.6 154.4 128.5 38.3 72.4 122.7 123.1 41.8 21.7 [25] 143.6 120.2 46.6 29.2 44.8 25.0 57.3 96.4 29.4 62.9 66.4 30.0 [37] 24.1 14.8 56.6 102.4 117.5 90.4 37.2 79.6 27.8 17.1 26.6 16.3 [49] 41.4 48.9 24.1 23.3 9.9 11.5 15.0 23.6 29.3 27.0 19.2 18.7 [61] 4.1 13.0 3.3 5.5 38.2 8.5 39.6 39.2 16.1 35.3 23.3 31.5 [73] 38.8 51.5 28.4 18.8 24.1 25.4 28.8 32.8 31.0 28.8 33.3 55.5 [85] 39.2 21.0 43.7 16.3 50.6 34.6 66.3 50.5 59.4 46.7 51.9 125.6 [97] 69.8 43.7 86.8 50.6 132.4 56.0 6.1 4.9 7.1 7.1 12.8 12.1 [109] 164.2 69.3 15.6 11.4 34.3 9.2 17.6 21.7 19.2 30.7 61.1 35.8 [121] 185.8 118.4 13.0 9.6 19.1 45.2 94.5 248.0 56.3 24.4 13.8 12.8 [133] 35.0 31.6 22.5 50.1 18.7 22.1 28.3 39.5 48.2 33.1 43.5 35.1 [145] 37.4 30.3 15.8 13.9 15.3 16.1 12.7 11.4 13.0 13.8 31.5 25.3 [157] 65.2 39.5 And the following parameter set (2 component) for gamma function. comp.1 comp.2 alpha (shape) 2.855444 2.152056 beta (scale) 10.418785 39.296224 These params are predefined/precalculated by user. My question is how can I create a bimodal gamma curve - based on the two parameter set - on top of the histogram of data points above? - Gundala Viswanath Jakarta - Indonesia
Patrizio Frederic
2008-Jul-30 08:50 UTC
[R] Howto Draw Bimodal Gamma Curve with User Supplied Parameters
can you write the bimodal gamma pdf? if so create your own pdf: dbigamma=function(x,alpha1,alpha2,beta1,beta2) { # ... the bimodal gamma pdf (I can't find it) } hist(x,probability=T) curve(dbigamma(x,alpha1,alpha2,beta1,beta2)) and look at the result regards, PF 2008/7/29 Gundala Viswanath <gundalav at gmail.com>:> Hi, > > Suppose I have the following vector (data points): >> x > [1] 36.0 57.3 73.3 92.0 300.4 80.9 19.8 31.4 85.8 44.9 24.6 48.0 > [13] 28.0 38.3 85.2 103.6 154.4 128.5 38.3 72.4 122.7 123.1 41.8 21.7 > [25] 143.6 120.2 46.6 29.2 44.8 25.0 57.3 96.4 29.4 62.9 66.4 30.0 > [37] 24.1 14.8 56.6 102.4 117.5 90.4 37.2 79.6 27.8 17.1 26.6 16.3 > [49] 41.4 48.9 24.1 23.3 9.9 11.5 15.0 23.6 29.3 27.0 19.2 18.7 > [61] 4.1 13.0 3.3 5.5 38.2 8.5 39.6 39.2 16.1 35.3 23.3 31.5 > [73] 38.8 51.5 28.4 18.8 24.1 25.4 28.8 32.8 31.0 28.8 33.3 55.5 > [85] 39.2 21.0 43.7 16.3 50.6 34.6 66.3 50.5 59.4 46.7 51.9 125.6 > [97] 69.8 43.7 86.8 50.6 132.4 56.0 6.1 4.9 7.1 7.1 12.8 12.1 > [109] 164.2 69.3 15.6 11.4 34.3 9.2 17.6 21.7 19.2 30.7 61.1 35.8 > [121] 185.8 118.4 13.0 9.6 19.1 45.2 94.5 248.0 56.3 24.4 13.8 12.8 > [133] 35.0 31.6 22.5 50.1 18.7 22.1 28.3 39.5 48.2 33.1 43.5 35.1 > [145] 37.4 30.3 15.8 13.9 15.3 16.1 12.7 11.4 13.0 13.8 31.5 25.3 > [157] 65.2 39.5 > > > And the following parameter set (2 component) for gamma function. > > comp.1 comp.2 > alpha (shape) 2.855444 2.152056 > beta (scale) 10.418785 39.296224 > > These params are predefined/precalculated by user. > > My question is how can I create a bimodal gamma curve - based on the > two parameter set - > on top of the histogram of data points above? > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >