lme4: Interfaces for lme4 package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

1
2
3
4
5
6
7
ntbt_glmer(data, ...)
ntbt_glmer.nb(data, ...)
ntbt_glFormula(data, ...)
ntbt_lFormula(data, ...)
ntbt_lmer(data, ...)
# ntbt_lmList(data, ...)   ## Already defined in nlme
ntbt_nlmer(data, ...)

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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
## Not run: 
library(intubate)
library(magrittr)
library(lme4)

## ntbt_glmer: Fitting Generalized Linear Mixed-Effects Models
## Original function to interface
glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
      data = cbpp, family = binomial)

## The interface puts data as first parameter
ntbt_glmer(cbpp, cbind(incidence, size - incidence) ~ period + (1 | herd),
           family = binomial)

## so it can be used easily in a pipeline.
cbpp %>%
  ntbt_glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
             family = binomial)


## ntbt_glmer.nb: Fitting Negative Binomial GLMMs
set.seed(101)
dd <- expand.grid(f1 = factor(1:3),
                  f2 = LETTERS[1:2], g=1:9, rep=1:15,
                  KEEP.OUT.ATTRS=FALSE)
summary(mu <- 5*(-4 + with(dd, as.integer(f1) + 4*as.numeric(f2))))
dd$y <- rnbinom(nrow(dd), mu = mu, size = 0.5)

## Original function to interface
glmer.nb(y ~ f1*f2 + (1|g), data = dd, verbose = FALSE)
 
## The interface puts data as first parameter
ntbt_glmer.nb(dd, y ~ f1*f2 + (1|g), verbose = FALSE)

## so it can be used easily in a pipeline.
dd %>%
  ntbt_glmer.nb(y ~ f1*f2 + (1|g), verbose = FALSE)


## ntbt_lmer: Fit Linear Mixed-Effects Models

## Original function to interface
lmer(Reaction ~ Days + (Days || Subject), sleepstudy)

## The interface puts data as first parameter
ntbt_lmer(sleepstudy, Reaction ~ Days + (Days || Subject))

## so it can be used easily in a pipeline.
sleepstudy %>%
  ntbt_lmer(Reaction ~ Days + (Days || Subject))


## ntbt_lmList: Fit List of lm Objects with a Common Model
## Original function to interface
lmList(Reaction ~ Days | Subject, sleepstudy)

## The interface puts data as first parameter
ntbt_lmList(sleepstudy, Reaction ~ Days | Subject)

## so it can be used easily in a pipeline.
sleepstudy %>%
  ntbt_lmList(Reaction ~ Days | Subject)


## Original function to interface
lFormula(Reaction ~ Days + (Days|Subject), sleepstudy)
glFormula(Reaction ~ Days + (Days|Subject), sleepstudy)

## The interface puts data as first parameter
ntbt_lFormula(sleepstudy, Reaction ~ Days + (Days|Subject))
ntbt_glFormula(sleepstudy, Reaction ~ Days + (Days|Subject))

## so it can be used easily in a pipeline.
sleepstudy %>%
  ntbt_lFormula(Reaction ~ Days + (Days|Subject))
sleepstudy %>%
  ntbt_glFormula(Reaction ~ Days + (Days|Subject))


## ntbt_nlmer: Fitting Nonlinear Mixed-Effects Models
## Original function to interface
nlmer(circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym|Tree,
      Orange, start = c(Asym = 200, xmid = 725, scal = 350))

## The interface puts data as first parameter
ntbt_nlmer(Orange, circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym|Tree,
           start = c(Asym = 200, xmid = 725, scal = 350))

## so it can be used easily in a pipeline.
Orange %>%
  ntbt_nlmer(circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym|Tree,
             start = c(Asym = 200, xmid = 725, scal = 350))

## End(Not run)

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