gam: Interfaces for gam package for data science pipelines.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

1

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

See Also

gam

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
## Not run: 
library(intubate)
library(gam)
data(kyphosis)

## Original function to interface
fit <- gam(Kyphosis ~ s(Age,4) + Number, family = binomial, data = kyphosis,
    trace = TRUE)
summary(fit)
fit <- gam(Kyphosis ~ poly(Age,2) + s(Start), data = kyphosis,
           family = binomial, subset = Number > 2)
summary(fit)
fit <- gam(Ozone^(1/3) ~ lo(Solar.R) + lo(Wind, Temp),
           data = airquality, na = na.gam.replace)
summary(fit)

## The interface reverses the order of data and formula
fit <- ntbt_gam(kyphosis, Kyphosis ~ s(Age,4) + Number,
                family = binomial, trace = TRUE)
summary(fit)
fit <- ntbt_gam(data = kyphosis, Kyphosis ~ poly(Age,2) + s(Start),
                family = binomial, subset = Number > 2)
summary(fit)
fit <- ntbt_gam(data = airquality, Ozone^(1/3) ~ lo(Solar.R) + lo(Wind, Temp),
                na = na.gam.replace)
summary(fit)

## so it can be used easily in a pipeline.
library(magrittr)
kyphosis %>%
  ntbt_gam(Kyphosis ~ s(Age,4) + Number,
          family = binomial, trace = TRUE) %>%
  summary()

kyphosis %>%
  ntbt_gam(Kyphosis ~ poly(Age,2) + s(Start),
           family = binomial, subset = Number > 2) %>%
  summary()
  
airquality %>%
  ntbt_gam(Ozone^(1/3) ~ lo(Solar.R) + lo(Wind, Temp),
           na = na.gam.replace) %>%
  summary()

## End(Not run)

Example output

Loading required package: splines
Loading required package: foreach
Loaded gam 1.14-4

GAM s.wam loop 1: deviance = 66.42095 
GAM s.wam loop 2: deviance = 63.77252 
GAM s.wam loop 3: deviance = 63.25199 
GAM s.wam loop 4: deviance = 63.13399 
GAM s.wam loop 5: deviance = 63.11016 
GAM s.wam loop 6: deviance = 63.10748 
GAM s.wam loop 7: deviance = 63.10727 
GAM s.wam loop 8: deviance = 63.10725 
GAM s.wam loop 9: deviance = 63.10725 

Call: gam(formula = Kyphosis ~ s(Age, 4) + Number, family = binomial, 
    data = kyphosis, trace = TRUE)
Deviance Residuals:
    Min      1Q  Median      3Q     Max 
-1.7844 -0.7190 -0.3593 -0.1199  2.3198 

(Dispersion Parameter for binomial family taken to be 1)

    Null Deviance: 83.2345 on 80 degrees of freedom
Residual Deviance: 63.1073 on 75 degrees of freedom
AIC: 75.1072 

Number of Local Scoring Iterations: 9 

Anova for Parametric Effects
          Df Sum Sq Mean Sq F value  Pr(>F)   
s(Age, 4)  1  0.382  0.3818  0.4459 0.50632   
Number     1  7.441  7.4412  8.6914 0.00426 **
Residuals 75 64.212  0.8562                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
            Npar Df Npar Chisq P(Chi)
(Intercept)                          
s(Age, 4)         3     5.8993 0.1166
Number                               

Call: gam(formula = Kyphosis ~ poly(Age, 2) + s(Start), family = binomial, 
    data = kyphosis, subset = Number > 2)
Deviance Residuals:
     Min       1Q   Median       3Q      Max 
-1.79693 -0.41691 -0.19525 -0.02327  2.09833 

(Dispersion Parameter for binomial family taken to be 1)

    Null Deviance: 77.0481 on 68 degrees of freedom
Residual Deviance: 44.5635 on 61.9998 degrees of freedom
AIC: 58.564 

Number of Local Scoring Iterations: 10 

Anova for Parametric Effects
             Df Sum Sq Mean Sq F value   Pr(>F)   
poly(Age, 2)  2  6.363  3.1813  4.5712 0.014065 * 
s(Start)      1  5.184  5.1838  7.4487 0.008251 **
Residuals    62 43.148  0.6959                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
             Npar Df Npar Chisq  P(Chi)  
