Computes the log-likelihood for a spatial statistical model with a covariance structure determined by parameters including spatial decay and variance.
log_lik(
par,
p1,
p2,
d1,
d2,
y,
u_dist,
n_x,
tau2_1 = 1,
tau2_2 = 1,
age_param_data
)
A numeric scalar. The computed log-likelihood value.
A numeric vector of parameters to estimate. The vector contains:
par[1:p1]
: Coefficients for fixed effects in dataset 1
(\(\beta_1\)).
par[(p1 + 1):(p1 + p2)]
: Coefficients for fixed effects in
dataset 2 (\(\beta_2\)).
par[p1 + p2 + 1]
: Spatial decay parameter (\(\gamma\)).
par[p1 + p2 + 2]
: Log of the variance parameter
(\(\sigma^2\)).
par[p1 + p2 + 3]
: Log of the range parameter (\(\phi\)).
An integer. The number of fixed-effect parameters in dataset 1.
An integer. The number of fixed-effect parameters in dataset 2.
A numeric matrix. Design matrix for dataset 1 used to model the mean structure.
A numeric matrix. Design matrix for dataset 2 used to model the mean structure.
A numeric vector. Observed response variable, including both datasets.
A numeric matrix. Distance matrix for spatial locations.
An integer. The number of unique spatial locations.
Variance parameter for first process (default = 1)
Variance parameter for second process (default = 1)
A numeric matrix or vector. Additional parameters specific to age-based modeling.
The log-likelihood is computed as: $$ -0.5 \left[ \log(\det(M)) + (y - \mu)^T M^{-1} (y - \mu) \right] $$ where:
\(M\) is the covariance matrix, computed using compute_cov
.
\(\mu\) is the mean structure, determined by the design matrices
d1
, d2
and coefficients \(\beta_1, \beta_2\).
The covariance matrix \(M\) is computed using spatial parameters
(\(\gamma, \sigma^2, \phi\)) and the distance matrix u_dist
.