View source: R/PredictAndSimulate.R
predictSLGP_cdf | R Documentation |
Computes the posterior cumulative distribution function (CDF) values at specified covariate values using a fitted SLGP model.
predictSLGP_cdf(
SLGPmodel,
newNodes,
interpolateBasisFun = "WNN",
nIntegral = 101,
nDiscret = 101
)
SLGPmodel |
An object of class |
newNodes |
A data frame with covariate values where the SLGP should be evaluated. |
interpolateBasisFun |
Character string indicating the interpolation scheme for basis functions:
one of |
nIntegral |
Number of integration points along the response axis. |
nDiscret |
Discretization resolution for interpolation (optional). |
A data frame with newNodes
and predicted CDF values, columns named cdf_1
, cdf_2
, ...
# Load Boston housing dataset
library(MASS)
data("Boston")
# Set input and output ranges manually (you can also use range(Boston$age), etc.)
range_x <- c(0, 100)
range_response <- c(0, 50)
#' #Create a SLGP model but don't fit it
modelPrior <- slgp(medv ~ age, # Use a formula to specify response and covariates
data = Boston, # Use the original Boston housing data
method = "none", # No training
basisFunctionsUsed = "RFF", # Random Fourier Features
sigmaEstimationMethod = "heuristic", # Auto-tune sigma2 (more stable)
predictorsLower = range_x[1], # Lower bound for 'age'
predictorsUpper = range_x[2], # Upper bound for 'age'
responseRange = range_response, # Range for 'medv'
opts_BasisFun = list(nFreq = 200, # Use 200 Fourier features
MatParam = 5/2), # Matern 5/2 kernel
seed = 1) # Reproducibility
#Let us make 3 draws from the prior
nrep <- 3
set.seed(8)
p <- ncol(modelPrior@coefficients)
modelPrior@coefficients <- matrix(rnorm(n=nrep*p), nrow=nrep)
# Where to predict the field of pdfs ?
dfGrid <- data.frame(expand.grid(seq(range_x[1], range_x[2], 5),
seq(range_response[1], range_response[2],, 101)))
colnames(dfGrid) <- c("age", "medv")
predPriorcdf <- predictSLGP_cdf(SLGPmodel=modelPrior,
newNodes = dfGrid)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.