x <- seq(from = 0, to = 10, by = .01)
plot(x, dchisq(x = x, df = 1), main = "title", sub = "subtitle", type = "l", 
xlab = "x-title", ylab = "y-title", ylim = c(0, .4), col = "red")
lines(x, dchisq(x = x, df = 2), type = "l", col = "green")
lines(x, dchisq(x = x, df = 3), type = "l", col = "blue")
lines(x, dchisq(x = x, df = 4), type = "l", col = "pink")
lines(x, dchisq(x = x, df = 5), type = "l", col = "darkgreen")

On Aug 17, 2010, at 1:57 PM, maiya wrote:


Hi! This is going to be a real newbie question, but I can't figure it out. 

I'm trying to plot densities of various functions of chi-square. A simple
chi-square plot I can do with dchisq(). But e.g. chi.sq/degrees of freedom I
only know how to do using density(rchisq()/df). For example:

plot(1, type="n",  xlab="", ylab="", xlim=c(0,2), ylim=c(0,7))

for (i in c(10,50,100,200,500)){
lines(density(rchisq(100000,i)/i))
}

But even with 100,000 samples the curves still aren't smooth. Surely there
must be a more elegant way to do this?

Thanks!

Maja
-- 
View this message in context: 
http://r.789695.n4.nabble.com/plotting-functions-of-chi-square-tp2329020p2329020.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to