r - Issues plotting count distribution displot() -
i have count data. i'm trying document decision use negative binomial distribution rather poisson (i couldn't quasi-poisson dist. in lme4) , having graphical issues (the vector appended end of post). i've been trying implement distplot()
function inform decision distribution model:
here's outcome variable (physician count): plot(d1.2$totalmds)
which might poisson
mean , variance aren't close (the variance doubled 2 extreme values; still not anywhere near mean)
> var(d1.2$totalmds, na.rm = t) [1] 114240.7 > mean(d1.2$totalmds, na.rm = t) [1] 89.3121
my outcome partly population driven i'm using total population offset variable in preliminary models. this, understand it, divides outcome natural log of offset variable totalmds/log(poptotal) what's being modeled. looks like:
but when try model using:
plot 1: distplot(x = d1.2$totalmds, type = "poisson")
plot 2: distplot(x = d1.2$totalmds, type = "nbinomial") # looks way off
plot 3: plot(fitdist(data = d1.2$totalmds, distr = "pois", method = "mle"))
plot 4: plot(fitdist(data = d1.2$totalmds, distr = "nbinom", method = "mle")) # throws warnings
plot 5: qqcomp(fitdist(data = d1.2$totalmds, distr = "pois", method = "mle"))
plot 6: qqcomp(fitdist(data = d1.2$totalmds, distr = "nbinom", method = "mle")) # throws warnings
does have suggestions why following plots little screwy/inconsistent?
as mentioned i'm using variable offset variable in actual analysis, if makes difference.
here's vector: https://gist.github.com/timothyslau/f95a777b713eb33a2fe6
i'm sure nb better poisson since var(d1.2$totalmds)/mean(d1.2$totalmds) # variance-to-mean ratio (vmr) > 1
but if nb appropriate plots should lot cleaner (i think, unless i'm doing wrong these plotting functions/packages).
Comments
Post a Comment