constrSelEst: Model selection algorithm for constrained estimation

Description Usage Arguments Value Examples

View source: R/estimateModel.R

Description

Model selection algorithm for constrained estimation

Usage

1
2
3
4
constrSelEst(formula, data, mustInclude = "", maxExponent = 1,
  interactionDepth = 1, intercept = TRUE, constraint_1 = FALSE,
  yUncertainty = rep(0, nrow(data)), xUncertainty = NULL,
  maxNumTerms = 10, scale = FALSE, chains = 4, iterations = 2000)

Arguments

formula

formula object: formula object without exponents or interactions. If formula is not of class formula, it is turned into one.

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

Value

A list of potential models

Examples

 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)

BMSC documentation built on Aug. 2, 2019, 5:05 p.m.

Related to constrSelEst in BMSC...