nlme: Interfaces for nlme package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

1
2
3
4
5

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
## Not run: 
library(intubate)
library(magrittr)
library(nlme)

## gls
## Original function to interface
fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
           correlation = corAR1(form = ~ 1 | Mare))
summary(fm1)

## The interface reverses the order of data and formula
fm1 <- ntbt_gls(Ovary, follicles ~ sin(2*pi*Time) + cos(2*pi*Time),
                correlation = corAR1(form = ~ 1 | Mare))
summary(fm1)

## so it can be used easily in a pipeline.
Ovary %>%
  ntbt_gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time),
                correlation = corAR1(form = ~ 1 | Mare))  %>%
  summary()
  
## nlme
## Original function to interface
lme(distance ~ age, data = Orthodont) # random is ~ age
lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)

## The interface reverses the order of data and formula
ntbt_lme(data = Orthodont, distance ~ age) # random is ~ age
ntbt_lme(data = Orthodont, distance ~ age + Sex, random = ~ 1)

## so it can be used easily in a pipeline.
Orthodont %>%
  ntbt_lme(distance ~ age) # random is ~ age
Orthodont %>%
  ntbt_lme(distance ~ age + Sex, random = ~ 1)

## lmList
## Original function to interface
lmList(distance ~ age | Subject, Orthodont)

## The interface reverses the order of data and formula
ntbt_lmList(Orthodont, distance ~ age | Subject)

## so it can be used easily in a pipeline.
Orthodont %>%
  ntbt_lmList(distance ~ age | Subject)
  
Orthodont %>%
  ntbt_lmList(distance ~ age | Subject) %>%
  summary()

## nlme
## Original function to interface
fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),
            data = Loblolly,
            fixed = Asym + R0 + lrc ~ 1,
            random = Asym ~ 1,
            start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
summary(fm1)

## The interface reverses the order of data and formula
fm1 <- ntbt_nlme(data = Loblolly,
                 height ~ SSasymp(age, Asym, R0, lrc),
                 fixed = Asym + R0 + lrc ~ 1,
                 random = Asym ~ 1,
                 start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
summary(fm1)

## so it can be used easily in a pipeline.
Loblolly %>%
  ntbt_nlme(height ~ SSasymp(age, Asym, R0, lrc),
            fixed = Asym + R0 + lrc ~ 1,
            random = Asym ~ 1,
            start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) %>%
  summary()

## End(Not run)

rbertolusso/intubate documentation built on May 27, 2019, 3 a.m.