繁体   English   中英

将对数正态分布拟合到 R 中的截断数据

[英]Fitting a lognormal distribution to truncated data in R

作为简要的背景,我很想描述火灾规模的分布,假设它遵循对数正态分布(许多小火和很少的大火)。 对于我的特定应用,我只对落在特定尺寸范围内(> min,< max)的火灾感兴趣。 因此,我试图将对数正态分布拟合到两端都经过审查的数据集。 本质上,我想在审查之前找到最适合完整分布的对数正态分布(mu 和 sigma)的参数。 考虑到我知道我只查看分布的一部分,我可以拟合分布吗?

我做了一些实验,但被难住了。 下面是一个例子:

# Generate data #
D <- rlnorm(1000,meanlog = -0.75, sdlog = 1.5)
# Censor data #
min <- 0.10
max <- 20
Dt <- D[D > min]
Dt <- Dt[Dt <= max]

如果我使用 fitdistr (MASS) 或 fitdist (fitdistrplus) 拟合非删失数据 (D),我显然会得到与我输入的参数值大致相同的参数值。 但是,如果我拟合删失数据 (Dt),则参数值不匹配,正如预期的那样。 问题是如何合并已知的审查。 我在其他地方看到过一些关于在 fitdistr 中使用 upper 和 lower 的参考资料,但是我遇到了一个我不确定如何解决的错误:

> fitt <- fitdist(Dt, "lognormal", lower = min, upper = max)
Error in fitdist(Dt, "lognormal", lower = min, upper = max) : 
The  dlognormal  function must be defined 

我会很感激任何建议,首先是关于这是否是适合审查分布的合适方法,如果是,如何定义 dlognormal 函数以便我可以完成这项工作。 谢谢!

您的数据没有被删失(这意味着区间外的观察值存在,但您不知道它们的确切值)但被截断(这些观察值已被丢弃)。

您只需要向fitdist提供截断分布的密度和累积分布函数。

library(truncdist)
dtruncated_log_normal <- function(x, meanlog, sdlog) 
  dtrunc(x, "lnorm", a=.10, b=20, meanlog=meanlog, sdlog=sdlog)
ptruncated_log_normal <- function(q, meanlog, sdlog) 
  ptrunc(q, "lnorm", a=.10, b=20, meanlog=meanlog, sdlog=sdlog)

library(fitdistrplus)
fitdist(Dt, "truncated_log_normal", start = list(meanlog=0, sdlog=1))
# Fitting of the distribution ' truncated_log_normal ' by maximum likelihood 
# Parameters:
#           estimate Std. Error
# meanlog -0.7482085 0.08390333
# sdlog    1.4232373 0.0668787

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM