Georg Otto <[EMAIL PROTECTED]> writes:

> Thanks a lot for your help!
> 
> Now I have a related problem, that I still can not solve:
> 
> I plot a t distribution using:
> 
> curve(dt(x, df = 20), xlim=c(-5,5))
> 
> The upper 5% of that distribution using:
> 
> qt(0.05, df=20, lower.tail=FALSE)
> 
> How can define the polygon to highlight the area representing the
> upper 5% of values?

curve(dt(x, df = 20), xlim=c(-5,5))
x0 <- qt(0.05, df=20, lower.tail=FALSE)
xmax <- 5
x <- seq(x0, xmax, length=100) # or whatever it takes
polygon(c(x0, x, xmax),c(0, dt(x, df = 20), 0), col="red")
 
> Thanks a lot!
> 
> Georg
> 
> "Ken Knoblauch" <[EMAIL PROTECTED]> writes:
> 
> > How about,
> >
> > d<-density(rnorm(10000))
> > plot(d)
> > wvs <- which(d$x > 1 & d$x < 2)
> > polygon(d$x[c( wvs[1], wvs, wvs[length(wvs)] ) ], c(0, d$y[wvs], 0), col =
> > "bisque")
> >
> > Georg Otto a écrit:
> > Hi,
> >
> > if I plot a normal distribution like this:
> >
> > d<-density(rnorm(10000))
> > plot(d)
> >
> > how can I highlight the area below the graph in a certain interval,
> > say x=1,2?  I understand that I should use polygon, but I have not
> > found the right way to give the result that I want.
> >
> > .
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])                  FAX: (+45) 35327907

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to