【问题标题】:QQ plot for a fitted normal / lognormal distrbution拟合正态/对数正态分布的 QQ 图
【发布时间】:2020-03-09 09:33:03
【问题描述】:

我在为拟合分布生成 QQ 图时遇到问题。 数据由

拟合
NormalFit <- fitdistr(obs, densfun="normal") 

其中 obs 是观测值。

我以为我能做到

qqnorm(NormalFit)

我也想这样做

LogNormalFit <- fitdistr(obs, densfun="log-normal") 

【问题讨论】:

    标签: r statistics risk-analysis


    【解决方案1】:

    拟合只给你推断的参数,所以你需要从中采样,给你 qqplot。请参阅下面的 3 个示例,了解如何操作。

    library(MASS)
    set.seed(999)
    par(mfrow=c(1,3))
    #simulate data
    obs = rnegbin(500, mu = 5, theta = 4)
    #fit data 
    NormalFit <- fitdistr(obs, densfun="normal") 
    
    #plot
    qqnorm(obs,main="qqnorm")
    # generate theoretical quantiles
    Theo_Quantile = qnorm(ppoints(length(obs)))
    qqplot(Theo_Quantile,obs,main="ppoint")
    # it's also similar to if you just sample from the fitted distribution
    Fitted = rnorm(length(obs),NormalFit$estimate[1],NormalFit$estimate[2])
    qqplot(Fitted,obs,main="Sampled from fitted")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-16
      • 2023-03-13
      • 2015-12-07
      • 1970-01-01
      • 2020-11-08
      • 2016-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多