search for: lik2

Displaying 2 results from an estimated 2 matches for "lik2".

Did you mean: lik
2006 Sep 08
1
maximizing a likelihood function containing an integral
...wing code to do the maximization: ll<-function(b.vec){ b0<-b.vec[1] b1<-b.vec[2] b2<-b.vec[3] p<-1/(1+exp(-b0-b1*z1-b2*x2)) lik1<-p^y*(1-p)^(1-y)*exp(-(z1^2+x2^2-2*rho*z1*x2)/(2*(1-rho^2))) log.lik1<-sum(log(lik1[1:n1])) log.lik2<-0 for(j in (n1+1):n){ integrand<-function(u,B0,B1,B2){ exp(-y[j]*(B0+B1*u+B2*x2[j])-(u-rho*x2[j])^2/2)/(1+exp(B0+B1*u+B2*x2[j])) } log.lik2<-log.lik2+log(integrate(integrand,lower=1,upper=Inf,B0=b0,B1=b1,B2=b2)$integral) } log.lik<-log.lik1+log.lik2...
2007 Oct 24
1
vectorized mle / optim
...erfectly (except that the default algorithm sometimes tries some negative variance parameters). However, if the parameters (m and v) are considered as a vector of parameters, the result is very disappointing: -------------------------------- example 2 ------------ 8< ---------------------- lik2 <- function(param, data) { N <- length(data) lik.mean <- dnorm(mean(data), param["m"], sqrt(param["v"]/N), log=T) lik.var <- dchisq(N*var(data)/param["v"], N-1, log=T) return(-lik.mean - lik.var) } ml.result <- mle(lik2, start=list(param=c(m=2, v...