in.or.out | R Documentation |
A symbolic routine to indicate that a predictor is included as a non-parametrically modeled predictor in a formula argument to ShapeSelect.
in.or.out(z)
z |
A non-parametrically modelled predictor which has the same length as the response vector. |
To include a categorical predictor, in.or.out(factor(z)) is used, and to include a linear predictor z, in.or.out(z) is used. If in.or.out is not used, the user can include z in a model by adding z or factor(z) in a ShapeSelect formula.
The vector z with three attributes, i.e., nm: the name of z; shape: 1 or 0 (in or out of the model); type: "fac" or "lin", i.e., z is modelled as a categorical predictor or a linear predictor.
Xiyue Liao
shapes
, ShapeSelect
## Not run:
n <- 100
# x is a continuous predictor
x <- runif(n)
# generate z and to include it as a categorical predictor
z <- rep(0:1, 50)
# y is generated as correlated to both x and z
# the relationship between y and x is smoothly increasing-convex
y <- x^2 + 2 * I(z == 1) + rnorm(n, sd = 1)
# call ShapeSelect to find the best model by the genetic algorithm
# factor(z) may be in or out of the model
fit <- ShapeSelect(y ~ shapes(x) + in.or.out(factor(z)), genetic = TRUE)
# factor(z) isn't chosen and is included in the model
fit <- ShapeSelect(y ~ shapes(x) + factor(z), genetic = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.