Description Usage Arguments Value See Also Examples
View source: R/interval_groups.R
Splits a continuous variable into equal-width groups. Useful for assessing linearity in regression models.
1 | interval_groups(x, groups = 5, ...)
|
x |
Numeric vector. |
groups |
Numeric value specifying number of groups to create. |
... |
Arguments to pass to |
Factor variable.
1 2 3 4 5 6 7 8 9 10 | # Convert values from N(0, 1) into 6 equal-width groups
x <- rnorm(1000)
groups <- interval_groups(x, 6)
table(groups)
# Use interval_groups to detect non-linearity
set.seed(123)
x <- rnorm(1000)
y <- 1.5 + 1.25 * x + 0.25 * x^2 + rnorm(1000)
plot(tapply(y, interval_groups(x), mean))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.