Skip to content

Estimating Mean of a Poisson Distribution Based on Interval censoring

5 messages · mohsen hs, John Kane, Peter Dalgaard

#
Dear all,
I appreciate that if you let me know if there is any package implemented in R for Estimating Mean of a Poisson Distribution Based on Interval censoring? And if yes, could you please provide some information about it:)?
By the way, is there anything for lognormal?I think fitdistcens is not good for this purpose as it gives me different result compared to SAS and only useful for right/left censoring and not interval censoring?(or both left and right together).?
Kind regards,Mohsen
1 day later
#
The general assumption is that if Excel or any other spreadsheet gives a result that is different from R then R will be correct.

Generally with SAS it may be that R is correct or just that R and SAS use slightly different algorithms.

John Kane
Kingston ON Canada
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
#
Fortune candidate :-)

However, the more scientific approach would be to ask for evidence to be scrutinized, acknowledging that R might be fallible, however unlikely that may seem.

Also, there is always the possibility that there are two answers because the question is not the same.

-pd

  
    
#
Thank you, kind sir, you are correct but I was too rushed to write more as the bread needed to be taken out of the oven.  

John Kane
Kingston ON Canada
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!
#
Hi John and Peter,
Thanks for your reply. I found that fitdistcens, is a good approach. I did that for lognormal,?exp?,and other?distributions. Values for lnorm?from SAS and R were close, but slightly different.?At the moment, my main concern is finding the estimated lambda value for?poisson?for the interval censored data, and it seems there is a problem somewhere and I really appreciate your support.Error:"Error in optim(par =?vstart,?fn?=?fnobjcens, fix.arg?= fix.arg,?rcens?=?rcens,??:?\n ?initial value in 'vmmin' is not finite\n"?
Kind regards,Mohsen
Background about my data and code:

I have to say I do not have any idea,?
[1] 39011?
[1] 1?
I am using ?library(fitdistrplus). I also passed the start param for optim, but no success as suggested before in some forums earlier.?
I have provided all scenarios (the first two ones work, the 3rd is my problem, and the 4th also works).?
And No missing value. I am getting some NAN form gamma also, but I do not know the reason.?

?------works?
df= read.csv ("E:/mydata/Motorway-Urban/hour/PathAll_TWOMONTH _BothDirection715_2.csv")?
?z=rep(df$timenum,time=df$count)?
?y<-z?
?ycens <- data.frame(left=y,right=y)?
? max=27219?
? ct=max?
? for(i in max:28666 )?
? {?
? ? ycens$right[ct]=NA?
? ? ? ct=ct+1?
? ?}?
? ct=1;?
? for(i in 1:28666 )?
? {?
? ?if( ycens$left[i]<3)?
? {?
? ? ycens$left[ct]=NA?
? }?
? ? if( i>max)?
? {?
? ycens$left[ct]=500?
? ?} ??
? ct=ct+1?
}?
?fitlnc<-fitdistcens(ycens,"pois")?
Fitting of the distribution ' pois ' on censored data by maximum likelihood?
Parameters:?
? ? ? ?estimate?
lambda 93.34093?

-----------------Works method 2--------------?
?z=rep(df$timenum,time=df$count)?
+ ?{?
+ ? ?ycens$right[ct]=NA?
+ ??
+ ? ?ct=ct+1?
+ ? ??
+ ?}?
+ ?{?
+ ??
+ ?if( ycens$left[i]<3)?
+ ?{?
+ ? ?ycens$left[ct]=NA?
+?
+ ? ?}?
+ ? ? ? ct=ct+1?
+ ?}?
Fitting of the distribution ' pois ' on censored data by maximum likelihood?
Parameters:?
? ? ? ?estimate?
lambda 142.0141?

==================PROBLEEEEEEEEEEMMMM======================?
? z=rep(df$timenum,time=df$count)?
? y<-z?
??
? ycens <- data.frame(left=y,right=y)?
? max=27219?
? ct=max?
? for(i in max:28666 )?
? {?
? ? ycens$right[ct]=y[ct]?
? ? ycens$left[ct]=500?
? ? ct=ct+1?
? ??
? }?
? ct=1;?
? for(i in 1:28666 )?
? {?
??
? if( ycens$left[i]<4)?
? {?
? ? ycens$left[ct]=1?
??
? ? } ? ? ? ct=ct+1?
?}?
[1] "Error in optim(par = vstart, fn = fnobjcens, fix.arg = fix.arg, rcens = rcens, ?: \n ?initial value in 'vmmin' is not finite\n"?
attr(,"class")?
[1] "try-error"?
attr(,"condition")?
<simpleError in optim(par = vstart, fn = fnobjcens, fix.arg = fix.arg, rcens = rcens, ? ? lcens = lcens, icens = icens, ncens = ncens, ddistnam = ddistname, ? ? pdistnam = pdistname, hessian = TRUE, method = meth, lower = lower, ? ? upper = upper, ...): initial value in 'vmmin' is not finite>
Error in fitdistcens(ycens, "pois") :?
? the function mle failed to estimate the parameters,?
? ? ? ? with the error code 100?
====================Works=========================?
z=rep(df$timenum,time=df$count)?
? y<-z?
??
? ycens <- data.frame(left=y,right=y)?
? max=27219?
? ct=max?
? for(i in max:28666 )?
? {?
? ? ycens$right[ct]=y[ct]?
? ? ycens$left[ct]=500?
? ? ct=ct+1?
? ??
? }?
? ct=1;?
? for(i in 1:28666 )?
? {?
??
? if( ycens$left[i]<4)?
? {?
? ? ycens$left[ct]=1?
??
? ? } ? ? ??
?ct=ct+1?
?}?

?fitlnc<-fitdistcens(ycens,"lnorm")?
?fitlnc<-fitdistcens(ycens,"exp")?
There were 12 warnings (use warnings() to see them)?
Warning messages:?
1: In dgamma(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
2: In pgamma(q = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, ?... : NaNs produced?
3: In pgamma(q = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
4: In dgamma(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
5: In pgamma(q = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, ?... : NaNs produced?
6: In pgamma(q = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
7: In dgamma(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
8: In pgamma(q = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, ?... : NaNs produced?
9: In pgamma(q = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
10: In dgamma(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
11: In pgamma(q = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, ?... : NaNs produced?
12: In pgamma(q = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ?... : NaNs produced?
Remove Ads
On Monday, February 15, 2016 3:40 AM, John Kane <jrkrideau at inbox.com> wrote:
Thank you, kind sir, you are correct but I was too rushed to write more as the bread needed to be taken out of the oven.? 

John Kane
Kingston ON Canada
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
[[elided Yahoo spam]]