These functions are not normally called directly by the user. Function uvector() is used by sdefit(). Function uvector_noh() is a more limited version, maintained for documentation purposes. Function logdet_and_v() is used by uvector() and uvector_noh().
uvector(x, t, unit =NULL, beta0, beta1, eta, eta0, x0, t0, lambda, mum =1, mu0 =1, mup =1, sorted =FALSE, final =FALSE)uvector_noh(x, t, beta0, beta1, eta, eta0, x0, t0, lambda, final =FALSE)logdet.and.v(cdiag, csub =NULL, z)
Arguments
x, t: Data vectors
unit: Unit id vector, if any.
beta0, beta1, eta, eta0, x0, t0: SDE parameters or re-parameterizations.
lambda: Named list of parameters(s) for phi(), possibly local vectors.
mum, mu0, mup: Optional σ multipliers.
sorted: Data already ordered by increasing t?
final: Mode, see below.
cdiag: Vector with the diagonal elements c[i,i] of C.
csub: Vector with sub-diagonal c[i,i−1] for c("i>\n", "1").
z: A numeric vector
Returns
uvector() and uvector_noh(): If final = FALSE
(default), return a vector whose sum of squares should be minimized over the parameters to obtain maximum-likelihood estimates. If final = TRUE, passing the ML parameter estimates returns a list with the sigma estimates, the maximized log-likelihood, and AIC and BIC criteria..
logdet_and_v(): List with elements logdet and v.
Details
uvector() and uvector_noh() calculate a vector of residuals for sum of squares minimization by nls() or nlme(). The first one works both for single-unit and for bilevel hierarchical models. It is backward-compatible with uvector_noh(), which is only for single-unit models but simpler and easier to understand. They require a transformation function phi(x, theta), and a function phiprime(x, theta) for the derivative dy/dx, where theta is a list containing the transformation parameters.
logdet_and_v() calculates log[det(L)] and v=L−1z, where C=LL′, with L lower-triangular.
The three functions are essentially unchanged from García (2019) <tools:::Rd_expr_doi("10.1007/s00180-018-0837-4") >, except for a somewhat safer computation for very small beta1, and adding in logdet_and_v() a shortcut for when L is diagonal (e.g., when σm=0). The transformation functions phi and phiprime can be passed as globals, as in the original, or in an environment named trfuns.