pkern_nLL | R Documentation |
p
Returns the negative log-likelihood of parameter vector p
for the covariance
model pars_fix
, given data grid g_obs
.
pkern_nLL(
p,
g_obs,
pars_fix,
X = 0,
iso = FALSE,
quiet = TRUE,
log_scale = FALSE
)
p |
numeric vector of covariance parameters accepted by |
g_obs |
list of form returned by |
pars_fix |
list of form returned by |
X |
numeric, vector, matrix, or NA, the mean or its linear predictors, passed to |
iso |
logical, indicates to use identical kernels for x and y ( |
quiet |
logical indicating to suppress console output |
This is a wrapper for -pkern_LL()
allowing parameters to be passed as a numeric
vector instead of a list (for use in optimization etc). Parameters in p
are copied
to pars_fix
and passed to the likelihood computer.
p
is the vector of covariance parameters to test. Names in p
are ignored; Its length
and order should correspond with the pattern of NAs in pars_fix
. Users should check that
the desired parameter list is being constructed correctly by testing with:
pkern_pars_update(pars_fix, p, iso=iso, na_omit=TRUE)
.
numeric, the negative log-likelihood of p
given g_obs
# set up example grid and data
g_obs = pkern_grid(10)
g_obs$gval = rnorm(10^2)
# get some default parameters and vectorize them
pars = pkern_pars(g_obs, 'gau')
p = pkern_pars_update(pars)
pkern_nLL(p, g_obs, pars)
# change a parameter and re-evaluate
p_compare = p
p_compare[1] = 2*p_compare[1]
pkern_nLL(p_compare, g_obs, pars)
# repeat by calling pkern_LL directly
pars_compare = pars
pars_compare$eps = 2*pars_compare$eps
-pkern_LL(pars_compare, g_obs)
# set up a subset of parameters for fitting
pars_fix = pars
pars_fix$eps = NA
pars_fix$y$kp = NA
# names in p_fit are for illustration only (only the order matters)
p_fit = c(eps=1, y.rho=1)
pkern_nLL(p_fit, g_obs, pars_fix)
# equivalently:
pars_fit = pars
pars_fit$eps = p_fit[1]
pars_fit$y$kp = p_fit[2]
-pkern_LL(pars_fit, g_obs)
# check an input specification
pkern_pars_update(pars_fix, p_fit, na_omit=TRUE)
pars_fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.