qqline connects the first and third quartiles. How do I draw a line between different quantiles (ie 30% and 70%)?

前端 未结 3 836
南笙
南笙 2021-01-20 14:14

I have a qqnorm plot of a data set with 1000+ points. I want to draw a line between two quantiles at a time (say 30% and 70%) just as qqline does with 25% and 75%, but with

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-20 15:05

    I think you just need

    qqline(diffbp,probs=c(0.3,0.7))
    

    edit: I see from the comments on R: qqline connects the first and third quartiles. How do I draw a line between different quantiles (ie 30% and 70%)? that the difference is that I am using R-devel, and (as @caracal points out) that this feature is new since R 2.15.1 patched (see http://developer.r-project.org/blosxom.cgi/R-2-15-branch/NEWS , 7 July 2012)

    Here's an example that seems to show that qqline() works (I used 0.1, 0.9 for greater contrast):

    set.seed(101)
    z <- rgamma(1000,shape=1)
    newprobs <- c(0.1,0.9)
    ## png("qq.png")
    qqnorm(z,pch=".")
    qqline(z,col="red")
    qqline(z,col="blue",probs=newprobs)
    ## add reference lines
    abline(h=quantile(z,c(0.25,0.75)),col="red",lty=2)
    abline(h=quantile(z,newprobs),col="blue",lty=2)
    abline(v=qnorm(c(0.25,0.75)),col="red",lty=2)
    abline(v=qnorm(newprobs),col="blue",lty=2)
    ## dev.off()
    

    enter image description here

提交回复
热议问题