Aha! Thank you both! Just as I thought: completely overlooked something
fundamental.
Thanks,
R.
On Wed, Mar 11, 2009 at 7:53 PM, <gov2001-l-request at lists.fas.harvard.edu>wrote:
> Send gov2001-l mailing list submissions to
> gov2001-l at
lists.fas.harvard.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
>
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
> or, via email, send a message with subject or body 'help' to
> gov2001-l-request at
lists.fas.harvard.edu
>
> You can reach the person managing the list at
> gov2001-l-owner at
lists.fas.harvard.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gov2001-l digest..."
>
>
> Today's Topics:
>
> 1. Optim vs. Zelig question (Rachel West)
> 2. Re: Optim vs. Zelig question (Brandon Stewart)
> 3. Re: Optim vs. Zelig question (Miya Woolfalk)
> 4. Re: problems with log(exp().... Sequential processing in R
> causing issues (Olena Ageyeva)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 11 Mar 2009 19:44:54 -0400
> From: Rachel West <rwest817 at gmail.com>
> Subject: [gov2001-l] Optim vs. Zelig question
> To: gov2001-l at
lists.fas.harvard.edu
> Message-ID:
> <188cad4e0903111644k6ceda0afh3b203441b5641c8d at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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
>