2016-10-21 2 views
1

난 단지 내가 같은에서이 전분기 플롯 좌표를 배치 할 수 있습니다 어떻게 ..장소 다른 QQ 플롯 좌표계

library(fitdistrplus) 


x1<-c(1300,541,441,35,278,167,276,159,126,60.8,160,5000,264.6,379,170,251.3,155.84,187.01,850) 
x2<-c(25,500,42,100,10,8.2,76,2.2,7.86,50) 
y1<-log10(x1) 
y2<-log10(x2) 
x1.logis <- fitdist(y1, "logis", method="mle") 
x2.logis <- fitdist(y2, "logis", method="mle") 
ppcomp(x1.logis, addlegend=FALSE) 
ppcomp(x2.logis, addlegend=FALSE) 

을 전분기 플롯 다른 데이터 세트와 하나 하나를 얻을 수 있습니다 체계?

답변

1

ggplot2을 사용하십시오. fitdist 개체 n에서 맞는 값을 추출하고 새 데이터 프레임을 만들어야합니다. ggplot2 레이어를 사용하여 두 데이터 세트의 맞춤 값을 추가 한 다음 윤곽선을 추가하십시오.

library(ggplot2) 
fittedx1 <- data.frame(x = sort(plogis(x1.logis$data, 
           location = x1.logis$estimate[1], 
           scale = x1.logis$estimate[2])), 
         p = (1:length(x1.logis$data))/length(x1.logis$data)) 

fittedx2 <- data.frame(x = sort(plogis(x2.logis$data, 
           location = x2.logis$estimate[1], 
           scale = x2.logis$estimate[2])), 
        p = (1:length(x2.logis$data))/length(x2.logis$data)) 

fitted <- rbind(fittedx1,fittedx2) #You need to combine the two datasets 
#Add a variable that identifies which dataset the values belong to 
#Then you can use the col option in ggplot to give each data set its own color! 
fitted$set <- c(rep("1", nrow(fittedx1)), rep("2", nrow(fittedx2))) 

#Now plot 
ggplot(fitted) + 
    geom_point(aes(p, x, col=set), shape=1, size=3) + 
    geom_abline(intercept=0, slope=1) 
+0

대단히 감사합니다! 정확히 내가 원하는 것입니다. –