Description Usage Arguments Value Examples
View source: R/estimateModel.R
Model selection algorithm for constrained estimation
1 2 3 4 |
formula |
formula object: formula object without exponents or
interactions. If |
data |
data.frame: dataset |
mustInclude |
character vector: variables to include in any case; use ":" for interactions and "I(..)" for powers, e.g.: "I(x1^2):I(x2^3)". |
maxExponent |
positive integer: highest exponent included in the formula. Default is 1, e.g., only linear effects. |
interactionDepth |
positive integer: maximum order of interaction. Default is 1, e.g., only main effects (no interactions). |
intercept |
logical: Should the intercept be included in the estimation or not? |
constraint_1 |
logical: Should the all beta variables add up to 1? |
yUncertainty |
numeric vector: optional, uncertainties in y variable given in standard deviations |
xUncertainty |
data.frame: optional, uncertainties in x variables. variable names must match with names in formula |
maxNumTerms |
positive integer: maximum number of variables to include |
scale |
logical: should the variables be scaled to mean 0 and sd 1? |
chains |
positive integer: number of chains for MCMC sampling |
iterations |
positive integer: number of iterations per chain for MCMC sampling |
A list of potential models
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## 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)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.