(Intercept)                              
poly(Age, 2)                             
s(Start)           3     6.9637 0.07308 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Warning message:
In na.action(mf) :
  37 observations omitted due to missing values in the response

Call: gam(formula = Ozone^(1/3) ~ lo(Solar.R) + lo(Wind, Temp), data = airquality, 
    na.action = na.gam.replace)
Deviance Residuals:
     Min       1Q   Median       3Q      Max 
-1.22276 -0.27667 -0.03453  0.32553  0.93450 

(Dispersion Parameter for gaussian family taken to be 0.1953)

    Null Deviance: 90.7149 on 115 degrees of freedom
Residual Deviance: 20.0523 on 102.6679 degrees of freedom
AIC: 154.2493 

Number of Local Scoring Iterations: 2 

Anova for Parametric Effects
                   Df Sum Sq Mean Sq F value    Pr(>F)    
lo(Solar.R)      1.00 15.515 15.5147  79.435 1.968e-14 ***
lo(Wind, Temp)   2.00 38.594 19.2972  98.802 < 2.2e-16 ***
Residuals      102.67 20.052  0.1953                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
               Npar Df Npar F     Pr(F)    
(Intercept)                                
lo(Solar.R)        2.6 2.6590   0.06092 .  
lo(Wind, Temp)     6.8 7.4772 4.027e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
GAM s.wam loop 1: deviance = 66.42095 
GAM s.wam loop 2: deviance = 63.77252 
GAM s.wam loop 3: deviance = 63.25199 
GAM s.wam loop 4: deviance = 63.13399 
GAM s.wam loop 5: deviance = 63.11016 
GAM s.wam loop 6: deviance = 63.10748 
GAM s.wam loop 7: deviance = 63.10727 
GAM s.wam loop 8: deviance = 63.10725 
GAM s.wam loop 9: deviance = 63.10725 

Call: gam(formula = Kyphosis ~ s(Age, 4) + Number, family = binomial, 
    data = kyphosis, trace = TRUE)
Deviance Residuals:
    Min      1Q  Median      3Q     Max 
-1.7844 -0.7190 -0.3593 -0.1199  2.3198 

(Dispersion Parameter for binomial family taken to be 1)

    Null Deviance: 83.2345 on 80 degrees of freedom
Residual Deviance: 63.1073 on 75 degrees of freedom
AIC: 75.1072 

Number of Local Scoring Iterations: 9 

Anova for Parametric Effects
          Df Sum Sq Mean Sq F value  Pr(>F)   
s(Age, 4)  1  0.382  0.3818  0.4459 0.50632   
Number     1  7.441  7.4412  8.6914 0.00426 **
Residuals 75 64.212  0.8562                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
            Npar Df Npar Chisq P(Chi)
(Intercept)                          
s(Age, 4)         3     5.8993 0.1166
Number                               

Call: gam(formula = Kyphosis ~ poly(Age, 2) + s(Start), family = binomial, 
    data = kyphosis, subset = Number > 2)
Deviance Residuals:
     Min       1Q   Median       3Q      Max 
-1.79693 -0.41691 -0.19525 -0.02327  2.09833 

(Dispersion Parameter for binomial family taken to be 1)

    Null Deviance: 77.0481 on 68 degrees of freedom
Residual Deviance: 44.5635 on 61.9998 degrees of freedom
AIC: 58.564 

Number of Local Scoring Iterations: 10 

Anova for Parametric Effects
             Df Sum Sq Mean Sq F value   Pr(>F)   
poly(Age, 2)  2  6.363  3.1813  4.5712 0.014065 * 
s(Start)      1  5.184  5.1838  7.4487 0.008251 **
Residuals    62 43.148  0.6959                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
             Npar Df Npar Chisq  P(Chi)  
(Intercept)                              
poly(Age, 2)                             
s(Start)           3     6.9637 0.07308 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Warning message:
In na.action(mf) :
  37 observations omitted due to missing values in the response

Call: gam(formula = Ozone^(1/3) ~ lo(Solar.R) + lo(Wind, Temp), data = airquality, 
    na.action = na.gam.replace)
Deviance Residuals:
     Min       1Q   Median       3Q      Max 
-1.22276 -0.27667 -0.03453  0.32553  0.93450 

(Dispersion Parameter for gaussian family taken to be 0.1953)

    Null Deviance: 90.7149 on 115 degrees of freedom
Residual Deviance: 20.0523 on 102.6679 degrees of freedom
AIC: 154.2493 

