[R] mle

pari hesabi statistics84 at hotmail.com
Fri Feb 27 08:19:37 CET 2015


Hello,
I am going to estimate the parameter of the count model: pr(N=n)= integration{B(x, alpha)-C(x,alpha)} by maximum likelihood estimation. 
n<-c(0,1,2,3)   and   F<- (0,3,4,5) are the vectors of values and observed frequency respectively. The function C(x,alpha) is not defined for n=0, but suppose C(x,alpha)=1 when n=0.  When I want to insert this exception in the following loop, I don't receive reasonable estimate.
pari (alpha){
nloglik<- function(alpha){
B<-function(x,k){........}
C<-function(x,k){........}
A<-function(x){
s<-rep(0,length(x))
s<-s+ C(x,k) 
s<- s+B(x,k) 
}
s
}
d<-0
for (n in seq(along=F)){
 lik<-integrate(A,0,1)$value
d<- d - F[n]*log(lik)}}
d }
F<-  (0,3,4,5)
n<-length(F)
mle (nloglik, start=list(alpha=alpha)
}     
This program gives the answer when n= 1,2,3. But for n=0 I get error, I have to consider the exception : C(x,alpha)=1.  
Does anybody know where I need to put the exception in the program? ( For 'if' loops, I don't get reasonable results) 
I would appreciate any help
Best Regards,  
    

 		 	   		  


More information about the R-help mailing list