Displaying 2 results from an estimated 2 matches for "log_lik".
Did you mean:
log_io
2012 Mar 14
2
Maximization problem in the optim function
Dear R Users
I am maximizing a user defined log likelihood function. It includes variance
parameter (sigma). I used R function optim with BFGS maximization method.
However, it stops before the solution saying ?sqrt(sigma): NaNs produced?
Could anybody know a proper transformation for sigma which can be passed in
the function? For the correlation parameter I used Fishers? transformation
so it
2012 Mar 20
1
MA process in panels
...res2<-arima(x=dem_yt,xreg=demXt,order=c(0,0,1))
#Alternatively, I tried to obtain res2 using maxLik() from the maxLik
package, but I am not sure about how to specify the log-likelihood function:
tslag <- function(x, d=l)
{
x <- as.vector(x)
n <- length(x)
c(rep(NA,d),x)[1:n]
}
log_Lik<-function(param) {
b1<-param[1]
b2<-param[2]
b3<-param[3]
sigma<-param[4]
ll<- -0.5*N*log(2*pi) - N*log(sigma) -
sum(0.5*(dem_yt-(b1*demXt[,1]+b2*demXt[,2]) +
b3*tslag(dem_yt-(b1*demXt[,1]+b2*demXt[,2]),d=1))^2/sigma^2)
ll
}
res2<-maxLik(logLik=log_Lik,start=c(coef(res1),1,1),...