Learn R Programming

GPpenalty (version 1.0.1)

mle_penalty: mle_penalty

Description

Computes penalized maximum likelihood estimates for the lengthscale parameter using optim.

Usage

mle_penalty(object, one.se = FALSE, lambda = NULL, ncores = 1)

Value

A list of y, x, and hyperparameters:

  • y: A copy of y.

  • x: A copy of x.

  • theta: A matrix of penalized lengthscale estimates.

  • sigma2: The estimated scale parameter.

  • mu: Returns 0 if mu=FALSE otherwise the estimated mu parameter.

  • g: Returns the fixed_g value if g=FALSE otherwise the estimated nugget value.

  • lambda: A scalar or vector of lambda values evaluated.

  • theta_upper: A copy of the upper bound for theta used in gp_cv function.

  • theta_lower: A copy of the lower bound for theta used in gp_cv function.

Arguments

object

A list returned from gp_cv.

one.se

Logical indicator for selecting the lambda value using the one-standard error. Default is FALSE. When FALSE, the lambda value that minimizes mse, dpe, or mahalanobis distance (md), or maximizes the score, is selected. When TRUE, the lambda value is chosen based on the one-standard error rule.

lambda

A user specified tuning parameter. This can be provided directly instead of performing cross-validation.

ncores

A number of cores for parallel computing with optim. Default is 1. Make sure your system supports the specified number of cores.

Details

This function takes the output from gp_cv and computes penalized MLEs for the lengthscale parameter, along with MLEs for other model parameters. Users may choose to apply the one standard error rule for selecting the lambda value. The gp_cv function returns both the optimal lambda and one standard error lambda except for the md metric. See gp_cv for details.

Examples

Run this code
# \donttest{
### training data ###
n <- 8

### test function ###
f_x <- function(x) {
return(sin(2*pi*x) + x^2)
}

### generate x ###
x <- runif(n, 0, 1)
y <- f_x(x)

### k-fold cross validation ###
cv.lambda <- gp_cv(y, x, k=4)

### fit the model ###
penalized.mle <- mle_penalty(cv.lambda)

#### use the one standard error rule ###
penalized.mle <- mle_penalty(cv.lambda, one.se=TRUE)

### specify lambda ###
penalized.mle <- mle_penalty(cv.lambda, lambda=cv.lambda$lambda.score.max)

# }

Run the code above in your browser using DataLab