fRegression/ 0000755 0001760 0000144 00000000000 12261241424 012566 5 ustar ripley users fRegression/inst/ 0000755 0001760 0000144 00000000000 12251673344 013554 5 ustar ripley users fRegression/inst/COPYRIGHT.html 0000644 0001760 0000144 00000020411 11370220736 016002 0 ustar ripley users
Rmetrics::COPYRIGHT
Rmetrics
Copyrights
2005-12-18 Built 221.10065
________________________________________________________________________________
Copyrights (C) for
R:
see R's copyright and license file
Version R 2.0.0 claims:
- The stub packages from 1.9.x have been removed.
- All the datasets formerly in packages 'base' and 'stats' have
been moved to a new package 'datasets'.
- Package 'graphics' has been split into 'grDevices' (the graphics
devices shared between base and grid graphics) and 'graphics'
(base graphics).
- Packages must have been re-installed for this version, and
library() will enforce this.
- Package names must now be given exactly in library() and
require(), regardless of whether the underlying file system is
case-sensitive or not.
________________________________________________________________________________
for
Rmetrics:
(C) 1999-2005, Diethelm Wuertz, GPL
Diethelm Wuertz
www.rmetrics.org
info@rmetrics.org
________________________________________________________________________________
for non default loaded basic packages part of R's basic distribution
MASS:
Main Package of Venables and Ripley's MASS.
We assume that MASS is available.
Package 'lqs' has been returned to 'MASS'.
S original by Venables & Ripley.
R port by Brian Ripley .
Earlier work by Kurt Hornik and Albrecht Gebhardt.
methods:
Formally defined methods and classes for R objects, plus other
programming tools, as described in the reference "Programming
with Data" (1998), John M. Chambers, Springer NY.
R Development Core Team.
mgcv:
Routines for GAMs and other generalized ridge regression
with multiple smoothing parameter selection by GCV or UBRE.
Also GAMMs by REML or PQL. Includes a gam() function.
Simon Wood
nnet:
Feed-forward Neural Networks and Multinomial Log-Linear Models
Original by Venables & Ripley.
R port by Brian Ripley .
Earlier work by Kurt Hornik and Albrecht Gebhardt.
________________________________________________________________________________
for the code partly included as builtin functions from other R ports:
fBasics:CDHSC.F
GRASS program for distributional testing.
By James Darrell McCauley
Original Fortran Source by Paul Johnson EZ006244@ALCOR.UCDAVIS.EDU>
fBasics:nortest
Five omnibus tests for the composite hypothesis of normality
R-port by Juergen Gross
fBasics:SYMSTB.F
Fast numerical approximation to the Symmetric Stable distribution
and density functions.
By Hu McCulloch
fBasics:tseries
Functions for time series analysis and computational finance.
Compiled by Adrian Trapletti
fCalendar:date
The tiny C program from Terry Therneau is used
R port by Th. Lumley ,
K. Halvorsen , and
Kurt Hornik
fCalendar:holidays
The holiday information was collected from the internet and
governmental sources obtained from a few dozens of websites
fCalendar:libical
Libical is an Open Source implementation of the IETF's
iCalendar Calendaring and Scheduling protocols. (RFC 2445, 2446,
and 2447). It parses iCal components and provides a C API for
manipulating the component properties, parameters, and subcomponents.
fCalendar:vtimezone
Olsen's VTIMEZONE database consists of data files are released under
the GNU General Public License, in keeping with the license options of
libical.
fSeries:bdstest.c
C Program to compute the BDS Test.
Blake LeBaron
fSeries:fracdiff
R functions, help pages and the Fortran Code for the 'fracdiff'
function are included.
S original by Chris Fraley
R-port by Fritz Leisch
since 2003-12: Martin Maechler
fSeries:lmtest
R functions and help pages for the linear modelling tests are included .
Compiled by Torsten Hothorn ,
Achim Zeileis , and
David Mitchell
fSeries:mda
R functions, help pages and the Fortran Code for the 'mars' function
are implemeted.
S original by Trevor Hastie & Robert Tibshirani,
R port by Friedrich Leisch, Kurt Hornik and Brian D. Ripley
fSeries:modreg
Brian Ripley and the R Core Team
fSeries:polspline
R functions, help pages and the C/Fortran Code for the 'polymars'
function are implemented
Charles Kooperberg
fSeries:systemfit
Simultaneous Equation Estimation Package.
R port by Jeff D. Hamann and
Arne Henningsen
fSeries:tseries
Functions for time series analysis and computational finance.
Compiled by Adrian Trapletti
fSeries:UnitrootDistribution:
The program uses the Fortran routine and the tables
from J.G. McKinnon.
fSeries:urca
Unit root and cointegration tests for time series data.
R port by Bernhard Pfaff .
fExtremes:evd
Functions for extreme value distributions.
R port by Alec Stephenson
Function 'fbvpot' by Chris Ferro.
fExtremes:evir
Extreme Values in R
Original S functions (EVIS) by Alexander McNeil
R port by Alec Stephenson
fExtremes:ismev
An Introduction to Statistical Modeling of Extreme Values
Original S functions by Stuart Coles
R port/documentation by Alec Stephenson
fOptions
Option Pricing formulas are implemented along the book and
the Excel spreadsheets of E.G. Haug, "The Complete Guide to Option
Pricing"; documentation is partly taken from www.derivicom.com which
implements a C Library based on Haug. For non-academic and commercial
use we recommend the professional software from "www.derivicom.com".
fOptions:SOBOL.F
ACM Algorithm 659 by P. Bratley and B.L. Fox
Extension on Algorithm 659 by S. Joe and F.Y. Kuo
fOptions:CGAMA.F
Complex gamma and related functions.
Fortran routines by Jianming Jin.
fOptions:CONHYP.F
Confluenet Hypergeometric and related functions.
ACM Algorithm 707 by mark Nardin, W.F. Perger, A. Bhalla
fPortfolio:mvtnorm
Multivariate Normal and T Distribution.
Alan Genz ,
Frank Bretz
R port by Torsten Hothorn
fPortfolio:quadprog
Functions to solve Quadratic Programming Problems.
S original by Berwin A. Turlach
R port by Andreas Weingessel
fPortfolio:sn
The skew-normal and skew-t distributions.
R port by Adelchi Azzalini
fPortfolio:tseries
Functions for time series analysis and computational finance.
Compiled by Adrian Trapletti
fRegression/inst/unitTests/ 0000755 0001760 0000144 00000000000 12256322055 015551 5 ustar ripley users fRegression/inst/unitTests/Makefile 0000644 0001760 0000144 00000000423 11370220736 017207 0 ustar ripley users PKG=fRegression
TOP=../..
SUITE=doRUnit.R
R=R
all: inst test
inst: # Install package -- but where ?? -- will that be in R_LIBS ?
cd ${TOP}/..;\
${R} CMD INSTALL ${PKG}
test: # Run unit tests
export RCMDCHECK=FALSE;\
cd ${TOP}/tests;\
${R} --vanilla --slave < ${SUITE} fRegression/inst/unitTests/runit.regFit.R 0000644 0001760 0000144 00000013164 11370220736 020260 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
# FUNCTION: REGRESSION MODELLING DESCRIPTION:
# regFit Wrapper Function for Regression Models
################################################################################
test.lmFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
lmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm")
print(lmfit)
summary(lmfit)
# plot(lmfit)
fitted(lmfit)
slot(lmfit, "fitted")
residuals(lmfit)
slot(lmfit, "residuals")
coef(lmfit)
formula(lmfit)
predict(lmfit)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.rlmFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
rlmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "rlm")
print(rlmfit)
summary(rlmfit)
# plot(rlmfit)
fitted(rlmfit)
slot(rlmfit, "fitted")
residuals(rlmfit)
slot(rlmfit, "residuals")
coef(rlmfit)
formula(rlmfit)
predict(rlmfit)
head(rlmfit@fit$model)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.glmFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
glmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "glm")
print(glmfit)
summary(glmfit)
# plot(glmfit)
print(glmfit@fit)
summary(glmfit@fit)
fitted(glmfit)
slot(glmfit, "fitted")
residuals(glmfit)
slot(glmfit, "residuals")
coef(glmfit)
formula(glmfit)
predict(glmfit)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.gamFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "GAM3", n = 50)
# Fit Parameters:
gamfit = regFit(Y ~ s(X1) + s(X2) + X3, data = x, use = "gam")
print(gamfit)
summary(gamfit)
# plot(gamfit)
print(gamfit@fit)
summary(gamfit@fit)
fitted(gamfit)
slot(gamfit, "fitted")
residuals(gamfit)
slot(gamfit, "residuals")
coef(gamfit)
formula(gamfit)
predict(gamfit)
gamfit@fit$terms
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.pprFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
pprfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "ppr")
ppr = ppr(Y ~ X1 + X2 + X3, data = x, nterms = 2)
print(pprfit)
summary(pprfit)
# plot(pprfit)
print(pprfit@fit)
summary(pprfit@fit)
fitted(pprfit)
slot(pprfit, "fitted")
residuals(pprfit)
slot(pprfit, "residuals")
coef(pprfit)
formula(pprfit)
predict(pprfit)
pprfit@fit$terms
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.nnetFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
nnetfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "nnet")
print(nnetfit)
summary(nnetfit)
# plot(nnetfit)
print(nnetfit@fit)
summary(nnetfit@fit)
fitted(nnetfit)
slot(nnetfit, "fitted")
residuals(nnetfit)
slot(nnetfit, "residuals")
coef(nnetfit)
formula(nnetfit)
predict(nnetfit)
nnetfit@fit$terms
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.polymarsFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
polymarsfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "polymars")
print(polymarsfit)
summary(polymarsfit)
fitted(polymarsfit)
slot(polymarsfit, "fitted")
residuals(polymarsfit)
slot(polymarsfit, "residuals")
coef(polymarsfit)
formula(polymarsfit)
predict(polymarsfit)
polymarsfit@fit$terms
# Return Value:
return()
}
################################################################################
fRegression/inst/unitTests/runit.RegressionModelling.R 0000644 0001760 0000144 00000027514 12256322055 023020 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
# FUNCTION: REGRESSION MODELLING DESCRIPTION:
# 'fREG' S4 Class Representation
# regSim Returns a regression example data set
# S3-METHODS: DESCRIPTION:
# print.fREG Prints results from a regression model fit
# plot.fREG Plots fit and diagnostics for a regression model
# summary.fREG Summarizes fit and diagnostics for a regression model
# S3-METHODS: DESCRIPTION:
# predict.fREG Predicts values from a fitted regression model
# coefficients.fREG Returns coefficients from a fitted regression model
# fitted.fREG Returns fitted values from a fitted regression model
# residulals.fREG Returns residuals from a fitted regression model
# vcov.fREG Returns variance-covariance matrix from a fitted model
################################################################################
test.regSim <-
function()
{
# Plot Parameters:
par(ask = FALSE)
par(mfrow = c(3, 1))
# Simulate Artificial LM:
X = regSim(model = "LM3", n = 365)
head(X)
plot(X[, "Y"], type = "l", main = "LM3", xlab = "1970", ylab = "Y")
# Simulate Artificial LOGIT:
X = regSim(model = "LOGIT3", n = 365)
head(X)
plot(X[, "Y"], type = "l", main = "LOGIT3", xlab = "1970", ylab = "Y")
# Simulate Artificial GAM:
X = regSim(model = "GAM3", n = 365)
head(X)
plot(X[, "Y"], type = "l", main = "GAM3", xlab = "1970", ylab = "Y")
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.regFit.dataframe <-
function()
{
# Working with timeSeries Objects ...
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Regression Fit:
LM = regFit(Y ~ X1 + X2, data = DATA, use = "lm")
RLM = regFit(Y ~ X1 + X2, data = DATA, use = "rlm")
AM = regFit(Y ~ X1 + X2, data = DATA, use = "gam")
PPR = regFit(Y ~ X1 + X2, data = DATA, use = "ppr")
POLYMARS = regFit(Y ~ X1 + X2, data = DATA, use = "polymars")
NNET = regFit(Y ~ X1 + X2, data = DATA, use = "nnet")
# ... a note on AM the smoothing functions are added by default!
# this is different to gam()
# Print Method:
print(LM)
print(RLM)
print(AM)
print(PPR)
print(POLYMARS)
print(NNET)
# Plot Method:
par(ask = FALSE)
par(mfrow = c(1, 1))
# plot(LM, which = "all") # CHECK which !!!
# plot(RLM, which = "all")
# plot(AM, which = "all")
# plot(PPR, which = "all")
# plot(POLYMARS, which = "all")
# plot(NNET, which = "all")
# Summary Method:
summary(LM)
summary(RLM)
summary(AM)
summary(PPR)
summary(POLYMARS)
summary(NNET)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.regFit.valueSlots <-
function()
{
# Working with timeSeries Objects ...
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Modelling:
LM = regFit(Y ~ X1 + X2, data = DATA, use = "lm")
RLM = regFit(Y ~ X1 + X2, data = DATA, use = "rlm")
AM = regFit(Y ~ s(X1) + s(X2), DATA, use = "gam")
PPR = regFit(Y ~ X1 + X2, data = DATA, use = "ppr")
POLYMARS = regFit(Y ~ X1 + X2, data = DATA, use = "polymars")
NNET = regFit(Y ~ X1 + X2, data = DATA, use = "nnet")
# Extract:
# call = "call"
# formula = "formula"
# family = "character"
# method = "character"
# data = "data.frame"
# fit = "list"
# residuals = "timeSeries"
# fitted.values = "timeSeries"
# title = "character"
# description = "character"
LM@call
RLM@call
AM@call
PPR@call
POLYMARS@call
NNET@call
LM@formula
RLM@formula
AM@formula # CHECK !!!
PPR@formula
POLYMARS@formula
NNET@formula
LM@family[1:2]
RLM@family[1:2]
AM@family[1:2]
PPR@family[1:2]
POLYMARS@family[1:2]
NNET@family[1:2]
LM@method
RLM@method
AM@method
PPR@method
POLYMARS@method
NNET@method
# Note the residuals are time tmeSeries objects!
print(LM@residuals[c(1,100)])
print(RLM@residuals[c(1,100)])
print(AM@residuals[c(1,100)])
print(PPR@residuals[c(1,100)])
print(POLYMARS@residuals[c(1,100)])
print(NNET@residuals[c(1,100)])
# Note the fitted values are time tmeSeries objects!
print(LM@fitted[c(1,100)])
print(RLM@fitted[c(1,100)])
print(AM@fitted[c(1,100)])
print(PPR@fitted[c(1,100)])
print(POLYMARS@fitted[c(1,100)])
print(NNET@fitted[c(1,100)])
# Returns a Title, by default the name of the algorithm applied:
LM@title
RLM@title
AM@title
PPR@title
POLYMARS@title
NNET@title
# Returns a Description, by default Date/Time and user:
LM@description
RLM@description
AM@description
PPR@description
POLYMARS@description
NNET@description
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.predict.fREG <-
function()
{
# Working with timeSeries Objects ...
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Regression Fit:
LM = regFit(Y ~ X1 + X2, data = DATA, use = "lm")
RLM = regFit(Y ~ X1 + X2, data = DATA, use = "rlm")
AM = regFit(Y ~ s(X1) + s(X2), DATA, use = "gam")
PPR = regFit(Y ~ X1 + X2, data = DATA, use = "ppr")
POLYMARS = regFit(Y ~ X1 + X2, data = DATA, use = "polymars")
NNET = regFit(Y ~ X1 + X2, data = DATA, use = "nnet")
# Just to rmember - Predict:
# predict.fREG(object, newdata, se.fit = FALSE, type = "response", ...)
# Selext some rows to predict:
set.seed(4711)
N = round(runif(5, 1, 100), 0)
N
# Predict Response:
predict(LM, DATA[N, ])
predict(RLM, DATA[N, ])
predict(AM, DATA[N, ])
predict(PPR, DATA[N, ])
predict(POLYMARS, DATA[N, ])
predict(NNET, DATA[N, ])
# Predict Response:
predict(LM, DATA[N, ], type = "response")
predict(RLM, DATA[N, ], type = "response")
predict(AM, DATA[N, ], type = "response")
predict(PPR, DATA[N, ], type = "response")
predict(POLYMARS, DATA[N, ], type = "response")
predict(NNET, DATA[N, ], type = "response")
# Predict Response with Standard Errors:
predict(LM, DATA[N, ], se.fit = TRUE)
predict(RLM, DATA[N, ], se.fit = TRUE)
predict(AM, DATA[N, ], se.fit = TRUE)
predict(PPR, DATA[N, ], se.fit = TRUE)
predict(POLYMARS, DATA[N, ], se.fit = TRUE)
predict(NNET, DATA[N, ], se.fit = TRUE)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.regFit.nonDefaults <-
function()
{
# Simulate Data - a data frame:
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Simulate Data - a timeSeries object:
DATA = as.timeSeries(DATA)
head(DATA)
class(DATA)
# LM:
LM1 = regFit(Y ~ X1 + X2, DATA, use = "lm")
print(LM1)
LM2 = regFit(Y ~ 1 + X1 + X2, DATA)
print(LM2)
LM3 = regFit(Y ~ -1 + X1 + X2, DATA)
print(LM3)
LM4 = regFit(Y ~ X1 + log(X2), DATA)
print(LM4)
# AM:
AM1 = regFit(Y ~ s(X1) + s(X2), data = DATA, use = "gam")
print(AM1)
# AM2 = regFit(Y ~ s(X1) + s(X2), DATA, "gam",
# method = gam.method(pearson = TRUE))
# print(AM2)
# PPR:
par(ask = FALSE)
par(mfrow = c(1, 1))
PPR1 = regFit(Y ~ sin(X1) + exp(X2), DATA, "ppr", nterms = 4,
sm.method = "supsmu", use = "ppr")
PPR2 = regFit(Y ~ sin(X1) + exp(X2), DATA, "ppr", nterms = 4,
sm.method = "spline", use = "ppr")
PPR3 = regFit(Y ~ sin(X1) + exp(X2), DATA, "ppr", nterms = 3,
sm.method = "gcvspline", use = "ppr")
## termPlot(PPR1)
## termPlot(PPR2)
## termPlot(PPR3)
# POLYMARS:
POLYMARS = regFit(Y ~ X1 + X2 + X3, DATA, use = "polymars")
POLYMARS = regFit(Y ~ X1*X2 + X2*X3 + X3*X1, DATA, use = "polymars")
# NNET
# todo ...
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.generalizedModels <-
function()
{
# Generalized * Models:
M1 = matrix(c(
1, 0.80, 0.83, 0.66, 1.9, 1.100, 0.996,
1, 0.90, 0.36, 0.32, 1.4, 0.740, 0.992,
0, 0.80, 0.88, 0.70, 0.8, 0.176, 0.982,
0, 1.00, 0.87, 0.87, 0.7, 1.053, 0.986,
1, 0.90, 0.75, 0.68, 1.3, 0.519, 0.980,
0, 1.00, 0.65, 0.65, 0.6, 0.519, 0.982,
1, 0.95, 0.97, 0.92, 1.0, 1.230, 0.992,
0, 0.95, 0.87, 0.83, 1.9, 1.354, 1.020,
0, 1.00, 0.45, 0.45, 0.8, 0.322, 0.999,
0, 0.95, 0.36, 0.34, 0.5, 0.000, 1.038,
0, 0.85, 0.39, 0.33, 0.7, 0.279, 0.988,
0, 0.70, 0.76, 0.53, 1.2, 0.146, 0.982,
0, 0.80, 0.46, 0.37, 0.4, 0.380, 1.006,
0, 0.20, 0.39, 0.08, 0.8, 0.114, 0.990,
0, 1.00, 0.90, 0.90, 1.1, 1.037, 0.990,
1, 1.00, 0.84, 0.84, 1.9, 2.064, 1.020,
0, 0.65, 0.42, 0.27, 0.5, 0.114, 1.014,
0, 1.00, 0.75, 0.75, 1.0, 1.322, 1.004,
0, 0.50, 0.44, 0.22, 0.6, 0.114, 0.990,
1, 1.00, 0.63, 0.63, 1.1, 1.072, 0.986,
0, 1.00, 0.33, 0.33, 0.4, 0.176, 1.010,
0, 0.90, 0.93, 0.84, 0.6, 1.591, 1.020,
1, 1.00, 0.58, 0.58, 1.0, 0.531, 1.002,
0, 0.95, 0.32, 0.30, 1.6, 0.886, 0.988,
1, 1.00, 0.60, 0.60, 1.7, 0.964, 0.990,
1, 1.00, 0.69, 0.69, 0.9, 0.398, 0.986,
0, 1.00, 0.73, 0.73, 0.7, 0.398, 0.986),
byrow = TRUE, ncol = 7)
colnames(M1) = c("Y", "X1", "X2", "X3", "X4", "X5", "X6")
D1 = data.frame(M1)
D1
# fit.glm = glm(Y ~ X1 + X2 + X3 + X4 + X5 + X6, data = D1,
# family = binomial("logit"))
# fit.gam = gam(Y ~ s(X1) + s(X2) + s(X3) + s(X4) + s(X5) + s(X6),
# data = D1, family = binomial("logit"))
M2 = matrix(c(
0,29,62,
0,30,83,
0,31,74,
0,31,88,
0,32,68,
1,29,41,
1,30,44,
1,31,21,
1,32,50,
1,33,33),
byrow = TRUE, ncol = 3)
colnames(M2) = c("Y", "X1", "X2")
D2 = data.frame(M2)
D2
plot (D2[1:5, "X1"], D2[1:5, "X2"],
xlim = range(D2[, "X1"]), ylim = range(D2[, "X2"]),
pch = 19, col = "blue")
points(D2[6:10,"X1"], D2[6:10,"X2"],
pch = 19, col = "red")
U = range(D2[, "X1"])
V = 2*U - 6
lines(U, V, lty = 3, col = "grey")
fit.glm = glm(Y ~ X1 + X2, data = D2, family = binomial("logit"))
print(fit.glm)
# Return Value:
return()
}
################################################################################
fRegression/inst/unitTests/runit.LPP2005.R 0000644 0001760 0000144 00000003066 11370220736 020002 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
test.Fit <-
function()
{
# Simulate Artificial LM:
x = as.timeSeries(data(LPP2005REC))
# Fit Parameters:
lmfit = regFit(LPP40 ~ 0 + SPI + SBI + SII + LMI + MPI + ALT,
data = x, use = "lm")
#
print(lmfit)
# Return Value:
return()
}
################################################################################
fRegression/inst/unitTests/runit.polymars.R 0000644 0001760 0000144 00000013660 11370220736 020707 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
# FUNCTION: REGRESSION MODELLING DESCRIPTION:
# polymars Polymars Regression
# .polymars Polymars regress from package polspline
# .polymarsDefault Internal Function
# .polymarsVormula Internal Function
# .predict.polymars Internal Function
################################################################################
test.polymars <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Original Polymars:
fit = polspline::polymars(responses = x[,1], predictors = x[,2:4])
# Model Fitting:
fit$fitting
# Model Produced:
fit$model
fit$coef
# Summary:
# Note print.polymars = summary.polymars
polspline::summary.polymars(fit)
# Predict:
ans = polspline::predict.polymars(object = fit, x = x[,-1])
as.vector(ans)
as.vector(fit$fitted)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.polymarsDefault <-
function()
{
# Simulate Artificial LM:
set.seed(4711)
x = regSim(model = "LM3", n = 50)
# Polymars Wrapper:
fit1 = .polymarsDefault(responses = x[,1], predictors = x[, 2:4])
class(fit1)
names(fit1)
# Note, this fails:
# fit1 = .polymars(responses = x[,1], predictors = x[,2:4])
# Model Fitting:
fit1$fitting
# Model Produced:
# fit1$model reserved for model series, use ...
fit1$coef
# Summary:
print(fit1)
# Print:
summary(fit1)
# Predict:
ans = polspline::predict.polymars(object = fit1, x = x[,-1])
as.vector(ans)
as.vector(fit1$fitted)
# Check:
fit1$ranges.and.medians
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.polymarsFormula <-
function()
{
# Simulate Artificial LM:
set.seed(4711)
x = regSim(model = "LM3", n = 50)
# Polymars Formula Wrapper:
fit2 = .polymarsFormula(formula = Y ~ X1 + X2 + X3, data = x)
fit2 = .polymars(formula = Y ~ X1 + X2 + X3, data = x)
class(fit2)
names(fit2)
# Model Fitting:
fit2$fitting
# Model Produced:
# fit$model reserved for model series, use ...
fit2$coef
# Summary:
print(fit2)
# Print:
summary(fit2)
# Predict:
fit2$model = fit2$coef
ans = polspline::predict.polymars(object = fit2, x = x[,-1])
as.vector(ans)
as.vector(fit2$fitted)
# Check:
fit2$ranges.and.medians
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.regFit.polymars <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Polymars Formula Wrapper:
fit = regFit(formula = Y ~ X1 + X2 + X3, data = x, use = "polymars")
class(fit)
# Model Fitting:
fit@fit$fitting
# Model Produced:
# fit$model reserved for model series, use ...
fit@fit$coef
# Summary:
print(fit)
# Print:
summary(fit)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.regFit.polymars.methods <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 20)
# Polymars Formula Wrapper:
polymarsfit = regFit(formula = Y ~ X1 + X2 + X3, data = x, use = "polymars")
# Print:
print(polymarsfit)
# Summary:
summary(polymarsfit)
# Fitted Values:
fitted(polymarsfit)
slot(polymarsfit, "fitted")
# Residuals:
residuals(polymarsfit)
slot(polymarsfit, "residuals")
# Coefficients:
coef(polymarsfit)
# Formula
formula(polymarsfit)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.regFit.polymars.predict <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# regFit / Polymars Formula Wrapper:
fit = regFit(formula = Y ~ X1 + X2 + X3, data = x, use = "polymars")
class(fit)
fit@fit$cmd
# Predict from predict.polymars:
object = fit@fit
class(object) = "polymars"
object
object$model = object$coef
ans = polspline::predict.polymars(object = object, x = x[,-1])
as.vector(ans)
as.vector(fit@fitted)
# Predict from predict.fREG:
ans = predict(object = fit, newdata = x)
as.vector(ans)
as.vector(fit@fitted)
# Return Value:
return()
}
################################################################################
fRegression/inst/unitTests/runTests.R 0000644 0001760 0000144 00000004533 11370220736 017527 0 ustar ripley users pkg <- "fRegression"
if(require("RUnit", quietly = TRUE))
{
library(package=pkg, character.only = TRUE)
if(!(exists("path") && file.exists(path)))
path <- system.file("unitTests", package = pkg)
## --- Testing ---
## Define tests
testSuite <- defineTestSuite(name = paste(pkg, "unit testing"),
dirs = path)
if(interactive()) {
cat("Now have RUnit Test Suite 'testSuite' for package '",
pkg, "' :\n", sep='')
str(testSuite)
cat('', "Consider doing",
"\t tests <- runTestSuite(testSuite)", "\nand later",
"\t printTextProtocol(tests)", '', sep = "\n")
} else {
## run from shell / Rscript / R CMD Batch / ...
## Run
tests <- runTestSuite(testSuite)
if(file.access(path, 02) != 0) {
## cannot write to path -> use writable one
tdir <- tempfile(paste(pkg, "unitTests", sep="_"))
dir.create(tdir)
pathReport <- file.path(tdir, "report")
cat("RUnit reports are written into ", tdir, "/report.(txt|html)",
sep = "")
} else {
pathReport <- file.path(path, "report")
}
## Print Results:
printTextProtocol(tests, showDetails = FALSE)
printTextProtocol(tests, showDetails = FALSE,
fileName = paste(pathReport, "Summary.txt", sep = ""))
printTextProtocol(tests, showDetails = TRUE,
fileName = paste(pathReport, ".txt", sep = ""))
## Print HTML Version to a File:
## printHTMLProtocol has problems on Mac OS X
if (Sys.info()["sysname"] != "Darwin")
printHTMLProtocol(tests,
fileName = paste(pathReport, ".html", sep = ""))
## stop() if there are any failures i.e. FALSE to unit test.
## This will cause R CMD check to return error and stop
tmp <- getErrors(tests)
if(tmp$nFail > 0 | tmp$nErr > 0) {
stop(paste("\n\nunit testing failed (#test failures: ", tmp$nFail,
", R errors: ", tmp$nErr, ")\n\n", sep=""))
}
}
} else {
cat("R package 'RUnit' cannot be loaded -- no unit tests run\n",
"for package", pkg,"\n")
}
################################################################################
fRegression/inst/unitTests/runit.TimeSeries.R 0000644 0001760 0000144 00000011635 11370220736 021112 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
test.lmCoef <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Convert to a timeSeries Object with Dummy Dates
x = as.timeSeries(x)
# Fit Parameters:
fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm")
fit
# Extract Fitted values:
head(slot(fit, "fitted"))
val = fitted(fit)
head(val)
class(val)
# Extract Residuals:
head(slot(fit, "residuals"))
val = residuals(fit)
head(val)
class(val)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.rlmCoef <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Convert to a timeSeries Object with Dummy Dates
x = as.timeSeries(x)
# Fit Parameters:
fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "rlm")
fit
# Extract Fitted values:
head(slot(fit, "fitted"))
val = fitted(fit)
head(val)
class(val)
# Extract Residuals:
head(slot(fit, "residuals"))
val = residuals(fit)
head(val)
class(val)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.amCoef <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "GAM3", n = 50)
# Convert to a timeSeries Object with Dummy Dates
x = as.timeSeries(x)
# Fit Parameters:
fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "gam")
fit
# Extract Fitted values:
head(slot(fit, "fitted"))
val = fitted(fit)
head(val)
class(val)
# Extract Residuals:
head(slot(fit, "residuals"))
val = residuals(fit)
head(val)
class(val)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.pprCoef <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Convert to a timeSeries Object with Dummy Dates
x = as.timeSeries(x)
# Fit Parameters:
fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "ppr")
fit
# Extract Fitted values:
head(slot(fit, "fitted"))
val = fitted(fit)
head(val)
class(val)
# Extract Residuals:
head(slot(fit, "residuals"))
val = residuals(fit)
head(val)
class(val)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.nnetCoef <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Convert to a timeSeries Object with Dummy Dates
x = as.timeSeries(x)
# Fit Parameters:
fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "nnet")
fit
# Extract Fitted values:
head(slot(fit, "fitted"))
val = fitted(fit)
head(val)
class(val)
# Extract Residuals:
head(slot(fit, "residuals"))
val = residuals(fit)
head(val)
class(val)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.polymarsCoef <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Convert to a timeSeries Object with Dummy Dates
x = as.timeSeries(x)
# Fit Parameters:
fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "polymars")
fit
# Extract Fitted values:
head(slot(fit, "fitted"))
val = fitted(fit)
head(val)
class(val)
# Extract Residuals:
head(slot(fit, "residuals"))
val = residuals(fit)
head(val)
class(val)
# Return Value:
return()
}
################################################################################
fRegression/inst/unitTests/runit.terms.R 0000644 0001760 0000144 00000010524 11370220736 020167 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
# FUNCTION: REGRESSION MODELLING DESCRIPTION:
# regFit Wrapper Function for Regression Models
################################################################################
test.lmFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
lmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm")
lm = lm(Y ~ X1 + X2 + X3, data = x)
# Terms:
terms(lmfit@fit)
terms(lm)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.rlmFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
rlmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "rlm")
rlm = rlm(Y ~ X1 + X2 + X3, data = x)
# Terms:
terms(rlmfit@fit)
terms(rlm)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.glmFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
glmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "glm")
glm = glm(Y ~ X1 + X2 + X3, data = x)
# Terms:
terms(glmfit@fit)
terms(glm)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.gamFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
gamfit = regFit(Y ~ s(X1) + s(X2) + X3, data = x, use = "gam")
gam = gam(Y ~ X1 + X2 + X3, data = x)
# Terms:
terms(gamfit@fit)
terms(gam)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.pprFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
pprfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "ppr")
ppr = ppr(Y ~ X1 + X2 + X3, data = x, nterms = 2)
# Terms:
terms(pprfit@fit)
terms(ppr)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.nnetFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
nnetfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "nnet")
nnet = nnet(Y ~ X1 + X2 + X3, data = x, trace = FALSE,
size = 2, linout = TRUE)
# Terms:
terms(nnetfit@fit)
terms(nnet)
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.polymarsFit <-
function()
{
# Simulate Artificial LM:
x = regSim(model = "LM3", n = 50)
# Fit Parameters:
polymarsfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "polymars")
polymars = .polymars(Y ~ X1 + X2 + X3, data = x)
# Terms:
terms(polymarsfit@fit)
terms(polymars)
# Return Value:
return()
}
################################################################################
fRegression/inst/unitTests/runit.TermPlots.R 0000644 0001760 0000144 00000015400 12256320251 020761 0 ustar ripley users
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Copyrights (C)
# for this R-port:
# 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL
# Diethelm Wuertz
# info@rmetrics.org
# www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
# see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
# see Rmetrics's copyright file
################################################################################
# FUNCTION: REGRESSION TERM PLOTS
# termPlot Line Plot
# termPersp Perspective Plot
# termContour Contour Plot
################################################################################
test.termPlot <-
function()
{
x = regSim(model = "LM3", n = 100)
lmfit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm")
# Simulate Data - a data frame:
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Convert to a timeSeries object:
DATATS = as.timeSeries(DATA)
head(DATATS)
class(DATATS)
# Fit:
LM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "lm")
RLM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "rlm")
AM = regFit(Y ~ 1 + X1 + X2 + X3, DATATS, use = "gam")
PPR = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "ppr")
PPR4 = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "ppr", nterms = 4)
POLYMARS = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "polymars")
NNET = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "nnet")
NNET6 = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "nnet", size = 6)
## TODO: Term Plot:
## par(ask = FALSE)
## par(mfrow = c(1, 1))
## termPlot(LM)
## termPlot(RLM)
## termPlot(AM)
## termPlot(PPR)
## termPlot(POLYMARS)
## termPlot(NNET)
## TODO:
## par(ask = FALSE)
## par(mfrow = c(1, 1))
## termPlot(LM, terms = "X1")
## termPlot(RLM, terms = "X1")
## termPlot(AM, terms = "X1")
## termPlot(PPR, terms = "X1")
## termPlot(PPR4, terms = "X1")
## termPlot(POLYMARS, terms = "X1")
## termPlot(NNET, terms = "X1")
## termPlot(NNET6, terms = "X1")
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.termPersp <-
function()
{
# Simulate Data - a data frame:
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Convert to a timeSeries object:
DATATS = as.timeSeries(DATA)
head(DATATS)
class(DATATS)
# Fit:
LM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "lm")
RLM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "rlm")
AM = regFit(Y ~ 1 + s(X1)+s(X2)+s(X3), DATATS, use = "gam")
PPR = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "ppr")
PPR4 = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "ppr", nterms = 4)
POLYMARS = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "polymars")
NNET = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "nnet")
NNET6 = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "nnet", size = 6)
## TODO: Bivariate Perspective Term Plot:
## par(ask = FALSE)
## par(mfrow = c(1, 1))
## termPersp(LM, terms = c("X1", "X2"))
## termPersp(RLM, terms = c("X1", "X2"))
## termPersp(AM, terms = c("X1", "X2"))
## termPersp(PPR, terms = c("X1", "X2"))
## termPersp(PPR4, terms = c("X1", "X2"))
## termPersp(POLYMARS, terms = c("X1", "X2"))
## termPersp(NNET, terms = c("X1", "X2"))
## termPersp(NNET6, terms = c("X1", "X2"))
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.termContour <-
function()
{
# Simulate Data - a data frame:
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Convert to a timeSeries object:
DATATS = as.timeSeries(DATA)
head(DATATS)
class(DATATS)
# Fit:
LM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "lm")
RLM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "rlm")
AM = regFit(Y ~ 1 + s(X1)+s(X2)+s(X3), DATATS, use = "gam")
PPR = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "ppr")
PPR4 = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "ppr", nterms = 4)
POLYMARS = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "polymars")
NNET = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "nnet")
NNET6 = regFit(Y ~ X1 + X2 + X3, data = DATATS, use = "nnet", size = 6)
## TODO: Bivariate Contour Term Plot:
## par(ask = FALSE)
## par(mfrow = c(1, 1))
## termContour(LM, terms = c("X1", "X2"))
## termContour(RLM, terms = c("X1", "X2"))
## termContour(AM, terms = c("X1", "X2"))
## termContour(PPR, terms = c("X1", "X2"))
## termContour(PPR4, terms = c("X1", "X2"))
## termContour(POLYMARS, terms = c("X1", "X2"))
## termContour(NNET, terms = c("X1", "X2"))
## termContour(NNET6, terms = c("X1", "X2"))
# Return Value:
return()
}
# ------------------------------------------------------------------------------
test.termComparison <-
function()
{
# Simulate Data - a data frame:
DATA = regSim(model = "GAM3", n = 100)
head(DATA)
class(DATA)
# Convert to a timeSeries object:
DATATS = as.timeSeries(DATA)
head(DATATS)
class(DATATS)
## TODO:
if (FALSE) {
# Comparison:
par(ask = FALSE)
par(mfrow = c(1, 1))
LM = regFit(Y ~ 1 + X1 + X2 + X3, data = DATATS, use = "lm")
termPlot(LM)
AM = regFit(Y ~ 1 + s(X1)+s(X2)+s(X3), data = DATATS, use = "gam")
termPlot(AM)
am = gam(formula = Y ~ s(X1) + s(X2) + s(X3), data = DATA)
for (s in 1:3) {
plot(am, residuals = residuals(am), se = TRUE,
main = "AM", cex = 0.7, select = s, pch = 19); grid()
}
}
# Return Value:
return()
}
################################################################################
fRegression/tests/ 0000755 0001760 0000144 00000000000 12256336614 013742 5 ustar ripley users fRegression/tests/Rplots.pdf 0000644 0001760 0000144 00000027623 12256336623 015732 0 ustar ripley users %PDF-1.4
%ρ\r
1 0 obj
<<
/CreationDate (D:20131224175956)
/ModDate (D:20131224175956)
/Title (R Graphics Output)
/Producer (R 3.1.0)
/Creator (R)
>>
endobj
2 0 obj
<< /Type /Catalog /Pages 3 0 R >>
endobj
7 0 obj
<< /Type /Page /Parent 3 0 R /Contents 8 0 R /Resources 4 0 R >>
endobj
8 0 obj
<<
/Length 606 /Filter /FlateDecode
>>
stream
xVMo0Wz \x-H@z*pXHc;.vrX+o_b}G(f`d Ge v?Ο~N+5ЗzsYt7Gp-mq|.
e5/ vӃCVEU(Sk7If艱.zVFNVs_[Ob lC9rNQbΰ$
a卣ϰ{˙VWh\ZꚖWERHC \ꣻS\jQ"'6t1I\xX{ l@l8Հ Ӽ>?}@
U
':Æq<PO|
|ʅ'Xyca3l^+4Oyov:qY&{*ӧlMb$)3|$}P:j^&Zr®P)4~TjcwB$lXT{rXbhS],Uكef,/.Ut8g6-}6R_DE8Ҙӝ SN@r'p+乩KzAO'vǭ+*g[S̸Ŗteendstream
endobj
9 0 obj
<< /Type /Page /Parent 3 0 R /Contents 10 0 R /Resources 4 0 R >>
endobj
10 0 obj
<<
/Length 7182 /Filter /FlateDecode
>>
stream
xM-UWCpDtK!FQ 2㵞:uovnWm_}OF<^G8?ï~o>mm>;k;??ͧ]|ͧ|1?RϏ>~Og{(*Wo_*טuYv=u*W9滍wzh4xx~
klxMx5u6ۆ·xQZ}qv4}6G{Qzk>_g11-NzDsN|x+O>ʬ|WqrSpM&q52|}5Esi̖˜P55m+wrWf.M,ט<*zqtM]W'G{Ujسؽ wOjϧڷiëCڷ]rU0zݓosr54\d*}}|{u]*ط9>|Pm>gB/jOwBr
y>;^h6Z<_i)M&e>Vݿrz/(Fs9.wnN{fvx|uD;l`)#iQU3mlYh0;OE=Gg@>{ݟQy
ڞUjP{ 9磡e]?~dTbiGO4zQ_d;DK?>ΈxkzhZTr.m?qiJ=Q>{=Cz:UVw:):ZӔzhf{5wzZ]
=IF~COs|GOS6^78oGOӱn=Sأv.kܳ~P's|1o=QFOs=GTqxOuL2znL[oqَJ_ԣ'I2\>!ըGOSYOZ~d>˻Cc-۷SOz+{Yii8oCSOLώ~=Tח8!FO%zRГgvg<U:͈=h5U9Ӝfr9-]jq);Ӵ?]υjoNώ˅
|tDW3i_cG槡'Ɍ2zz?~<9q=QzRlO{2ڹ>JGOn'^pԾvd:xx)۱g=Mck?}?mn=z[=MYFx+o7F=^Sݢ;۞uۈo/_Ӝd2zw@ԟqk>2zR{=]u_w3dw4i}4
Ęoķgݭ:rv{48Wݳ?EUg?q|_HۧXOjj-iķiAF9f~=S|KXI=z֓磧NH9/CzJBNGO%A
tŷ_9/F?>H$^u{%z*G9ow2[GؑQy=-Q0*$~EO;-93Y?}8V:/98tt\qE_&^=h9o=m7Z'ϟ>;xNd?'zk߉__oo40'z*q}OO9:(`9^{Dž.ڻX_b!(K"x͗82>9U~?(~bO|w/O__ǧ?|?\<-Pm_=~mo>nTiǫ/Mx|\g?-wyfz-/V}PzpS|ӡݿCW\np?4ZxrI;sdeu:WKc,;k}^b%:꾄}`*ٷWeS_M?gznjFYК֛oT*[0)>܋6%SY5P(
>DwL, J{)Fכ*)Er6.Ⴥʈlo>w*|P>Tvb{A%|/>l|P#8C*K3T|2=4(T[9|P-{':J_y߅Vქd%Tj1|гo PQ3 >Ҕ?`NWJ9~rҢxdҜUO>ҢtҌ4P{y/*Ejc`YALJZT /4(o>? .Oy6|P+>ɇp/mR|Pia@>3A^?x"$|i\οu?GdTZ&ArWhIiKxaĴx*|P'gȹoჲ_z:l婙ڳ
z[|A}_b]f{|g!LM1<=Wxy;<=(,*
I
=%I|AGOʷ
3ϐzA'tg!3_Aw=VKAo;@_|x
?${ʿh5
GƳj)GOo>/>|P=3Gyc~>({=^"|P
Uz:O-:ϛgh=-kG0T=A??Aj~w詅Ҹ7z^AMDO:Z7gh<Ă>{|A;%k
6z:AEf>3_Agz.;1AwCORA3YɄ:9eτ>a|PˎjYzJ7,}
zAOgj}z Դ^W>eπڞB4߇ȯeix~9|m
=?Z|{Ty'y=eس?ǤჲSFO=ZF|P/
"
avѓΟz,gA-~=i`|CGOWxxwx?&
COO>|Póކo>zf}4gt5|C=zۂ'3 y ؈oO>}`Y y3P1i.=şA}\>(·_-z:8߄:uo=~W|PK{AmB}5?IH}e=5~t<Ot:UFOM\p?A~7A|=?DOo'
Oz?/|P|>h=Ҿ`{A_ߡ5|PAzWZO¦oy;sCԎDO/|P;x"C_jAՇz5z'z:>}}v