Clip
Clip copied to clipboard
βΈπΆπ©π£ .
This script reproduces, in sequence, the results and examples
in the accompannying paper. (Please note that a full run of the
script may take between a few hours and a day to run depending
on the computer.)
Package version information:
A3 0.9.2
e1071 1.6-1
randomForest 4.6-7
xtable 1.7-1
pbapply 1.0-5
R 2.15.2 OS X 64 bit
Due to the usage of stochasticity in the A3 method, minor
differences in results may be obtained if different versions of
packages are used. These differences will be minor and not
affect overall conclusions.
Each block represents an output (either a table or a figure) in
the original paper. Blocks are sequential as the results appear
in the paper.
set.seed(1) library("A3") print(a3(formula = rating ~ ., data = attitude, model.fn = lm))
library("e1071") print(a3(rating ~ . + 0, attitude, svm))
library("randomForest") out.rf <- a3(rating ~ . + 0, attitude, randomForest, p.acc = 0.05) print(out.rf)
print(a3(rating ~ . + 0, attitude, randomForest, p.acc = 0.05, model.args = list(ntree = 1000)))
print(out.rf)
plotPredictions(out.rf)
plotSlopes(out.rf)
data("housing", package = "A3") reg <- lm(MED.VALUE ~ AGE + ROOMS + NOX + PUPIL.TEACHER + HIGHWAY, housing) print(summary(reg))
NOTE: this may take 2 hours+; this data is cached in a file in data/ for article generation
housing.lm <- a3.lm(MED.VALUE ~ AGE +ROOMS + NOX + PUPIL.TEACHER + HIGHWAY, housing, p.acc = 0.01, n.folds = 50) print(housing.lm)
NOTE: this may take 2 hours+; this data is cached in a file in data/ for article generation
housing.svm <- a3(MED.VALUE ~ AGE +ROOMS + NOX + PUPIL.TEACHER + HIGHWAY+0, housing, svm, p.acc = 0.01, n.folds = 50) housing.rf <- a3(MED.VALUE ~ AGE +ROOMS + NOX + PUPIL.TEACHER + HIGHWAY+0, housing, randomForest, p.acc = 0.01, n.folds = 50)
print(housing.svm) print(housing.rf)
plotSlopes(housing.rf)
NOTE: this may take 2 hours+; this data is cached in a file in data/ for article generation
data("multifunctionality", package = "A3") reg <- lm(MUL ~ SR + SLO + SAC + PCA_C1 + PCA_C2 + PCA_C3 + PCA_C4 + LAT + LONG + ELE, multifunctionality) print(summary(reg))
NOTE: this may take 2 hours+; this data is cached in a file in data/ for article generation
mult.lm <- a3.lm(MUL ~ SR + SLO + SAC + PCA_C1 + PCA_C2 + PCA_C3 + PCA_C4 + LAT + LONG + ELE, multifunctionality, p.acc = 0.01, n.folds = 50) print(mult.lm)
NOTE: this may take 2 hours+; this data is cached in a file in data/ for article generation
mult.rf <- a3(MUL ~ SR + SLO + SAC + PCA_C1 + PCA_C2 + PCA_C3 + PCA_C4 + LAT + LONG + ELE + 0, multifunctionality, randomForest, p.acc = 0.01, n.folds = 50) print(mult.rf)
set.seed(1) createAutoCorrelatedSeries <- function(n, r) { dat <- rnorm(n, 0, 1) for(i in 2:n) dat[i] <- dat[i-1]r + dat[i](1-r) dat } sample <- data.frame(x = createAutoCorrelatedSeries(100, 0.95), y = createAutoCorrelatedSeries(100, 0.95)) reg <- lm(y ~ x, sample) print(summary(reg))