shapes | R Documentation |
A symbolic routine to indicate that a predictor is included as a non-parametrically modelled predictor in a formula argument to ShapeSelect.
shapes(x, set = "s.9")
x |
A numeric predictor which has the same length as the response vector. |
set |
A character or a numeric vector indicating all possible shapes defined for x. For example, we are not only interested in modeling the relationship between the growth of an organism (dependent variable To be more specific, the user can choose to specify this argument as following
|
The default is set = "s.9".
The vector x with three attributes, i.e., nm: the name of x; shape: a numeric vector ranging from 0 to 16 to indicate possible shapes imposed on the relationship between the response and x; type: "nparam", i.e., x is non-parametrically modelled.
Xiyue Liao
in.or.out
, ShapeSelect
## Not run:
# Example 1.
n <- 100
# generate predictors, x is non-parametrically modelled
# and z is parametrically modelled
x <- runif(n)
z <- rep(0:1, 50)
# E(y) is generated as correlated to both x and z
# the relationship between E(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
fit <- ShapeSelect(y ~ shapes(x) + in.or.out(factor(z)), genetic = TRUE)
# Example 2.
n <- 100
z <- rep(c("A","B"), n / 2)
x <- runif(n)
# y0 is generated as correlated to z with a tree-ordering in it
# y0 is smoothly increasing-convex in x
y0 <- x^2 + I(z == "B") * 1.5
y <- y0 + rnorm(n, 1)
fit <- ShapeSelect(y ~ s.incr(x) + shapes(z, set = "tree"), genetic = FALSE)
# check the best fit in terms of z
fit$top
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.