我如何测试数据以使其与Poisson分布具有良好的拟合度?

问题描述 投票:0回答:2

我有一个数据集,每分钟有汽车到达。

我绘制了直方图,并使用以下R代码拟合到泊松分布。

#Aladdin Arrivals
Datast <- read.csv("Vehiclecount.csv", header = T, sep=";", dec=",")
hist(Datast$Arrival, xlab="Arrivals", 
  probability = TRUE,col=16, ylim = c(0,0.2), xlim =c(0, 30),    
  main = "Arrivals from Aladdin Street")
lines(dpois(x=0:25, lambda=13.20), col=2,lwd=3)
legend("topright", c("Probability of Vehicle Arrivals ", 
    "Poisson Distribution Curve"),  fill=c(col=16, col=2))

上面的代码成功运行,我在直方图中得到了拟合线。

但是当我想使用goodfit()函数来了解p值时,出现以下错误;

“ optimize(chi2,range(count))中的错误:'xmin'不小于'xmax'”]

dfs <- dpois(x=1:25, lambda=13.20)
summary(dfs)
goodfit(dfs, type="poisson", method="MinChisq")

我该如何解决这个问题?还有其他功能要使用吗?

r poisson p-value goodness-of-fit p
2个回答
1
投票

您正在将goodfit(应该说是来自vcd程序包,顺便说一句)应用于错误的内容。第一个参数应该是您的计数数据:try

vcd::goodfit(Datast$Arrival, type="poisson")

0
投票

我将示例数据添加为图像。。

Arrival Rate of Vehicles

© www.soinside.com 2019 - 2024. All rights reserved.