Displaying 1 result from an estimated 1 matches for "phi_e".
Did you mean:
phi_1
2007 Nov 06
0
Discrepancy of Neg. Binomial Estimation in R
...independent variable
z= runif(obs)
# Generate X matrix
x = cbind(rep(1,obs),z)
# Generate the dependent variable from a neg. binomial distribution
phi = exp(x%*%beta)
sigma_2 = 10
y = rnbinom(obs,size=phi/(sigma_2-1),mu=phi)
# Neg. Binomial log-likelihood function
like.nb=function(par,x,y)
{
phi_e=exp(x%*%par[1:2])
sig2_e=exp(par[3])+1
sum(lgamma(phi_e/(sig2_e-1)+y)-lgamma(phi_e/(sig2_e-1))+y*log((sig2_e-1)/sig2_e)-(phi_e/(
sig2_e-1))*log(sig2_e))
}
# Ng. Binomial regression
b = solve(t(x)%*%x,(t(x)%*%y))
b = matrix(c(b,var(y)/mean(y)),nrow=3) # set initial value for means and
variance...