Last data update: 2014.03.03

R: A3 Results for Arbitrary Model
a3R Documentation

A3 Results for Arbitrary Model

Description

This function calculates the A3 results for an arbitrary model construction algorithm (e.g. Linear Regressions, Support Vector Machines or Random Forests). For linear regression models, you may use the a3.lm convenience function.

Usage

a3(formula, data, model.fn, model.args = list(), ...)

Arguments

formula

the regression formula.

data

a data frame containing the data to be used in the model fit.

model.fn

the function to be used to build the model.

model.args

a list of arguments passed to model.fn.

...

additional arguments passed to a3.base.

Value

S3 A3 object; see a3.base for details

References

Scott Fortmann-Roe (2015). Consistent and Clear Reporting of Results from Diverse Modeling Techniques: The A3 Method. Journal of Statistical Software, 66(7), 1-23. <http://www.jstatsoft.org/v66/i07/>

Examples


 ## Standard linear regression results:

 summary(lm(rating ~ ., attitude))

 ## A3 Results for a Linear Regression model:

 # In practice, p.acc should be <= 0.01 in order
 # to obtain finer grained p values.

 a3(rating ~ ., attitude, lm, p.acc = 0.1)


 ## A3 Results for a Random Forest model:

 # It is important to include the "+0" in the formula
 # to eliminate the constant term.

 require(randomForest)
 a3(rating ~ .+0, attitude, randomForest, p.acc = 0.1)

 # Set the ntrees argument of the randomForest function to 100

 a3(rating ~ .+0, attitude, randomForest, p.acc = 0.1, model.args = list(ntree = 100))

 # Speed up the calculation by doing 5-fold cross-validation.
 # This is faster and more conservative (i.e. it should over-estimate error)

 a3(rating ~ .+0, attitude, randomForest, n.folds = 5, p.acc = 0.1)

 # Use Leave One Out Cross Validation. The least biased approach,
 # but, for large data sets, potentially very slow.

 a3(rating ~ .+0, attitude, randomForest, n.folds = 0, p.acc = 0.1)

 ## Use a Support Vector Machine algorithm.

 # Just calculate the slopes and R^2 values, do not calculate p values.

 require(e1071)
 a3(rating ~ .+0, attitude, svm, p.acc = NULL)
 

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(A3)
Loading required package: xtable
Loading required package: pbapply
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/A3/a3.Rd_%03d_medium.png", width=480, height=480)
> ### Name: a3
> ### Title: A3 Results for Arbitrary Model
> ### Aliases: a3
> 
> ### ** Examples
> 
> ## No test: 
>  ## Standard linear regression results:
> 
>  summary(lm(rating ~ ., attitude))

Call:
lm(formula = rating ~ ., data = attitude)

Residuals:
     Min       1Q   Median       3Q      Max 
-10.9418  -4.3555   0.3158   5.5425  11.5990 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 10.78708   11.58926   0.931 0.361634    
complaints   0.61319    0.16098   3.809 0.000903 ***
privileges  -0.07305    0.13572  -0.538 0.595594    
learning     0.32033    0.16852   1.901 0.069925 .  
raises       0.08173    0.22148   0.369 0.715480    
critical     0.03838    0.14700   0.261 0.796334    
advance     -0.21706    0.17821  -1.218 0.235577    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 7.068 on 23 degrees of freedom
Multiple R-squared:  0.7326,	Adjusted R-squared:  0.6628 
F-statistic:  10.5 on 6 and 23 DF,  p-value: 1.24e-05

> 
>  ## A3 Results for a Linear Regression model:
> 
>  # In practice, p.acc should be <= 0.01 in order
>  # to obtain finer grained p values.
> 
>  a3(rating ~ ., attitude, lm, p.acc = 0.1)
             Average Slope   CV R^2 p value
-Full Model-                 58.9 %   < 0.1
(Intercept)        10.7871 -  5.0 %     0.9
complaints          0.6132 + 28.8 %   < 0.1
privileges         -0.0731 -  0.7 %     0.2
learning            0.3203 +  8.0 %   < 0.1
raises              0.0817 -  1.8 %     0.2
critical            0.0384 -  4.1 %     0.8
advance            -0.2171 -  0.9 %     0.4
> 
> 
>  ## A3 Results for a Random Forest model:
> 
>  # It is important to include the "+0" in the formula
>  # to eliminate the constant term.
> 
>  require(randomForest)
Loading required package: randomForest
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
>  a3(rating ~ .+0, attitude, randomForest, p.acc = 0.1)
             Average Slope   CV R^2 p value
-Full Model-                 47.3 %   < 0.1
complaints        0.034917 + 27.0 %   < 0.1
privileges        0.000000 +  4.8 %     0.6
learning          0.039700 + 12.5 %     0.1
raises            0.036250 +  9.8 %     0.4
critical         -0.015625 +  1.0 %     1.0
advance          -0.000992 +  3.6 %     0.8
> 
>  # Set the ntrees argument of the randomForest function to 100
> 
>  a3(rating ~ .+0, attitude, randomForest, p.acc = 0.1, model.args = list(ntree = 100))
             Average Slope   CV R^2 p value
-Full Model-                 47.5 %   < 0.1
complaints         0.02500 + 22.4 %   < 0.1
privileges         0.00000 -  2.9 %     1.0
learning           0.00921 +  8.9 %     0.5
raises             0.02633 +  3.5 %     0.9
critical           0.00000 +  0.7 %     0.8
advance           -0.00333 +  0.9 %     1.0
> 
>  # Speed up the calculation by doing 5-fold cross-validation.
>  # This is faster and more conservative (i.e. it should over-estimate error)
> 
>  a3(rating ~ .+0, attitude, randomForest, n.folds = 5, p.acc = 0.1)
             Average Slope   CV R^2 p value
-Full Model-                 52.6 %   < 0.1
complaints         0.02885 + 26.5 %   < 0.1
privileges         0.00000 +  4.2 %     1.0
learning           0.07213 + 12.1 %   < 0.1
raises             0.04520 +  8.8 %     0.2
critical          -0.02430 +  5.6 %     0.9
advance           -0.00977 +  1.4 %     0.9
> 
>  # Use Leave One Out Cross Validation. The least biased approach,
>  # but, for large data sets, potentially very slow.
> 
>  a3(rating ~ .+0, attitude, randomForest, n.folds = 0, p.acc = 0.1)
             Average Slope   CV R^2 p value
-Full Model-                 47.4 %   < 0.1
complaints          0.0429 + 25.7 %   < 0.1
privileges         -0.0126 +  2.9 %     0.9
learning            0.0700 + 15.0 %     0.2
raises              0.0510 +  6.9 %     0.1
critical           -0.0224 +  2.3 %     0.9
advance            -0.0264 +  3.7 %     0.6
> 
>  ## Use a Support Vector Machine algorithm.
> 
>  # Just calculate the slopes and R^2 values, do not calculate p values.
> 
>  require(e1071)
Loading required package: e1071
>  a3(rating ~ .+0, attitude, svm, p.acc = NULL)
             Average Slope   CV R^2
-Full Model-                 37.4 %
complaints          0.3702 + 28.1 %
privileges          0.0797 -  1.5 %
learning            0.1203 +  2.0 %
raises              0.0748 +  2.8 %
critical           -0.1381 - 10.9 %
advance            -0.1574 +  6.6 %
>  
> ## End(No test)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>