In this document we show how to apply functions to the left-hand side of an observation equation.
# Create model object
obj = ctsmTMB$new()
# Set name of model (and the created .cpp file)
obj$setModelname("ornstein_uhlenbeck")
# Add system equations
obj$addSystem(
dx ~ theta * (mu-x) * dt + sigma_x*dw
)
Let’s assume that our observations yt are
log-normally distributed conditioned on xt i.e. log yti ∼ 𝒩(xti, σy2)
It is sufficient for the user to provide the data column y
in the provided data.frame
to e.g. estimate
or
predict
by adding the following observation equation
Note that these kind of observation equations, where the left-hand
side is a function of one (or more) observed variables must be
explicitly named using the obsnames
argument.
The names given with obsnames
are important because they
are needed to specify the observation variance. As an example the code
below does not work, because the observation was named
log_y
## Error in check_observation_variance_eqs(form, self, private): Please add an observation equation for y before specifying its variance
So the correct way to add the observation variance is this: