Title: | Composite Grid Gaussian Processes |
---|---|
Description: | Run computer experiments using the adaptive composite grid algorithm with a Gaussian process model. The algorithm works best when running an experiment that can evaluate thousands of points from a deterministic computer simulation. This package is an implementation of a forthcoming paper by Plumlee, Erickson, Ankenman, et al. For a preprint of the paper, contact the maintainer of this package. |
Authors: | Collin Erickson [aut, cre], Matthew Plumlee [aut] |
Maintainer: | Collin Erickson <[email protected]> |
License: | GPL-3 |
Version: | 1.0.4.9000 |
Built: | 2025-01-19 03:15:26 UTC |
Source: | https://github.com/collinerickson/cggp |
The CGGP package implements the method presented in Plumlee et al. (2019).
The CGGP functions: CGGPcreate, CGGPfit, CGGPappend, and CGGPpred
Calculated using grid of integration points. Can be calculated exactly, but not much reason in 1D.
CGGP_internal_calcMSE(xl, theta, CorrMat)
CGGP_internal_calcMSE(xl, theta, CorrMat)
xl |
Vector of points in 1D |
theta |
Correlation parameters |
CorrMat |
Function that gives correlation matrix for vectors of 1D points. |
MSE value
CGGP_internal_calcMSE(xl=c(0,.5,.9), theta=c(1,2,3), CorrMat=CGGP_internal_CorrMatCauchySQT)
CGGP_internal_calcMSE(xl=c(0,.5,.9), theta=c(1,2,3), CorrMat=CGGP_internal_CorrMatCauchySQT)
Delta of adding block is product over i=1..d of IMSE(i,j-1) - IMSE(i,j)
CGGP_internal_calcMSEde(valsinds, MSE_MAP)
CGGP_internal_calcMSEde(valsinds, MSE_MAP)
valsinds |
Block levels to calculate MSEs for |
MSE_MAP |
Matrix of MSE values |
All MSE values
SG <- CGGPcreate(d=3, batchsize=100) y <- apply(SG$design, 1, function(x){x[1]+x[2]^2}) SG <- CGGPfit(SG, Y=y) MSE_MAP <- outer(1:SG$d, 1:8, Vectorize(function(dimlcv, lcv1) { CGGP_internal_calcMSE(SG$xb[1:SG$sizest[dimlcv]], theta=SG$thetaMAP[(dimlcv-1)*SG$numpara+1:SG$numpara], CorrMat=SG$CorrMat) })) CGGP_internal_calcMSEde(SG$po[1:SG$poCOUNT, ], MSE_MAP)
SG <- CGGPcreate(d=3, batchsize=100) y <- apply(SG$design, 1, function(x){x[1]+x[2]^2}) SG <- CGGPfit(SG, Y=y) MSE_MAP <- outer(1:SG$d, 1:8, Vectorize(function(dimlcv, lcv1) { CGGP_internal_calcMSE(SG$xb[1:SG$sizest[dimlcv]], theta=SG$thetaMAP[(dimlcv-1)*SG$numpara+1:SG$numpara], CorrMat=SG$CorrMat) })) CGGP_internal_calcMSEde(SG$po[1:SG$poCOUNT, ], MSE_MAP)
Predictive weights are Sigma^(-1)*y in standard GP. This calculation is much faster since we don't need to solve the full system of equations.
CGGP_internal_calcpw(CGGP, y, theta, return_lS = FALSE)
CGGP_internal_calcpw(CGGP, y, theta, return_lS = FALSE)
CGGP |
CGGP object |
y |
Measured values for CGGP$design |
theta |
Correlation parameters |
return_lS |
Should lS be returned? |
Vector with predictive weights
cggp <- CGGPcreate(d=3, batchsize=100) y <- apply(cggp$design, 1, function(x){x[1]+x[2]^2+rnorm(1,0,.01)}) CGGP_internal_calcpw(CGGP=cggp, y=y, theta=cggp$thetaMAP)
cggp <- CGGPcreate(d=3, batchsize=100) y <- apply(cggp$design, 1, function(x){x[1]+x[2]^2+rnorm(1,0,.01)}) CGGP_internal_calcpw(CGGP=cggp, y=y, theta=cggp$thetaMAP)
Calculate derivative of pw
CGGP_internal_calcpwanddpw(CGGP, y, theta, return_lS = FALSE)
CGGP_internal_calcpwanddpw(CGGP, y, theta, return_lS = FALSE)
CGGP |
CGGP object |
y |
Measured values for CGGP$design |
theta |
Correlation parameters |
return_lS |
Should lS and dlS be returned? |
derivative matrix of pw with respect to logtheta
cggp <- CGGPcreate(d=3, batchsize=100) y <- apply(cggp$design, 1, function(x){x[1]+x[2]^2+rnorm(1,0,.01)}) CGGP_internal_calcpwanddpw(CGGP=cggp, y=y, theta=cggp$thetaMAP)
cggp <- CGGPcreate(d=3, batchsize=100) y <- apply(cggp$design, 1, function(x){x[1]+x[2]^2+rnorm(1,0,.01)}) CGGP_internal_calcpwanddpw(CGGP=cggp, y=y, theta=cggp$thetaMAP)
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatCauchy( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatCauchy( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatCauchy(c(0,.2,.4),c(.1,.3,.5), theta=c(-1,.9,.1))
CGGP_internal_CorrMatCauchy(c(0,.2,.4),c(.1,.3,.5), theta=c(-1,.9,.1))
Calculate correlation matrix for two sets of points in one dimension Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatCauchySQ( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatCauchySQ( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatCauchySQ(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7,-.5))
CGGP_internal_CorrMatCauchySQ(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7,-.5))
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatCauchySQT( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatCauchySQT( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatCauchySQT(c(0,.2,.4),c(.1,.3,.5), theta=c(-.1,.3,-.7))
CGGP_internal_CorrMatCauchySQT(c(0,.2,.4),c(.1,.3,.5), theta=c(-.1,.3,-.7))
Calculate correlation matrix for two sets of points in one dimension Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatGaussian( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatGaussian( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
WE HIGHLY ADVISE NOT USING THIS CORRELATION FUNCTION. Try Power Exponential, CauchySQT, Cauchy, or Matern 3/2 instead.
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatGaussian(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7))
CGGP_internal_CorrMatGaussian(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7))
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatMatern32( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatMatern32( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatMatern32(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7))
CGGP_internal_CorrMatMatern32(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7))
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatMatern52( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatMatern52( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatMatern52(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7))
CGGP_internal_CorrMatMatern52(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7))
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatPowerExp( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatPowerExp( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatPowerExp(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7,.2))
CGGP_internal_CorrMatPowerExp(c(0,.2,.4),c(.1,.3,.5), theta=c(-.7,.2))
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatWendland0( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatWendland0( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland1()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatWendland0(c(0,.2,.4),c(.1,.3,.5), theta=-.7)
CGGP_internal_CorrMatWendland0(c(0,.2,.4),c(.1,.3,.5), theta=-.7)
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatWendland1( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatWendland1( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland2()
CGGP_internal_CorrMatWendland1(c(0,.2,.4),c(.1,.3,.5), theta=-.7)
CGGP_internal_CorrMatWendland1(c(0,.2,.4),c(.1,.3,.5), theta=-.7)
Calculate correlation matrix for two sets of points in one dimension. Note that this is not the correlation between two vectors.
CGGP_internal_CorrMatWendland2( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
CGGP_internal_CorrMatWendland2( x1, x2, theta, return_dCdtheta = FALSE, return_numpara = FALSE, returnlogs = FALSE )
x1 |
Vector of coordinates from same dimension |
x2 |
Vector of coordinates from same dimension |
theta |
Correlation parameters:
|
return_dCdtheta |
Should dCdtheta be returned? |
return_numpara |
Should it just return the number of parameters? |
returnlogs |
Should log of correlation be returned? |
Matrix of correlation values between x1 and x2
Other correlation functions:
CGGP_internal_CorrMatCauchySQT()
,
CGGP_internal_CorrMatCauchySQ()
,
CGGP_internal_CorrMatCauchy()
,
CGGP_internal_CorrMatGaussian()
,
CGGP_internal_CorrMatMatern32()
,
CGGP_internal_CorrMatMatern52()
,
CGGP_internal_CorrMatPowerExp()
,
CGGP_internal_CorrMatWendland0()
,
CGGP_internal_CorrMatWendland1()
CGGP_internal_CorrMatWendland2(c(0,.2,.4),c(.1,.3,.5), theta=-.7)
CGGP_internal_CorrMatWendland2(c(0,.2,.4),c(.1,.3,.5), theta=-.7)
Gradient of negative log likelihood posterior
CGGP_internal_gneglogpost( theta, CGGP, y, ..., return_lik = FALSE, ys = NULL, Xs = NULL, HandlingSuppData = "Correct" )
CGGP_internal_gneglogpost( theta, CGGP, y, ..., return_lik = FALSE, ys = NULL, Xs = NULL, HandlingSuppData = "Correct" )
theta |
Log of correlation parameters |
CGGP |
CGGP object |
y |
CGGP$design measured values |
... |
Forces you to name remaining arguments |
return_lik |
If yes, it returns a list with lik and glik |
ys |
Supplementary output data |
Xs |
Supplementary input data |
HandlingSuppData |
How should supplementary data be handled? * Correct: full likelihood with grid and supplemental data * Only: only use supplemental data * Ignore: ignore supplemental data |
Vector for gradient of likelihood w.r.t. x (theta)
cg <- CGGPcreate(d=3, batchsize=20) Y <- apply(cg$design, 1, function(x){x[1]+x[2]^2}) cg <- CGGPfit(cg, Y) CGGP_internal_gneglogpost(cg$thetaMAP, CGGP=cg, y=cg$y)
cg <- CGGPcreate(d=3, batchsize=20) Y <- apply(cg$design, 1, function(x){x[1]+x[2]^2}) cg <- CGGPfit(cg, Y) CGGP_internal_gneglogpost(cg$thetaMAP, CGGP=cg, y=cg$y)
Calculate MSE prediction along a single dimension
CGGP_internal_MSEpredcalc(xp, xl, theta, CorrMat)
CGGP_internal_MSEpredcalc(xp, xl, theta, CorrMat)
xp |
Points at which to calculate MSE |
xl |
Levels along dimension, vector??? |
theta |
Correlation parameters |
CorrMat |
Function that gives correlation matrix for vectors of 1D points. |
MSE predictions
CGGP_internal_MSEpredcalc(c(.4,.52), c(0,.25,.5,.75,1), theta=c(.1,.2), CorrMat=CGGP_internal_CorrMatCauchySQ)
CGGP_internal_MSEpredcalc(c(.4,.52), c(0,.25,.5,.75,1), theta=c(.1,.2), CorrMat=CGGP_internal_CorrMatCauchySQ)
Calculate negative log posterior
CGGP_internal_neglogpost( theta, CGGP, y, ..., ys = NULL, Xs = NULL, HandlingSuppData = "Correct" )
CGGP_internal_neglogpost( theta, CGGP, y, ..., ys = NULL, Xs = NULL, HandlingSuppData = "Correct" )
theta |
Correlation parameters |
CGGP |
CGGP object |
y |
Measured values of CGGP$design |
... |
Forces you to name remaining arguments |
ys |
Supplementary output data |
Xs |
Supplementary input data |
HandlingSuppData |
How should supplementary data be handled?
|
Likelihood
cg <- CGGPcreate(d=3, batchsize=20) Y <- apply(cg$design, 1, function(x){x[1]+x[2]^2}) cg <- CGGPfit(cg, Y) CGGP_internal_neglogpost(cg$thetaMAP, CGGP=cg, y=cg$y)
cg <- CGGPcreate(d=3, batchsize=20) Y <- apply(cg$design, 1, function(x){x[1]+x[2]^2}) cg <- CGGPfit(cg, Y) CGGP_internal_neglogpost(cg$thetaMAP, CGGP=cg, y=cg$y)
Set correlation function of CGGP object
CGGP_internal_set_corr(CGGP, corr)
CGGP_internal_set_corr(CGGP, corr)
CGGP |
CGGP object |
corr |
Correlation function |
CGGP object
obj <- CGGPcreate(3, 20, corr="matern52") CGGP_internal_set_corr(obj, "gaussian")
obj <- CGGPcreate(3, 20, corr="matern52") CGGP_internal_set_corr(obj, "gaussian")
Add 'batchsize' points to 'SG' using 'theta'.
CGGPappend(CGGP, batchsize, selectionmethod = "MAP")
CGGPappend(CGGP, batchsize, selectionmethod = "MAP")
CGGP |
Sparse grid object |
batchsize |
Number of points to add |
selectionmethod |
How points will be selected: one of 'UCB', 'TS', 'MAP', 'Oldest', 'Random', or 'Lowest'. 'UCB' uses Upper Confidence Bound estimates for the parameters. 'TS' uses Thompson sampling, a random sample from the posterior. 'MAP' uses maximum a posteriori parameter estimates. 'Oldest' adds the block that has been available the longest. 'Random' adds a random block. 'Lowest' adds the block with the lowest sum of index levels. 'UCB' and 'TS' are based on bandit algorithms and account for uncertainty in the parameter estimates, but are the slowest. ‘MAP' is fast but doesn’t account for parameter uncertainty. The other three are naive methods that are not adaptive and won't perform well. |
SG with new points added.
Other CGGP core functions:
CGGPcreate()
,
CGGPfit()
,
predict.CGGP()
SG <- CGGPcreate(d=3, batchsize=100) y <- apply(SG$design, 1, function(x){x[1]+x[2]^2}) SG <- CGGPfit(SG, Y=y) SG <- CGGPappend(CGGP=SG, batchsize=20, selectionmethod="MAP")
SG <- CGGPcreate(d=3, batchsize=100) y <- apply(SG$design, 1, function(x){x[1]+x[2]^2}) SG <- CGGPfit(SG, Y=y) SG <- CGGPappend(CGGP=SG, batchsize=20, selectionmethod="MAP")
Create sparse grid GP
CGGPcreate( d, batchsize, corr = "PowerExponential", grid_sizes = c(1, 2, 4, 4, 8, 12, 20, 28, 32), Xs = NULL, Ys = NULL, HandlingSuppData = "Correct", supp_args = list() )
CGGPcreate( d, batchsize, corr = "PowerExponential", grid_sizes = c(1, 2, 4, 4, 8, 12, 20, 28, 32), Xs = NULL, Ys = NULL, HandlingSuppData = "Correct", supp_args = list() )
d |
Input dimension |
batchsize |
Number added to design each batch for now only on predictions |
corr |
Name of correlation function to use. Must be one of "CauchySQT", "CauchySQ", "Cauchy", "Gaussian", "PowerExp", "Matern32", "Matern52". |
grid_sizes |
Size of grid refinements. |
Xs |
Supplemental X data |
Ys |
Supplemental Y data |
HandlingSuppData |
How should supplementary data be handled? * Correct: full likelihood with grid and supplemental data * Only: only use supplemental data * Ignore: ignore supplemental data |
supp_args |
Arguments used to fit if Xs and Ys are given |
CGGP
Other CGGP core functions:
CGGPappend()
,
CGGPfit()
,
predict.CGGP()
CGGPcreate(d=8,200)
CGGPcreate(d=8,200)
This function will update the GP parameters for a CGGP design.
CGGPfit( CGGP, Y, Xs = NULL, Ys = NULL, theta0 = pmax(pmin(CGGP$thetaMAP, 0.8), -0.8), HandlingSuppData = CGGP$HandlingSuppData, separateoutputparameterdimensions = is.matrix(CGGP$thetaMAP), set_thetaMAP_to, corr, Ynew )
CGGPfit( CGGP, Y, Xs = NULL, Ys = NULL, theta0 = pmax(pmin(CGGP$thetaMAP, 0.8), -0.8), HandlingSuppData = CGGP$HandlingSuppData, separateoutputparameterdimensions = is.matrix(CGGP$thetaMAP), set_thetaMAP_to, corr, Ynew )
CGGP |
Sparse grid objects |
Y |
Output values calculated at CGGP$design |
Xs |
Supplemental X matrix |
Ys |
Supplemental Y values |
theta0 |
Initial theta |
HandlingSuppData |
How should supplementary data be handled? * Correct: full likelihood with grid and supplemental data * Only: only use supplemental data * Ignore: ignore supplemental data |
separateoutputparameterdimensions |
If multiple output dimensions, should separate parameters be fit to each dimension? |
set_thetaMAP_to |
Value for thetaMAP to be set to |
corr |
Will update correlation function, if left missing it will be same as last time. |
Ynew |
Values of 'CGGP$design_unevaluated' |
Updated CGGP object fit to data given
Other CGGP core functions:
CGGPappend()
,
CGGPcreate()
,
predict.CGGP()
cg <- CGGPcreate(d=3, batchsize=100) y <- apply(cg$design, 1, function(x){x[1]+x[2]^2}) cg <- CGGPfit(CGGP=cg, Y=y)
cg <- CGGPcreate(d=3, batchsize=100) y <- apply(cg$design, 1, function(x){x[1]+x[2]^2}) cg <- CGGPfit(CGGP=cg, Y=y)
Plot the 2D projections of the blocks of an CGGP object.
CGGPplotblocks(CGGP, singleplot = TRUE)
CGGPplotblocks(CGGP, singleplot = TRUE)
CGGP |
CGGP object |
singleplot |
If only two dimensions, should a single plot be made? |
ggplot2 plot
Other CGGP plot functions:
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPplotvariogram()
,
CGGPvalplot()
# The first and fourth dimensions are most active and will have greater depth ss <- CGGPcreate(d=5, batchsize=50) f <- function(x) {cos(2*pi*x[1]*3) + x[3]*exp(4*x[4])} ss <- CGGPfit(ss, Y=apply(ss$design, 1, f)) ss <- CGGPappend(CGGP=ss, batchsize=100) CGGPplotblocks(ss) mat <- matrix(c(1,1,1,2,2,1,2,2,1,3), ncol=2, byrow=TRUE) CGGPplotblocks(mat)
# The first and fourth dimensions are most active and will have greater depth ss <- CGGPcreate(d=5, batchsize=50) f <- function(x) {cos(2*pi*x[1]*3) + x[3]*exp(4*x[4])} ss <- CGGPfit(ss, Y=apply(ss$design, 1, f)) ss <- CGGPappend(CGGP=ss, batchsize=100) CGGPplotblocks(ss) mat <- matrix(c(1,1,1,2,2,1,2,2,1,3), ncol=2, byrow=TRUE) CGGPplotblocks(mat)
Shows the order in which blocks were selected for each dimension. Gives an idea of how the selections change over time.
CGGPplotblockselection(CGGP, indims)
CGGPplotblockselection(CGGP, indims)
CGGP |
CGGP object |
indims |
Which input dimensions should be shown? |
ggplot2 object
gs <- CGGPcreate(d=3, batchsize=100) # All dimensions will look similar CGGPplotblockselection(gs) # You need to append with CGGPappend after fitting to see a difference f <- function(x){x[1]^1.2} y <- apply(gs$design, 1, f) gs <- CGGPfit(gs, Y=y) gs <- CGGPappend(gs, 100) # Now you will see higher for X1 from 100 to 200 while others remain low. CGGPplotblockselection(gs)
gs <- CGGPcreate(d=3, batchsize=100) # All dimensions will look similar CGGPplotblockselection(gs) # You need to append with CGGPappend after fitting to see a difference f <- function(x){x[1]^1.2} y <- apply(gs$design, 1, f) gs <- CGGPfit(gs, Y=y) gs <- CGGPappend(gs, 100) # Now you will see higher for X1 from 100 to 200 while others remain low. CGGPplotblockselection(gs)
Plot samples for a given correlation function and parameters. Useful for getting an idea of what the correlation parameters mean in terms of smoothness.
CGGPplotcorr( Corr = CGGP_internal_CorrMatGaussian, theta = NULL, numlines = 20, outdims = NULL, zero = TRUE )
CGGPplotcorr( Corr = CGGP_internal_CorrMatGaussian, theta = NULL, numlines = 20, outdims = NULL, zero = TRUE )
Corr |
Correlation function or CGGP object. If CGGP object, it will make plots for thetaMAP, the max a posteriori theta. |
theta |
Parameters for Corr |
numlines |
Number of sample paths to draw |
outdims |
Which output dimensions should be used? |
zero |
Should the sample paths start at y=0? |
Plot
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPplotvariogram()
,
CGGPvalplot()
CGGPplotcorr() CGGPplotcorr(theta=c(-2,-1,0,1)) SG <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+sin(2*pi*x[2]*3)} y <- apply(SG$design, 1, f) SG <- CGGPfit(SG, Y=y) CGGPplotcorr(SG)
CGGPplotcorr() CGGPplotcorr(theta=c(-2,-1,0,1)) SG <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+sin(2*pi*x[2]*3)} y <- apply(SG$design, 1, f) SG <- CGGPfit(SG, Y=y) CGGPplotcorr(SG)
The values on the diagonal are largest design depth for that dimension. The off-diagonal values are the largest design depth that both dimensions have been measured at simultaneously. A greater depth means that more points have been measured along that dimension or two-dimensional subspace.
CGGPplotheat(CGGP)
CGGPplotheat(CGGP)
CGGP |
CGGP object |
A heat map made from ggplot2
https://stackoverflow.com/questions/14290364/heatmap-with-values-ggplot2
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPplotvariogram()
,
CGGPvalplot()
# All dimensions should look similar d <- 8 SG = CGGPcreate(d,201) CGGPplotheat(SG) # The first and fourth dimensions are most active and will have greater depth SG <- CGGPcreate(d=5, batchsize=50) f <- function(x) {cos(2*pi*x[1]*3) + exp(4*x[4])} for (i in 1:1) { SG <- CGGPfit(SG, Y=apply(SG$design, 1, f)) SG <- CGGPappend(CGGP=SG, batchsize=200) } # SG <- CGGPfit(SG, Y=apply(SG$design, 1, f)) CGGPplotheat(SG)
# All dimensions should look similar d <- 8 SG = CGGPcreate(d,201) CGGPplotheat(SG) # The first and fourth dimensions are most active and will have greater depth SG <- CGGPcreate(d=5, batchsize=50) f <- function(x) {cos(2*pi*x[1]*3) + exp(4*x[4])} for (i in 1:1) { SG <- CGGPfit(SG, Y=apply(SG$design, 1, f)) SG <- CGGPappend(CGGP=SG, batchsize=200) } # SG <- CGGPfit(SG, Y=apply(SG$design, 1, f)) CGGPplotheat(SG)
A greater design depth signifies a more important dimension. Thus a larger right tail on the histogram are more important variables.
CGGPplothist(CGGP, ylog = TRUE)
CGGPplothist(CGGP, ylog = TRUE)
CGGP |
CGGP object |
ylog |
Should the y axis be put on a log scale? |
Histogram plot made using ggplot2
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPplotvariogram()
,
CGGPvalplot()
# All dimensions should look similar d <- 8 SG = CGGPcreate(d,201) CGGPplothist(SG) CGGPplothist(SG, ylog=FALSE) # The first dimension is more active and will have greater depth f <- function(x) {sin(x[1]^.6*5)} SG <- CGGPcreate(d=5, batchsize=100) SG <- CGGPfit(SG, apply(SG$design, 1, f)) SG <- CGGPappend(CGGP=SG, batchsize=1000) CGGPplothist(SG)
# All dimensions should look similar d <- 8 SG = CGGPcreate(d,201) CGGPplothist(SG) CGGPplothist(SG, ylog=FALSE) # The first dimension is more active and will have greater depth f <- function(x) {sin(x[1]^.6*5)} SG <- CGGPcreate(d=5, batchsize=100) SG <- CGGPfit(SG, apply(SG$design, 1, f)) SG <- CGGPappend(CGGP=SG, batchsize=1000) CGGPplothist(SG)
Plot negative log posterior likelihood of samples
CGGPplotsamplesneglogpost(CGGP)
CGGPplotsamplesneglogpost(CGGP)
CGGP |
CGGP object |
ggplot2 object
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPplotvariogram()
,
CGGPvalplot()
gs <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+x[3]^.4*sin(2*pi*x[2]^2*3) + .1*exp(3*x[3])} y <- apply(gs$design, 1, f) gs <- CGGPfit(gs, Y=y) CGGPplotsamplesneglogpost(gs)
gs <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+x[3]^.4*sin(2*pi*x[2]^2*3) + .1*exp(3*x[3])} y <- apply(gs$design, 1, f) gs <- CGGPfit(gs, Y=y) CGGPplotsamplesneglogpost(gs)
Show prediction plots when varying over only one dimension. Most useful when setting all values to 0.5 because it will have the most points.
CGGPplotslice( CGGP, proj = 0.5, np = 300, color = "pink", outdims, scales = "free_y", facet = "grid" )
CGGPplotslice( CGGP, proj = 0.5, np = 300, color = "pink", outdims, scales = "free_y", facet = "grid" )
CGGP |
CGGP object |
proj |
Point to project onto |
np |
Number of points to use along each dimension |
color |
Color to make error region |
outdims |
If multiple outputs, which of them should be plotted? |
scales |
Parameter passed to ggplot2::facet_grid() |
facet |
If "grid", will use ggplot2::facet_grid(), if "wrap" will use ggplot2::facet_wrap(). Only applicable for a single output dimension. |
ggplot2 object
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplottheta()
,
CGGPplotvariogram()
,
CGGPvalplot()
d <- 5 f1 <- function(x){x[1]+x[2]^2 + cos(x[3]^2*2*pi*4) - 3.3} s1 <- CGGPcreate(d, 200) s1 <- CGGPfit(s1, apply(s1$design, 1, f1)) #s1 <- CGGPappend(s1, 200) #s1 <- CGGPfit(s1, apply(s1$design, 1, f1)) CGGPplotslice(s1) CGGPplotslice(s1, 0.) CGGPplotslice(s1, s1$design[nrow(s1$design),])
d <- 5 f1 <- function(x){x[1]+x[2]^2 + cos(x[3]^2*2*pi*4) - 3.3} s1 <- CGGPcreate(d, 200) s1 <- CGGPfit(s1, apply(s1$design, 1, f1)) #s1 <- CGGPappend(s1, 200) #s1 <- CGGPfit(s1, apply(s1$design, 1, f1)) CGGPplotslice(s1) CGGPplotslice(s1, 0.) CGGPplotslice(s1, s1$design[nrow(s1$design),])
Plot theta samples
CGGPplottheta(CGGP)
CGGPplottheta(CGGP)
CGGP |
CGGP object |
ggplot2 object
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplotvariogram()
,
CGGPvalplot()
gs <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+x[3]^.4*sin(2*pi*x[2]^2*3) + .1*exp(3*x[3])} y <- apply(gs$design, 1, f) gs <- CGGPfit(gs, Y=y) CGGPplottheta(gs)
gs <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+x[3]^.4*sin(2*pi*x[2]^2*3) + .1*exp(3*x[3])} y <- apply(gs$design, 1, f) gs <- CGGPfit(gs, Y=y) CGGPplottheta(gs)
It's not actually a variogram or semivariogram. It shows how the correlation function falls off as distance increases.
CGGPplotvariogram(CGGP, facet = 1, outdims = NULL)
CGGPplotvariogram(CGGP, facet = 1, outdims = NULL)
CGGP |
CGGP object |
facet |
How should the plots be faceted? If 1, in a row, if 2, in a column, if 3, wrapped around. |
outdims |
Which output dimensions should be shown. |
ggplot2 object
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPvalplot()
SG <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+x[3]^.4*sin(2*pi*x[2]^2*3) + .1*exp(3*x[3])} y <- apply(SG$design, 1, f) SG <- CGGPfit(SG, Y=y) CGGPplotvariogram(SG)
SG <- CGGPcreate(d=3, batchsize=100) f <- function(x){x[1]^1.2+x[3]^.4*sin(2*pi*x[2]^2*3) + .1*exp(3*x[3])} y <- apply(SG$design, 1, f) SG <- CGGPfit(SG, Y=y) CGGPplotvariogram(SG)
Plot validation prediction errors for CGGP object
CGGPvalplot(CGGP, Xval, Yval, d = NULL)
CGGPvalplot(CGGP, Xval, Yval, d = NULL)
CGGP |
CGGP object that has been fitted |
Xval |
X validation data |
Yval |
Y validation data |
d |
If output is multivariate, which column to use. Will do all if left as NULL. |
None, makes a plot
Other CGGP plot functions:
CGGPplotblocks()
,
CGGPplotcorr()
,
CGGPplotheat()
,
CGGPplothist()
,
CGGPplotsamplesneglogpost()
,
CGGPplotslice()
,
CGGPplottheta()
,
CGGPplotvariogram()
SG <- CGGPcreate(d=3, batchsize=100) f1 <- function(x){x[1]+x[2]^2} y <- apply(SG$design, 1, f1) SG <- CGGPfit(SG, y) Xval <- matrix(runif(3*100), ncol=3) Yval <- apply(Xval, 1, f1) CGGPvalplot(CGGP=SG, Xval=Xval, Yval=Yval)
SG <- CGGPcreate(d=3, batchsize=100) f1 <- function(x){x[1]+x[2]^2} y <- apply(SG$design, 1, f1) SG <- CGGPfit(SG, y) Xval <- matrix(runif(3*100), ncol=3) Yval <- apply(Xval, 1, f1) CGGPvalplot(CGGP=SG, Xval=Xval, Yval=Yval)
Calculate stats for CGGP prediction on validation data
CGGPvalstats(CGGP, Xval, Yval, bydim = TRUE, ...)
CGGPvalstats(CGGP, Xval, Yval, bydim = TRUE, ...)
CGGP |
CGGP object |
Xval |
X validation matrix |
Yval |
Y validation data |
bydim |
If multiple outputs, should it be done separately by dimension? |
... |
Passed to valstats, such as which stats to calculate. |
data frame
SG <- CGGPcreate(d=3, batchsize=100) f1 <- function(x){x[1]+x[2]^2} y <- apply(SG$design, 1, f1) SG <- CGGPfit(SG, y) Xval <- matrix(runif(3*100), ncol=3) Yval <- apply(Xval, 1, f1) CGGPvalstats(CGGP=SG, Xval=Xval, Yval=Yval) # Multiple outputs SG <- CGGPcreate(d=3, batchsize=100) f1 <- function(x){x[1]+x[2]^2} f2 <- function(x){x[1]^1.3+.4*sin(6*x[2])+10} y1 <- apply(SG$design, 1, f1)#+rnorm(1,0,.01) y2 <- apply(SG$design, 1, f2)#+rnorm(1,0,.01) y <- cbind(y1, y2) SG <- CGGPfit(SG, Y=y) Xval <- matrix(runif(3*100), ncol=3) Yval <- cbind(apply(Xval, 1, f1), apply(Xval, 1, f2)) CGGPvalstats(SG, Xval, Yval) CGGPvalstats(SG, Xval, Yval, bydim=FALSE)
SG <- CGGPcreate(d=3, batchsize=100) f1 <- function(x){x[1]+x[2]^2} y <- apply(SG$design, 1, f1) SG <- CGGPfit(SG, y) Xval <- matrix(runif(3*100), ncol=3) Yval <- apply(Xval, 1, f1) CGGPvalstats(CGGP=SG, Xval=Xval, Yval=Yval) # Multiple outputs SG <- CGGPcreate(d=3, batchsize=100) f1 <- function(x){x[1]+x[2]^2} f2 <- function(x){x[1]^1.3+.4*sin(6*x[2])+10} y1 <- apply(SG$design, 1, f1)#+rnorm(1,0,.01) y2 <- apply(SG$design, 1, f2)#+rnorm(1,0,.01) y <- cbind(y1, y2) SG <- CGGPfit(SG, Y=y) Xval <- matrix(runif(3*100), ncol=3) Yval <- cbind(apply(Xval, 1, f1), apply(Xval, 1, f2)) CGGPvalstats(SG, Xval, Yval) CGGPvalstats(SG, Xval, Yval, bydim=FALSE)
There are a few different plot functions for CGGP objects: 'CGGPplotblocks', 'CGGPplotblockselection', 'CGGPplotcorr', 'CGGPplotheat', 'CGGPplothist', 'CGGPvalplot', 'CGGPplotslice', 'CGGPplotslice', and 'CGGPplotvariogram'. Currently 'CGGPplotblocks' is the default plot object.
## S3 method for class 'CGGP' plot(x, y, ...)
## S3 method for class 'CGGP' plot(x, y, ...)
x |
CGGP object |
y |
Don't use |
... |
Passed to CGGPplotblocks |
Either makes plot or returns plot object
SG = CGGPcreate(3,100) plot(SG)
SG = CGGPcreate(3,100) plot(SG)
Passes to CGGPpred
Predict using SG with y values at xp? Shouldn't y values already be stored in SG?
## S3 method for class 'CGGP' predict(object, xp, ...) CGGPpred(CGGP, xp, theta = NULL, outdims = NULL)
## S3 method for class 'CGGP' predict(object, xp, ...) CGGPpred(CGGP, xp, theta = NULL, outdims = NULL)
object |
CGGP object |
xp |
x value to predict at |
... |
Other arguments passed to 'CGGPpred' |
CGGP |
SG object |
theta |
Leave as NULL unless you want to use a value other than thetaMAP. Much slower. |
outdims |
If multiple outputs fit without PCA and with separate parameters, you can predict just for certain dimensions to speed it up. Will leave other columns in the output, but they will be wrong. |
Predicted mean values
Other CGGP core functions:
CGGPappend()
,
CGGPcreate()
,
CGGPfit()
SG <- CGGPcreate(d=3, batchsize=100) y <- apply(SG$design, 1, function(x){x[1]+x[2]^2+rnorm(1,0,.01)}) SG <- CGGPfit(SG, Y=y) CGGPpred(SG, matrix(c(.1,.1,.1),1,3)) cbind(CGGPpred(SG, SG$design)$mean, y) # Should be near equal
SG <- CGGPcreate(d=3, batchsize=100) y <- apply(SG$design, 1, function(x){x[1]+x[2]^2+rnorm(1,0,.01)}) SG <- CGGPfit(SG, Y=y) CGGPpred(SG, matrix(c(.1,.1,.1),1,3)) cbind(CGGPpred(SG, SG$design)$mean, y) # Should be near equal
Default print as a list is bad since there's a lot of elements.
## S3 method for class 'CGGP' print(x, ...)
## S3 method for class 'CGGP' print(x, ...)
x |
CGGP object |
... |
Passed to print |
String to be printed
SG = CGGPcreate(3,21) print(SG) f <- function(x) {x[1]+exp(x[2]) + log(x[3]+4)} y <- apply(SG$design, 1, f) SG <- CGGPfit(SG, y) print(SG)
SG = CGGPcreate(3,21) print(SG) f <- function(x) {x[1]+exp(x[2]) + log(x[3]+4)} y <- apply(SG$design, 1, f) SG <- CGGPfit(SG, y) print(SG)
rcpp_fastmatclcr
rcpp_fastmatclcr(I, w, MSEmat, S, maxlevel)
rcpp_fastmatclcr(I, w, MSEmat, S, maxlevel)
I |
Matrix |
w |
vector |
MSEmat |
Matrix |
S |
Vector |
maxlevel |
Integer |
Nothing, void
rcpp_fastmatclcranddclcr
rcpp_fastmatclcranddclcr(I, w, MSEmat, dMSEmat, S, dS, maxlevel, numpara)
rcpp_fastmatclcranddclcr(I, w, MSEmat, dMSEmat, S, dS, maxlevel, numpara)
I |
Matrix |
w |
vector |
MSEmat |
Matrix |
dMSEmat |
Matrix |
S |
Vector |
dS |
Matrix |
maxlevel |
Integer |
numpara |
Integer |
Nothing, void
rcpp_kronDBS
rcpp_gkronDBS(A, dA, B, p)
rcpp_gkronDBS(A, dA, B, p)
A |
Vector |
dA |
Vector |
B |
Vector |
p |
Vector |
kronDBS calculation
rcpp_gkronDBS(c(1,1), c(0,0), c(.75), c(1,1))
rcpp_gkronDBS(c(1,1), c(0,0), c(.75), c(1,1))
rcpp_kronDBS
rcpp_kronDBS(A, B, p)
rcpp_kronDBS(A, B, p)
A |
Vector |
B |
Vector |
p |
Vector |
kronDBS calculation
Plot validation prediction errors
valplot(predmean, predvar, Yval, d = NULL)
valplot(predmean, predvar, Yval, d = NULL)
predmean |
Predicted mean |
predvar |
Predicted variance |
Yval |
Y validation data |
d |
If output is multivariate, which column to use. Will do all if left as NULL. |
None, makes a plot
x <- matrix(runif(100*3), ncol=3) f1 <- function(x){x[1]+x[2]^2} y <- apply(x, 1, f1) # Create a linear model on the data mod <- lm(y ~ ., data.frame(x)) # Predict at validation data Xval <- matrix(runif(3*100), ncol=3) mod.pred <- predict.lm(mod, data.frame(Xval), se.fit=TRUE) # Compare to true results Yval <- apply(Xval, 1, f1) valplot(mod.pred$fit, mod.pred$se.fit^2, Yval=Yval)
x <- matrix(runif(100*3), ncol=3) f1 <- function(x){x[1]+x[2]^2} y <- apply(x, 1, f1) # Create a linear model on the data mod <- lm(y ~ ., data.frame(x)) # Predict at validation data Xval <- matrix(runif(3*100), ncol=3) mod.pred <- predict.lm(mod, data.frame(Xval), se.fit=TRUE) # Compare to true results Yval <- apply(Xval, 1, f1) valplot(mod.pred$fit, mod.pred$se.fit^2, Yval=Yval)
Calculate stats for prediction on validation data
valstats( predmean, predvar, Yval, bydim = TRUE, RMSE = TRUE, score = TRUE, CRPscore = TRUE, coverage = TRUE, corr = TRUE, R2 = TRUE, MAE = FALSE, MIS90 = FALSE, metrics, min_var = .Machine$double.eps )
valstats( predmean, predvar, Yval, bydim = TRUE, RMSE = TRUE, score = TRUE, CRPscore = TRUE, coverage = TRUE, corr = TRUE, R2 = TRUE, MAE = FALSE, MIS90 = FALSE, metrics, min_var = .Machine$double.eps )
predmean |
Predicted mean |
predvar |
Predicted variance |
Yval |
Y validation data |
bydim |
If multiple outputs, should it be done separately by dimension? |
RMSE |
Should root mean squared error (RMSE) be included? |
score |
Should score be included? |
CRPscore |
Should CRP score be included? |
coverage |
Should coverage be included? |
corr |
Should correlation between predicted and true mean be included? |
R2 |
Should R^2 be included? |
MAE |
Should mean absolute error (MAE) be included? |
MIS90 |
Should mean interval score for 90% confidence be included? See Gneiting and Raftery (2007). |
metrics |
Optional additional metrics to be calculated. Should have same first three parameters as this function. |
min_var |
Minimum value of the predicted variance. Negative or zero variances can cause errors. |
data frame
Gneiting, Tilmann, and Adrian E. Raftery. "Strictly proper scoring rules, prediction, and estimation." Journal of the American Statistical Association 102.477 (2007): 359-378.
valstats(c(0,1,2), c(.01,.01,.01), c(0,1.1,1.9)) valstats(cbind(c(0,1,2), c(1,2,3)), cbind(c(.01,.01,.01),c(.1,.1,.1)), cbind(c(0,1.1,1.9),c(1,2,3))) valstats(cbind(c(0,1,2), c(8,12,34)), cbind(c(.01,.01,.01),c(1.1,.81,1.1)), cbind(c(0,1.1,1.9),c(10,20,30)), bydim=FALSE) valstats(cbind(c(.8,1.2,3.4), c(8,12,34)), cbind(c(.01,.01,.01),c(1.1,.81,1.1)), cbind(c(1,2,3),c(10,20,30)), bydim=FALSE)
valstats(c(0,1,2), c(.01,.01,.01), c(0,1.1,1.9)) valstats(cbind(c(0,1,2), c(1,2,3)), cbind(c(.01,.01,.01),c(.1,.1,.1)), cbind(c(0,1.1,1.9),c(1,2,3))) valstats(cbind(c(0,1,2), c(8,12,34)), cbind(c(.01,.01,.01),c(1.1,.81,1.1)), cbind(c(0,1.1,1.9),c(10,20,30)), bydim=FALSE) valstats(cbind(c(.8,1.2,3.4), c(8,12,34)), cbind(c(.01,.01,.01),c(1.1,.81,1.1)), cbind(c(1,2,3),c(10,20,30)), bydim=FALSE)