Description Usage Arguments Details Value Examples
This function creates simulated datasets to illustrate the use of gam3
.
1 |
n |
numeric value specifying the number of observations. |
p |
numeric value specifying the number of covariates. |
test.n |
numeric value specifying the number of observations in the test set. |
sigma |
numeric value specifying the standard deviation of the errors. |
probs |
numeric vector of length 6 specifying the proportion of covariates that are polynomial, linear, exponential, logarithmic, sinusoidal, and zero functions. |
This function creates simulated datasets to illustrate the use of gam3
.
The covariates are sampled uniformly over $[0, 1]$, and their associated functions are randomly
chosen from polynomial, linear, exponential, logarithmic, sinusoidal, and zero using weights provided
in the probs
argument.
A named list containing data
, functions
, line
, and test
.
|
An |
|
A list of length |
|
A character vector of length |
|
An |
1 2 3 4 5 6 7 8 9 | set.seed(2018)
probs <- c(0.1, 0.1, 0.1, 0.1, 0.1, 0.5)
simulated_data <- gamSim2(n = 100, p = 1, test.n = 20, sigma = 0.1, probs = probs)
# -1*2*x*sin(2.70259540737607*pi * x^2 - 1.3270146084221)
sin.fun <- function(x) eval(parse(text = simulated_data$functions[[1]]))
truth <- sin.fun(seq(0, 1, length.out = 100))
truth <- truth/diff(range(truth))
plot(simulated_data$data[, 2], simulated_data$data[, 1])
lines(seq(0, 1, length.out = 100), truth, col = "red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.