TMB-interface {RTMB}R Documentation

Interface to TMB

Description

Interface to TMB

Usage

MakeADFun(
  func,
  parameters,
  random = NULL,
  profile = NULL,
  integrate = NULL,
  intern = FALSE,
  map = list(),
  ADreport = FALSE,
  silent = FALSE,
  ridge.correct = FALSE,
  ...
)

sdreport(obj, ...)

ADREPORT(x)

REPORT(x)

getAll(..., warn = TRUE)

OBS(x)

checkConsistency(obj, fast = TRUE, ...)

Arguments

func

Function taking a parameter list (or parameter vector) as input.

parameters

Parameter list (or parameter vector) used by func.

random

As MakeADFun.

profile

As MakeADFun.

integrate

As MakeADFun.

intern

As MakeADFun.

map

As MakeADFun.

ADreport

As MakeADFun.

silent

As MakeADFun.

ridge.correct

Experimental

...

Passed to TMB

obj

TMB model object (output from MakeADFun)

x

Observation object

warn

Give a warning if overwriting an existing object?

fast

Pass observation.name to TMB ?

Value

TMB model object.

Functions

Examples

data(rivers)
f <- function(p) { -sum(dnorm(rivers, p$mu, p$sd, log=TRUE)) }
obj <- MakeADFun(f, list(mu=0, sd=1), silent=TRUE)
opt <- nlminb(obj$par, obj$fn, obj$gr)
sdreport(obj)
## 'REML trick'
obj2 <- MakeADFun(f, list(mu=0, sd=1), random="mu", silent=TRUE)
opt2 <- nlminb(obj2$par, obj2$fn, obj2$gr)
sdreport(obj2) ## Compare with sd(rivers)
## Single argument vector function with numeric 'parameters'
fr <- function(x) {   ## Rosenbrock Banana function
    x1 <- x[1]
    x2 <- x[2]
    100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
obj <- MakeADFun(fr, numeric(2), silent=TRUE)
nlminb(c(-1.2, 1), obj$fn, obj$gr, obj$he)

[Package RTMB version 1.5 Index]