[R] Plotting Bi-Gamma Distribution

Gundala Viswanath gundalav at gmail.com
Tue Jul 1 17:14:17 CEST 2008


Hi all,

I've tried to plot a vector which has two peaks in the density.
This link shows the figure.

http://docs.google.com/View?docid=dcvdrfrh_1dk9r2rc7

The red line is normal curve and green line is gamma curve.
Notice that red line can correctly fit the histogram that has two peaks
(i.e. red curve also has two peaks).

But the gamma curve there only has one curve.

Is there a way I can fit the gamma function such that it also
yields two peaks?

Below is my code that generate the graph:

__BEGIN__
    dgexp <- density(gexp.arr)
    gexp.ymax <- max(dgexp$y)

    # Histograms
    gehist <- hist(gexp.arr,
                col="blue",
                 main=paste(genm,"-",desc, ", Mean=",ge_mean, ", SD=",ge_sd, ",
                 Krt=",ge_kurt, ", AIC=",aic, ", BIC=",bic, sep=""),
                more = TRUE,
                xlab = "Exp Level",
                ylim = c(0, gexp.ymax),
                freq=FALSE
    )

    # Normal Curve
    lines(density(gexp.arr), col = "red",lwd = 3)

    # Gamma Curve
    curve(dgamma(x,1.25,gexp.ymax),add=TRUE,col="green",lwd=3)

__END__

- Gundala Viswanath
Jakarta - Indonesia



More information about the R-help mailing list