Number of Local Scoring Iterations: 2 

Anova for Parametric Effects
                   Df Sum Sq Mean Sq F value    Pr(>F)    
lo(Solar.R)      1.00 15.515 15.5147  79.435 1.968e-14 ***
lo(Wind, Temp)   2.00 38.594 19.2972  98.802 < 2.2e-16 ***
Residuals      102.67 20.052  0.1953                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
               Npar Df Npar F     Pr(F)    
(Intercept)                                
lo(Solar.R)        2.6 2.6590   0.06092 .  
lo(Wind, Temp)     6.8 7.4772 4.027e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
GAM s.wam loop 1: deviance = 66.42095 
GAM s.wam loop 2: deviance = 63.77252 
GAM s.wam loop 3: deviance = 63.25199 
GAM s.wam loop 4: deviance = 63.13399 
GAM s.wam loop 5: deviance = 63.11016 
GAM s.wam loop 6: deviance = 63.10748 
GAM s.wam loop 7: deviance = 63.10727 
GAM s.wam loop 8: deviance = 63.10725 
GAM s.wam loop 9: deviance = 63.10725 

Call: gam(formula = Kyphosis ~ s(Age, 4) + Number, family = binomial, 
    data = ., trace = TRUE)
Deviance Residuals:
    Min      1Q  Median      3Q     Max 
-1.7844 -0.7190 -0.3593 -0.1199  2.3198 

(Dispersion Parameter for binomial family taken to be 1)

    Null Deviance: 83.2345 on 80 degrees of freedom
Residual Deviance: 63.1073 on 75 degrees of freedom
AIC: 75.1072 

Number of Local Scoring Iterations: 9 

Anova for Parametric Effects
          Df Sum Sq Mean Sq F value  Pr(>F)   
s(Age, 4)  1  0.382  0.3818  0.4459 0.50632   
Number     1  7.441  7.4412  8.6914 0.00426 **
Residuals 75 64.212  0.8562                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
            Npar Df Npar Chisq P(Chi)
(Intercept)                          
s(Age, 4)         3     5.8993 0.1166
Number                               

Call: gam(formula = Kyphosis ~ poly(Age, 2) + s(Start), family = binomial, 
    data = ., subset = Number > 2)
Deviance Residuals:
     Min       1Q   Median       3Q      Max 
-1.79693 -0.41691 -0.19525 -0.02327  2.09833 

(Dispersion Parameter for binomial family taken to be 1)

    Null Deviance: 77.0481 on 68 degrees of freedom
Residual Deviance: 44.5635 on 61.9998 degrees of freedom
AIC: 58.564 

Number of Local Scoring Iterations: 10 

Anova for Parametric Effects
             Df Sum Sq Mean Sq F value   Pr(>F)   
poly(Age, 2)  2  6.363  3.1813  4.5712 0.014065 * 
s(Start)      1  5.184  5.1838  7.4487 0.008251 **
Residuals    62 43.148  0.6959                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
             Npar Df Npar Chisq  P(Chi)  
(Intercept)                              
poly(Age, 2)                             
s(Start)           3     6.9637 0.07308 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Call: gam(formula = Ozone^(1/3) ~ lo(Solar.R) + lo(Wind, Temp), data = ., 
    na.action = na.gam.replace)
Deviance Residuals:
     Min       1Q   Median       3Q      Max 
-1.22276 -0.27667 -0.03453  0.32553  0.93450 

(Dispersion Parameter for gaussian family taken to be 0.1953)

    Null Deviance: 90.7149 on 115 degrees of freedom
Residual Deviance: 20.0523 on 102.6679 degrees of freedom
AIC: 154.2493 

Number of Local Scoring Iterations: 2 

Anova for Parametric Effects
                   Df Sum Sq Mean Sq F value    Pr(>F)    
lo(Solar.R)      1.00 15.515 15.5147  79.435 1.968e-14 ***
lo(Wind, Temp)   2.00 38.594 19.2972  98.802 < 2.2e-16 ***
Residuals      102.67 20.052  0.1953                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Anova for Nonparametric Effects
               Npar Df Npar F     Pr(F)    
(Intercept)                                
lo(Solar.R)        2.6 2.6590   0.06092 .  
lo(Wind, Temp)     6.8 7.4772 4.027e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Warning message:
In na.action(mf) :
  37 observations omitted due to missing values in the response

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