###################################################
# Generate a data sample for the response variable
# Y and the single covariate X
set.seed(123)
N <- 500
f_1 <- function(x) (10*x/(1+100*x^2))*4+4
X <- sort(runif(N, min = -2, max = 2))
# Specify a model for the mean of Y to include only a component
# non-linear in X, defined by the function f_1
means <- f_1(X)
# Add (Normal) noise to the mean of Y
Y <- rnorm(N, means, sd = 0.1)
data = data.frame(X = X, Y = Y)
if (FALSE) {
## NGeDS
# Define different combinations of parameters to cross-validate
param = list(beta_grid = c(0.5),
phi_grid = c(0.9, 0.95),
q_grid = c(2))
cv_NGeDS <- crossv_GeDS(Y ~ f(X), data = data, NGeDS, n = 3L,
parameters = param)
print(cv_NGeDS$best_params)
View(cv_NGeDS$results)
## NGeDSboost
param = list(int.knots_init_grid = c(1, 2),
shrinkage_grid = 1,
beta_grid = c(0.3, 0.5),
phi_grid = c(0.95, 0.99),
q_grid = 2)
cv_NGeDSboost <- crossv_GeDS(Y ~ f(X), data = data, NGeDSboost, n = 2L,
n_folds = 2L, parameters = param)
print(cv_NGeDSboost$best_params)
View(cv_NGeDSboost$results)
}
Run the code above in your browser using DataLab