https://github.com/cran/emplik
Raw File
Tip revision: 344f321e5cd2c16878948de01191cd7cb678027a authored by Mai Zhou on 05 August 2018, 08:53:00 UTC
version 1.0-3.1
Tip revision: 344f321
findUL.R
findUL <- function (step = 0.01, initStep = 0, fun, MLE, level = 3.84, 
    ...) 
{
    value <- 0
    step1 <- step
    Lbeta <- MLE - initStep
    for (i in 1:8) {
        while (value < level) {
            Lbeta <- Lbeta - step1
            value <- fun(Lbeta, ...)$"-2LLR"
        }
        Lbeta <- Lbeta + step1
        step1 <- step1/10
        value <- fun(Lbeta, ...)$"-2LLR"
    }
    value1 <- value
    value <- 0
    Ubeta <- MLE + initStep
    for (i in 1:8) {
        while (value < level) {
            Ubeta <- Ubeta + step
            value <- fun(Ubeta, ...)$"-2LLR"
        }
        Ubeta <- Ubeta - step
        step <- step/10
        value <- fun(Ubeta, ...)$"-2LLR"
    }
	if ( (value1>level)|(value>level) ) warning("Something wrong. Check the MLE and step inputs.")
    return(list(Low = Lbeta, Up = Ubeta, FstepL = step1, FstepU = step, 
        Lvalue = value1, Uvalue = value))
}
back to top