gss: Interfaces for gss package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13

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
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
## Not run: 
library(intubate)
library(magrittr)
library(gss)


## ntbt_gssanova: Fitting Smoothing Spline ANOVA Models with Non-Gaussian Responses
data(bacteriuria)

## Original function to interface
gssanova(infect ~ trt + time, family="binomial", data = bacteriuria,
         id.basis = (1:820)[bacteriuria$id %in% c(3,38)], random = ~ 1 | id)
gssanova0(infect ~ trt + time, family="binomial", data = bacteriuria)
gssanova1(infect ~ trt + time, family="binomial", data = bacteriuria,
         id.basis = (1:820)[bacteriuria$id %in% c(3,38)], random = ~ 1 | id)

## The interface puts data as first parameter
ntbt_gssanova(bacteriuria, infect ~ trt + time, family="binomial",
              id.basis = (1:820)[bacteriuria$id %in% c(3,38)], random = ~ 1 | id)
ntbt_gssanova0(bacteriuria, infect ~ trt + time, family="binomial")
ntbt_gssanova1(bacteriuria, infect ~ trt + time, family="binomial",
               id.basis = (1:820)[bacteriuria$id %in% c(3,38)], random = ~ 1 | id)

## so it can be used easily in a pipeline.
bacteriuria %>%
  ntbt_gssanova(infect ~ trt + time, family="binomial",
                id.basis = (1:820)[bacteriuria$id %in% c(3,38)], random = ~ 1 | id)
bacteriuria %>%
  ntbt_gssanova0(infect ~ trt + time, family="binomial")
bacteriuria %>%
  ntbt_gssanova1(infect ~ trt + time, family="binomial",
                 id.basis = (1:820)[bacteriuria$id %in% c(3,38)], random = ~ 1 | id)


## ntbt_ssanova: Fitting Smoothing Spline ANOVA Models
data(nox)

## Original function to interface
ssanova(log10(nox) ~ comp*equi, data = nox)
ssanova0(log10(nox) ~ comp*equi, data = nox)

## The interface puts data as first parameter
ntbt_ssanova(nox, log10(nox) ~ comp*equi)
ntbt_ssanova0(nox, log10(nox) ~ comp*equi)

## so it can be used easily in a pipeline.
nox %>%
  ntbt_ssanova(log10(nox) ~ comp*equi)
nox %>%
  ntbt_ssanova0(log10(nox) ~ comp*equi)


## ntbt_ssanova9: Fitting Smoothing Spline ANOVA Models with Correlated Data
x <- runif(100); y <- 5 + 3*sin(2*pi*x) + rnorm(x)
dta <- data.frame(x, y)

## Original function to interface
ssanova9(y ~ x, data = dta, cov = list("arma", c(1, 0)))

## The interface puts data as first parameter
ntbt_ssanova9(dta, y ~ x, cov = list("arma", c(1, 0)))

## so it can be used easily in a pipeline.
dta %>%
  ntbt_ssanova9(y ~ x, cov = list("arma", c(1, 0)))


## ntbt_sscden: Estimating Conditional Probability Density Using Smoothing Splines
data(penny)

## Original function to interface
set.seed(5732)
sscden(~ year*mil, ~ mil, data = penny, ydomain = data.frame(mil=c(49, 61)))
sscden1(~ year*mil, ~ mil, data = penny, ydomain = data.frame(mil=c(49, 61)))

## The interface puts data as first parameter
set.seed(5732)
ntbt_sscden(penny, ~ year*mil, ~ mil, ydomain = data.frame(mil=c(49, 61)))
ntbt_sscden1(penny, ~ year*mil, ~ mil, ydomain = data.frame(mil=c(49, 61)))

## so it can be used easily in a pipeline.
set.seed(5732)
penny %>%
  ntbt_sscden(~ year*mil, ~ mil, ydomain = data.frame(mil=c(49, 61)))
penny %>%
  ntbt_sscden1(~ year*mil, ~ mil, ydomain = data.frame(mil=c(49, 61)))


## ntbt_sscox: Estimating Relative Risk Using Smoothing Splines
data(stan)

## Original function to interface
sscox(Surv(futime, status) ~ age, data = stan)

## The interface puts data as first parameter
ntbt_sscox(stan, Surv(futime, status) ~ age)

## so it can be used easily in a pipeline.
stan %>%
  ntbt_sscox(Surv(futime, status) ~ age)


## ntbt_ssden: Estimating Probability Density Using Smoothing Splines
data(aids)
## rectangular quadrature
quad.pt <- expand.grid(incu=((1:40)-.5)/40*100,infe=((1:40)-.5)/40*100)
quad.pt <- quad.pt[quad.pt$incu<=quad.pt$infe,]
quad.wt <- rep(1,nrow(quad.pt))
quad.wt[quad.pt$incu==quad.pt$infe] <- .5
quad.wt <- quad.wt/sum(quad.wt)*5e3

## Original function to interface
ssden(~ incu + infe, data = aids, subset = age >= 60,
      domain = data.frame(incu = c(0, 100), infe=c(0, 100)),
      quad = list(pt = quad.pt, wt = quad.wt))
ssden1(~ incu + infe, data = aids, subset = age >= 60,
       domain = data.frame(incu = c(0, 100), infe=c(0, 100)),
       quad = list(pt = quad.pt, wt = quad.wt))

## The interface puts data as first parameter
ntbt_ssden(aids, ~ incu + infe, subset = age >= 60,
           domain = data.frame(incu = c(0, 100), infe=c(0, 100)),
           quad = list(pt = quad.pt, wt = quad.wt))
ntbt_ssden1(aids, ~ incu + infe, subset = age >= 60,
            domain = data.frame(incu = c(0, 100), infe=c(0, 100)),
            quad = list(pt = quad.pt, wt = quad.wt))

## so it can be used easily in a pipeline.
aids %>%
  ntbt_ssden(~ incu + infe, subset = age >= 60,
             domain = data.frame(incu = c(0, 100), infe=c(0, 100)),
             quad = list(pt = quad.pt, wt = quad.wt))
aids %>%
  ntbt_ssden1(~ incu + infe, subset = age >= 60,
              domain = data.frame(incu = c(0, 100), infe=c(0, 100)),
              quad = list(pt = quad.pt, wt = quad.wt))


## ntbt_sshzd: Estimating Hazard Function Using Smoothing Splines
data(gastric)

## Original function to interface
sshzd(Surv(futime, status) ~ futime*trt, data = gastric)

## The interface puts data as first parameter
ntbt_sshzd(gastric, Surv(futime, status) ~ futime*trt)

## so it can be used easily in a pipeline.
gastric %>%
  ntbt_sshzd(Surv(futime, status) ~ futime*trt)


## ntbt_ssllrm: Fitting Smoothing Spline Log-Linear Regression Models
test <- function(x)
        {.3*(1e6*(x^11*(1-x)^6)+1e4*(x^3*(1-x)^10))-2}
x <- (0:100)/100
p <- 1-1/(1+exp(test(x)))
y <- rbinom(x,3,p)
y1 <- as.ordered(y)
y2 <- as.factor(rbinom(x,1,p))

dta <- data.frame(x, y1, y2)

## Original function to interface
ssllrm(~ y1*y2*x, ~ y1 + y2, data = dta)

## The interface puts data as first parameter
ntbt_ssllrm(dta, ~ y1*y2*x, ~ y1 + y2)

## so it can be used easily in a pipeline.
dta %>%
  ntbt_ssllrm(~ y1*y2*x, ~ y1 + y2)

## End(Not run)

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