Is there a way in maxLik to fix/constraint a parameter to fall within a certain range ? For example I want sigma to be always between 1.98 and 2.02
library(maxLik) loglik <- function(param) { mu <- param[1] sigma <- param[2] ll <- -0.5*N*log(2*pi) - N*log(sigma) - sum(0.5*(x - mu)^2/sigma^2) ll } x <- rnorm(1000, 4.5, 2.1) N <- length(x) res <- maxLik(loglik, start=c(0.5,0.5)) # use 'wrong' start values print( res ) coef( res ) ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.