2012-06-28 2 views
2

X 축이 확률이고 y 축이 로그 스케일 인 R에서 이와 같은 로그 확률 도표를 만드는 방법을 아는 사람이 있습니까? heR.Misc 꾸러미를 읽고 다운로드했는데 어떻게 사용하는지 모르겠습니다. ! enter image description hereR에 로그 확률 플롯?

+3

는에 보라 [이] (http://stats.stackexchange.com/q/27607/3903) – MYaseen208

+0

는 정말 고마워요! 그 작품! – Amateur

+0

그 플롯의 x 축은 확률로 표시되지 않았지만 샘플 값으로 표시되었습니다. 나는 당신이 그런 그래프의 "전치"를 원한다고 생각하고 있습니다. –

답변

0
#create log probablity plot 
#MPM 131201 
#Make some dummy data 
set.seed(21) 
Dt<-as.data.frame(rlnorm(625, log(10), log(2.5))) 
names(Dt)<-"Au_ppm" 

#Create probablity scale lines and associated labels - 
PrbGrd <- qnorm(c(0.001,0.01, 0.05, 0.10,0.20,0.30,0.40, 0.50, 0.60, 0.70,0.80,0.90,0.95,0.99,0.999)) 
PrbGrdL<-c("0.1","1","5","10","20","30","40","50","60","70","80","90","95","99","99.9") 

#create some value grid lines then convert to logs 
ValGrd<-c(seq(0.001,0.01,0.001),seq(0.01,0.1,0.01),seq(0.1,1,0.1),seq(1,10,1),seq(10,100,10)) 
ValGrd<-log10(ValGrd) 

#load up lattice packages - latticeExtra for nice log scale 
require(lattice) 
require(latticeExtra) 

#Use qqmath to make the plot (note lattice does not work for weighted data - shame about that) 

qqmath(~ Au_ppm, 
     data= Dt, 
      distribution = function(p) qnorm(p), 
     main = "Normal probablity/log (base 10) plot", 
     pch=20, 
     cex=0.5, 
     xlab="Normal distribution scale (%)", 
     scales=list(y=list(log=10,alternating=1),x = list(at = PrbGrd, labels = PrbGrdL, cex = 0.8)), 
     yscale.components=yscale.components.log10ticks, 
     panel=function(x,...){ 
      panel.abline(v=PrbGrd ,col="grey",lty=3) 
      panel.abline(h=ValGrd,col="grey",lty=3) 
      panel.qqmath(x,distribution=qnorm) 
     } 

    ) 
0

여기 기재 R을 사용한 예이며,이 글에서 약간 단순화 (https://stat.ethz.ch/pipermail/r-help/2004-February/045370.html).

## Make some data 
y <- rnorm(n=175, mean=100, sd=75) 
y <- sort(y) 
pct <- 1:length(y)/(length(y)+1) 

## For x ticks 
probs <- c(0.0001, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 
      0.9, 0.99, 0.999, 0.9999) 
x.vals <- qnorm(probs)  

## Plotting area 
xs <- c(-4, 4) 
ys <- seq(-2,4) 
par(xaxs="i", yaxs="i") 
plot(NA, NA, xlim=c(xs[1], xs[2]), ylim=c(min(ys), max(ys)), 
    axes=FALSE, xlab=NA, ylab=NA) 

## X Axis 
axis(side=1, at=x.vals, labels=FALSE, tck=-0.01) 

text(x=x.vals, y=rep(min(ys)-0.35, length(x.vals)), 
    labels=probs*100, xpd=TRUE, srt=325, font=2) 

## Y Axis 
axis(side=2, at=ys, labels=FALSE) 
text(y=ys, x=rep(xs[1]-.08, length(ys)), 
    labels= as.character(10^ys), xpd = NA, font=2, 
    pos=2) 

for (i in ys){ 
    axis(side=2, at=log10(seq(2,9))+ i, 
     labels=NA, tck = -0.01) 
} 

## Grid lines and box 
abline(h=ys, col="grey80", lty=2) 
abline(v=qnorm(probs), col="grey80", lty=2) 
box() 

## Plot Data 
lines(x=qnorm(pct), y=log10(y), col="blue") 

enter image description here