
Performs full multi-dimensional profile likelihood calculations
Source:R/S3methods.R
profile.ctsmTMB.fit.Rd
Performs full multi-dimensional profile likelihood calculations
Arguments
- fitted
a ctmsTMB fit object
- parlist
a named-list of parameters to profile over. The user can either supply grid-values in the list or leave it empty. If the any one list is empty then grid-values will be calculated using the estimated parameter mean value and standard deviation.
- grid.size
a vector of
length(parlist)
indicating the number of grid-points along each parameter direction. This is only used if theparlist
is empty.- grid.qnt
a vector of
length(parlist)
determining the width of the grid points from the mean value in multiples of the standard deviation.- hessian
a boolean indicating whether to use the hessian or not during the profile optimization.
- silent
boolean whether or not to mute current iteration number the
control
argument.- control
a list of optimization output controls (see nlminb)
- ...
various arguments (not in use)
Note
The implementation was modified from that of https://github.com/kaskr/adcomp/blob/master/TMB/R/tmbprofile.R
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)
#> Checking model components...
#> Checking and setting data...
#> Constructing objective function and derivative tables...
#> Minimizing the negative log-likelihood...
#> 0: 160.35328: 1.00000 1.50000 1.00000
#> 10: 89.603625: 2.58436 2.91384 1.15608
#> Optimization finished!:
#> Elapsed time: 0.008 seconds.
#> The objective value is: 7.387879e+01
#> The maximum gradient component is: 9.9e-08
#> The convergence message is: relative convergence (4)
#> Iterations: 19
#> Evaluations: Fun: 29 Grad: 20
#> See stats::nlminb for available tolerance/control arguments.
#> Returning results...
#> Finished!
# calculate profile likelihood
out <- profile(fit,parlist=list(theta=NULL))
#> Iteration: 1 / 10
#> Iteration: 2 / 10
#> Iteration: 3 / 10
#> Iteration: 4 / 10
#> Iteration: 5 / 10
#> Iteration: 6 / 10
#> Iteration: 7 / 10
#> Iteration: 8 / 10
#> Iteration: 9 / 10
#> Iteration: 10 / 10