Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. # data
  2. x <- c(0.35,0.45,0.90,0.05,1.00,0.50,0.45,0.25,0.15,0.40,0.26,0.37,0.43,0.34,0.00,0.11,0.00,0.00,0.00,0.41,0.14,0.80,0.60,0.23,0.17,0.31,0.30,0.00,0.23,0.33,0.30,0.00,0.00)
  3. y <- c(1,10,0,0,67,0,9,5,0,0,0,82,36,0,32,7,7,132,14,33,0,67,11,39,41,67,9,1,44,62,111,52,0)
  4.  
  5. # log-likelihood function
  6. negbinglmLL = function(beta,gamma,k) {
  7. mu= exp(beta+gamma*x)
  8. -sum(dnbinom(y,mu=mu, size=k, log=TRUE))
  9. }
  10.  
  11. # maximum likelihood estimator
  12. model <- mle2(negbinglmLL, start=list(beta=mean(y), gamma= 0, k=mean(y)^2/(var(y)-mean(y))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement