NoiseKriging::logLikelihoodFun
Description
Compute the Profile Log-Likelihood of a NoiseKriging
Model for a
given Vector \(\boldsymbol{\theta}\) of Correlation Ranges and a given
GP Variance \(\sigma^2\)
Usage
Python
# k = NoiseKriging(...) k.logLikelihoodFun(theta_sigma2, grad)
R
# k = NoiseKriging(...) k$logLikelihoodFun(theta_sigma2, grad)
Matlab/Octave
% k = NoiseKriging(...) k.logLikelihoodFun(theta_sigma2, grad)
Arguments
Argument |
Description |
---|---|
|
A numeric vector of (positive) range parameters and variance at which the log-likelihood will be evaluated. |
|
Logical. Should the function return the gradient? |
Details
The profile log-likelihood is obtained from the log-likelihood function \(\ell(\boldsymbol{\theta},\, \sigma^2, \, \boldsymbol{\beta})\) by replacing the vector \(\boldsymbol{\beta}\) of trend coefficients by its ML estimate \(\widehat{\boldsymbol{\beta}}\) which is obtained by Generalized Least Squares. See here for more details.
Value
The value of the profile log-likelihood \(\ell_{\texttt{prof}}(\boldsymbol{\theta},\,\sigma^2)\) for the given vector \(\boldsymbol{\theta}\) of correlation ranges and the given GP variance \(\sigma^2\).
Examples
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7)
set.seed(123)
X <- as.matrix(runif(10))
y <- f(X) + X/10 *rnorm(nrow(X))
k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2")
print(k)
# theta0 = k$theta()
# ll_sigma2 <- function(sigma2) k$logLikelihoodFun(cbind(theta0,sigma2))$logLikelihood
# s2 <- seq(from = 0.001, to = 1, length.out = 101)
# plot(s2, Vectorize(ll_sigma2)(s2), type = 'l')
# abline(v = k$sigma2(), col = "blue")
# sigma20 = k$sigma2()
# ll_theta <- function(theta) k$logLikelihoodFun(cbind(theta,sigma20))$logLikelihood
# t <- seq(from = 0.001, to = 2, length.out = 101)
# plot(t, Vectorize(ll_theta)(t), type = 'l')
# abline(v = k$theta(), col = "blue")
ll <- function(theta_sigma2) k$logLikelihoodFun(theta_sigma2)$logLikelihood
s2 <- seq(from = 0.001, to = 1, length.out = 31)
t <- seq(from = 0.001, to = 2, length.out = 31)
contour(t,s2,matrix(ncol=length(s2),ll(expand.grid(t,s2))),xlab="theta",ylab="sigma2")
points(k$theta(),k$sigma2(),col='blue')
Results
* data: 10x[0.0455565,0.940467] -> 10x[0.152144,0.957381]
* noise: 10x[2.07539e-05,0.00884479]
* trend constant (est.): 0.487335
* variance (est.): 0.0635381
* covariance:
* kernel: matern3_2
* range (est.): 0.211413
* fit:
* objective: LL
* optim: BFGS