mgcv: Interfaces for mgcv package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to mgcv functions that can be used in a pipeline implemented by magrittr.

Usage

1
2

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Not run: 
library(intubate)
library(magrittr)
library(mgcv)

## ntbt_bam: Generalized additive models for very large datasets
set.seed(3)
dat <- gamSim(1,n=25000,dist="normal",scale=20)
bs <- "cr"
k <- 12

## Original function to interface
bam(y ~ s(x0, bs=bs) + s(x1, bs=bs) + s(x2, bs=bs, k=k) + s(x3, bs=bs), data = dat)

## The interface puts data as first parameter
ntbt_bam(dat, y ~ s(x0, bs=bs) + s(x1, bs=bs) + s(x2, bs=bs, k=k) + s(x3, bs=bs))

## so it can be used easily in a pipeline.
dat %>%
  ntbt_bam(y ~ s(x0, bs=bs) + s(x1, bs=bs) + s(x2, bs=bs, k=k) + s(x3, bs=bs))


## ntbt_gam: Generalized additive models with integrated smoothness estimation
set.seed(2) ## simulate some data... 
dat <- gamSim(1, n = 400, dist = "normal", scale = 2)
## Original function to interface
gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)

## The interface puts data as first parameter
ntbt_gam(dat, y ~ s(x0) + s(x1) + s(x2) + s(x3))

## so it can be used easily in a pipeline.
dat %>%
  ntbt_gam(y ~ s(x0) + s(x1) + s(x2) + s(x3))


## ntbt_gamm: Generalized Additive Mixed Models
set.seed(0)
dat <- gamSim(1, n = 200, scale = 2)

## Original function to interface
gamm(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)

## The interface puts data as first parameter
ntbt_gamm(dat, y ~ s(x0) + s(x1) + s(x2) + s(x3))

## so it can be used easily in a pipeline.
dat %>%
  ntbt_gamm(y ~ s(x0) + s(x1) + s(x2) + s(x3))

## End(Not run)

intubate documentation built on May 2, 2019, 2:46 p.m.