search for: lik1

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

Did you mean: lik
2006 Sep 08
1
maximizing a likelihood function containing an integral
...ihood function which contains an integral. The integral contains the unknown parameter as well. I am trying to use the following 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.li...
2007 Oct 24
1
vectorized mle / optim
...ed some advice on something that looks like a FAQ: the possibility of providing vectors to optim() function. Here is a stupid and short example summarizing the problem: -------------------------------- example 1 ------------ 8< ---------------------- library(stats4) data <- rnorm(100,0,1) lik1 <- function(m, v, data) { N <- length(data) lik.mean <- dnorm(mean(data), m, sqrt(v/N), log=T) lik.var <- dchisq(N*var(data)/v, N-1, log=T) return(-lik.mean - lik.var) } ml.result <- mle(lik1, start=list(m=2, v=2), fixed=list(data=data)) summary(ml.result) -------------------...