[R] Plot Mixtures of Synthetically Generated Gamma Distributions

Moshe Olshansky m_olshansky at yahoo.com
Mon Jul 7 05:57:34 CEST 2008


I know very little about graphics, so my primitive and brute force solution would be

plot(density(x[1:30]),col="blue");lines(density(x[31:60]),col="red");lines(density(x[61:90]),col="green")


--- On Mon, 7/7/08, Gundala Viswanath <gundalav at gmail.com> wrote:

> From: Gundala Viswanath <gundalav at gmail.com>
> Subject: [R] Plot Mixtures of Synthetically Generated Gamma Distributions
> To: r-help at stat.math.ethz.ch
> Received: Monday, 7 July, 2008, 1:24 PM
> Hi,
> 
> I have the following vector
> which is created from 3 distinct distribution (three
> components) of gamma:
> 
> x=c(rgamma(30,shape=.2,scale=14),rgamma(30,shape=12,scale=10),rgamma(30,shape=5,scale=6))
> 
> I want to plot the density curve of X, in a way that it
> shows
> a distinct 3 curves that represent each component.
> 
> How can I do that?
> 
> I tried this but doesn't work:
> 
> lines(density(x))
> 
> Please advise.
> 
> - 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.



More information about the R-help mailing list