Re: [R] Fitting GLM with BFGS algorithm

2010-10-27 Thread Prof. John C Nash
ems. John Nash > From: Dimitris Rizopoulos > To: justin bem > Cc: R Maillist > Subject: Re: [R] Fitting GLM with BFGS algorithm > Message-ID: <4cc6c0db.9070...@erasmusmc.nl> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > for instance, for

Re: [R] Fitting GLM with BFGS algorithm

2010-10-26 Thread Dimitris Rizopoulos
for instance, for logistic regression you can do something like this: # simulate some data x <- cbind(1, runif(100, -3, 3), rbinom(100, 1, 0.5)) y <- rbinom(100, 1, plogis(c( x%*% c(-2, 1, 0.3 # BFGS from optim() fn <- function (betas, y, x) { -sum(dbinom(y, 1, plogis(c(x %*% betas)), log