tmbroot: Compute likelihood profile confidence intervals of a TMB...

Description Usage Arguments Value Examples

Description

Compute likelihood profile confidence intervals of a TMB object by root-finding in contrast to tmbprofile, which tries to compute somewhat equally spaced values along the likelihood profile (which is useful for visualizing the shape of the likelihood surface), and then (via confint.tmbprofile) extracting a critical value by linear interpolation,

Usage

1
2
3
tmbroot(obj, name, target = 0.5 * qchisq(0.95, df = 1), lincomb,
  parm.range = c(NA, NA), sd.range = 7, trace = FALSE,
  continuation = FALSE)

Arguments

obj

Object from MakeADFun that has been optimized.

name

Name or index of a parameter to profile.

target

desired deviation from minimum log-likelihood. Default is set to retrieve the 95 if the objective function is a negative log-likelihood function

lincomb

Optional linear combination of parameters to profile. By default a unit vector corresponding to name.

parm.range

lower and upper limits; if NA, a value will be guessed based on the parameter value and sd.range

sd.range

in the absence of explicit parm.range values, the range chosen will be the parameter value plus or minus sd.range times the corresponding standard deviation. May be specified as a two-element vector for different ranges below and above the parameter value.

trace

report information?

continuation

use continuation method, i.e. set starting parameters for non-focal parameters to solutions from previous fits?

Value

a two-element numeric vector containing the lower and upper limits (or NA if the target is not achieved in the range), with an attribute giving the total number of function iterations used

Examples

1
2
3
4
5
## Not run: 
runExample("simple",thisR=TRUE)
logsd0.ci <- tmbroot(obj,"logsd0")

## End(Not run)

Example output

Warning message:
In checkMatrixPackageVersion() : Package version inconsistency detected.
TMB was built with Matrix version 1.2.15
Current Matrix version is 1.2.17
Please re-install 'TMB' from source using install.packages('TMB', type = 'source') or ask CRAN for a binary version of 'TMB' matching CRAN's 'Matrix' package
Running example simple 

> require(TMB)

> dyn.load(dynlib("simple"))

> set.seed(123)

> y <- rep(1900:2010, each = 2)

> year <- factor(y)

> quarter <- factor(rep(1:4, length.out = length(year)))

> period <- factor((y > mean(y)) + 1)

> B <- model.matrix(~year + quarter - 1)

> A <- model.matrix(~period - 1)

> B <- as(B, "dgTMatrix")

> A <- as(A, "dgTMatrix")

> u <- rnorm(ncol(B))

> beta <- rnorm(ncol(A)) * 100

> eps <- rnorm(nrow(B), sd = 1)

> x <- as.numeric(A %*% beta + B %*% u + eps)

> obj <- MakeADFun(data = list(x = x, B = B, A = A), 
+     parameters = list(u = u * 0, beta = beta * 0, logsdu = 1, 
+         logsd0 = 1), random = .... [TRUNCATED] 

> opt <- nlminb(obj$par, obj$fn, obj$gr)

TMB documentation built on April 8, 2021, 5:07 p.m.

Related to tmbroot in TMB...