0

I have a data set with car arrivals per minute.

I drew a histogram and fit to the Poisson distribution with the following R codes.

#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))

The code above successfully ran and I got the fitted lines over the histogram.

But when I want to use the goodfit() function to know how the p-value is I got following error;

"Error in optimize(chi2, range(count)) : 'xmin' not less than 'xmax'”

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

How I can solve this issue ? Is there another function to use?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

1

You're applying goodfit (you should say it's from the vcd package, BTW) to the wrong thing. The first argument should be your count data: try

vcd::goodfit(Datast$Arrival, type="poisson")
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Yes it works in this way, thanks.. How should I follow when I want to measure the compatibility of this data set with the Chisquare test and get the p value? – Fatih Güneş May 15 '20 at 22:40