plot.ctsmTMB.profile: #' Plot a profile likelihood ctsmTMB object

View source: R/methods.R

plot.ctsmTMB.profileR Documentation

#' Plot a profile likelihood ctsmTMB object

Description

#' Plot a profile likelihood ctsmTMB object

Usage

## S3 method for class 'ctsmTMB.profile'
plot(x, y, include.opt = TRUE, ...)

Arguments

x

a profile.ctsmTMB object

y

not in use

include.opt

boolean which indicates whether or not to include the total likelihood optimizer in the plot.

...

additional arguments

Examples

library(ctsmTMB)
model <- ctsmTMB$new()

# create model
model$addSystem(dx ~ theta * (mu+u-x) * dt + sigma_x*dw)
model$addObs(y ~ x)
model$setVariance(y ~ sigma_y^2)
model$addInput(u)
model$setParameter(
  theta   = c(initial = 1, lower=1e-5, upper=50),
  mu      = c(initial=1.5, lower=0, upper=5),
  sigma_x = c(initial=1, lower=1e-10, upper=30),
  sigma_y = 1e-2
)
model$setInitialState(list(1,1e-1))

# fit model to data
fit <- model$estimate(Ornstein)

# calculate profile likelihood
out <- profile(fit,parlist=list(theta=NULL))

# plot profile
plot(out)

ctsmTMB documentation built on April 12, 2025, 1:45 a.m.