Displaying 1 result from an estimated 1 matches for "llfn".
Did you mean:
lfn
2012 May 13
2
Discrete choice model maximum likelihood estimation
...rn(L3l)
}
L2 <- function(b1,b2,b3,b,t) {
P11 <- P1(b1,b,t)
P22 <- P2(b2,b,t)
P33 <- P3(b3,b,t)
L2l <- (P11=1)*(P22=1)*(P33=0)
return(L2l)
}
L1 <- function(b1,b2,b,t) {
P11 <- P1(b1,b,t)
P22 <- P2(b2,b,t)
L1l <- (P11=1)*(P22=0)
return(L1l)
}
# Log-likelihood function
llfn <- function(par,a,t) {
b1 <- par[1]
b2 <- par[2]
b3 <- par[3]
b <- par[4]
lL1 <- log(L1(b1,b2,b,t))
lL2 <- log(L2(b1,b2,b3,b,t))
lL3 <- log(L3(b1,b2,b3,b,t))
llfn <- (a==1)*lL1+(a==2)*lL2+(a==3)*lL3
}
est <- optim(par,llfn, method = c("CG"),control=list(tr...