A quick look suggests you may have forgotten the intercept.
Best,
Miya
On Wed, Mar 11, 2009 at 7:44 PM, Rachel West <rwest817 at gmail.com> wrote:
Hi all -
Probably a fundamental misunderstanding on my part here :: but I've
implemented the logit log-likelihood function as it was derived in the
lecture slides (to the best of my knowledge), and am attempting to optimize
the vector of coefficients (beta)......the code gives me an output in the
proper format (and is consistent for any reasonable starting values for
"par" in optim), but the output is not in the range of the coefficients
estimated by Zelig when I use it to check the function.Am I completely
missing something having to do with constraints or reparametrization here?
Conceptually, I can't think of what the problem would be, yet I must be
misunderstanding something here.....right?
likelihood.logit <- function(beta, y, X){
likelihood.logit <- (-1)*sum(log(1+exp((1-2*y)*(X%*%beta))))
return(likelihood.logit)
}
beta <- c()
y <- Incident
X <- as.matrix(cbind(Temperature, Pressure))
MLE.logit <- optim(par=c(.5,.5), fn=likelihood.logit, y=y, X=X,
method="BFGS", control=list(fnscale=-1))$par
MLE.logit
Many thanks,
Rachel
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
--
Miya Woolfalk
Ph.D. Student
Harvard University
Government and Social Policy