Displaying 2 results from an estimated 2 matches for "fbetax".
Did you mean:
betax
2006 Jan 29
1
Logit regression using MLE
...instead of directly calling ‘optim’.
Can someone please figure out the command to do this?
Thank you in advance.
Martin
# mlelo.r - maximum likelihood estimation for logit regression
# log-likelihood function (returns negative to minimise)
log.lo.like <- function(beta,Y,X) {
Fbetax <- 1/(1+exp(-beta%*%t(X)))
loglbeta <- -log(prod(Fbetax^Y*(1-Fbetax)^(1-Y)))
}
# data
Y <- c(0,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,1)
X <-
cbind(matrix(1,21,1),matrix(c(-48.5,24.4,82.8,-24.6,-31.6,91.0,52.1,-87.
7,
-17.0,-51.5,-90.7,65.5,-44.0,-7.0,51.6,32.4,-61.8,34.0...
2009 Sep 28
1
Using linear formula inside MLE
...icitly have to be created by the user?
Y <- c(0,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,1)
X <-
cbind(matrix(1,21,1),matrix(c(-48.5,24.4,82.8,-24.6,-31.6,91.0,52.1,-87.7,-17.0,-51.5,
-90.7,65.5,-44.0,-7.0,51.6,32.4,-61.8,34.0,27.9,-72.9,49.9), 21,1))
log.lo.like <- function(beta,Y,X) {
Fbetax <- 1/(1+exp(-beta%*%t(X)))
loglbeta <- -log(prod(Fbetax^Y*(1-Fbetax)^(1-Y)))
}
#####Using MLE#####
ll <- eval(function(beta0=0,beta1=0)
log.lo.like (c(beta0,beta1),Y,X),
list(X=X,Y=Y))
summary(mle(ll))
####Comparison using glm#####
glm(Y~X-1,family=binomial)...