vignettes/piecewise.R

## ---- setup, echo = FALSE------------------------------------------------
suppressPackageStartupMessages(require(dplyr))

## ---- eval = FALSE-------------------------------------------------------
#  require(dplyr)

## ------------------------------------------------------------------------
# Models generation
# First model generation
mod_01 <- data.frame(x_1 = rep(1:6,each = 6), x_2 = rep(1:6, times = 6)) %>%
  mutate(y = x_1 + 2*x_2) %>%
  glm(formula = "y ~ x_1 + x_2", data = .)

# Second model generation
mod_02 <- data.frame(x_1 = rep(6:10,each = 5), x_2 = rep(6:10, times = 5)) %>%
  mutate(y = 20 - x_1 + x_2) %>%
  glm(formula = "y ~ x_1 + x_2", data = .)

# Third model generation
mod_03 <- data.frame(x_1 = 0, x_2 = 0, y = 0) %>% glm(formula = "y ~ x_1 + x_2", data = .)

## ------------------------------------------------------------------------
# Conditions generation
# First condition
cond_01 <- "x >= 0 & x < 6"
# Second condition
cond_02 <- "x >= 6 & x <= 10"
# Third condition
cond_03 <- "x < 0 & x > 10"


## ---- echo = FALSE-------------------------------------------------------
suppressPackageStartupMessages(require(piecewise))
p <- piecewise(models = list(mod_01, mod_02, mod_03), condition = c(cond_01, cond_02, cond_03))

## ---- eval = FALSE-------------------------------------------------------
#  require(piecewise)
#  p <- piecewise(models = list(mod_01, mod_02, mod_03), condition = c(cond_01, cond_02, cond_03))
alvarofranq/piecewise documentation built on May 27, 2019, 7:43 a.m.