# NOT RUN {
suppressWarnings(RNGversion("3.5.0"))
set.seed(44)
n <- 80
x1 <- rnorm(n, sd = 1)
x2 <- rnorm(n, sd = 1)
x3 <- rnorm(n, sd = 1)
y <- 0.4 + 0.3 * x1 + 0.3 * x1 * x3 + 0.4 * x1 ^ 2 * x2 ^ 3 + rnorm(n, sd = 0.3)
yUncertainty <- rexp(n, 10) * 0.01
#optional (slow)
#xUncertainty <- data.frame(x3 = rep(0.1, n), x1 = rep(0.1, n), x2 = rep(1, n))
data <- data.frame(x1, x2, x3, y, yUncertainty)
models <- constrSelEst(y ~ x1 + x2 + x3, mustInclude = "x1", maxExponent = 3,
interactionDepth = 3, intercept = TRUE,
constraint_1 = TRUE, data = data,
yUncertainty = yUncertainty,
xUncertainty = NULL,
maxNumTerms = 10)
plotModelFit(models)
bestModel <- getBestModel(models, thresholdSE = 2)
print(bestModel)
# }
Run the code above in your browser using DataLab