Description Usage Arguments Value Examples
log.posterior for gaussian process for x,y, and f, at the given correlation hyperparameters specified in cor.par
1 | log_posterior(x, y, f, cor.par, prior)
|
x |
covariate matrix/vector x |
y |
response vector y |
f |
regression model, must be a matrix. If constant, should be a vector (as.matrix) of 1s of length n, where n is the number of data points in x |
cor.par |
matrix of theta and alpha parameters for power-exponential model, includes two columns, the first for theta parameters and the second for alpha parameters. For Guassian correlation structure, alpha parameters can be initialized as 0. |
prior |
prior for log-posterior, options are "Exp" for exponential prior and "Hig" for Higdon's prior |
returns the log-posterior
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | n <- 5
x1 <- seq(-5,10,length.out = n)
x2 <- seq(0,15,length.out = n)
data1 <- expand.grid(x1,x2)
x <- data1
# create hyperparameter matrix of thetas and alphas, alphas set to 0 indicated guassian correlation
d2 <- c(0.01,0.2,0,0)
cor.par <- data.frame(matrix(data = d2,nrow = dim(x)[2],ncol = 2))
names(cor.par) <- c("Theta.y","Alpha.y")
R <- cor.matrix(data1,cor.par) # obtain covariance matrix
L <- chol(R)
z <- as.vector(rnorm(n^2))
y <- t(L)%*%z
logpost <- log_posterior(data1,y,as.matrix(rep(1,n^2)),cor.par,prior = "Exp")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.