0

我有一个超过 2000 万个值的大数据,由于隐私和使代码可重复,我使用 mydata 来替换它。

set.seed(1234)
mydata <- rlnorm(28000000,3.14,1.3)

我想找到mydata最适合的已知发行版,因此选择fitdist了包fitdistrplus中的功能。

library(fitdistrplus)
fit.lnorm <- fitdist(mydata,"lnorm")
fit.weibull <- fitdist(mydata, "weibull")
fit.gamma <- fitdist(mydata, "gamma", lower = c(0, 0))
fit.exp <- fitdist(mydata,"exp")

然后,我使用ppcomp函数绘制 PP 图来帮助我选择最佳拟合分布。

library(RColorBrewer)
tiff("./pplot.tiff",res = 300,compression = "lzw",height = 6,width = 10,units = "in",pointsize = 12)
ppcomp(list(fit.lnorm,fit.weibull, fit.gamma,fit.exp), fitcol = brewer.pal(9,"Set1")[1:4],legendtext = c("lnorm","weibull", "gamma","exp"))
dev.off()

绘图 当然,对数正态mydata最适合,但是看一下legend情节,缺少不同颜色的线条注释,只显示文本注释,我该怎么办?

我尝试了一些值很少的数据集,它奏效了。那么大数据引出了一个问题,我应该怎么做才能让传奇变得完美呢?

4

1 回答 1

0

A lot of function questions could be done by fix(function), in this way, we could know how the function works.

fix(ppcomp)

And I find some codes about legend,

if (addlegend) {
    if (missing(legendtext)) 
      legendtext <- paste("fit", 1:nft)
    if (!largedata) 
      legend(x = xlegend, y = ylegend, bty = "n", legend = legendtext, 
        pch = fitpch, col = fitcol, ...)
    else legend(x = xlegend, y = ylegend, bty = "n", legend = legendtext, 
      col = fitcol, ...)
  }

Then, I add lty=1 to the legend, and it works.

于 2016-07-06T07:33:30.553 回答