From noreply at r-forge.r-project.org Thu Jul 11 22:32:56 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 11 Jul 2013 22:32:56 +0200 (CEST) Subject: [Analogue-commits] r335 - in pkg: R inst man Message-ID: <20130711203256.A87DD1845BE@r-forge.r-project.org> Author: gsimpson Date: 2013-07-11 22:32:56 +0200 (Thu, 11 Jul 2013) New Revision: 335 Modified: pkg/R/chooseTaxa.R pkg/inst/ChangeLog pkg/man/chooseTaxa.Rd Log: adds 'na.rm = FALSE' argument to chooseTaxa Modified: pkg/R/chooseTaxa.R =================================================================== --- pkg/R/chooseTaxa.R 2013-06-04 03:04:16 UTC (rev 334) +++ pkg/R/chooseTaxa.R 2013-07-11 20:32:56 UTC (rev 335) @@ -4,12 +4,15 @@ chooseTaxa.default <- function(object, n.occ = 1, max.abun = 0, type = c("AND","OR"), value = TRUE, - ...) { + na.rm = FALSE, ...) { if(missing(type)) type <- "AND" type <- match.arg(type) - occ.want <- colSums(object > 0) >= n.occ - abun.want <- apply(object, 2, max) >= max.abun + ## issue a warning if any values in object are NA + if(any(is.na(object))) + warning("'NA's present in data; results may not be what you expect.\nConsider using 'na.rm = TRUE'.") + occ.want <- colSums(object > 0, na.rm = na.rm) >= n.occ + abun.want <- apply(object, 2, max, na.rm = na.rm) >= max.abun want <- if(isTRUE(all.equal(type, "AND"))) { occ.want & abun.want } else { Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-06-04 03:04:16 UTC (rev 334) +++ pkg/inst/ChangeLog 2013-07-11 20:32:56 UTC (rev 335) @@ -6,6 +6,10 @@ the selected species or a logical vector indicating which columns (species) met the selection criteria. + New argument `na.rm = FALSE` to control whether or not `NA`s are + excluded from the calculation of abundance and occurrence. Suggested + by Michael Burstert. + * scores.prcurve: now preserves the rownames on the `lambda` component. Modified: pkg/man/chooseTaxa.Rd =================================================================== --- pkg/man/chooseTaxa.Rd 2013-06-04 03:04:16 UTC (rev 334) +++ pkg/man/chooseTaxa.Rd 2013-07-11 20:32:56 UTC (rev 335) @@ -13,7 +13,8 @@ chooseTaxa(object, \dots) \method{chooseTaxa}{default}(object, n.occ = 1, max.abun = 0, - type = c("AND","OR"), value = TRUE, \dots) + type = c("AND","OR"), value = TRUE, na.rm = FALSE, + \dots) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -38,6 +39,8 @@ returned? If \code{TRUE}, the default, the data for the chosen taxa are returned. If \code{FALSE}, a logical vector is returned, indicating which taxa met the selection criteria.} + \item{na.rm}{logical; should missing values \code{NA}s be excluded + from the calculation of abundances and occurrence?} \item{\dots}{arguments passed on to subsequent methods.} } %\details{ From noreply at r-forge.r-project.org Fri Jul 12 00:34:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 12 Jul 2013 00:34:19 +0200 (CEST) Subject: [Analogue-commits] r336 - in pkg: . R inst Message-ID: <20130711223419.DCF4F185658@r-forge.r-project.org> Author: gsimpson Date: 2013-07-12 00:34:19 +0200 (Fri, 12 Jul 2013) New Revision: 336 Modified: pkg/DESCRIPTION pkg/NAMESPACE pkg/R/logitreg.R pkg/inst/ChangeLog Log: add option to use Firth's bias reduced method for logistic regression. Bump to 0.11-4 and adds brglm to Imports Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-07-11 20:32:56 UTC (rev 335) +++ pkg/DESCRIPTION 2013-07-11 22:34:19 UTC (rev 336) @@ -1,10 +1,10 @@ Package: analogue Type: Package Title: Analogue and weighted averaging methods for palaeoecology -Version: 0.11-3 +Version: 0.11-4 Date: $Date$ Depends: R (>= 2.15.0), vegan (>= 1.17-12), princurve, lattice -Imports: mgcv, MASS, stats, graphics, grid +Imports: mgcv, MASS, stats, graphics, grid, brglm Author: Gavin L. Simpson, Jari Oksanen Maintainer: Gavin L. Simpson Description: Fits Modern Analogue Technique and Weighted Averaging transfer Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-07-11 20:32:56 UTC (rev 335) +++ pkg/NAMESPACE 2013-07-11 22:34:19 UTC (rev 336) @@ -32,6 +32,10 @@ textGrob, unit, unit.c) +## brglm +importFrom(brglm, + brglm, + brglm.control) ## Exports export(analog, Modified: pkg/R/logitreg.R =================================================================== --- pkg/R/logitreg.R 2013-07-11 20:32:56 UTC (rev 335) +++ pkg/R/logitreg.R 2013-07-11 22:34:19 UTC (rev 336) @@ -1,10 +1,17 @@ `logitreg` <- function(object, groups, k = 1, ...) UseMethod("logitreg") -`logitreg.default` <- function(object, groups, k = 1, ...) { +`logitreg.default` <- function(object, groups, k = 1, biasReduced = FALSE, + ...) { if(!is.factor(groups)) groups <- factor(groups) lev <- levels(groups) + ## bias reduced fitting via brglm? + if(biasReduced) { + FIT <- brglm + } else { + FIT <- glm + } within <- without <- vector(mode = "list", length = length(lev)) names(within) <- names(without) <- lev models <- vector(mode = "list", length = length(lev) + 1) @@ -18,8 +25,8 @@ function(x, k) {x[order(x)[k]]}, k = k)) analogs <- rep(c(TRUE, FALSE), times = c(length(IN), length(OUT))) Dij <- c(IN, OUT) - models[[l]] <- glm(analogs ~ Dij, data = data.frame(analogs, Dij), - family = binomial(link = "logit")) + models[[l]] <- FIT(analogs ~ Dij, data = data.frame(analogs, Dij), + family = binomial(link = "logit"), ...) models[[l]]$Dij <- Dij within[[l]] <- IN without[[l]] <- OUT @@ -28,9 +35,9 @@ OUT <- do.call(c, without) analogs <- rep(c(TRUE, FALSE), times = c(length(IN), length(OUT))) Dij <- c(IN, OUT) - models[["Combined"]] <- glm(analogs ~ Dij, + models[["Combined"]] <- FIT(analogs ~ Dij, data = data.frame(analogs, Dij), - family = binomial(link = "logit")) + family = binomial(link = "logit"), ...) models[["Combined"]]$Dij <- Dij ##class(models) <- "logitreg" out <- list(models = models, groups = groups, method = NULL) Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-11 20:32:56 UTC (rev 335) +++ pkg/inst/ChangeLog 2013-07-11 22:34:19 UTC (rev 336) @@ -1,5 +1,10 @@ analogue Change Log +Version 0.11-4 + + * logitreg: fitting is now possible using Firth's bias reduction + technique via the brglm package. + Version 0.11-3 * chooseTaxa: new argument `value` controls whether the data for From noreply at r-forge.r-project.org Mon Jul 15 06:33:44 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 15 Jul 2013 06:33:44 +0200 (CEST) Subject: [Analogue-commits] r337 - pkg/man Message-ID: <20130715043344.E2D301854E9@r-forge.r-project.org> Author: gsimpson Date: 2013-07-15 06:33:44 +0200 (Mon, 15 Jul 2013) New Revision: 337 Modified: pkg/man/logitreg.Rd Log: push updated documentation to fix check issues Modified: pkg/man/logitreg.Rd =================================================================== --- pkg/man/logitreg.Rd 2013-07-11 22:34:19 UTC (rev 336) +++ pkg/man/logitreg.Rd 2013-07-15 04:33:44 UTC (rev 337) @@ -13,7 +13,7 @@ the dissimilarity between the two samples. } \usage{ -logitreg(object, groups, k = 1, ...) +logitreg(object, groups, k = 1, biasReduced = FALSE, ...) \method{logitreg}{default}(object, groups, k = 1, ...) @@ -30,8 +30,17 @@ the group membership for each sample in \code{object}.} \item{k}{numeric; the \code{k} closest analogues to use in the model fitting.} + \item{biasReduced}{logical; should Firth's method for bias reduced + logistic regression be used to fit the models? If \code{TRUE}, model + fits are performed via \code{\link{brglm}}. The default, + \code{FALSE}, indicates that models will be fitted via the standard + \code{\link{glm}} function.} \item{p}{probability at which to predict the dose needed.} - \item{\dots}{arguments passed to other methods.} + \item{\dots}{arguments passed to other methods. These arguments are + passed on to \code{\link{glm}} or \code{\link{brglm}}. See their + respective helps pages for details. Note that \code{logitreg} sets + internally the \code{formula}, \code{data}, and \code{family} + arguments and hence can not be specified by the user.} } \details{ Fits logistic regression models to each level of \code{group} to @@ -42,6 +51,13 @@ probability that two sites are analogues, conditional upon dissimilarity, that can also be done less directly using \code{\link{roc}} and \code{\link{bayesF}}. + + Often, the number of true analogues in the training set is small, both + in absolute terms and as a proportion of comparisons. Logistic + regression is known to suffer from a small-sample bias. Firth's method + of bias reduction is a general solution to this problem and is + implemented in \code{logitreg} through the \pkg{brglm} package of + Ioannis Kosmidis. } \value{ \code{logitreg} returns an object of class \code{"logitreg"}; a list @@ -65,7 +81,10 @@ its standard error. These are computed using \code{\link[MASS]{dose.p}}.} } -%\references{ ~put references to the literature/web site here ~ } +\references{ + Firth, D. (1993). Bias reduction of maximum likelihood + estimates. \emph{Biometrika} \strong{80}, 27-38. +} \author{Gavin L. Simpson} \note{ The function may generate warnings from function @@ -78,7 +97,8 @@ the reference cited therein which \strong{may} indicate problems with the fitted models, such as (quasi-)complete separation. } -\seealso{\code{\link{roc}}, \code{\link{bayesF}}, \code{\link{glm}}. } +\seealso{\code{\link{roc}}, \code{\link{bayesF}}, \code{\link{glm}}, and + \code{\link{brglm}}.} \examples{ ## load the example data data(swapdiat, swappH, rlgh) @@ -121,6 +141,11 @@ ## compute them pred <- predict(swap.lrm, newdata = swap.ana$analogs) head(pred) + +## Bias reduction +## fit the logit models to the analog object +swap.brlrm <- logitreg(swap.ana, grps, biasReduced = TRUE) +summary(swap.brlrm) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. From noreply at r-forge.r-project.org Sat Jul 20 00:38:44 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 00:38:44 +0200 (CEST) Subject: [Analogue-commits] r338 - pkg/man Message-ID: <20130719223844.6B5CB1852A7@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 00:38:44 +0200 (Sat, 20 Jul 2013) New Revision: 338 Modified: pkg/man/logitreg.Rd Log: fixing the mess I made of arguments in which methods Modified: pkg/man/logitreg.Rd =================================================================== --- pkg/man/logitreg.Rd 2013-07-15 04:33:44 UTC (rev 337) +++ pkg/man/logitreg.Rd 2013-07-19 22:38:44 UTC (rev 338) @@ -13,9 +13,10 @@ the dissimilarity between the two samples. } \usage{ -logitreg(object, groups, k = 1, biasReduced = FALSE, ...) +logitreg(object, groups, k = 1, ...) -\method{logitreg}{default}(object, groups, k = 1, ...) +\method{logitreg}{default}(object, groups, k = 1, + biasReduced = FALSE, ...) \method{logitreg}{analog}(object, groups, k = 1, ...) From noreply at r-forge.r-project.org Sat Jul 20 00:39:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 00:39:58 +0200 (CEST) Subject: [Analogue-commits] r339 - in pkg: . R inst man Message-ID: <20130719223958.5E8711851E2@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 00:39:58 +0200 (Sat, 20 Jul 2013) New Revision: 339 Added: pkg/R/plot3d.prcurve.R pkg/man/plot3d.prcurve.Rd Modified: pkg/DESCRIPTION pkg/NAMESPACE pkg/inst/ChangeLog Log: add plot3d method for prcurve Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-07-19 22:38:44 UTC (rev 338) +++ pkg/DESCRIPTION 2013-07-19 22:39:58 UTC (rev 339) @@ -3,7 +3,7 @@ Title: Analogue and weighted averaging methods for palaeoecology Version: 0.11-4 Date: $Date$ -Depends: R (>= 2.15.0), vegan (>= 1.17-12), princurve, lattice +Depends: R (>= 2.15.0), vegan (>= 1.17-12), princurve, lattice, rgl Imports: mgcv, MASS, stats, graphics, grid, brglm Author: Gavin L. Simpson, Jari Oksanen Maintainer: Gavin L. Simpson Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-07-19 22:38:44 UTC (rev 338) +++ pkg/NAMESPACE 2013-07-19 22:39:58 UTC (rev 339) @@ -4,7 +4,7 @@ ## Imports ## ## vegan -importFrom(vegan, pasteCall, eigenvals, tolerance, scores) +importFrom(vegan, pasteCall, eigenvals, tolerance, scores, ordirgl) ## mgcv importFrom(mgcv, gam, s, smoothCon, mono.con, pcls, Predict.matrix) ## MASS @@ -36,6 +36,11 @@ importFrom(brglm, brglm, brglm.control) +## rgl +importFrom(rgl, + plot3d, + lines3d, + decorate3d) ## Exports export(analog, @@ -202,6 +207,7 @@ S3method(plot, timetrack) S3method(plot, wa) S3method(plot, weightedCor) +S3method(plot3d, prcurve) S3method(reconPlot, default) S3method(reconPlot, predict.mat) S3method(reconPlot, predict.wa) Added: pkg/R/plot3d.prcurve.R =================================================================== --- pkg/R/plot3d.prcurve.R (rev 0) +++ pkg/R/plot3d.prcurve.R 2013-07-19 22:39:58 UTC (rev 339) @@ -0,0 +1,37 @@ +`plot3d.prcurve` <- function(x, data, scale = FALSE, + choices = 1:3, display = "sites", + scaling = 0, + lcol = "darkorange", lwd = 2, + decorate = TRUE, + xlab = NULL, ylab = NULL, zlab = NULL, + main = NULL, ...) { + ## check choices + if(!missing(choices)) { + lc <- length(choices) + if(lc > 3L) { + warning("More than 3 axes specified in 'choices', using the first 3.") + choices <- rep(choices, length.out = 3) + } else if(lc < 3L) { + warning("Fewer than 3 axes specified; reverting to defaults ('1:3')") + choices <- 1:3 + } + } + ## do ordination + ord <- rda(data, scale = scale) + ## process labels + if(missing(xlab) || is.null(xlab)) + xlab <- paste0("PC", choices[1]) + if(missing(ylab) || is.null(ylab)) + ylab <- paste0("PC", choices[2]) + if(missing(zlab) || is.null(zlab)) + zlab <- paste0("PC", choices[3]) + ordirgl(ord, scaling = scaling, choices = choices, display = display, + ...) + pred <- predict(ord, x[["s"]], type = "wa", + scaling = scaling)[x[["tag"]], ] + lines3d(pred[,1], pred[,2], pred[,3], col = lcol, lwd = lwd, ...) + if(decorate) { + decorate3d(xlab = xlab, ylab = ylab, zlab = zlab, ...) + } + invisible() +} Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-19 22:38:44 UTC (rev 338) +++ pkg/inst/ChangeLog 2013-07-19 22:39:58 UTC (rev 339) @@ -5,6 +5,9 @@ * logitreg: fitting is now possible using Firth's bias reduction technique via the brglm package. + * plot3d.prcurve: dynamic 3D plot of the data in PCA space with + the fitted principal curve superimposed. + Version 0.11-3 * chooseTaxa: new argument `value` controls whether the data for Added: pkg/man/plot3d.prcurve.Rd =================================================================== --- pkg/man/plot3d.prcurve.Rd (rev 0) +++ pkg/man/plot3d.prcurve.Rd 2013-07-19 22:39:58 UTC (rev 339) @@ -0,0 +1,97 @@ +\name{plot3d.prcurve} +\alias{plot3d.prcurve} + +\title{Interactive 3D plof of a principal curve in principal coordinate + space} +\description{ + Draws a 3D plot of the principal curve in principal coordinate space + using the \pkg{rgl} package and functions from \pkg{vegan}. +} +\usage{ +\method{plot3d}{prcurve}(x, data, scale = FALSE, choices = 1:3, + display = "sites", scaling = 0, lcol = "darkorange", lwd = 2, + decorate = TRUE, xlab = NULL, ylab = NULL, zlab = NULL, + main = NULL, ...) +} +%- maybe also 'usage' for other objects documented here. +\arguments{ + \item{x}{ + an object of class \code{"prcurve"} resulting from a call to + \code{\link{prcurve}}. + } + \item{data}{ + the data used to fit the principal curve. + } + \item{scale}{ + logical; should the variables in \code{data} be scaled to zero mean + and unit variance? + } + \item{choices}{ + numeric vector of length 3; the ordination axes to plot. + } + \item{display}{ + character; which scores to display. See \code{\link{scores.rda}}. + } + \item{scaling}{ + numeric; the scaling to use for the scores. Default is no scaling. + } + \item{lcol, lwd}{ + The colour and width, respectively, for the principal curve. + } + \item{decorate}{ + logical; should the plot be decorated with bounding box, axes and + labels? + } + \item{xlab, ylab, zlab, main}{ + Labels for the plot, to be drawn using \code{\link{decorate3d}}. + } + \item{\dots}{ + Arguments passed to other functions. In particular, argments are + passed to \code{\link{ordirgl}}, \code{\link{lines3d}}, and + \code{\link{decorate3d}}. + } +} +%\details{ +%% ~~ If necessary, more details than the description above ~~ +%} +\value{ + A plot is drawn on the active RGL device. If there is no active RGL + device, one is opened upon plotting. +} + +%\references{ +%% ~put references to the literature/web site here ~ +%} + +\author{ + Gavin L. Simpson +} + +%\note{ +%% ~~further notes~~ +%} + +%% ~Make other sections like Warning with \section{Warning }{....} ~ + +\seealso{ + \code{\link{ordirgl}}, \code{\link{prcurve}}, \code{decorate3d}, + \code{\link{lines3d}}. +} +\examples{ +data(abernethy) + +## Remove the Depth and Age variables +abernethy2 <- abernethy[, -(37:38)] + +## Fit the principal curve using the median complexity over +## all species +aber.pc <- prcurve(abernethy2, method = "ca", trace = TRUE, + vary = FALSE, penalty = 1.4) + +## 3D plot of data with curve superimposed +plot3d(aber.pc, abernethy2) +} +% Add one or more standard keywords, see file 'KEYWORDS' in the +% R documentation directory. +\keyword{ dynamic } +\keyword{ graphics }% __ONLY ONE__ keyword per line From noreply at r-forge.r-project.org Sat Jul 20 06:51:46 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 06:51:46 +0200 (CEST) Subject: [Analogue-commits] r340 - pkg/R Message-ID: <20130720045147.1B8BF184F80@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 06:51:46 +0200 (Sat, 20 Jul 2013) New Revision: 340 Modified: pkg/R/smoothSpline.R Log: minor formatting tweaks Modified: pkg/R/smoothSpline.R =================================================================== --- pkg/R/smoothSpline.R 2013-07-19 22:39:58 UTC (rev 339) +++ pkg/R/smoothSpline.R 2013-07-20 04:51:46 UTC (rev 340) @@ -1,10 +1,10 @@ -## smoothSpline: smootherFcn supplied to principal.curve +## smoothSpline: smootherFcn supplied to prcurve ## again a wrapper but allow us to specify De'ath's recommended ## smoother strategy -smoothSpline <- function(lambda, x, choose = TRUE, - complexity, ..., penalty = 1, - cv = FALSE, keep.data = FALSE, - control.spar = list(low = 0)) { +`smoothSpline` <- function(lambda, x, choose = TRUE, + complexity, ..., penalty = 1, + cv = FALSE, keep.data = FALSE, + control.spar = list(low = 0)) { ## complexity is the 'df' argument ## choose selects whether to use fixed complexity or allow ## underlying fitting function to return complexity @@ -26,5 +26,5 @@ res <- list(lambda = lambda, x = x, fitted.values = p, complexity = f$df, model = f) class(res) <- "prcurveSmoother" - return(res) + res } From noreply at r-forge.r-project.org Sat Jul 20 22:28:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 22:28:39 +0200 (CEST) Subject: [Analogue-commits] r341 - in pkg: R inst Message-ID: <20130720202839.21913184E39@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 22:28:38 +0200 (Sat, 20 Jul 2013) New Revision: 341 Modified: pkg/R/summary.logitreg.R pkg/inst/ChangeLog Log: shorten some of the labels in printed output Modified: pkg/R/summary.logitreg.R =================================================================== --- pkg/R/summary.logitreg.R 2013-07-20 04:51:46 UTC (rev 340) +++ pkg/R/summary.logitreg.R 2013-07-20 20:28:38 UTC (rev 341) @@ -10,9 +10,9 @@ } DF <- t(sapply(object$models, FOO, p = p, USE.NAMES = FALSE)) DF <- data.frame(DF) - names(DF) <- c("In","Out","Est.(Dij)","Std.Err", "Z-value","p-value", + names(DF) <- c("In","Out","E[Dij]","SE", "Z","p-value", paste("Dij(p=", format(p), ")", sep = ""), - "Std.Err(Dij)") + "SE (Dij)") class(DF) <- "summary.logitreg" DF } Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-20 04:51:46 UTC (rev 340) +++ pkg/inst/ChangeLog 2013-07-20 20:28:38 UTC (rev 341) @@ -5,6 +5,8 @@ * logitreg: fitting is now possible using Firth's bias reduction technique via the brglm package. + Changes to the labels in the output of the `summary` method. + * plot3d.prcurve: dynamic 3D plot of the data in PCA space with the fitted principal curve superimposed. From noreply at r-forge.r-project.org Sat Jul 20 22:30:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 22:30:29 +0200 (CEST) Subject: [Analogue-commits] r342 - in pkg: . R man Message-ID: <20130720203029.5BC57185180@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 22:30:28 +0200 (Sat, 20 Jul 2013) New Revision: 342 Added: pkg/R/smoothGAM.R pkg/man/smoothFuns.Rd Modified: pkg/NAMESPACE pkg/R/prcurve.R pkg/man/prcurve.Rd Log: add smoothGAM as a plugin for prcurve; rearrange documentation for plugins separate from main prcurve function Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-07-20 20:28:38 UTC (rev 341) +++ pkg/NAMESPACE 2013-07-20 20:30:28 UTC (rev 342) @@ -78,6 +78,7 @@ rankDC, roc, smoothSpline, + smoothGAM, sppResponse, Stratiplot, stdError, Modified: pkg/R/prcurve.R =================================================================== --- pkg/R/prcurve.R 2013-07-20 20:28:38 UTC (rev 341) +++ pkg/R/prcurve.R 2013-07-20 20:30:28 UTC (rev 342) @@ -49,11 +49,24 @@ ## Vary degrees of freedom per variable? if(missing(complexity)) { complexity <- numeric(length = m) + if (trace){ ## set up progress bar + writeLines("\n Determining initial DFs for each variable...") + pb <- txtProgressBar(max = m, style = 3) + } for(j in seq_along(complexity)) { - complexity[j] <- smoother(config$lambda, X[, j], - choose = TRUE, ...)$complexity + if(trace) { ## update progress + setTxtProgressBar(pb, j) + } + ## fit the mode & grab DF + complexity[j] <- + smoother(config$lambda, X[, j], choose = TRUE, ...)$complexity } - if(!vary) { + if (trace) { ## finalise the progress bar + close(pb) + writeLines("\n") + } + + if(!vary) { ## median complexity for all vars complexity <- rep(median(complexity), m) } } else { @@ -70,10 +83,21 @@ ## iter <- 0L if(trace) { - writeLines(strwrap(tmp <- paste(rep("-", options("width")[[1]]), - collapse = ""))) - writeLines(sprintf("Initial curve: d.sq: %.4f", config$dist)) + ##writeLines(strwrap(tmp <- paste(rep("-", options("width")[[1]]), + ## collapse = ""))) + writeLines("Fitting Principal Curve:\n") + writeLines(sprintf("Initial curve: d.sq: %.3f", config$dist)) } + + ## vary == FALSE needs to set some things for smoothers like GAM + ## which will select smoothness even if complexity stated + smooths <- c("smoothGAM") + if(!vary && (deparse(substitute(smoother)) %in% smooths)) { + CHOOSE <- TRUE + } else { + CHOOSE <- FALSE + } + ##dist.raw <- sum(diag(var(X))) * (NROW(X) - 1) dist.old <- sum(diag(var(X))) s <- matrix(NA, nrow = n, ncol = m) @@ -87,7 +111,7 @@ for(j in seq_len(m)) { smooths[[j]] <- smoother(config$lambda, X[, j], complexity = complexity[j], - choose = FALSE, ...) + choose = CHOOSE, ...) s[, j] <- fitted(smooths[[j]]) } ## @@ -108,7 +132,7 @@ if (trace) writeLines(sprintf(paste("Iteration %", max(3, nchar(maxit)), - "i: d.sq: %.4f", sep = ""), + "i: d.sq: %.3f", sep = ""), iter, config$dist)) } ## End iterations ------------------------------------------------ @@ -149,14 +173,14 @@ "CV", config$dist)) } if(trace){ - writeLines(strwrap(tmp)) + cat("\n") if(converged) { writeLines(strwrap(paste("PC Converged in", iter, "iterations."))) } else { writeLines(strwrap(paste("PC did not converge after", iter, "iterations."))) } - writeLines(strwrap(tmp)) + cat("\n") } names(config$tag) <- names(config$lambda) <- rownames(config$s) <- rownames(X) Added: pkg/R/smoothGAM.R =================================================================== --- pkg/R/smoothGAM.R (rev 0) +++ pkg/R/smoothGAM.R 2013-07-20 20:30:28 UTC (rev 342) @@ -0,0 +1,30 @@ +## smoothGAM: smoother function supplied to prcurve +## wrapper to mcgv + +`smoothGAM` <- function(lambda, x, choose = TRUE, complexity, + bs = "tp", ..., + family = gaussian(), + method = "REML", + select = FALSE, + control = list()) { + ## complexity is the 'k' argument - + ## choose selects whether to use fixed complexity or allow + ## underlying fitting function to return complexity + ord <- order(lambda) + lambda <- lambda[ord] + x <- x[ord] + if(!missing(complexity)) { + complexity <- round(complexity) ## move this out of smoothGAM + } else { + complexity <- -1 + } + f <- gam(x ~ s(lambda, k = complexity, fx = choose, bs = bs), + family = family, method = method, select = select, + control = control, ...) + p <- predict(f, x = lambda, type = "response") + edf <- sum(f$edf[f$smooth[[1]]$first.para:f$smooth[[1]]$last.para]) + 1 + res <- list(lambda = lambda, x = x, fitted.values = p, + complexity = edf, model = f) + class(res) <- "prcurveSmoother" + res +} Modified: pkg/man/prcurve.Rd =================================================================== --- pkg/man/prcurve.Rd 2013-07-20 20:28:38 UTC (rev 341) +++ pkg/man/prcurve.Rd 2013-07-20 20:30:28 UTC (rev 342) @@ -1,7 +1,6 @@ \name{prcurve} \alias{prcurve} \alias{initCurve} -\alias{smoothSpline} \alias{print.prcurve} \title{ @@ -21,10 +20,6 @@ initCurve(X, method = c("ca", "pca", "random", "user"), rank = FALSE, axis = 1, start) - -smoothSpline(lambda, x, choose = TRUE, complexity, ..., - penalty = 1, cv = FALSE, keep.data = FALSE, - control.spar = list(low = 0)) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -39,11 +34,13 @@ \item{start}{numeric vector specifying the initial curve when \code{method = "user"}. Must be of length \code{nrow(X)}.} \item{smoother}{function; the choice of smoother used to fit the - principal curve. Currently, the only option is \code{smoothSpline} - which is a wrapper to \code{\link{smooth.spline}}.} + principal curve. Currently, the only options are + \code{smoothSpline}, which is a wrapper to + \code{\link{smooth.spline}}, and \code{smoothGAM}, which is a + wrapper to \code{\link[mgcv]{gam}}.} \item{complexity}{numeric; the complexity of the fitted smooth functions. - + The function passed as argument \code{smoother} should arrange for this argument to be passed on to relevant aspect of the underlying smoother. In the case of \code{smoothSpline}, complexity is the @@ -73,26 +70,8 @@ \item{plotit}{logical; should the fitting process be plotted? If \code{TRUE}, then the fitted principal curve and observations in \code{X} are plotted in principal component space.} - \item{\dots}{arguments passed on to lower functions. In the case of - \code{prcurve}, these additional arguments are passed solely on to - the function \code{smoother}. - - In \code{smoothSpline}, \dots is passed on the the underlying - function \code{\link{smooth.spline}} and users should read that - function's help page for further details. - } - \item{lambda}{the current projection function; the position that each - sample projects to on the current principal curve. This is the - predictor variable or covariate in the smooth function.} - \item{x}{numeric vector; a column from \code{X} used as the response - variable in the smooth function. The principal curve algorithm fits - a separate scatterplot smoother (or similar smoother) to each - variable in \code{X} in turn as the response.} - \item{choose}{logical; should the underlying smoother function be - allowed to choose the degree of smooth complexity for each variable - in \code{X}?} - \item{penalty, cv, keep.data, control.spar}{arguments to - \code{\link{smooth.spline}}.} + \item{\dots}{additional arguments are passed solely on to the function + \code{smoother}.} } %\details{ %TODO @@ -128,24 +107,17 @@ %% ~Make other sections like Warning with \section{Warning }{....} ~ -%\seealso{ -%% ~~objects to See Also as \code{\link{help}}, ~~~ -%} +\seealso{ + \code{\link{smoothGAM}} and \code{\link{smoothSpline}} for the + wrappers fitting smooth functions to each variable. +} \examples{ +## Load Abernethy Forest data set data(abernethy) -## Plot the most common taxa -Stratiplot(Age ~ . - Depth, data = - chooseTaxa(abernethy, max.abun = 15, n.occ = 10), - type = c("g","poly"), sort = "wa") - ## Remove the Depth and Age variables abernethy2 <- abernethy[, -(37:38)] -## Fit PCA and CA -aber.pca <- rda(abernethy2) -aber.ca <- cca(abernethy2) - ## Fit the principal curve using the median complexity over ## all species aber.pc <- prcurve(abernethy2, method = "ca", trace = TRUE, @@ -155,6 +127,10 @@ ## for each species aber.pc2 <- prcurve(abernethy2, method = "ca", trace = TRUE, vary = TRUE, penalty = 1.4) + +## Fit principal curve using a GAM - currently slow ~10secs +aber.pc3 <- prcurve(abernethy2, method = "ca", trace = TRUE, + vary = TRUE, smoother = smoothGAM, bs = "cr") } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. Added: pkg/man/smoothFuns.Rd =================================================================== --- pkg/man/smoothFuns.Rd (rev 0) +++ pkg/man/smoothFuns.Rd 2013-07-20 20:30:28 UTC (rev 342) @@ -0,0 +1,74 @@ +\name{smoothers} +\alias{smoothSpline} +\alias{smoothGAM} + +\title{ + Smoother plugin function for use in fitting a principal curve +} + +\description{ + Functions to be used as plugins to \code{\link{prcurve}} that fit + smooth functions to each variable that, when combined, give the + principal curve. The functions act as wrappers to the main fitting + functions, which currently include \code{\link{smooth.spline}} and + \code{\link[mgcv]{gam}}. +} + +\usage{ +smoothSpline(lambda, x, choose = TRUE, complexity, ..., + penalty = 1, cv = FALSE, keep.data = FALSE, + control.spar = list(low = 0)) + +smoothGAM(lambda, x, choose = TRUE, complexity, bs = "tp", ..., + family = gaussian(), method = "REML", select = FALSE, + control = list()) +} +\arguments{ + \item{lambda}{the current projection function; the position that each + sample projects to on the current principal curve. This is the + predictor variable or covariate in the smooth function.} + \item{x}{numeric vector; used as the response variable in the smooth + function. The principal curve algorithm fits a separate scatterplot + smoother (or similar smoother) to each variable in \code{X} + in turn as the response.} + \item{choose}{logical; should the underlying smoother function be + allowed to choose the degree of smooth complexity for each + variable?} + \item{complexity}{numeric; the complexity of the fitted smooth + functions.} + \item{penalty, cv, keep.data, control.spar}{arguments to + \code{\link{smooth.spline}}.} + \item{bs, family}{arguments to \code{\link[mgcv]{s}}.} + \item{method, select, control}{arguments to \code{\link{gam}}.} + \item{\dots}{arguments passed on the the underlying function + \code{\link{smooth.spline}} and users should read that function's + help page for further details.} +} + +\value{ + An object of class \code{"prcurveSmoother"} with the following + components: + + \item{lambda}{for each observations, its arc-length from the beginning + of the curve.} + \item{x}{numeric vector of response values.} + \item{fitted.values}{numeric vector of fitted values for the + observations generated from the fitted smooth function.} + \item{complexity}{numeric; the degrees of freedom used for the smooth + function. The exact details of what these pertain to are in the help + for the respective fitting functions \code{\link{smooth.spline}} and + \code{\link[mgcv]{gam}}.} + \item{model}{the object fitted by the wrapped fitting function.} +} + +\author{ + Gavin L. Simpson +} + +\seealso{ + \code{\link{prcurve}} for how these functions are used. +} + +\keyword{multivariate} +\keyword{nonparametric} +\keyword{smooth} \ No newline at end of file From noreply at r-forge.r-project.org Sat Jul 20 22:31:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 22:31:01 +0200 (CEST) Subject: [Analogue-commits] r343 - pkg/tests/Examples Message-ID: <20130720203101.3DCF4185180@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 22:31:00 +0200 (Sat, 20 Jul 2013) New Revision: 343 Modified: pkg/tests/Examples/analogue-Ex.Rout.save Log: Update example test output Modified: pkg/tests/Examples/analogue-Ex.Rout.save =================================================================== --- pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-20 20:30:28 UTC (rev 342) +++ pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-20 20:31:00 UTC (rev 343) @@ -1,7 +1,7 @@ -R version 3.0.1 (2013-05-16) -- "Good Sport" +R version 3.0.1 RC (2013-05-11 r62732) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing -Platform: x86_64-pc-linux-gnu (64-bit) +Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -23,10 +23,11 @@ > library('analogue') Loading required package: vegan Loading required package: permute -This is vegan 2.0-7 +This is vegan 2.1-29 Loading required package: princurve Loading required package: lattice -This is analogue 0.11-3 +Loading required package: rgl +This is analogue 0.11-4 > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > cleanEx() @@ -3441,14 +3442,14 @@ Logit regression models - In Out Est.(Dij) Std.Err Z-value p-value Dij(p=0.9) Std.Err(Dij) -1 46 121 -15.8 2.80 -5.63 1.8454e-08 0.338 0.0332 -2 35 132 -32.2 6.87 -4.68 2.8597e-06 0.409 0.0200 -3 22 145 -34.1 10.19 -3.35 0.00081417 0.366 0.0264 -4 24 143 -27.2 6.74 -4.03 5.6098e-05 0.495 0.0274 -5 25 142 -16.2 3.93 -4.12 3.7464e-05 0.461 0.0494 -6 15 152 -11.0 2.71 -4.06 4.8045e-05 0.283 0.0794 -Combined 167 835 -16.2 1.41 -11.51 < 2.22e-16 0.359 0.0166 + In Out E[Dij] SE Z p-value Dij(p=0.9) SE (Dij) +1 46 121 -15.8 2.80 -5.63 1.8454e-08 0.338 0.0332 +2 35 132 -32.2 6.87 -4.68 2.8597e-06 0.409 0.0200 +3 22 145 -34.1 10.19 -3.35 0.00081417 0.366 0.0264 +4 24 143 -27.2 6.74 -4.03 5.6098e-05 0.495 0.0274 +5 25 142 -16.2 3.93 -4.12 3.7464e-05 0.461 0.0494 +6 15 152 -11.0 2.71 -4.06 4.8045e-05 0.283 0.0794 +Combined 167 835 -16.2 1.41 -11.51 < 2.22e-16 0.359 0.0166 > > ## plot the fitted logit curves @@ -3480,8 +3481,25 @@ 002.3 0.9372000 0.02182155 0.3034852 0.031319684 1.133939e-05 0.01383880 002.8 0.9732644 0.05464832 0.5834611 0.027163318 4.119295e-05 0.03144971 > +> ## Bias reduction +> ## fit the logit models to the analog object +> swap.brlrm <- logitreg(swap.ana, grps, biasReduced = TRUE) +> summary(swap.brlrm) + +Logit regression models + + In Out E[Dij] SE Z p-value Dij(p=0.9) SE (Dij) +1 46 121 -15.1 2.68 -5.63 1.7690e-08 0.331 0.0346 +2 35 132 -29.5 6.08 -4.85 1.2174e-06 0.403 0.0212 +3 22 145 -28.5 7.82 -3.65 0.00026651 0.353 0.0287 +4 24 143 -24.2 5.73 -4.22 2.4163e-05 0.485 0.0298 +5 25 142 -14.5 3.34 -4.33 1.4819e-05 0.442 0.0530 +6 15 152 -10.1 2.44 -4.15 3.3636e-05 0.260 0.0858 +Combined 167 835 -16.0 1.38 -11.55 < 2.22e-16 0.357 0.0167 + > > +> > cleanEx() > nameEx("mat") > ### * mat @@ -5101,7 +5119,7 @@ > ## the model performance statistics > performance(mod) RMSE R2 Avg.Bias Max.Bias - 2.019e+00 9.173e-01 2.854e-15 -3.815e+00 + 2.019e+00 9.173e-01 2.228e-14 -3.815e+00 > > > @@ -5953,17 +5971,97 @@ > ## for each species > aber.pc <- prcurve(abernethy2, method = "ca", trace = TRUE, + vary = TRUE, penalty = 1.4) --------------------------------------------------------------------------------- -Initial curve: d.sq: 103233.4502 -Iteration 1: d.sq: 4283.4308 -Iteration 2: d.sq: 4312.2976 -Iteration 3: d.sq: 4340.6911 -Iteration 4: d.sq: 4355.3876 -Iteration 5: d.sq: 4366.4975 -Iteration 6: d.sq: 4369.9444 --------------------------------------------------------------------------------- + + Determining initial DFs for each variable... + + | + | | 0% + | + |== | 3% + | + |==== | 6% + | + |====== | 8% + | + |======== | 11% + | + |========== | 14% + | + |============ | 17% + | + |============== | 19% + | + |================ | 22% + | + |================== | 25% + | + |=================== | 28% + | + |===================== | 31% + | + |======================= | 33% + | + |========================= | 36% + | + |=========================== | 39% + | + |============================= | 42% + | + |=============================== | 44% + | + |================================= | 47% + | + |=================================== | 50% + | + |===================================== | 53% + | + |======================================= | 56% + | + |========================================= | 58% + | + |=========================================== | 61% + | + |============================================= | 64% + | + |=============================================== | 67% + | + |================================================= | 69% + | + |=================================================== | 72% + | + |==================================================== | 75% + | + |====================================================== | 78% + | + |======================================================== | 81% + | + |========================================================== | 83% + | + |============================================================ | 86% + | + |============================================================== | 89% + | + |================================================================ | 92% + | + |================================================================== | 94% + | + |==================================================================== | 97% + | + |======================================================================| 100% + + +Fitting Principal Curve: + +Initial curve: d.sq: 103233.450 +Iteration 1: d.sq: 4283.431 +Iteration 2: d.sq: 4312.298 +Iteration 3: d.sq: 4340.691 +Iteration 4: d.sq: 4355.388 +Iteration 5: d.sq: 4366.497 +Iteration 6: d.sq: 4369.944 + PC Converged in 6 iterations. --------------------------------------------------------------------------------- + > > ## Plot the curve > plot(aber.pc, abernethy2) @@ -6033,6 +6131,125 @@ > > > cleanEx() +> nameEx("plot3d.prcurve") +> ### * plot3d.prcurve +> +> flush(stderr()); flush(stdout()) +> +> ### Name: plot3d.prcurve +> ### Title: Interactive 3D plof of a principal curve in principal coordinate +> ### space +> ### Aliases: plot3d.prcurve +> ### Keywords: dynamic graphics +> +> ### ** Examples +> +> data(abernethy) +> +> ## Remove the Depth and Age variables +> abernethy2 <- abernethy[, -(37:38)] +> +> ## Fit the principal curve using the median complexity over +> ## all species +> aber.pc <- prcurve(abernethy2, method = "ca", trace = TRUE, ++ vary = FALSE, penalty = 1.4) + + Determining initial DFs for each variable... + + | + | | 0% + | + |== | 3% + | + |==== | 6% + | + |====== | 8% + | + |======== | 11% + | + |========== | 14% + | + |============ | 17% + | + |============== | 19% + | + |================ | 22% + | + |================== | 25% + | + |=================== | 28% + | + |===================== | 31% + | + |======================= | 33% + | + |========================= | 36% + | + |=========================== | 39% + | + |============================= | 42% + | + |=============================== | 44% + | + |================================= | 47% + | + |=================================== | 50% + | + |===================================== | 53% + | + |======================================= | 56% + | + |========================================= | 58% + | + |=========================================== | 61% + | + |============================================= | 64% + | + |=============================================== | 67% + | + |================================================= | 69% + | + |=================================================== | 72% + | + |==================================================== | 75% + | + |====================================================== | 78% + | + |======================================================== | 81% + | + |========================================================== | 83% + | + |============================================================ | 86% + | + |============================================================== | 89% + | + |================================================================ | 92% + | + |================================================================== | 94% + | + |==================================================================== | 97% + | + |======================================================================| 100% + + +Fitting Principal Curve: + +Initial curve: d.sq: 103233.450 +Iteration 1: d.sq: 4853.791 +Iteration 2: d.sq: 5013.497 +Iteration 3: d.sq: 5109.973 +Iteration 4: d.sq: 5135.654 +Iteration 5: d.sq: 5137.944 + +PC Converged in 5 iterations. + +> +> ## 3D plot of data with curve superimposed +> plot3d(aber.pc, abernethy2) +> +> +> +> cleanEx() > nameEx("prcurve") > ### * prcurve > @@ -6040,58 +6257,304 @@ > > ### Name: prcurve > ### Title: Fits a principal curve to m-dimensional data -> ### Aliases: prcurve initCurve smoothSpline print.prcurve +> ### Aliases: prcurve initCurve print.prcurve > ### Keywords: multivariate nonparametric smooth > > ### ** Examples > +> ## Load Abernethy Forest data set > data(abernethy) > -> ## Plot the most common taxa -> Stratiplot(Age ~ . - Depth, data = -+ chooseTaxa(abernethy, max.abun = 15, n.occ = 10), -+ type = c("g","poly"), sort = "wa") -> > ## Remove the Depth and Age variables > abernethy2 <- abernethy[, -(37:38)] > -> ## Fit PCA and CA -> aber.pca <- rda(abernethy2) -> aber.ca <- cca(abernethy2) -> > ## Fit the principal curve using the median complexity over > ## all species > aber.pc <- prcurve(abernethy2, method = "ca", trace = TRUE, + vary = FALSE, penalty = 1.4) --------------------------------------------------------------------------------- -Initial curve: d.sq: 103233.4502 -Iteration 1: d.sq: 4853.7911 -Iteration 2: d.sq: 5013.4971 -Iteration 3: d.sq: 5109.9732 -Iteration 4: d.sq: 5135.6541 -Iteration 5: d.sq: 5137.9439 --------------------------------------------------------------------------------- + + Determining initial DFs for each variable... + + | + | | 0% + | + |== | 3% + | + |==== | 6% + | + |====== | 8% + | + |======== | 11% + | + |========== | 14% + | + |============ | 17% + | + |============== | 19% + | + |================ | 22% + | + |================== | 25% + | + |=================== | 28% + | + |===================== | 31% + | + |======================= | 33% + | + |========================= | 36% + | + |=========================== | 39% + | + |============================= | 42% + | + |=============================== | 44% + | + |================================= | 47% + | + |=================================== | 50% + | + |===================================== | 53% + | + |======================================= | 56% + | + |========================================= | 58% + | + |=========================================== | 61% + | + |============================================= | 64% + | + |=============================================== | 67% + | + |================================================= | 69% + | + |=================================================== | 72% + | + |==================================================== | 75% + | + |====================================================== | 78% + | + |======================================================== | 81% + | + |========================================================== | 83% + | + |============================================================ | 86% + | + |============================================================== | 89% + | + |================================================================ | 92% + | + |================================================================== | 94% + | + |==================================================================== | 97% + | + |======================================================================| 100% + + +Fitting Principal Curve: + +Initial curve: d.sq: 103233.450 +Iteration 1: d.sq: 4853.791 +Iteration 2: d.sq: 5013.497 +Iteration 3: d.sq: 5109.973 +Iteration 4: d.sq: 5135.654 +Iteration 5: d.sq: 5137.944 + PC Converged in 5 iterations. --------------------------------------------------------------------------------- + > > ## Fit the principal curve using varying complexity of smoothers > ## for each species > aber.pc2 <- prcurve(abernethy2, method = "ca", trace = TRUE, + vary = TRUE, penalty = 1.4) --------------------------------------------------------------------------------- -Initial curve: d.sq: 103233.4502 -Iteration 1: d.sq: 4283.4308 -Iteration 2: d.sq: 4312.2976 -Iteration 3: d.sq: 4340.6911 -Iteration 4: d.sq: 4355.3876 -Iteration 5: d.sq: 4366.4975 -Iteration 6: d.sq: 4369.9444 --------------------------------------------------------------------------------- + + Determining initial DFs for each variable... + + | + | | 0% + | + |== | 3% + | + |==== | 6% + | + |====== | 8% + | + |======== | 11% + | + |========== | 14% + | + |============ | 17% + | + |============== | 19% + | + |================ | 22% + | + |================== | 25% + | + |=================== | 28% + | + |===================== | 31% + | + |======================= | 33% + | + |========================= | 36% + | + |=========================== | 39% + | + |============================= | 42% + | + |=============================== | 44% + | + |================================= | 47% + | + |=================================== | 50% + | + |===================================== | 53% + | + |======================================= | 56% + | + |========================================= | 58% + | + |=========================================== | 61% + | + |============================================= | 64% + | + |=============================================== | 67% + | + |================================================= | 69% + | + |=================================================== | 72% + | + |==================================================== | 75% + | + |====================================================== | 78% + | + |======================================================== | 81% + | + |========================================================== | 83% + | + |============================================================ | 86% + | + |============================================================== | 89% + | + |================================================================ | 92% + | + |================================================================== | 94% + | + |==================================================================== | 97% + | + |======================================================================| 100% + + +Fitting Principal Curve: + +Initial curve: d.sq: 103233.450 +Iteration 1: d.sq: 4283.431 +Iteration 2: d.sq: 4312.298 +Iteration 3: d.sq: 4340.691 +Iteration 4: d.sq: 4355.388 +Iteration 5: d.sq: 4366.497 +Iteration 6: d.sq: 4369.944 + PC Converged in 6 iterations. --------------------------------------------------------------------------------- + > +> ## Fit principal curve using a GAM - currently slow ~10secs +> aber.pc3 <- prcurve(abernethy2, method = "ca", trace = TRUE, ++ vary = TRUE, smoother = smoothGAM, bs = "cr") + + Determining initial DFs for each variable... [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/analogue -r 343 From noreply at r-forge.r-project.org Sat Jul 20 22:59:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 22:59:04 +0200 (CEST) Subject: [Analogue-commits] r344 - pkg/inst Message-ID: <20130720205904.523F7183EEB@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 22:59:03 +0200 (Sat, 20 Jul 2013) New Revision: 344 Modified: pkg/inst/ChangeLog Log: documenta changes in prcurve's printed output and addition of smoothGAM Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-20 20:31:00 UTC (rev 343) +++ pkg/inst/ChangeLog 2013-07-20 20:59:03 UTC (rev 344) @@ -10,6 +10,22 @@ * plot3d.prcurve: dynamic 3D plot of the data in PCA space with the fitted principal curve superimposed. + * smoothGAM: new smooth function plugin for `prcurve`. Allows + fitting principal curves via individual GAM models using + `mgcv::gam` as the engine. The main advantage is that data sets + with non-Gaussian errors can now be handled more appropriately, + such as handling count data correctly. + + `smoothGAM` is much slower than `smoothSpline` currently, although + there is potential for speeding this up via pre-computing some of + the GAM terms. As an example, the Abernethy Forest example in + `?prcurve` takes ~10 seconds on my 2-year old laptop. + + * prcurve: improvements to the printed output during fitting (i.e. + with `trace = TRUE`) displays a progress bar during initial + estimates of smooth complexities. Residual variance printed to + fewer decimal places. + Version 0.11-3 * chooseTaxa: new argument `value` controls whether the data for From noreply at r-forge.r-project.org Sat Jul 20 23:00:38 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 23:00:38 +0200 (CEST) Subject: [Analogue-commits] r345 - in pkg: inst man Message-ID: <20130720210038.AF629185286@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 23:00:38 +0200 (Sat, 20 Jul 2013) New Revision: 345 Modified: pkg/inst/ChangeLog pkg/man/caterpillarPlot.Rd pkg/man/mat.Rd pkg/man/performance.Rd pkg/man/plot.mat.Rd Log: streamline some of the examples Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-20 20:59:03 UTC (rev 344) +++ pkg/inst/ChangeLog 2013-07-20 21:00:38 UTC (rev 345) @@ -26,6 +26,9 @@ estimates of smooth complexities. Residual variance printed to fewer decimal places. + * Streamlined some of the documentation to avoid runnning the same + code many times. + Version 0.11-3 * chooseTaxa: new argument `value` controls whether the data for Modified: pkg/man/caterpillarPlot.Rd =================================================================== --- pkg/man/caterpillarPlot.Rd 2013-07-20 20:59:03 UTC (rev 344) +++ pkg/man/caterpillarPlot.Rd 2013-07-20 21:00:38 UTC (rev 345) @@ -86,20 +86,17 @@ data(SumSST) ## default plot -caterpillarPlot(ImbrieKipp, SumSST) +caterpillar(ImbrieKipp, SumSST) ## customisation opttol <- - caterpillarPlot(ImbrieKipp, SumSST, col = "red2", - bg = "yellow", lcol = "blue", - xlab = expression(Summer ~ Sea ~ Surface ~ - Temperature~(degree*C))) + caterpillar(ImbrieKipp, SumSST, col = "red2", + bg = "yellow", lcol = "blue", + xlab = expression(Summer ~ Sea ~ Surface ~ + Temperature~(degree*C))) ## invisibly returns the optima and tolerances head(opttol) - -## The short form name may be easier on the typing fingers -caterpillar(ImbrieKipp, SumSST) } % Add one or more standard keywords, see file 'KEYWORDS' in the Modified: pkg/man/mat.Rd =================================================================== --- pkg/man/mat.Rd 2013-07-20 20:59:03 UTC (rev 344) +++ pkg/man/mat.Rd 2013-07-20 21:00:38 UTC (rev 345) @@ -251,7 +251,7 @@ plot(ik.mat) par(mfrow = c(1,1)) -## reconstruct for the RLGH core data +## reconstruct for the V12.122 core data coreV12.mat <- predict(ik.mat, V12.122, k = 3) coreV12.mat summary(coreV12.mat) @@ -265,29 +265,6 @@ ik.mat2 <- mat(ImbrieKipp, SumSST, method = "chord", kmax = 20) ik.mat2 -## model summary -summary(ik.mat2) - -## fitted values -fitted(ik.mat2) - -## model residuals -resid(ik.mat2) - -## draw summary plots of the model -par(mfrow = c(2,2)) -plot(ik.mat2) -par(mfrow = c(1,1)) - -## reconstruct for the V12.122 core data -coreV12.mat2 <- predict(ik.mat, V12.122, k = 3) -coreV12.mat2 -summary(coreV12.mat2) - -## draw the reconstruction -reconPlot(coreV12.mat2, use.labels = TRUE, display.error = "bars", - xlab = "Depth", ylab = "SumSST") - } \keyword{models}% at least one, from doc/KEYWORDS \keyword{multivariate}% __ONLY ONE__ keyword per line Modified: pkg/man/performance.Rd =================================================================== --- pkg/man/performance.Rd 2013-07-20 20:59:03 UTC (rev 344) +++ pkg/man/performance.Rd 2013-07-20 21:00:38 UTC (rev 345) @@ -37,9 +37,13 @@ \seealso{\code{\link{wa}}, \code{\link{predict.wa}}, \code{\link{bootstrap.wa}}.} \examples{ -## continue the example from ?wa -example(wa) +data(ImbrieKipp) +data(SumSST) +## fit the WA model +mod <- wa(SumSST ~., data = ImbrieKipp) +mod + ## the model performance statistics performance(mod) } Modified: pkg/man/plot.mat.Rd =================================================================== --- pkg/man/plot.mat.Rd 2013-07-20 20:59:03 UTC (rev 344) +++ pkg/man/plot.mat.Rd 2013-07-20 21:00:38 UTC (rev 345) @@ -92,8 +92,6 @@ ## MAT ik.mat <- mat(ImbrieKipp, SumSST, method = "chord") -ik.mat -summary(ik.mat) ## summary plot of MAT model layout(matrix(1:4, ncol = 2, byrow = TRUE)) From noreply at r-forge.r-project.org Sat Jul 20 23:08:47 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 23:08:47 +0200 (CEST) Subject: [Analogue-commits] r346 - pkg/tests/Examples Message-ID: <20130720210847.45D97185166@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 23:08:46 +0200 (Sat, 20 Jul 2013) New Revision: 346 Modified: pkg/tests/Examples/analogue-Ex.Rout.save Log: updated test checks Modified: pkg/tests/Examples/analogue-Ex.Rout.save =================================================================== --- pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-20 21:00:38 UTC (rev 345) +++ pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-20 21:08:46 UTC (rev 346) @@ -1231,14 +1231,14 @@ > data(SumSST) > > ## default plot -> caterpillarPlot(ImbrieKipp, SumSST) +> caterpillar(ImbrieKipp, SumSST) > > ## customisation > opttol <- -+ caterpillarPlot(ImbrieKipp, SumSST, col = "red2", -+ bg = "yellow", lcol = "blue", -+ xlab = expression(Summer ~ Sea ~ Surface ~ -+ Temperature~(degree*C))) ++ caterpillar(ImbrieKipp, SumSST, col = "red2", ++ bg = "yellow", lcol = "blue", ++ xlab = expression(Summer ~ Sea ~ Surface ~ ++ Temperature~(degree*C))) > > ## invisibly returns the optima and tolerances > head(opttol) @@ -1250,11 +1250,8 @@ G.saccu 26.18001 1.979651 G.mentu 26.13778 2.386584 > -> ## The short form name may be easier on the typing fingers -> caterpillar(ImbrieKipp, SumSST) > > -> > cleanEx() > nameEx("chooseTaxa") > ### * chooseTaxa @@ -3808,7 +3805,7 @@ > plot(ik.mat) > par(mfrow = c(1,1)) > -> ## reconstruct for the RLGH core data +> ## reconstruct for the V12.122 core data > coreV12.mat <- predict(ik.mat, V12.122, k = 3) > coreV12.mat @@ -3988,376 +3985,9 @@ 10 1.857 0.935 0.362 5.927 > -> ## model summary -> summary(ik.mat2) - - Modern Analogue Technique - -Call: -mat(x = ImbrieKipp, y = SumSST, method = "chord", kmax = 20) - -Percentiles of the dissimilarities for the training set: - - 1% 2% 5% 10% 20% -0.220 0.280 0.341 0.414 0.501 - -Inferences based on the mean of k-closest analogues: - - k RMSEP R2 Avg Bias Max Bias - 1 2.50 0.88 0.32 9.00 - 2 1.87 0.93 0.28 6.00 - 3 1.71 0.94 0.13 5.17 - 4 1.80 0.94 0.18 5.12 - 5 1.75 0.94 0.21 5.10 - 6 1.72 0.94 0.28 5.67 - 7 1.76 0.94 0.38 6.43 - 8 1.83 0.94 0.39 6.62 - 9 1.91 0.94 0.45 7.22 - 10 2.04 0.93 0.58 7.50 - -Inferences based on the weighted mean of k-closest analogues: - - k RMSEP R2 Avg Bias Max Bias - 1 2.50 0.88 0.32 9.00 - 2 1.89 0.93 0.26 6.18 - 3 1.73 0.94 0.14 5.47 - 4 1.77 0.94 0.17 5.38 - 5 1.75 0.94 0.19 5.37 - 6 1.71 0.94 0.22 5.49 - 7 1.71 0.94 0.25 5.63 - 8 1.76 0.94 0.25 5.69 - 9 1.78 0.94 0.27 5.84 - 10 1.86 0.94 0.36 5.93 - -Results for training set - - * (W.)Est and (W.)Resi are based on k=10-closest analogues - * minDC is the minimum distance to another sample in the training set - * min(W.)Resi is the minimum residual for a k-closest model, - where k = 1,...,10. Column k(.W) displays which k has minResi - - Obs Est Resi W.Est W.Resi minDC minResi k minW.Resi -V14.61 2.0 9.50 7.50 7.93 5.9273 0.104 5.1000 5 5.37e+00 -V17.196 5.0 9.20 4.20 6.86 1.8572 0.130 0.1667 3 4.61e-01 -V18.110 5.5 9.15 3.65 7.13 1.6290 0.134 0.5000 1 4.84e-01 -V16.227 7.0 9.00 2.00 7.16 0.1554 0.134 0.1667 3 2.62e-02 -V14.47 7.0 9.00 2.00 8.66 1.6594 0.452 0.0000 4 3.63e-02 -V23.22 10.5 8.65 -1.85 8.68 -1.8229 0.467 0.5000 3 7.43e-01 -V2.12 11.0 8.60 -2.40 5.70 -5.2971 0.119 2.4000 10 5.30e+00 -V23.29 10.0 13.65 3.65 13.33 3.3347 0.467 1.2500 2 1.41e+00 -V12.43 13.0 13.25 0.25 13.31 0.3135 0.490 0.0000 5 1.71e-01 -R9.7 12.0 14.85 2.85 14.29 2.2876 0.432 1.0000 2 4.65e-01 -A157.3 14.0 16.30 2.30 16.04 2.0418 0.407 0.5000 2 3.14e-01 -V23.81 14.5 15.45 0.95 15.40 0.8996 0.299 0.1667 3 8.08e-02 -V23.82 15.0 16.20 1.20 15.84 0.8369 0.299 0.1429 7 1.40e-01 -V12.53 14.5 17.80 3.30 17.76 3.2607 0.442 2.3571 7 2.55e+00 -V23.83 16.0 15.30 -0.70 15.02 -0.9814 0.295 0.7000 10 9.81e-01 -V12.56 18.0 20.90 2.90 20.78 2.7832 0.380 1.0000 2 1.03e+00 -A152.84 20.0 21.60 1.60 21.64 1.6374 0.361 0.1429 7 5.77e-01 -V16.50 18.0 20.50 2.50 20.28 2.2759 0.429 0.0000 1 0.00e+00 -V22.122 19.0 17.95 -1.05 17.58 -1.4223 0.429 1.0500 10 1.42e+00 -V16.41 18.5 23.90 5.40 23.64 5.1402 0.380 2.5000 1 2.50e+00 -V4.32 21.5 23.60 2.10 23.62 2.1185 0.333 1.6250 8 1.73e+00 -V12.66 21.0 21.10 0.10 21.12 0.1228 0.421 0.0000 1 0.00e+00 -V19.245 21.0 23.20 2.20 22.72 1.7177 0.331 0.1667 3 4.41e-01 -V4.8 24.0 23.35 -0.65 23.38 -0.6203 0.280 0.0000 1 0.00e+00 -A180.15 24.0 22.95 -1.05 22.99 -1.0083 0.292 0.0000 1 0.00e+00 -V18.34 23.0 24.35 1.35 24.49 1.4904 0.411 1.3500 10 1.49e+00 -V20.213 24.0 24.57 0.57 24.56 0.5565 0.326 0.0833 6 1.38e-01 -V19.222 23.0 23.00 0.00 23.06 0.0580 0.384 0.0000 10 3.83e-02 -A180.39 23.0 24.25 1.25 24.24 1.2366 0.347 0.4167 6 5.12e-01 -V16.189 24.0 25.89 1.89 25.85 1.8495 0.399 1.0000 1 1.00e+00 -V12.18 25.0 25.39 0.39 25.48 0.4751 0.289 0.3000 9 4.19e-01 -V7.67 26.0 23.45 -2.55 23.76 -2.2436 0.308 0.0000 1 0.00e+00 -V17.165 26.0 24.77 -1.23 24.80 -1.2021 0.308 0.0000 1 0.00e+00 -V19.310 26.0 23.75 -2.25 23.97 -2.0257 0.296 0.0000 1 0.00e+00 -V16.190 25.0 25.32 0.32 25.34 0.3424 0.324 0.0000 2 3.98e-02 -A153.154 26.0 25.67 -0.33 25.73 -0.2694 0.222 0.1000 2 1.11e-01 -V19.308 26.0 25.99 -0.01 25.98 -0.0223 0.222 0.0100 10 2.23e-02 -V22.172 24.5 26.72 2.22 26.71 2.2110 0.307 1.5000 1 1.50e+00 -V10.98 27.0 24.82 -2.18 24.77 -2.2349 0.330 2.0000 1 2.00e+00 -V22.219 26.2 25.65 -0.55 25.63 -0.5709 0.189 0.2000 1 2.00e-01 -V16.33 25.0 26.37 1.37 26.37 1.3703 0.493 0.7333 3 7.48e-01 -V22.204 26.5 26.80 0.30 26.74 0.2362 0.325 0.0000 6 3.12e-02 -V20.167 26.2 26.90 0.70 26.87 0.6732 0.257 0.0333 3 1.17e-02 -V10.89 26.0 26.04 0.04 26.12 0.1184 0.308 0.0400 10 1.18e-01 -V12.79 26.0 26.90 0.90 26.88 0.8813 0.249 0.3750 4 5.16e-01 -V19.216 27.0 25.27 -1.73 25.32 -1.6776 0.363 0.9000 7 9.65e-01 -V14.90 27.0 26.95 -0.05 26.89 -0.1113 0.249 0.0000 4 2.56e-02 -A180.72 27.5 26.75 -0.75 26.74 -0.7623 0.185 0.4286 7 5.18e-01 -V16.21 27.0 26.87 -0.13 26.85 -0.1453 0.247 0.0000 1 0.00e+00 -A180.76 27.0 27.15 0.15 27.16 0.1582 0.233 0.0000 6 3.86e-02 -V15.164 27.0 26.82 -0.18 26.79 -0.2081 0.257 0.0000 1 0.00e+00 -A180.78 27.0 27.20 0.20 27.19 0.1940 0.405 0.0000 5 1.03e-04 -V14.5 27.0 27.02 0.02 27.07 0.0730 0.219 0.0000 1 3.55e-15 -V3.128 29.0 26.72 -2.28 26.69 -2.3050 0.366 2.1500 2 2.17e+00 -A179.13 28.5 26.09 -2.41 26.13 -2.3699 0.327 1.8333 3 1.85e+00 -V9.31 27.5 26.87 -0.63 26.92 -0.5805 0.309 0.0000 1 0.00e+00 -V20.230 27.5 26.87 -0.63 26.90 -0.6015 0.291 0.1667 3 1.77e-01 -V20.7 27.5 27.27 -0.23 27.25 -0.2452 0.431 0.0000 2 1.06e-03 -V20.234 27.0 27.02 0.02 27.08 0.0788 0.228 0.0000 1 0.00e+00 -V18.21 27.0 26.77 -0.23 26.87 -0.1318 0.252 0.0000 1 3.55e-15 -V12.122 28.0 26.92 -1.08 26.94 -1.0561 0.228 0.9000 5 9.17e-01 - k.W -V14.61 5 -V17.196 3 -V18.110 2 -V16.227 9 -V14.47 6 -V23.22 3 -V2.12 10 -V23.29 2 -V12.43 5 -R9.7 2 -A157.3 2 -V23.81 4 -V23.82 7 -V12.53 7 -V23.83 10 -V12.56 2 -A152.84 7 -V16.50 1 -V22.122 10 -V16.41 1 -V4.32 8 -V12.66 1 -V19.245 4 -V4.8 1 -A180.15 1 -V18.34 10 -V20.213 6 -V19.222 9 -A180.39 6 -V16.189 1 -V12.18 9 -V7.67 1 -V17.165 1 -V19.310 1 -V16.190 3 -A153.154 2 -V19.308 10 -V22.172 1 -V10.98 1 -V22.219 2 -V16.33 3 -V22.204 7 -V20.167 4 -V10.89 10 -V12.79 4 -V19.216 7 -V14.90 4 -A180.72 7 -V16.21 1 -A180.76 7 -V15.164 1 -A180.78 5 -V14.5 1 -V3.128 2 -A179.13 3 -V9.31 1 -V20.230 3 -V20.7 2 -V20.234 1 -V18.21 1 -V12.122 5 - > -> ## fitted values -> fitted(ik.mat2) - - Modern Analogue Technique: Fitted values - -No. of analogues (k) : 3 -User supplied k? : FALSE -Weighted analysis? : FALSE - - V14.61 V17.196 V18.110 V16.227 V14.47 V23.22 V2.12 V23.29 - 7.167 4.833 4.667 7.167 7.667 10.000 4.833 11.833 - V12.43 R9.7 A157.3 V23.81 V23.82 V12.53 V23.83 V12.56 - 13.500 13.667 14.500 14.333 14.167 17.000 14.500 20.667 - A152.84 V16.50 V22.122 V16.41 V4.32 V12.66 V19.245 V4.8 - 22.000 17.167 15.500 23.333 24.000 21.833 20.833 23.833 - A180.15 V18.34 V20.213 V19.222 A180.39 V16.189 V12.18 V7.67 - 23.333 25.333 24.500 23.833 24.000 25.733 26.067 25.333 - V17.165 V19.310 V16.190 A153.154 V19.308 V22.172 V10.98 V22.219 - 25.333 25.333 25.000 25.733 25.733 26.400 24.667 25.667 - V16.33 V22.204 V20.167 V10.89 V12.79 V19.216 V14.90 A180.72 - 25.733 26.000 26.167 27.233 27.000 25.667 26.833 26.667 - V16.21 A180.76 V15.164 A180.78 V14.5 V3.128 A179.13 V9.31 - 26.400 27.167 26.733 26.833 27.333 26.067 26.667 27.167 - V20.230 V20.7 V20.234 V18.21 V12.122 - 27.333 27.333 27.333 27.333 27.000 > -> ## model residuals -> resid(ik.mat2) - - Modern Analogue Technique Residuals - -No. of analogues (k) : 3 -User supplied k? : FALSE -Weighted analysis? : FALSE - - V14.61 V17.196 V18.110 V16.227 V14.47 V23.22 V2.12 V23.29 - 5.1667 -0.1667 -0.8333 0.1667 0.6667 -0.5000 -6.1667 1.8333 - V12.43 R9.7 A157.3 V23.81 V23.82 V12.53 V23.83 V12.56 - 0.5000 1.6667 0.5000 -0.1667 -0.8333 2.5000 -1.5000 2.6667 - A152.84 V16.50 V22.122 V16.41 V4.32 V12.66 V19.245 V4.8 - 2.0000 -0.8333 -3.5000 4.8333 2.5000 0.8333 -0.1667 -0.1667 - A180.15 V18.34 V20.213 V19.222 A180.39 V16.189 V12.18 V7.67 - -0.6667 2.3333 0.5000 0.8333 1.0000 1.7333 1.0667 -0.6667 - V17.165 V19.310 V16.190 A153.154 V19.308 V22.172 V10.98 V22.219 - -0.6667 -0.6667 0.0000 -0.2667 -0.2667 1.9000 -2.3333 -0.5333 - V16.33 V22.204 V20.167 V10.89 V12.79 V19.216 V14.90 A180.72 - 0.7333 -0.5000 -0.0333 1.2333 1.0000 -1.3333 -0.1667 -0.8333 - V16.21 A180.76 V15.164 A180.78 V14.5 V3.128 A179.13 V9.31 - -0.6000 0.1667 -0.2667 -0.1667 0.3333 -2.9333 -1.8333 -0.3333 - V20.230 V20.7 V20.234 V18.21 V12.122 - -0.1667 -0.1667 0.3333 0.3333 -1.0000 > -> ## draw summary plots of the model -> par(mfrow = c(2,2)) -> plot(ik.mat2) -> par(mfrow = c(1,1)) -> -> ## reconstruct for the V12.122 core data -> coreV12.mat2 <- predict(ik.mat, V12.122, k = 3) -> coreV12.mat2 - - Modern Analogue Technique predictions - -Dissimilarity: chord -k-closest analogues: 3, Chosen automatically? FALSE -Weighted mean: FALSE -Bootstrap estimates: FALSE - -Model error estimates: - RMSEP r.squared avg.bias max.bias - 1.7130 0.9409 0.1328 5.1667 - -Predicted values: - 0 10 20 30 40 50 60 70 80 90 100 110 120 -27.33 27.33 27.33 26.33 25.90 25.90 25.50 25.83 26.17 26.00 27.00 27.33 26.33 - 130 140 150 160 170 180 190 200 210 220 230 240 250 -27.17 26.50 25.57 26.57 26.57 27.23 27.33 26.50 26.83 27.50 27.33 27.73 26.00 - 260 270 280 290 300 310 320 330 340 350 360 370 380 -25.90 26.33 26.50 27.33 25.90 26.33 26.33 26.17 25.83 27.07 25.90 25.90 27.50 - 390 400 410 420 430 440 450 460 470 480 490 500 510 -26.83 27.00 27.73 27.17 27.50 27.17 27.00 27.40 25.90 26.83 27.67 27.33 27.00 - 520 530 540 550 560 570 580 590 600 610 620 630 640 -27.00 25.90 26.07 26.17 27.33 27.33 26.50 25.90 27.17 27.07 26.57 27.17 27.33 - 650 660 670 680 690 700 710 720 730 740 750 760 770 -27.17 26.83 27.00 26.83 27.17 26.90 27.40 26.17 27.83 27.00 26.83 26.83 27.40 - 780 790 800 810 820 830 840 850 860 870 880 890 900 -27.67 27.33 27.33 26.50 26.83 25.50 26.17 27.00 26.00 25.90 26.33 25.00 26.83 - 910 920 930 940 950 960 970 980 990 1000 1010 1020 1030 -26.17 26.50 27.33 27.33 26.73 27.50 27.33 27.33 27.33 26.17 27.33 26.17 26.17 - 1040 1050 1060 1070 1080 1090 -27.00 26.00 26.83 25.50 26.50 26.00 -> summary(coreV12.mat2) - - Modern Analogue Technique predictions - -Dissimilarity: chord -k-closest analogues: 3, Chosen automatically? FALSE -Weighted mean: FALSE -Bootstrap estimates: FALSE - -Model error estimates: - RMSEP r.squared avg.bias max.bias - 1.7130 0.9409 0.1328 5.1667 - -Predicted values: - 0 10 20 30 40 50 60 70 80 90 100 110 120 -27.33 27.33 27.33 26.33 25.90 25.90 25.50 25.83 26.17 26.00 27.00 27.33 26.33 - 130 140 150 160 170 180 190 200 210 220 230 240 250 -27.17 26.50 25.57 26.57 26.57 27.23 27.33 26.50 26.83 27.50 27.33 27.73 26.00 - 260 270 280 290 300 310 320 330 340 350 360 370 380 -25.90 26.33 26.50 27.33 25.90 26.33 26.33 26.17 25.83 27.07 25.90 25.90 27.50 - 390 400 410 420 430 440 450 460 470 480 490 500 510 -26.83 27.00 27.73 27.17 27.50 27.17 27.00 27.40 25.90 26.83 27.67 27.33 27.00 - 520 530 540 550 560 570 580 590 600 610 620 630 640 -27.00 25.90 26.07 26.17 27.33 27.33 26.50 25.90 27.17 27.07 26.57 27.17 27.33 - 650 660 670 680 690 700 710 720 730 740 750 760 770 -27.17 26.83 27.00 26.83 27.17 26.90 27.40 26.17 27.83 27.00 26.83 26.83 27.40 - 780 790 800 810 820 830 840 850 860 870 880 890 900 -27.67 27.33 27.33 26.50 26.83 25.50 26.17 27.00 26.00 25.90 26.33 25.00 26.83 - 910 920 930 940 950 960 970 980 990 1000 1010 1020 1030 -26.17 26.50 27.33 27.33 26.73 27.50 27.33 27.33 27.33 26.17 27.33 26.17 26.17 - 1040 1050 1060 1070 1080 1090 -27.00 26.00 26.83 25.50 26.50 26.00 - -Training set assessment: - - Obs Est Resid -V14.61 2.0 7.167 5.16667 -V17.196 5.0 4.833 -0.16667 -V18.110 5.5 4.667 -0.83333 -V16.227 7.0 7.167 0.16667 -V14.47 7.0 7.667 0.66667 -V23.22 10.5 10.000 -0.50000 -V2.12 11.0 4.833 -6.16667 -V23.29 10.0 11.833 1.83333 -V12.43 13.0 13.500 0.50000 -R9.7 12.0 13.667 1.66667 -A157.3 14.0 14.500 0.50000 -V23.81 14.5 14.333 -0.16667 -V23.82 15.0 14.167 -0.83333 -V12.53 14.5 17.000 2.50000 -V23.83 16.0 14.500 -1.50000 -V12.56 18.0 20.667 2.66667 -A152.84 20.0 22.000 2.00000 -V16.50 18.0 17.167 -0.83333 -V22.122 19.0 15.500 -3.50000 -V16.41 18.5 23.333 4.83333 -V4.32 21.5 24.000 2.50000 -V12.66 21.0 21.833 0.83333 -V19.245 21.0 20.833 -0.16667 -V4.8 24.0 23.833 -0.16667 -A180.15 24.0 23.333 -0.66667 -V18.34 23.0 25.333 2.33333 -V20.213 24.0 24.500 0.50000 -V19.222 23.0 23.833 0.83333 -A180.39 23.0 24.000 1.00000 -V16.189 24.0 25.733 1.73333 -V12.18 25.0 26.067 1.06667 -V7.67 26.0 25.333 -0.66667 -V17.165 26.0 25.333 -0.66667 -V19.310 26.0 25.333 -0.66667 -V16.190 25.0 25.000 0.00000 -A153.154 26.0 25.733 -0.26667 -V19.308 26.0 25.733 -0.26667 -V22.172 24.5 26.400 1.90000 -V10.98 27.0 24.667 -2.33333 -V22.219 26.2 25.667 -0.53333 -V16.33 25.0 25.733 0.73333 -V22.204 26.5 26.000 -0.50000 -V20.167 26.2 26.167 -0.03333 -V10.89 26.0 27.233 1.23333 -V12.79 26.0 27.000 1.00000 -V19.216 27.0 25.667 -1.33333 -V14.90 27.0 26.833 -0.16667 -A180.72 27.5 26.667 -0.83333 -V16.21 27.0 26.400 -0.60000 -A180.76 27.0 27.167 0.16667 -V15.164 27.0 26.733 -0.26667 -A180.78 27.0 26.833 -0.16667 -V14.5 27.0 27.333 0.33333 -V3.128 29.0 26.067 -2.93333 -A179.13 28.5 26.667 -1.83333 -V9.31 27.5 27.167 -0.33333 -V20.230 27.5 27.333 -0.16667 -V20.7 27.5 27.333 -0.16667 -V20.234 27.0 27.333 0.33333 -V18.21 27.0 27.333 0.33333 -V12.122 28.0 27.000 -1.00000 -> -> ## draw the reconstruction -> reconPlot(coreV12.mat2, use.labels = TRUE, display.error = "bars", -+ xlab = "Depth", ylab = "SumSST") -> -> -> -> > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("mcarlo") @@ -4897,22 +4527,13 @@ > > ### ** Examples > -> ## continue the example from ?wa -> example(wa) +> data(ImbrieKipp) +> data(SumSST) +> +> ## fit the WA model +> mod <- wa(SumSST ~., data = ImbrieKipp) +> mod -wa> ## Don't show: -wa> od <- options(digits = 5) - -wa> ## End Don't show -wa> data(ImbrieKipp) - -wa> data(SumSST) - -wa> ## fit the WA model -wa> mod <- wa(SumSST ~., data = ImbrieKipp) - -wa> mod - Weighted Averaging Transfer Function Call: @@ -4927,194 +4548,6 @@ RMSE R-squared Avg. Bias Max. Bias 2.0188 0.9173 0.0000 -3.8155 - -wa> ## extract the fitted values -wa> fitted(mod) - V14.61 V17.196 V18.110 V16.227 V14.47 V23.22 V2.12 V23.29 - 3.7310 3.8599 4.1077 4.2939 8.2876 9.2444 4.0761 13.8155 - V12.43 R9.7 A157.3 V23.81 V23.82 V12.53 V23.83 V12.56 - 14.3345 16.5213 15.8044 18.7365 18.2896 18.4587 17.3886 20.4020 - A152.84 V16.50 V22.122 V16.41 V4.32 V12.66 V19.245 V4.8 - 19.9694 19.7086 18.7815 22.7892 22.4079 20.7855 22.4544 22.1814 - A180.15 V18.34 V20.213 V19.222 A180.39 V16.189 V12.18 V7.67 - 21.5623 23.3379 23.3608 22.8445 24.2193 25.6257 25.4988 23.3779 - V17.165 V19.310 V16.190 A153.154 V19.308 V22.172 V10.98 V22.219 - 23.7472 23.1125 24.5166 25.3837 25.7968 26.2585 24.1625 25.4644 - V16.33 V22.204 V20.167 V10.89 V12.79 V19.216 V14.90 A180.72 - 26.2402 25.8240 26.6780 26.3945 26.0913 25.7191 25.8627 26.3385 - V16.21 A180.76 V15.164 A180.78 V14.5 V3.128 A179.13 V9.31 - 26.7898 26.6969 26.8217 25.9874 26.8824 26.9062 26.5153 26.0680 - V20.230 V20.7 V20.234 V18.21 V12.122 - 26.6088 27.2316 26.7654 26.9459 26.8330 - -wa> ## residuals for the training set -wa> residuals(mod) - V14.61 V17.196 V18.110 V16.227 V14.47 V23.22 V2.12 V23.29 --1.730960 1.140079 1.392336 2.706094 -1.287580 1.255591 6.923869 -3.815481 - V12.43 R9.7 A157.3 V23.81 V23.82 V12.53 V23.83 V12.56 --1.334514 -4.521301 -1.804396 -4.236542 -3.289596 -3.958708 -1.388560 -2.401983 - A152.84 V16.50 V22.122 V16.41 V4.32 V12.66 V19.245 V4.8 - 0.030579 -1.708591 0.218460 -4.289225 -0.907882 0.214508 -1.454368 1.818595 - A180.15 V18.34 V20.213 V19.222 A180.39 V16.189 V12.18 V7.67 - 2.437667 -0.337938 0.639214 0.155458 -1.219277 -1.625657 -0.498810 2.622087 - V17.165 V19.310 V16.190 A153.154 V19.308 V22.172 V10.98 V22.219 - 2.252766 2.887535 0.483422 0.616261 0.203160 -1.758495 2.837538 0.735556 - V16.33 V22.204 V20.167 V10.89 V12.79 V19.216 V14.90 A180.72 --1.240175 0.675969 -0.477965 -0.394526 -0.091336 1.280861 1.137318 1.161456 - V16.21 A180.76 V15.164 A180.78 V14.5 V3.128 A179.13 V9.31 - 0.210242 0.303094 0.178331 1.012626 0.117565 2.093765 1.984665 1.432030 - V20.230 V20.7 V20.234 V18.21 V12.122 - 0.891171 0.268358 0.234590 0.054063 1.166988 - -wa> ## deshrinking coefficients -wa> coef(mod) -[1] -5.6876 1.2659 - -wa> ## diagnostics plots -wa> par(mfrow = c(1,2)) - -wa> plot(mod) - -wa> par(mfrow = c(1,1)) - -wa> ## caterpillar plot of optima and tolerances -wa> caterpillarPlot(mod) ## observed tolerances - -wa> caterpillarPlot(mod, type = "model") ## with tolerances used in WA model - -wa> ## plot diagnostics for the WA model -wa> par(mfrow = c(1,2)) - -wa> plot(mod) - -wa> par(mfrow = c(1,1)) - -wa> ## tolerance DW -wa> mod2 <- wa(SumSST ~ ., data = ImbrieKipp, tol.dw = TRUE, -wa+ min.tol = 2, small.tol = "min") - -wa> mod2 - - Weighted Averaging Transfer Function - -Call: -wa(formula = SumSST ~ ., data = ImbrieKipp, tol.dw = TRUE, small.tol = "min", - - min.tol = 2) - -Deshrinking : Inverse -Tolerance DW : Yes -No. samples : 61 -No. species : 27 - -Performance: - RMSE R-squared Avg. Bias Max. Bias - 2.0268 0.9166 0.0000 -2.4507 - - -wa> ## compare actual tolerances to working values -wa> with(mod2, rbind(tolerances, model.tol)) - O.univ G.cglob G.ruber G.tenel G.saccu G.rubes G.pacL G.pacR G.bullo -tolerances 3.7464 1.8956 1.9096 2.1248 1.9797 1.9683 3.9414 5.1812 5.828 -model.tol 3.7464 2.1248 2.1248 2.1248 2.1248 2.1248 3.9414 5.1812 5.828 - G.falco G.calid G.aequi G.gluti G.duter G.infla G.trnL G.trnR -tolerances 3.1092 2.9731 2.5617 5.8983 1.9983 4.7239 4.1617 3.4349 -model.tol 3.1092 2.9731 2.5617 5.8983 2.1248 4.7239 4.1617 3.4349 - G.crasf G.scitu G.mentu P.obliq C.nitid S.dehis G.digit Other -tolerances 3.354 3.9907 2.3866 1.5548 1.4617 3.8447 3.1089 5.1125 -model.tol 3.354 3.9907 2.3866 2.1248 2.1248 3.8447 3.1089 5.1125 - G.quin G.hirsu -tolerances 4.2688 3.9421 -model.tol 4.2688 3.9421 - -wa> ## tolerance DW -wa> mod3 <- wa(SumSST ~ ., data = ImbrieKipp, tol.dw = TRUE, -wa+ min.tol = 2, small.tol = "mean") - -wa> mod3 - - Weighted Averaging Transfer Function - -Call: -wa(formula = SumSST ~ ., data = ImbrieKipp, tol.dw = TRUE, small.tol = "mean", - - min.tol = 2) - -Deshrinking : Inverse -Tolerance DW : Yes -No. samples : 61 -No. species : 27 - -Performance: - RMSE R-squared Avg. Bias Max. Bias - 1.9924 0.9194 0.0000 -2.5992 - - -wa> ## fit a WA model with monotonic deshrinking -wa> mod4 <- wa(SumSST ~., data = ImbrieKipp, deshrink = "monotonic") - -wa> mod4 - - Weighted Averaging Transfer Function - -Call: -wa(formula = SumSST ~ ., data = ImbrieKipp, deshrink = "monotonic") - -Deshrinking : Monotonic -Tolerance DW : No -No. samples : 61 -No. species : 27 - -Performance: - RMSE R-squared Avg. Bias Max. Bias - 1.6107 0.9474 0.0000 -3.8985 - - -wa> ## extract the fitted values -wa> fitted(mod4) - V14.61 V17.196 V18.110 V16.227 V14.47 V23.22 V2.12 V23.29 - 5.8985 5.9591 6.0758 6.1635 8.1265 8.6414 6.0609 11.5633 - V12.43 R9.7 A157.3 V23.81 V23.82 V12.53 V23.83 V12.56 - 11.9710 14.0109 13.2762 16.8040 16.1689 16.4046 15.0028 19.3976 - A152.84 V16.50 V22.122 V16.41 V4.32 V12.66 V19.245 V4.8 - 18.7065 18.2923 16.8700 22.9403 22.4278 20.0083 22.4915 22.1128 - A180.15 V18.34 V20.213 V19.222 A180.39 V16.189 V12.18 V7.67 - 21.2115 23.6373 23.6652 23.0128 24.6599 26.0993 25.9754 23.6862 - V17.165 V19.310 V16.190 A153.154 V19.308 V22.172 V10.98 V22.219 - 24.1262 23.3567 24.9810 25.8625 26.2661 26.7165 24.5973 25.9417 - V16.33 V22.204 V20.167 V10.89 V12.79 V19.216 V14.90 A180.72 - 26.6986 26.2926 27.1273 26.8495 26.5532 26.1904 26.3303 26.7948 - V16.21 A180.76 V15.164 A180.78 V14.5 V3.128 A179.13 V9.31 - 27.2370 27.1459 27.2683 26.4518 27.3279 27.3512 26.9679 26.5304 - V20.230 V20.7 V20.234 V18.21 V12.122 - 27.0595 27.6704 27.2131 27.3901 27.2794 - -wa> ## residuals for the training set -wa> residuals(mod4) - V14.61 V17.196 V18.110 V16.227 V14.47 V23.22 V2.12 V23.29 --3.898451 -0.959142 -0.575776 0.836468 -1.126549 1.858557 4.939074 -1.563327 - V12.43 R9.7 A157.3 V23.81 V23.82 V12.53 V23.83 V12.56 - 1.029013 -2.010916 0.723792 -2.303976 -1.168939 -1.904646 0.997217 -1.397640 - A152.84 V16.50 V22.122 V16.41 V4.32 V12.66 V19.245 V4.8 - 1.293463 -0.292346 2.130001 -4.440318 -0.927838 0.991727 -1.491527 1.887240 - A180.15 V18.34 V20.213 V19.222 A180.39 V16.189 V12.18 V7.67 - 2.788500 -0.637275 0.334750 -0.012758 -1.659931 -2.099307 -0.975387 2.313835 - V17.165 V19.310 V16.190 A153.154 V19.308 V22.172 V10.98 V22.219 - 1.873805 2.643276 0.019001 0.137472 -0.266124 -2.216472 2.402708 0.258265 - V16.33 V22.204 V20.167 V10.89 V12.79 V19.216 V14.90 A180.72 --1.698566 0.207389 -0.927317 -0.849545 -0.553215 0.809566 0.669733 0.705244 - V16.21 A180.76 V15.164 A180.78 V14.5 V3.128 A179.13 V9.31 --0.236962 -0.145893 -0.268262 0.548197 -0.327863 1.648793 1.532122 0.969585 - V20.230 V20.7 V20.234 V18.21 V12.122 - 0.440478 -0.170385 -0.213081 -0.390149 0.720613 - -wa> ## Don't show: -wa> options(od) - -wa> ## End Don't show -wa> -wa> -wa> > > ## the model performance statistics > performance(mod) @@ -5554,218 +4987,6 @@ > > ## MAT > ik.mat <- mat(ImbrieKipp, SumSST, method = "chord") -> ik.mat - - Modern Analogue Technique - -Call: -mat(x = ImbrieKipp, y = SumSST, method = "chord") - -Percentiles of the dissimilarities for the training set: - - 1% 2% 5% 10% 20% -0.220 0.280 0.341 0.414 0.501 - -Inferences based on the mean of k-closest analogues: - - k RMSEP R2 Avg Bias Max Bias - 1 2.501 0.880 0.321 9.000 - 2 1.875 0.931 0.284 6.000 - 3 1.713 0.941 0.133 5.167 - 4 1.796 0.935 0.177 5.125 - 5 1.748 0.939 0.209 5.100 - 6 1.716 0.943 0.284 5.667 - 7 1.763 0.943 0.381 6.429 - 8 1.831 0.941 0.390 6.625 - 9 1.913 0.940 0.449 7.222 - 10 2.040 0.935 0.577 7.500 - -Inferences based on the weighted mean of k-closest analogues: - - k RMSEP R2 Avg Bias Max Bias - 1 2.501 0.880 0.321 9.000 - 2 1.894 0.929 0.263 6.183 - 3 1.733 0.940 0.138 5.470 - 4 1.773 0.937 0.173 5.384 - 5 1.750 0.939 0.187 5.366 - 6 1.709 0.942 0.218 5.493 - 7 1.712 0.942 0.254 5.635 - 8 1.758 0.940 0.253 5.693 - 9 1.777 0.939 0.274 5.838 - 10 1.857 0.935 0.362 5.927 - -> summary(ik.mat) - - Modern Analogue Technique - -Call: -mat(x = ImbrieKipp, y = SumSST, method = "chord") - -Percentiles of the dissimilarities for the training set: - - 1% 2% 5% 10% 20% -0.220 0.280 0.341 0.414 0.501 - -Inferences based on the mean of k-closest analogues: - - k RMSEP R2 Avg Bias Max Bias - 1 2.50 0.88 0.32 9.00 - 2 1.87 0.93 0.28 6.00 - 3 1.71 0.94 0.13 5.17 - 4 1.80 0.94 0.18 5.12 - 5 1.75 0.94 0.21 5.10 - 6 1.72 0.94 0.28 5.67 - 7 1.76 0.94 0.38 6.43 - 8 1.83 0.94 0.39 6.62 - 9 1.91 0.94 0.45 7.22 - 10 2.04 0.93 0.58 7.50 - -Inferences based on the weighted mean of k-closest analogues: - - k RMSEP R2 Avg Bias Max Bias - 1 2.50 0.88 0.32 9.00 - 2 1.89 0.93 0.26 6.18 - 3 1.73 0.94 0.14 5.47 - 4 1.77 0.94 0.17 5.38 - 5 1.75 0.94 0.19 5.37 - 6 1.71 0.94 0.22 5.49 - 7 1.71 0.94 0.25 5.63 - 8 1.76 0.94 0.25 5.69 - 9 1.78 0.94 0.27 5.84 - 10 1.86 0.94 0.36 5.93 - -Results for training set - - * (W.)Est and (W.)Resi are based on k=10-closest analogues - * minDC is the minimum distance to another sample in the training set - * min(W.)Resi is the minimum residual for a k-closest model, - where k = 1,...,10. Column k(.W) displays which k has minResi - - Obs Est Resi W.Est W.Resi minDC minResi k minW.Resi -V14.61 2.0 9.50 7.50 7.93 5.9273 0.104 5.1000 5 5.37e+00 -V17.196 5.0 9.20 4.20 6.86 1.8572 0.130 0.1667 3 4.61e-01 -V18.110 5.5 9.15 3.65 7.13 1.6290 0.134 0.5000 1 4.84e-01 -V16.227 7.0 9.00 2.00 7.16 0.1554 0.134 0.1667 3 2.62e-02 -V14.47 7.0 9.00 2.00 8.66 1.6594 0.452 0.0000 4 3.63e-02 -V23.22 10.5 8.65 -1.85 8.68 -1.8229 0.467 0.5000 3 7.43e-01 -V2.12 11.0 8.60 -2.40 5.70 -5.2971 0.119 2.4000 10 5.30e+00 -V23.29 10.0 13.65 3.65 13.33 3.3347 0.467 1.2500 2 1.41e+00 -V12.43 13.0 13.25 0.25 13.31 0.3135 0.490 0.0000 5 1.71e-01 -R9.7 12.0 14.85 2.85 14.29 2.2876 0.432 1.0000 2 4.65e-01 -A157.3 14.0 16.30 2.30 16.04 2.0418 0.407 0.5000 2 3.14e-01 -V23.81 14.5 15.45 0.95 15.40 0.8996 0.299 0.1667 3 8.08e-02 -V23.82 15.0 16.20 1.20 15.84 0.8369 0.299 0.1429 7 1.40e-01 -V12.53 14.5 17.80 3.30 17.76 3.2607 0.442 2.3571 7 2.55e+00 -V23.83 16.0 15.30 -0.70 15.02 -0.9814 0.295 0.7000 10 9.81e-01 -V12.56 18.0 20.90 2.90 20.78 2.7832 0.380 1.0000 2 1.03e+00 -A152.84 20.0 21.60 1.60 21.64 1.6374 0.361 0.1429 7 5.77e-01 -V16.50 18.0 20.50 2.50 20.28 2.2759 0.429 0.0000 1 0.00e+00 -V22.122 19.0 17.95 -1.05 17.58 -1.4223 0.429 1.0500 10 1.42e+00 -V16.41 18.5 23.90 5.40 23.64 5.1402 0.380 2.5000 1 2.50e+00 -V4.32 21.5 23.60 2.10 23.62 2.1185 0.333 1.6250 8 1.73e+00 -V12.66 21.0 21.10 0.10 21.12 0.1228 0.421 0.0000 1 0.00e+00 -V19.245 21.0 23.20 2.20 22.72 1.7177 0.331 0.1667 3 4.41e-01 -V4.8 24.0 23.35 -0.65 23.38 -0.6203 0.280 0.0000 1 0.00e+00 -A180.15 24.0 22.95 -1.05 22.99 -1.0083 0.292 0.0000 1 0.00e+00 -V18.34 23.0 24.35 1.35 24.49 1.4904 0.411 1.3500 10 1.49e+00 -V20.213 24.0 24.57 0.57 24.56 0.5565 0.326 0.0833 6 1.38e-01 -V19.222 23.0 23.00 0.00 23.06 0.0580 0.384 0.0000 10 3.83e-02 -A180.39 23.0 24.25 1.25 24.24 1.2366 0.347 0.4167 6 5.12e-01 -V16.189 24.0 25.89 1.89 25.85 1.8495 0.399 1.0000 1 1.00e+00 -V12.18 25.0 25.39 0.39 25.48 0.4751 0.289 0.3000 9 4.19e-01 -V7.67 26.0 23.45 -2.55 23.76 -2.2436 0.308 0.0000 1 0.00e+00 -V17.165 26.0 24.77 -1.23 24.80 -1.2021 0.308 0.0000 1 0.00e+00 -V19.310 26.0 23.75 -2.25 23.97 -2.0257 0.296 0.0000 1 0.00e+00 -V16.190 25.0 25.32 0.32 25.34 0.3424 0.324 0.0000 2 3.98e-02 -A153.154 26.0 25.67 -0.33 25.73 -0.2694 0.222 0.1000 2 1.11e-01 -V19.308 26.0 25.99 -0.01 25.98 -0.0223 0.222 0.0100 10 2.23e-02 -V22.172 24.5 26.72 2.22 26.71 2.2110 0.307 1.5000 1 1.50e+00 -V10.98 27.0 24.82 -2.18 24.77 -2.2349 0.330 2.0000 1 2.00e+00 -V22.219 26.2 25.65 -0.55 25.63 -0.5709 0.189 0.2000 1 2.00e-01 -V16.33 25.0 26.37 1.37 26.37 1.3703 0.493 0.7333 3 7.48e-01 -V22.204 26.5 26.80 0.30 26.74 0.2362 0.325 0.0000 6 3.12e-02 -V20.167 26.2 26.90 0.70 26.87 0.6732 0.257 0.0333 3 1.17e-02 -V10.89 26.0 26.04 0.04 26.12 0.1184 0.308 0.0400 10 1.18e-01 -V12.79 26.0 26.90 0.90 26.88 0.8813 0.249 0.3750 4 5.16e-01 -V19.216 27.0 25.27 -1.73 25.32 -1.6776 0.363 0.9000 7 9.65e-01 -V14.90 27.0 26.95 -0.05 26.89 -0.1113 0.249 0.0000 4 2.56e-02 -A180.72 27.5 26.75 -0.75 26.74 -0.7623 0.185 0.4286 7 5.18e-01 -V16.21 27.0 26.87 -0.13 26.85 -0.1453 0.247 0.0000 1 0.00e+00 -A180.76 27.0 27.15 0.15 27.16 0.1582 0.233 0.0000 6 3.86e-02 -V15.164 27.0 26.82 -0.18 26.79 -0.2081 0.257 0.0000 1 0.00e+00 -A180.78 27.0 27.20 0.20 27.19 0.1940 0.405 0.0000 5 1.03e-04 -V14.5 27.0 27.02 0.02 27.07 0.0730 0.219 0.0000 1 3.55e-15 -V3.128 29.0 26.72 -2.28 26.69 -2.3050 0.366 2.1500 2 2.17e+00 -A179.13 28.5 26.09 -2.41 26.13 -2.3699 0.327 1.8333 3 1.85e+00 -V9.31 27.5 26.87 -0.63 26.92 -0.5805 0.309 0.0000 1 0.00e+00 -V20.230 27.5 26.87 -0.63 26.90 -0.6015 0.291 0.1667 3 1.77e-01 -V20.7 27.5 27.27 -0.23 27.25 -0.2452 0.431 0.0000 2 1.06e-03 -V20.234 27.0 27.02 0.02 27.08 0.0788 0.228 0.0000 1 0.00e+00 -V18.21 27.0 26.77 -0.23 26.87 -0.1318 0.252 0.0000 1 3.55e-15 -V12.122 28.0 26.92 -1.08 26.94 -1.0561 0.228 0.9000 5 9.17e-01 - k.W -V14.61 5 -V17.196 3 -V18.110 2 -V16.227 9 -V14.47 6 -V23.22 3 -V2.12 10 -V23.29 2 -V12.43 5 -R9.7 2 -A157.3 2 -V23.81 4 -V23.82 7 -V12.53 7 -V23.83 10 -V12.56 2 -A152.84 7 -V16.50 1 -V22.122 10 -V16.41 1 -V4.32 8 -V12.66 1 -V19.245 4 -V4.8 1 -A180.15 1 -V18.34 10 -V20.213 6 -V19.222 9 -A180.39 6 -V16.189 1 -V12.18 9 -V7.67 1 -V17.165 1 -V19.310 1 -V16.190 3 -A153.154 2 -V19.308 10 -V22.172 1 -V10.98 1 -V22.219 2 -V16.33 3 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/analogue -r 346 From noreply at r-forge.r-project.org Sat Jul 20 23:41:14 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 23:41:14 +0200 (CEST) Subject: [Analogue-commits] r347 - pkg/man Message-ID: <20130720214114.DE00F183DA1@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 23:41:14 +0200 (Sat, 20 Jul 2013) New Revision: 347 Modified: pkg/man/prcurve.Rd Log: stop the smoothGAM example from running as it is too slow at the moment Modified: pkg/man/prcurve.Rd =================================================================== --- pkg/man/prcurve.Rd 2013-07-20 21:08:46 UTC (rev 346) +++ pkg/man/prcurve.Rd 2013-07-20 21:41:14 UTC (rev 347) @@ -128,10 +128,12 @@ aber.pc2 <- prcurve(abernethy2, method = "ca", trace = TRUE, vary = TRUE, penalty = 1.4) +\dontrun{ ## Fit principal curve using a GAM - currently slow ~10secs aber.pc3 <- prcurve(abernethy2, method = "ca", trace = TRUE, vary = TRUE, smoother = smoothGAM, bs = "cr") } +} % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. \keyword{multivariate} From noreply at r-forge.r-project.org Sat Jul 20 23:42:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 20 Jul 2013 23:42:04 +0200 (CEST) Subject: [Analogue-commits] r348 - pkg/tests/Examples Message-ID: <20130720214204.18594185ABA@r-forge.r-project.org> Author: gsimpson Date: 2013-07-20 23:42:03 +0200 (Sat, 20 Jul 2013) New Revision: 348 Modified: pkg/tests/Examples/analogue-Ex.Rout.save Log: update example test output following r347 Modified: pkg/tests/Examples/analogue-Ex.Rout.save =================================================================== --- pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-20 21:41:14 UTC (rev 347) +++ pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-20 21:42:03 UTC (rev 348) @@ -5680,99 +5680,11 @@ PC Converged in 6 iterations. > -> ## Fit principal curve using a GAM - currently slow ~10secs -> aber.pc3 <- prcurve(abernethy2, method = "ca", trace = TRUE, -+ vary = TRUE, smoother = smoothGAM, bs = "cr") - - Determining initial DFs for each variable... - - | - | | 0% - | - |== | 3% - | - |==== | 6% - | - |====== | 8% - | - |======== | 11% - | - |========== | 14% - | - |============ | 17% - | - |============== | 19% - | - |================ | 22% - | - |================== | 25% - | - |=================== | 28% - | - |===================== | 31% - | - |======================= | 33% - | - |========================= | 36% - | - |=========================== | 39% - | - |============================= | 42% - | - |=============================== | 44% - | - |================================= | 47% - | - |=================================== | 50% - | - |===================================== | 53% - | - |======================================= | 56% - | - |========================================= | 58% - | - |=========================================== | 61% - | - |============================================= | 64% - | - |=============================================== | 67% - | - |================================================= | 69% - | - |=================================================== | 72% - | - |==================================================== | 75% - | - |====================================================== | 78% - | - |======================================================== | 81% - | - |========================================================== | 83% - | - |============================================================ | 86% - | - |============================================================== | 89% - | - |================================================================ | 92% - | - |================================================================== | 94% - | - |==================================================================== | 97% - | - |======================================================================| 100% - - -Fitting Principal Curve: - -Initial curve: d.sq: 103233.450 -Iteration 1: d.sq: 5266.091 -Iteration 2: d.sq: 4939.941 -Iteration 3: d.sq: 4946.650 -Iteration 4: d.sq: 5000.879 -Iteration 5: d.sq: 5004.138 - -PC Converged in 5 iterations. - +> ## Not run: +> ##D ## Fit principal curve using a GAM - currently slow ~10secs +> ##D aber.pc3 <- prcurve(abernethy2, method = "ca", trace = TRUE, +> ##D vary = TRUE, smoother = smoothGAM, bs = "cr") +> ## End(Not run) > > > @@ -7443,7 +7355,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 35.017 0.416 38.804 0.003 0.001 +Time elapsed: 23.821 0.291 25.103 0.001 0.004 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Sun Jul 21 22:50:38 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 21 Jul 2013 22:50:38 +0200 (CEST) Subject: [Analogue-commits] r349 - in pkg: . R inst man Message-ID: <20130721205038.9CF5D1811AF@r-forge.r-project.org> Author: gsimpson Date: 2013-07-21 22:50:38 +0200 (Sun, 21 Jul 2013) New Revision: 349 Added: pkg/R/residuals.prcurve.R pkg/man/residuals.prcurve.Rd Modified: pkg/NAMESPACE pkg/R/prcurve.R pkg/inst/ChangeLog pkg/man/prcurve.Rd Log: add a residuals method for prcurve; changes to prcurve as a result Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-07-20 21:42:03 UTC (rev 348) +++ pkg/NAMESPACE 2013-07-21 20:50:38 UTC (rev 349) @@ -184,6 +184,7 @@ S3method(residuals, bootstrap.mat) S3method(residuals, mat) S3method(residuals, pcr) +S3method(residuals, prcurve) ## plotting S3method(caterpillarPlot, default) S3method(caterpillarPlot, data.frame) Modified: pkg/R/prcurve.R =================================================================== --- pkg/R/prcurve.R 2013-07-20 21:42:03 UTC (rev 348) +++ pkg/R/prcurve.R 2013-07-21 20:50:38 UTC (rev 349) @@ -182,6 +182,9 @@ } cat("\n") } + ## fit a PCA and store in result + ord <- rda(X) + ## prepare objects for return names(config$tag) <- names(config$lambda) <- rownames(config$s) <- rownames(X) colnames(config$s) <- names(complexity) <- colnames(X) @@ -193,8 +196,10 @@ config$smooths <- smooths names(config$smooths) <- colnames(X) config$call <- match.call() + config$ordination <- ord + config$data <- X class(config) <- c("prcurve") - return(config) + config } `print.prcurve` <- function(x, digits = max(3, getOption("digits") - 3), Added: pkg/R/residuals.prcurve.R =================================================================== --- pkg/R/residuals.prcurve.R (rev 0) +++ pkg/R/residuals.prcurve.R 2013-07-21 20:50:38 UTC (rev 349) @@ -0,0 +1,24 @@ +`residuals.prcurve` <- function(object, + which = c("distance","raw","smooths","pca"), + ...) { + which <- match.arg(which) + + ## predict locations of curve in PCA space and exctract the + ## site scores for each sample + if( isTRUE(all.equal(which, "pca"))) { + p <- predict(object[["ordination"]], object[["s"]], + which = "wa", scaling = 1) ## site scaling + scrs <- scores(object[["ordination"]], scaling = 1, + choices = seq_along(eigenvals(object[["ordination"]])), + display = "sites") + } + + res <- switch(which, + distance = diag(distance(object$s, object$data, + method = "euclidean")), + raw = object[["data"]] - object[["s"]], + smooths = sapply(object$smooths, function(x, ...) + residuals(x$model, ...), ...), + pca = p - scrs) + res +} Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-20 21:42:03 UTC (rev 348) +++ pkg/inst/ChangeLog 2013-07-21 20:50:38 UTC (rev 349) @@ -26,6 +26,10 @@ estimates of smooth complexities. Residual variance printed to fewer decimal places. + * residuals.prcurve: new `residuals` method for principal curves + extracting or computing various types of residual for a fitted + curve. + * Streamlined some of the documentation to avoid runnning the same code many times. Modified: pkg/man/prcurve.Rd =================================================================== --- pkg/man/prcurve.Rd 2013-07-20 21:42:03 UTC (rev 348) +++ pkg/man/prcurve.Rd 2013-07-21 20:50:38 UTC (rev 349) @@ -92,6 +92,10 @@ \item{complexity}{numeric vector; the complexity of the smoother fitted to each variable in \code{X}.} \item{call}{the matched call.} + \item{ordination}{an object of class \code{"rda"}, the result of a + call to \code{\link{rda}}. This is a principal components analysis + of the input data \code{X}.} + \item{data}{a copy of the data used to fit the principal curve.} } %\references{ %% ~put references to the literature/web site here ~ Added: pkg/man/residuals.prcurve.Rd =================================================================== --- pkg/man/residuals.prcurve.Rd (rev 0) +++ pkg/man/residuals.prcurve.Rd 2013-07-21 20:50:38 UTC (rev 349) @@ -0,0 +1,105 @@ +\name{residuals.prcurve} +\alias{residuals.prcurve} +\alias{resid.prcurve} + +\title{ + Residuals of a principal curve fit. +} +\description{ + Returns various representations of the residuals of a principal curve + fit. +} +\usage{ +\method{residuals}{prcurve}(object, which = c("distance", "raw", "smooths", "pca"), + ...) +} + +\arguments{ + \item{object}{an object of class \code{"prcurve"}, the result of a + call to \code{\link{prcurve}}.} + \item{which}{character; the type of residuals to return. See Details.} + \item{\dots}{arguments passed to other methods. See Details.} +} +\details{ + Various types of residual are available for the principal curve. In a + departure from the usual convention, which residuals are returned is + controlled via the \code{which} argument. This is to allow users to + pass a \code{type} argument to the \code{residuals} method for the + function used to fit the individual smooth functions when \code{which + = "smooths"}. + + The types of residuals available are + + \describe{ + \item{\code{"distance"}}{the default residual for a principal + curve. This residual is taken as the Euclidean distance between each + observations and the point on the principal curve to which it + projects, in full multivariate space.} + \item{\code{"raw"}}{raw residuals are the basis for + \code{"distance"} residuals, and are the difference between the + observed and fitted values (position on the curve) for each + observation in terms of each variable in the data set. These + residuals are in the form of a matrix with number of observation + \emph{rows} and number of variables \emph{cols}.} + \item{\code{"smooths"}}{these residuals are the result of calling + \code{residuals()} on each of the smooth models fitted to the + individual variables. See below for further details. A matrix of + the same dimensions as for \code{which = "raw"} is returned.} + \item{\code{"pca"}}{similar to the raw residuals, but expressed in + terms of the principal components of the input data. Hence these + residuals are the difference between each observation's location + in PCA space and their corresponding location on the curve.} + } + + For \code{"smooths"} residuals, what is returned is governed by the + \code{residuals} method available for the smooth model fitted to the + individual variables. For principal curves fitted using the + \code{\link{smoothSpline}} plugin, see + \code{\link{smooth.spline}}. For principal curves fitted via the + \code{\link{smoothGAM}} plugin, see + \code{\link[mgcv]{residuals.gam}}. + + \dots can be used to pass additional arguments to these + \code{residuals} methods. In particular, the \code{type} argument is + commonly used to choose which type of residual is returned by the + specific methods. + + In the case of principal curves fitted using the plugin + \code{\link{smoothSpline}}, residuals for \code{which = "smooths"} are + only available if the the additional argument \code{keep.data} was + specified during fitting via \code{\link{prcurve}}. See the examples + for an illustration of this usage. +} +\value{ + A vector of residual distances (\code{which = "distance"}) or a matrix + of residuals (for the other options). +} + +\author{Gavin L. Simpson} + +\seealso{ + \code{\link{prcurve}} for fitting a principal curve. +} + +\examples{ + ## Load Abernethy Forest data set + data(abernethy) + + ## Remove the Depth and Age variables + abernethy2 <- abernethy[, -(37:38)] + + ## Fit the principal curve, preserving the data in the smooth.spline + ## smooth functions fitted via keep.data = TRUE + aber.pc <- prcurve(abernethy2, method = "ca", keep.data = TRUE) + + ## default "distance" residuals + resid(aber.pc) + + ## residuals from the underlying smooth models, also illustrates + ## how to select specific types of residual from the individual + ## method using argument 'type' + resid(aber.pc, which = "smooths", type = "deviance") + +} + +\keyword{ methods } From noreply at r-forge.r-project.org Mon Jul 22 00:50:59 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 22 Jul 2013 00:50:59 +0200 (CEST) Subject: [Analogue-commits] r350 - in pkg: R inst man Message-ID: <20130721225059.EE549184C51@r-forge.r-project.org> Author: gsimpson Date: 2013-07-22 00:50:59 +0200 (Mon, 22 Jul 2013) New Revision: 350 Modified: pkg/R/lines.prcurve.R pkg/R/plot.prcurve.R pkg/inst/ChangeLog pkg/man/plot.prcurve.Rd Log: improvements to plot and lines methods following addition of components ordination and data to object returned from prcurve Modified: pkg/R/lines.prcurve.R =================================================================== --- pkg/R/lines.prcurve.R 2013-07-21 20:50:38 UTC (rev 349) +++ pkg/R/lines.prcurve.R 2013-07-21 22:50:59 UTC (rev 350) @@ -1,13 +1,13 @@ -lines.prcurve <- function(x, data, axes = 1:2, segments = TRUE, +lines.prcurve <- function(x, axes = 1:2, scaling = 0, segments = TRUE, col = "red", col.seg = "forestgreen", lwd = 2, lwd.seg = 1, ...) { - scl <- 0 - ordi <- rda(data) - pred <- predict(ordi, x$s, type = "wa", scaling = scl)[, axes] - scrs <- scores(ordi, display = "sites", scaling = scl, choices = axes) + pred <- predict(x$ordination, x$s, type = "wa", + scaling = scaling)[, axes] + scrs <- scores(x$ordination, display = "sites", scaling = scaling, + choices = axes) if(segments) - segments(scrs[, 1], scrs[, 2], pred[, 1], pred[, 2], + segments(scrs[, 1], scrs[, 2], pred[, 1], pred[, 2], col = col.seg, lwd = lwd.seg) lines(pred[x$tag, 1:2], lwd = lwd, col = col, ...) Modified: pkg/R/plot.prcurve.R =================================================================== --- pkg/R/plot.prcurve.R 2013-07-21 20:50:38 UTC (rev 349) +++ pkg/R/plot.prcurve.R 2013-07-21 22:50:59 UTC (rev 350) @@ -1,17 +1,17 @@ ## plot a principle curve in PCA space -plot.prcurve <- function(x, data, axes = 1:2, +plot.prcurve <- function(x, axes = 1:2, + scaling = 0, segments = TRUE, col = "red", col.seg = "forestgreen", lwd = 2, lwd.seg = 1, ...) { - scl <- 0 - ordi <- rda(data) - pred <- predict(ordi, x$s, type = "wa", scaling = scl)[,axes] - scrs <- scores(ordi, display = "sites", scaling = scl, + pred <- predict(x$ordination, x$s, type = "wa", + scaling = scaling)[,axes] + scrs <- scores(x$ordination, display = "sites", scaling = scaling, choices = axes) xlim <- range(scrs[,1], pred[,1]) ylim <- range(scrs[,2], pred[,2]) - plot(ordi, display = "sites", scaling = scl, type = "n", + plot(x$ordination, display = "sites", scaling = scaling, type = "n", xlim = xlim, ylim = ylim, choices = axes, ...) points(scrs, ...) if(segments) Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-21 20:50:38 UTC (rev 349) +++ pkg/inst/ChangeLog 2013-07-21 22:50:59 UTC (rev 350) @@ -26,10 +26,23 @@ estimates of smooth complexities. Residual variance printed to fewer decimal places. + Now returns components `ordination` and `data`, the PCA ordination + (resulting from `rda()`) and the original data used to fit the + curve, respectively. This simplifies the `plot` and `lines` + methods for example. + * residuals.prcurve: new `residuals` method for principal curves extracting or computing various types of residual for a fitted curve. + * plot.prcurve, lines.prcurve: much improved following the + addition of new components in the object returned by `prcurve`. + No longer need to supply the original data used to fit the curve. + + The scaling to use for the plot can now be specified via new + argument `scaling`. This makes the `lines` method more broadly + useful. + * Streamlined some of the documentation to avoid runnning the same code many times. Modified: pkg/man/plot.prcurve.Rd =================================================================== --- pkg/man/plot.prcurve.Rd 2013-07-21 20:50:38 UTC (rev 349) +++ pkg/man/plot.prcurve.Rd 2013-07-21 22:50:59 UTC (rev 350) @@ -9,20 +9,24 @@ underlying data in a biplot. } \usage{ -\method{plot}{prcurve}(x, data, axes = 1:2, segments = TRUE, +\method{plot}{prcurve}(x, axes = 1:2, scaling = 0, segments = TRUE, col = "red", col.seg = "forestgreen", lwd = 2, lwd.seg = 1, ...) -\method{lines}{prcurve}(x, data, axes = 1:2, segments = TRUE, +\method{lines}{prcurve}(x, axes = 1:2, scaling = 0, segments = TRUE, col = "red", col.seg = "forestgreen", lwd = 2, lwd.seg = 1, ...) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{x}{an object of class \code{"prcurve"}.} - \item{data}{The data the principal curve was fitted to.} \item{axes}{numeric vector of length 2; this is passed to the - \code{choices} argument of the \code{\link[vegan]{scores}} function.} + \code{choices} argument of the \code{\link[vegan]{scores}} + function.} + \item{scaling}{numeric; the scaling to use. See + \code{\link{scores.rda}} for the available options. The default is + not to scale the scores, but \code{scaling = 1} might be a useful + alternative.} \item{segments}{logical; should segments be drawn between the observed points to the location on the principal curve on to which they project.} @@ -46,11 +50,11 @@ \author{ Gavin L. Simpson } -\note{ - Note that all plotting is done using \code{scaling == 0} at the - moment, and as such the \code{lines()} method only makes sense when - added to an underlying PCA in the same scaling. See the Examples. -} +%% \note{ +%% Note that all plotting is done using \code{scaling == 0} at the +%% moment, and as such the \code{lines()} method only makes sense when +%% added to an underlying PCA in the same scaling. See the Examples. +%% } %% ~Make other sections like Warning with \section{Warning }{....} ~ @@ -71,13 +75,13 @@ vary = TRUE, penalty = 1.4) ## Plot the curve -plot(aber.pc, abernethy2) +plot(aber.pc) ## The lines() method can be used to add the principal curve to an ## existing plot ord <- rda(abernethy2) -plot(ord) -lines(aber.pc, data = abernethy2) +plot(ord, scaling = 1) +lines(aber.pc, scaling = 1) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. From noreply at r-forge.r-project.org Thu Jul 25 18:55:27 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 25 Jul 2013 18:55:27 +0200 (CEST) Subject: [Analogue-commits] r351 - in pkg: R inst tests/Examples Message-ID: <20130725165527.E86DC184976@r-forge.r-project.org> Author: gsimpson Date: 2013-07-25 18:55:27 +0200 (Thu, 25 Jul 2013) New Revision: 351 Modified: pkg/R/chooseTaxa.R pkg/inst/ChangeLog pkg/tests/Examples/analogue-Ex.Rout.save Log: fix warning, and dropping of empty dimensions Modified: pkg/R/chooseTaxa.R =================================================================== --- pkg/R/chooseTaxa.R 2013-07-21 22:50:59 UTC (rev 350) +++ pkg/R/chooseTaxa.R 2013-07-25 16:55:27 UTC (rev 351) @@ -9,7 +9,7 @@ type <- "AND" type <- match.arg(type) ## issue a warning if any values in object are NA - if(any(is.na(object))) + if(!na.rm && any(is.na(object))) warning("'NA's present in data; results may not be what you expect.\nConsider using 'na.rm = TRUE'.") occ.want <- colSums(object > 0, na.rm = na.rm) >= n.occ abun.want <- apply(object, 2, max, na.rm = na.rm) >= max.abun @@ -21,7 +21,7 @@ if(value) { rname <- rownames(object) cname <- colnames(object) - object <- object[, want] + object <- object[, want, drop = FALSE] rownames(object) <- rname colnames(object) <- cname[want] } else { Modified: pkg/inst/ChangeLog =================================================================== --- pkg/inst/ChangeLog 2013-07-21 22:50:59 UTC (rev 350) +++ pkg/inst/ChangeLog 2013-07-25 16:55:27 UTC (rev 351) @@ -43,6 +43,13 @@ argument `scaling`. This makes the `lines` method more broadly useful. + * chooseTaxa: would drop empty dimensions if conditions resulted + in just a single taxon being selected. Reported by Michael + Burstert. + + The warning about `NA`s was also being issued even if + `na.rm = TRUE` was used. Now fixed. + * Streamlined some of the documentation to avoid runnning the same code many times. Modified: pkg/tests/Examples/analogue-Ex.Rout.save =================================================================== --- pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-21 22:50:59 UTC (rev 350) +++ pkg/tests/Examples/analogue-Ex.Rout.save 2013-07-25 16:55:27 UTC (rev 351) @@ -6022,6 +6022,454 @@ > > > cleanEx() +> nameEx("residuals.prcurve") +> ### * residuals.prcurve +> +> flush(stderr()); flush(stdout()) +> +> ### Name: residuals.prcurve +> ### Title: Residuals of a principal curve fit. +> ### Aliases: residuals.prcurve resid.prcurve +> ### Keywords: methods +> +> ### ** Examples +> +> ## Load Abernethy Forest data set +> data(abernethy) +> +> ## Remove the Depth and Age variables +> abernethy2 <- abernethy[, -(37:38)] +> +> ## Fit the principal curve, preserving the data in the smooth.spline +> ## smooth functions fitted via keep.data = TRUE +> aber.pc <- prcurve(abernethy2, method = "ca", keep.data = TRUE) +> +> ## default "distance" residuals +> resid(aber.pc) + 1 2 3 4 5 6 7 8 +14.264852 3.339616 4.534670 7.343308 1.395606 2.276634 1.497317 5.424320 + 9 10 11 12 13 14 15 16 + 2.571996 2.803516 3.041763 4.775465 1.715575 2.382978 4.218761 4.606372 + 17 18 19 20 21 22 23 24 + 5.301167 2.993025 9.986568 6.411143 3.234004 5.207111 6.458562 4.446028 + 25 26 27 28 29 30 31 32 + 4.648528 10.693325 8.145018 7.354527 6.058375 5.054151 4.866059 17.164061 + 33 34 35 36 37 38 39 40 +13.632436 22.271686 6.458558 3.465228 6.082847 3.619209 6.032345 3.241343 + 41 42 43 44 45 46 47 48 + 5.045163 6.146788 14.719240 13.464204 12.087784 24.672399 14.475148 12.994268 + 49 +19.998570 +> +> ## residuals from the underlying smooth models, also illustrates +> ## how to select specific types of residual from the individual +> ## method using argument 'type' +> resid(aber.pc, which = "smooths", type = "deviance") + Betula Pinus sylvestris Ulmus Quercus Alnus glutinosa + [1,] -2.3568160 0.129150193 -0.013915687 0.079415037 -0.026196824 + [2,] -0.4075439 -2.492365530 -0.039673056 0.034621642 0.327227517 + [3,] 3.1795872 0.429126767 -0.043901759 0.025847590 -0.261576556 + [4,] 1.5921355 -0.106538689 0.298530963 -0.029896200 0.152575972 + [5,] 0.5507456 0.588796664 -0.064651531 -0.053670391 -0.191653028 + [6,] -0.9362944 1.569895168 -0.069748608 -0.120315991 0.137792588 + [7,] 0.2709890 1.124477590 -0.070619016 -0.132709233 -0.158319057 + [8,] 0.3086439 -2.164067744 -0.144929186 -0.172451969 -0.145053462 + [9,] -3.5886738 -1.147462100 -0.169750053 0.362204750 -0.164479867 +[10,] -1.8848090 -1.178907937 -0.172769019 0.323807573 -0.166915724 +[11,] -0.8102093 -1.232364776 -0.175766614 0.588174902 -0.169291394 +[12,] 2.1066669 5.497765163 0.772276816 -0.666055364 0.779242704 +[13,] 0.9237452 -1.615350086 -0.068444108 -0.061929875 -0.068257556 +[14,] 0.6817618 -0.866359478 -0.035476065 -0.149470282 -0.042534916 +[15,] 8.5831720 -0.745136344 -0.001516665 -0.062188471 -0.019614027 +[16,] -8.9862051 0.256044224 0.028271072 0.004878063 -0.003394177 +[17,] -0.4357694 2.349352134 0.038758115 0.026042260 0.001348441 +[18,] -8.5906877 -0.084236500 0.078921796 0.108028774 0.015703405 +[19,] 0.9052950 -0.870406275 0.063759677 0.094785437 0.014080195 +[20,] -1.1249921 2.399343622 0.024717835 0.061093714 0.010775619 +[21,] 0.7713952 1.953011315 -0.170758819 -0.111571654 -0.002441168 +[22,] 3.1499196 0.878175705 -0.184020899 -0.123578479 -0.003309095 +[23,] 5.1123765 1.524003520 -0.193318665 -0.132014596 -0.003917835 +[24,] 8.5764542 0.556821118 -0.409467559 -0.333755267 -0.018610254 +[25,] -3.0746710 -0.359270653 -0.097563130 -0.020641391 -0.021372559 +[26,] 5.5825908 -0.755825225 0.093895515 -0.011995117 -0.037001699 +[27,] 3.6772473 -0.562790930 -0.308763586 -0.585504794 0.141917703 +[28,] 0.9059052 -1.440377607 0.097957430 -0.541084273 -0.048484473 +[29,] -1.5624323 -2.675959610 -0.329773913 -0.280673732 -0.055748154 +[30,] -2.1426332 -3.159841359 0.303299036 -0.165532438 -0.060231118 +[31,] -0.4347984 -0.369514060 0.525156971 0.384433989 0.118716506 +[32,] -4.5539640 -2.849690314 0.451685879 0.877722129 -0.063082891 +[33,] -4.2164216 -0.625920690 0.683121452 1.103668879 -0.071917042 +[34,] -1.1571606 3.352185982 -0.652286809 -0.038482951 0.207882834 +[35,] 0.6724060 2.165113303 -0.289564681 -0.396366555 -0.171431899 +[36,] 0.7312017 1.784694473 -0.432249949 -1.025125372 -0.386693920 +[37,] 1.5035894 1.529226958 0.535987724 -0.908301982 -0.692949607 +[38,] 0.6563814 0.800576527 -0.392538193 0.307405781 -0.700964216 +[39,] 2.9045505 2.219908920 0.299949242 -0.123647870 -0.575954719 +[40,] -0.6476012 0.001325783 -0.234389385 0.915284912 -0.419598849 +[41,] 1.0908527 0.984316627 0.292108553 0.163113441 -0.789969718 +[42,] -9.1869423 -7.111762276 1.208118960 1.804508926 4.714647321 +[43,] -1.8565871 -1.352213705 -0.495224853 0.243956626 0.092112784 +[44,] 5.2762582 2.706909680 -0.230686660 -0.835881759 -0.612190087 +[45,] 0.2557774 0.068057883 0.539967422 0.429203981 -0.382163027 +[46,] -0.9473611 -0.225621493 -0.953188021 -1.263395482 -0.360902502 +[47,] -2.7812601 -1.374282945 -0.285025921 -0.102218582 0.281909036 +[48,] 1.3749402 0.509481310 0.449421464 0.200496640 -0.156194609 +[49,] 0.3392452 -0.011494304 -0.055923506 0.309765026 0.056483403 + Corylus-Myrica Salix Juniperus communis Calluna vulgaris + [1,] 0.001429671 -0.07923696 -0.481974983 -0.21282316 + [2,] -0.027293562 0.24570363 0.567815283 0.51511594 + [3,] 0.079475893 -0.23091046 0.631698390 -0.41163018 + [4,] 0.012195976 3.32235686 -0.401254434 -0.17140611 + [5,] -0.354381416 -1.42613443 -0.338021966 -0.21280309 + [6,] -0.070050718 -2.94849327 -0.209415204 -0.31176499 + [7,] 0.467929141 0.19594078 0.229335326 1.05423907 + [8,] -0.410137053 -8.08739427 0.698368415 0.23844063 + [9,] 0.582970525 -6.31324883 0.244409311 -0.12396841 +[10,] -0.464652098 4.46150982 0.240099248 -0.11277921 +[11,] -0.473517335 21.81153874 1.491917890 -0.10194443 +[12,] 0.468903189 -5.75566457 0.221618200 -0.09455353 +[13,] -0.266498596 -2.58653149 -3.419587870 -0.50694227 +[14,] 0.181173844 -2.52182352 -5.499046942 -0.37634203 +[15,] 0.520960338 -1.58928866 -6.171314588 -1.00550600 +[16,] 0.944027932 0.22663164 7.677262530 3.18957802 +[17,] 1.308134693 -0.70459365 -1.683687751 -1.02669180 +[18,] 0.882848770 1.15493709 13.592631380 0.28552416 +[19,] -0.283090157 -0.55032600 1.566940805 -1.81888545 +[20,] -0.675266908 1.36772982 1.924585478 0.43755098 +[21,] -5.427984101 0.49110784 -3.111405624 1.22346917 +[22,] -4.959699181 1.04061107 -0.521675481 -0.65996168 +[23,] -5.416731457 0.77474026 -0.070335891 -0.56186839 +[24,] -5.162637420 -3.29419330 -1.108016782 1.00084322 +[25,] -0.239027564 2.99216121 -0.628386096 1.35285148 +[26,] 0.672764313 -1.03775511 -2.699772597 -0.06164797 +[27,] 0.695659386 0.30336399 -1.877856059 -0.85884022 +[28,] 1.792856114 0.62860387 -1.850459107 -0.22338451 +[29,] 4.143999657 -0.69356826 -0.478481266 1.35307125 +[30,] 5.306894600 -0.16596401 -0.967229313 0.51513632 +[31,] 2.921799408 -0.74337724 -0.708738813 -1.11282598 +[32,] 8.971767958 -0.74263939 -0.759626534 -0.23242762 +[33,] 3.686444345 -0.35374574 -0.008252441 -0.44590285 +[34,] -4.929909013 0.40838820 2.042385226 -0.37270965 +[35,] -3.716857729 0.60839506 1.676594705 -0.66538829 +[36,] -0.576285516 0.18878317 0.308535673 -0.87622019 +[37,] -1.316730195 0.06877344 0.144552865 -0.92670984 +[38,] -0.783151411 -0.15797066 0.167300309 0.46944530 +[39,] -2.652226339 -0.06081836 0.251699994 -1.20712135 +[40,] 2.047499685 0.29311400 0.089847605 -0.30399880 +[41,] -0.892698051 0.65498749 0.083767257 -1.60166098 +[42,] 0.212555877 -1.04879460 -0.295920207 5.22562211 +[43,] 1.427759785 -0.02696289 -0.305922317 1.47658765 +[44,] -4.036998840 -0.33605066 -0.245373086 -0.90937305 +[45,] 0.684599981 0.30775127 0.150491189 -0.34530956 +[46,] 4.934437726 -0.23973823 0.149463931 -0.89076568 +[47,] 2.824410709 -0.32782626 -0.172624712 1.08155917 +[48,] -1.387378514 0.34276181 -0.121407392 -0.71924590 +[49,] -1.250296344 0.13315976 -0.015533554 0.04436869 + Empetrum Gramineae Cyperaceae Solidago-type Compositae + [1,] -0.936740745 0.38033033 0.69032995 0.1011160997 8.242185e-02 + [2,] -0.158371473 1.18491629 0.54628257 0.2952804722 5.532643e-03 + [3,] 1.130344817 1.33174155 0.31552188 -0.0243115652 -8.789593e-03 + [4,] 0.881193944 -1.05584618 -2.28181376 -0.1455062952 2.686291e-01 + [5,] 1.120145417 -1.98833765 -1.47230893 -0.1971357202 -1.227161e-01 + [6,] 0.276526544 -1.16501864 4.88656904 -0.0417253536 -2.078328e-01 + [7,] 0.880317687 -2.76391400 -4.83371969 -0.3684119074 -2.237378e-01 + [8,] 0.320974277 15.11545079 7.11900267 -1.0188686010 -9.975502e-01 + [9,] -3.785663676 -10.53581224 8.04940104 2.5830702513 3.056334e+00 +[10,] -4.461771120 1.13893796 -5.66884742 0.4157020844 -1.119891e+00 +[11,] -4.360473223 4.10864795 -6.24571472 -0.3150382118 -1.123207e+00 +[12,] -3.161091313 -5.43684217 -0.99094836 -0.6123316330 7.769960e-01 +[13,] 8.986082184 -2.95715150 -3.37500927 -0.4354396334 1.707080e-01 +[14,] 8.769089683 3.71253275 2.81605165 -0.4368795319 -4.130236e-01 +[15,] 8.342357448 -4.64118608 -0.77151734 0.0655652016 -2.769221e-01 +[16,] -3.013733299 3.61979069 0.42576419 -0.1780638438 1.282175e-03 +[17,] -4.427944275 0.95406039 2.42421975 0.1831368500 1.060202e-02 +[18,] -4.951908340 -2.62832523 -1.31252048 -0.0075447483 -1.405854e-02 +[19,] -1.508910506 3.51496492 -1.08332971 0.1628509241 1.571429e-01 +[20,] -3.277868703 -1.13082101 0.05325698 -0.0062965705 -1.050220e-02 +[21,] -0.366728283 2.81049455 0.59853709 -0.0054328417 -4.417859e-03 +[22,] 0.013417415 0.10838538 0.65015813 -0.0055222490 -4.182936e-03 +[23,] 1.416370900 -2.34867336 -0.27868909 -0.0055925768 -4.026456e-03 +[24,] 0.472447744 -0.06363820 -0.44875058 -0.0085081026 -1.580394e-03 +[25,] 0.482412731 -0.64256063 -0.27920667 -0.0092199660 -1.300698e-03 +[26,] 0.019072421 -0.95150782 -0.79988392 -0.0137000336 -2.338620e-04 +[27,] 0.007279354 -0.85221181 -0.10282943 -0.0140283736 -1.822963e-04 +[28,] -0.025218099 0.13959746 0.99165976 -0.0171897171 2.177118e-04 +[29,] 0.043650996 0.41183531 0.11953827 -0.0192594448 4.147643e-04 +[30,] 0.415208493 0.45111668 -0.04612818 -0.0204340850 5.123305e-04 +[31,] 0.284336767 -0.59953620 0.17697290 -0.0206964293 5.330956e-04 +[32,] 0.349457977 -0.75775727 -0.10793391 -0.0211320973 5.669339e-04 +[33,] 0.035839419 0.10735222 -0.03628661 0.1770182453 7.067903e-04 +[34,] 0.035269153 1.02181233 0.32293018 -0.0258337877 1.017374e-03 +[35,] 0.035990363 0.20008627 -0.05236042 -0.0079378244 3.969321e-04 +[36,] 0.104290257 0.41885266 -0.18917328 -0.0031338909 1.650508e-04 +[37,] -0.115505050 0.45717648 -0.57695790 -0.0010227806 5.906876e-05 +[38,] -0.118585601 0.08890327 -0.53383398 -0.0009355469 5.461822e-05 +[39,] -0.135867561 -0.20127188 -0.64359417 -0.0004843826 3.148939e-05 +[40,] -0.149202239 -0.58186374 -0.62509308 -0.0001759742 1.555557e-05 +[41,] -0.153509995 0.67870764 -0.82526092 -0.0000826024 1.070788e-05 +[42,] 0.589580940 0.14101785 3.55669922 0.0002649263 -7.462870e-06 +[43,] 0.557539176 -0.54745998 0.79603255 0.0005149194 -2.072486e-05 +[44,] -0.199115680 -0.29761626 -0.47097525 0.0007869891 -3.802447e-05 +[45,] -0.202524019 -0.56931916 -0.70300744 0.0007439443 -3.620783e-05 +[46,] -0.204989268 0.57553624 -0.50805945 0.0007186060 -3.511160e-05 +[47,] 0.136512721 -0.25084454 1.18730080 0.0005788945 -2.888623e-05 +[48,] -0.251303666 0.05049510 -0.32838535 0.0004252889 -2.186761e-05 +[49,] 0.261317307 0.24477251 -0.13408933 0.0001026248 -6.919770e-06 + Artemisia Caryophyllaceae Sagina Silene Chenopodiaceae + [1,] 3.757862e-01 -2.511874e-01 7.235126e-02 4.340981e-02 -5.194826e-02 + [2,] 2.186127e-01 -1.151244e-01 -2.530108e-01 -4.370880e-02 2.137172e-01 + [3,] -1.067275e+00 -2.147048e-01 -2.565897e-01 -5.925150e-02 -9.150889e-02 + [4,] -9.932399e-01 7.240537e-01 8.205640e-01 -1.406678e-01 -1.173287e-01 + [5,] 5.342839e-01 3.151279e-01 8.352264e-02 1.831023e-01 2.237299e-01 + [6,] 2.339655e+00 -4.544043e-01 -2.505431e-01 -2.221588e-01 -1.489049e-01 + [7,] 1.129567e+00 2.158524e-01 -2.478709e-01 1.895953e-01 -1.531741e-01 + [8,] 3.100242e+00 -3.872675e-01 -2.068684e-01 1.325319e-01 1.720243e-01 + [9,] -1.227241e+00 7.828953e-01 8.468060e-01 7.527390e-01 7.704749e-01 +[10,] -2.811338e+00 -2.397866e-01 -1.893488e-01 -2.773679e-01 -2.622952e-01 +[11,] -2.919603e+00 -2.205042e-01 -1.843566e-01 -2.655348e-01 -2.533224e-01 +[12,] -2.727466e+00 -2.047441e-01 -1.797675e-01 -2.552613e-01 -2.453135e-01 +[13,] 1.374057e+00 -3.481658e-02 -5.935471e-02 -4.723468e-02 -5.316389e-02 +[14,] 1.389217e+00 -3.657919e-02 -4.561453e-02 -2.346063e-02 -2.810768e-02 +[15,] 1.395971e+00 -4.527726e-02 -3.658342e-02 -4.881868e-03 -7.980043e-03 +[16,] -1.036168e-01 -5.522312e-02 -3.202625e-02 6.502821e-03 4.673488e-03 +[17,] 1.963948e-01 2.719882e-01 1.293272e-01 9.460065e-03 8.004406e-03 +[18,] -1.373243e-01 -2.582612e-02 -7.519212e-03 9.588708e-03 5.051606e-03 +[19,] 5.282770e-02 -2.018631e-02 -5.501973e-03 7.823584e-03 1.790896e-03 +[20,] -8.504693e-02 -1.248533e-02 -2.930888e-03 5.252658e-03 -3.713551e-03 +[21,] -2.663158e-02 -1.819055e-03 1.076164e-04 1.233811e-03 -1.503448e-02 +[22,] -2.475571e-02 -1.549734e-03 1.692870e-04 1.119146e-03 -1.541251e-02 +[23,] -2.351874e-02 -1.375045e-03 2.085288e-04 1.044106e-03 -1.566067e-02 +[24,] -5.694716e-03 7.879758e-04 6.002804e-04 3.244491e-05 1.620539e-01 +[25,] -3.876665e-03 9.526956e-04 6.128173e-04 -5.975315e-05 -1.769654e-02 +[26,] 2.428336e-03 1.344639e-03 5.683496e-04 -3.442451e-04 -1.447082e-02 +[27,] 2.700592e-03 1.351383e-03 5.614362e-04 -3.545283e-04 -1.419752e-02 +[28,] 4.671654e-03 1.350803e-03 4.871526e-04 -4.192631e-04 -1.156855e-02 +[29,] 5.532899e-03 1.309317e-03 4.344711e-04 -4.394424e-04 -9.877060e-03 +[30,] 5.927738e-03 1.276917e-03 4.037562e-04 -4.460629e-04 -8.925456e-03 +[31,] 6.008922e-03 1.268951e-03 3.968014e-04 -4.471680e-04 -8.712634e-03 +[32,] 6.139007e-03 1.255141e-03 3.851439e-04 -4.487327e-04 -8.357836e-03 +[33,] 6.643370e-03 1.185564e-03 3.320827e-04 -4.516478e-04 -6.771191e-03 +[34,] 7.328260e-03 8.676768e-04 1.504534e-04 -4.116854e-04 -1.675809e-03 +[35,] 2.198917e-03 9.065805e-05 -3.808762e-05 -9.016837e-05 1.730982e-03 +[36,] 8.629206e-04 1.839084e-05 -2.337612e-05 -3.200603e-05 9.055199e-04 +[37,] 2.783663e-04 -4.852982e-06 -1.283092e-05 -8.204284e-06 4.340858e-04 +[38,] 2.542563e-04 -5.664825e-06 -1.232396e-05 -7.251452e-06 4.127085e-04 +[39,] 1.296317e-04 -9.631846e-06 -9.590946e-06 -2.371347e-06 2.991889e-04 +[40,] 4.451768e-05 -1.208631e-05 -7.599388e-06 9.114806e-07 2.183041e-04 +[41,] 1.876389e-05 -1.278003e-05 -6.972777e-06 1.895176e-06 1.931857e-04 +[42,] -7.701141e-05 -1.509557e-05 -4.512828e-06 5.501450e-06 9.629371e-05 +[43,] -1.457874e-04 -1.636285e-05 -2.552362e-06 8.013352e-06 2.150965e-05 +[44,] -2.188420e-04 -1.176121e-05 2.447316e-06 9.512210e-06 -1.362209e-04 +[45,] -2.067075e-04 -1.056892e-05 2.576546e-06 8.878582e-06 -1.357779e-04 +[46,] -1.995814e-04 -9.923129e-06 2.625761e-06 8.517170e-06 -1.348018e-04 +[47,] -1.604024e-04 -6.739836e-06 2.716208e-06 6.602338e-06 -1.246008e-04 +[48,] -1.174362e-04 -3.603306e-06 2.641536e-06 4.572098e-06 -1.087474e-04 +[49,] -2.730931e-05 2.558535e-06 2.280173e-06 3.954876e-07 -6.999858e-05 + Epilobium-type Papilionaceae Anthyllis vulneraria Astragalus alpinus + [1,] -5.330066e-02 -1.123777e-01 2.831316e-02 2.293431e-01 + [2,] 2.482379e-01 1.044191e-01 1.354724e-02 -3.062019e-01 + [3,] -5.081461e-02 -2.083636e-01 1.062567e-02 -3.479955e-01 + [4,] -4.712676e-02 -2.592395e-01 -8.268953e-03 -5.699743e-01 + [5,] -4.824452e-02 7.923814e-01 -1.649058e-02 -2.889661e-01 + [6,] -5.801477e-02 3.363865e-02 -3.994052e-02 4.283724e-01 + [7,] -6.059746e-02 -2.642006e-01 -4.435915e-02 1.315752e+00 + [8,] -2.524522e-01 -6.178048e-02 -2.565565e-01 -2.692691e-01 + [9,] -2.853638e-01 -2.211951e-02 -2.881449e-01 -1.110511e-01 +[10,] 7.127386e-01 -1.748764e-02 7.101587e-01 -9.205324e-02 +[11,] 3.419868e-01 -1.255612e-02 3.396309e-01 -7.171625e-02 +[12,] -2.874382e-01 -8.683612e-03 -2.896108e-01 -5.566342e-02 +[13,] -1.013754e-01 1.383506e-02 -1.013571e-01 5.024231e-02 +[14,] -6.220326e-02 1.066969e-02 -6.209078e-02 3.984539e-02 +[15,] -2.837120e-02 7.164130e-03 -2.821322e-02 2.767469e-02 +[16,] -5.436151e-03 4.309875e-03 -5.269509e-03 1.744828e-02 +[17,] 9.916369e-04 3.417762e-03 1.156426e-03 1.420106e-02 +[18,] 1.425474e-02 -7.817446e-04 1.430619e-02 -2.252895e-03 +[19,] 1.198654e-02 -7.518792e-04 1.202542e-02 -2.285290e-03 +[20,] 8.476553e-03 -6.422601e-04 8.498914e-03 -2.073240e-03 +[21,] 2.438563e-03 -2.942629e-04 2.439912e-03 -1.049215e-03 +[22,] 2.252222e-03 -2.798263e-04 2.253095e-03 -1.002325e-03 +[23,] 2.129647e-03 -2.701773e-04 2.130213e-03 -9.708490e-04 +[24,] 3.999655e-04 -1.153616e-04 3.970714e-04 -4.495461e-04 +[25,] 2.293085e-04 -9.707942e-05 2.262128e-04 -3.856760e-04 +[26,] -3.440227e-04 -2.568797e-05 -3.473332e-04 -1.298677e-04 +[27,] -3.677289e-04 -2.215164e-05 -3.710211e-04 -1.168739e-04 +[28,] -5.342563e-04 5.651723e-06 -5.372827e-04 -1.334862e-05 +[29,] -6.027637e-04 1.963735e-05 -6.055624e-04 3.977531e-05 +[30,] -6.327898e-04 2.664525e-05 -6.354480e-04 6.669022e-05 +[31,] -6.388290e-04 2.814425e-05 -6.414549e-04 7.247372e-05 +[32,] -6.483979e-04 3.059281e-05 -6.509689e-04 8.194117e-05 +[33,] -6.838434e-04 4.080060e-05 -6.861587e-04 1.217156e-04 +[34,] -7.089168e-04 6.461582e-05 -7.102808e-04 2.184714e-04 +[35,] -1.952020e-04 2.694937e-05 -1.951524e-04 9.802308e-05 +[36,] -7.482923e-05 1.134146e-05 -7.476329e-05 4.175545e-05 +[37,] -2.302563e-05 4.139145e-06 -2.297519e-05 1.553337e-05 +[38,] -2.090414e-05 3.835543e-06 -2.085475e-05 1.442375e-05 +[39,] -9.961855e-06 2.255999e-06 -9.918434e-06 8.644181e-06 +[40,] -2.514976e-06 1.165872e-06 -2.476327e-06 4.648183e-06 +[41,] -2.667523e-07 8.338412e-07 -2.296795e-07 3.429711e-06 +[42,] 8.066838e-06 -4.127205e-07 8.097334e-06 -1.152223e-06 +[43,] 1.401034e-05 -1.325494e-06 1.403505e-05 -4.518168e-06 +[44,] 1.970970e-05 -2.560052e-06 1.971216e-05 -9.231515e-06 +[45,] 1.856107e-05 -2.442167e-06 1.856194e-05 -8.822990e-06 +[46,] 1.789214e-05 -2.370514e-06 1.789222e-05 -8.572672e-06 +[47,] 1.425231e-05 -1.960208e-06 1.424903e-05 -7.126164e-06 +[48,] 1.029721e-05 -1.494445e-06 1.029121e-05 -5.472007e-06 +[49,] 2.044005e-06 -4.988552e-07 2.033426e-06 -1.922349e-06 + Ononis-type Rosaceae Rubiaceae Ranunculaceae Thalictrum + [1,] -1.372937e-01 1.654573e-01 0.0357345324 3.191122e-02 -1.116407e-02 + [2,] -6.568944e-01 -7.469269e-02 0.0174694199 1.458846e-02 -5.813685e-02 + [3,] -7.441653e-01 -6.492705e-02 0.0138457401 1.117886e-02 4.556740e-01 + [4,] 1.416579e+00 -3.110089e-02 -0.0096995564 -1.067033e-02 -4.018084e-01 + [5,] 5.397728e-01 -2.616427e-02 -0.0199977765 -2.008053e-02 -4.207849e-01 + [6,] 4.601093e-01 -2.562087e-02 -0.0494985870 -4.668608e-02 -4.762187e-01 + [7,] -4.974600e-01 -2.679256e-02 -0.0550754718 -5.166613e-02 7.742746e-01 + [8,] 3.821056e-01 -1.655893e-01 -0.3322865847 -2.736133e-01 8.495744e-01 + [9,] -2.966524e-01 8.600692e-01 0.6610923199 7.431614e-01 -4.640867e-01 +[10,] -2.616604e-01 -1.792077e-01 0.6177204870 -2.966642e-01 5.531244e-01 +[11,] -2.237029e-01 -1.774839e-01 -0.3848606650 3.348587e-01 -4.272493e-01 +[12,] -1.933668e-01 -1.754101e-01 -0.3862285408 -2.927746e-01 -4.109013e-01 +[13,] 6.307449e-02 -5.440929e-02 -0.1490604682 -9.545097e-02 -3.233129e-03 +[14,] 5.564241e-02 -3.238577e-02 -0.1414171588 -5.756064e-02 1.291821e-02 +[15,] 4.322832e-02 -1.361588e-02 0.2022840594 -2.519219e-02 -1.560951e-01 +[16,] 3.110080e-02 -9.622666e-04 0.2264053151 -3.470082e-03 2.988848e-02 +[17,] 2.698584e-02 2.596172e-03 -0.3117732456 2.575182e-03 1.822526e-01 +[18,] 1.708941e-04 1.152475e-02 0.2425133268 1.395928e-02 -8.263714e-02 +[19,] -5.906311e-04 1.061548e-02 -0.0824658902 1.169442e-02 9.545076e-02 +[20,] -1.276518e-03 9.217347e-03 -0.0636876358 8.218901e-03 -6.167136e-02 +[21,] -1.217867e-03 5.544214e-03 0.1626063856 2.313855e-03 1.253402e-01 +[22,] -1.187336e-03 5.318600e-03 -0.1438466923 2.133325e-03 -3.348027e-02 +[23,] -1.166068e-03 5.159844e-03 0.0385696421 2.014643e-03 -3.267652e-02 +[24,] -7.210092e-04 8.742759e-04 -0.0964282821 3.485128e-04 -1.792993e-02 +[25,] -6.537340e-04 -6.204336e-05 -0.0901082877 1.855155e-04 -1.592611e-02 +[26,] -3.502539e-04 -6.305447e-03 0.1289825992 -3.574758e-04 -7.374427e-03 +[27,] -3.331653e-04 -6.803170e-03 0.1207425577 -3.796575e-04 -6.914174e-03 +[28,] -1.901142e-04 -1.200802e-02 -0.0435671338 -5.341075e-04 -3.140521e-03 +[29,] -1.114728e-04 -1.596728e-02 -0.0342488373 -5.964693e-04 -1.123145e-03 +[30,] -7.018310e-05 -1.850314e-02 -0.0291777217 -6.233963e-04 -7.869118e-05 +[31,] -6.118323e-05 -1.910727e-02 -0.0280571785 -6.287708e-04 1.477133e-04 +[32,] -4.635262e-05 -2.014747e-02 -0.0261991534 -6.372525e-04 5.198474e-04 +[33,] 1.742216e-05 -2.534341e-02 -0.0180378214 -6.681455e-04 2.105955e-03 +[34,] 1.914518e-04 1.111891e-01 0.0063870017 -6.823321e-04 6.256378e-03 +[35,] 1.238564e-04 -9.404908e-02 0.0120511621 -1.836513e-04 3.393885e-03 +[36,] 5.533056e-05 6.018595e-02 0.0057556276 -6.993445e-05 1.485455e-03 +[37,] 2.206972e-05 7.302930e-02 0.0025008266 -2.121950e-05 5.755793e-04 +[38,] 2.064042e-05 9.339711e-02 0.0023578124 -1.922850e-05 5.367391e-04 +[39,] 1.316252e-05 -9.410215e-02 0.0016048688 -8.965516e-06 3.339233e-04 +[40,] 7.955641e-06 -9.169039e-02 0.0010754143 -1.987944e-06 1.931297e-04 +[41,] 6.360992e-06 8.919038e-02 0.0009122891 1.172453e-07 1.500910e-04 +[42,] 3.272319e-07 -8.659650e-02 0.0002898581 7.913342e-06 -1.232746e-05 +[43,] -4.160369e-06 1.079823e-01 -0.0001807278 1.346255e-05 -1.324943e-04 +[44,] -1.125475e-05 -5.236211e-02 -0.0010358031 1.861781e-05 -3.132925e-04 +[45,] -1.084208e-05 -4.971258e-02 -0.0010106282 1.751836e-05 -3.007482e-04 +[46,] -1.057844e-05 -4.843980e-02 -0.0009925956 1.687945e-05 -2.928954e-04 +[47,] -8.985263e-06 -4.338448e-02 -0.0008715195 1.341239e-05 -2.464385e-04 +[48,] -7.099361e-06 1.507636e-01 -0.0007175697 9.654247e-06 -1.923229e-04 +[49,] -2.980106e-06 -2.916819e-02 -0.0003697126 1.822958e-06 -7.507847e-05 + Rumex acetosa-type Oxyria-type Parnassia palustris Saxifraga spp1 + [1,] 2.426777e+00 1.851769e-02 2.504843e-02 5.199540e-02 + [2,] 7.358972e-01 8.599773e-03 1.375980e-02 -3.266410e-01 + [3,] -2.969326e+00 6.644267e-03 1.147960e-02 7.091831e-02 + [4,] -3.313191e+00 -5.925327e-03 -3.792834e-03 3.312681e-01 + [5,] 7.352067e-01 -1.135758e-02 -1.069145e-02 2.858254e-01 + [6,] -8.442616e-01 -2.676180e-02 -3.097954e-02 -4.443279e-01 + [7,] 1.269407e+00 -2.965169e-02 -3.488892e-02 -2.941500e-02 + [8,] -1.175137e+01 -1.618425e-01 -2.675244e-01 -6.913929e-01 + [9,] 1.130471e+01 -1.777625e-01 -3.277544e-01 1.357932e+00 +[10,] 1.084105e+01 8.219498e-01 -3.348532e-01 -7.208642e-01 +[11,] -6.230437e+00 -1.774463e-01 -3.419163e-01 -7.171662e-01 +[12,] 3.571385e+00 -1.762385e-01 1.553382e+00 1.188033e+00 +[13,] 4.413778e+00 -5.840849e-02 -1.463670e-01 -2.350281e-01 +[14,] -6.488385e+00 -3.535533e-02 -9.292240e-02 -1.421375e-01 +[15,] -2.671378e+00 -1.561605e-02 -4.566199e-02 -6.264411e-02 +[16,] -3.636150e+00 -2.340613e-03 -1.294173e-02 -9.209336e-03 +[17,] 4.121800e-01 1.359519e-03 -3.639963e-03 5.678642e-03 +[18,] 7.530403e-01 8.471144e-03 1.892016e-02 3.415494e-02 +[19,] -2.267771e-01 7.102257e-03 1.604453e-02 2.863033e-02 +[20,] 5.572395e-01 4.997998e-03 1.150406e-02 2.014143e-02 +[21,] 7.835641e-01 1.413551e-03 3.465819e-03 5.690203e-03 +[22,] 3.851939e-01 1.303751e-03 3.212471e-03 5.247736e-03 +[23,] 6.166727e-01 1.231557e-03 3.045601e-03 4.956825e-03 +[24,] 1.746760e-01 2.169622e-04 6.642281e-04 8.694676e-04 +[25,] -1.871573e-01 1.175255e-04 4.249800e-04 4.690540e-04 +[26,] 1.145552e-01 -2.143254e-04 -3.930204e-04 -8.666720e-04 +[27,] -6.871241e-02 -2.279172e-04 -4.276775e-04 -9.213459e-04 +[28,] -1.879218e-01 -3.227374e-04 -6.753583e-04 -1.302593e-03 +[29,] -1.513310e-01 -3.611802e-04 -7.808877e-04 -1.457010e-03 +[30,] -1.313168e-01 -3.778345e-04 -8.283937e-04 -1.523854e-03 +[31,] -1.268872e-01 -3.811644e-04 -8.380765e-04 -1.537214e-03 +[32,] -1.195376e-01 -3.864241e-04 -8.535231e-04 -1.558311e-03 +[33,] -8.719368e-02 -4.056551e-04 -9.123656e-04 -1.635380e-03 +[34,] 9.948485e-03 -4.155776e-04 -9.776765e-04 -1.674112e-03 +[35,] 2.683149e-02 -1.123990e-04 -2.822768e-04 -4.522608e-04 +[36,] -2.619057e-04 -4.286313e-05 -1.096512e-04 -1.724095e-04 +[37,] -1.235300e-02 -1.304534e-05 -3.466745e-05 -5.243437e-05 +[38,] 1.772313e-01 -1.182615e-05 -3.158434e-05 -4.752933e-05 +[39,] -1.464234e-02 -5.540762e-06 -1.566267e-05 -2.224279e-05 +[40,] -1.561463e-02 -1.266543e-06 -4.805398e-06 -5.048219e-06 +[41,] -1.584980e-02 2.320205e-08 -1.523404e-06 1.400701e-07 +[42,] -1.640559e-02 4.800451e-06 1.066467e-05 1.935670e-05 +[43,] -1.632776e-02 8.202316e-06 1.939106e-05 3.303940e-05 +[44,] -9.072600e-03 1.138474e-05 2.827182e-05 4.581829e-05 +[45,] -7.918169e-03 1.071432e-05 2.666891e-05 4.311836e-05 +[46,] -7.305807e-03 1.032456e-05 2.573113e-05 4.154884e-05 +[47,] -4.381939e-03 8.208252e-06 2.059927e-05 3.302805e-05 +[48,] -1.602903e-03 5.913067e-06 1.499449e-05 2.378819e-05 +[49,] 3.723101e-03 1.128893e-06 3.265048e-06 4.529640e-06 + Saxifraga spp2 Sedum Urtica Veronica + [1,] -4.475967e-02 -1.536234e-03 1.563617e-01 1.560104e-01 + [2,] -5.859376e-02 -3.392649e-01 -9.684482e-02 8.098336e-02 + [3,] 3.496461e-01 -3.971910e-01 -8.919475e-02 6.597204e-02 + [4,] -6.914392e-02 5.847736e-02 -6.377708e-02 -3.298724e-02 + [5,] -7.506157e-02 6.668903e-01 -5.996042e-02 -7.695110e-02 + [6,] -9.947818e-02 -5.563766e-01 2.435235e-01 -2.045296e-01 + [7,] -1.049991e-01 8.017602e-01 -5.623522e-02 -2.288780e-01 + [8,] -4.817282e-01 4.895166e-01 3.430241e-01 -1.558441e+00 + [9,] -5.595670e-01 -2.586787e-01 -1.885371e-01 -1.847755e+00 +[10,] 4.336650e-01 -2.317867e-01 -2.017115e-01 1.122912e+00 +[11,] 6.883410e-01 -2.024520e-01 -2.186508e-01 -1.903603e+00 +[12,] 3.761852e-01 -1.788861e-01 -2.346457e-01 5.701164e+00 +[13,] -2.170931e-01 3.877211e-02 8.201077e-01 -7.622344e-01 +[14,] -1.351060e-01 3.722462e-02 2.698059e-01 -4.787337e-01 +[15,] -6.362354e-02 3.146732e-02 -2.108221e-02 -2.299768e-01 +[16,] -1.474885e-02 2.498679e-02 -4.517688e-01 -5.892500e-02 +[17,] -9.709263e-04 2.271451e-02 -8.732805e-02 -1.051961e-02 +[18,] 2.951273e-02 5.462627e-03 -8.385884e-02 1.012932e-01 +[19,] 2.489902e-02 4.285782e-03 -6.769569e-02 8.565379e-02 +[20,] 1.770419e-02 2.250300e-03 -5.255625e-02 6.113132e-02 +[21,] 5.188563e-03 -5.651022e-03 -5.466446e-02 1.814041e-02 +[22,] 4.799094e-03 -6.189107e-03 -5.536375e-02 1.679495e-02 +[23,] 4.542768e-03 -6.567785e-03 -5.584583e-02 1.590913e-02 +[24,] 9.094491e-04 -1.578650e-02 2.988217e-01 3.314791e-03 +[25,] 5.483528e-04 -1.750613e-02 2.895610e-01 2.056970e-03 +[26,] -6.734541e-04 -2.697973e-02 -4.983517e-02 -2.219195e-03 +[27,] -7.244826e-04 -2.761364e-02 -4.891744e-02 -2.398963e-03 +[28,] -1.085519e-03 -3.341175e-02 -4.004162e-02 -3.676754e-03 +[29,] -1.236263e-03 -3.691340e-02 -3.430089e-02 -4.215311e-03 +[30,] -1.303098e-03 -3.878150e-02 -3.106463e-02 -4.455798e-03 +[31,] -1.316619e-03 1.408154e-01 -3.034033e-02 -4.504621e-03 +[32,] -1.338105e-03 -3.984151e-02 -2.913245e-02 -4.582349e-03 +[33,] -1.418688e-03 1.575206e-01 -2.372515e-02 -4.876032e-03 +[34,] -1.490144e-03 -4.543301e-02 -6.291086e-03 -5.167730e-03 +[35,] -4.182901e-04 -1.308288e-02 5.777574e-03 -1.469275e-03 +[36,] -1.612285e-04 -5.078440e-03 3.043595e-03 -5.683485e-04 +[37,] -5.017694e-05 -1.603294e-03 1.469012e-03 -1.781707e-04 +[38,] -4.562158e-05 -1.460438e-03 1.397435e-03 -1.621483e-04 +[39,] -2.211384e-05 -7.227530e-04 1.017091e-03 -7.943783e-05 +[40,] -6.102226e-06 -2.197669e-04 7.458173e-04 -2.307180e-05 +[41,] -1.265754e-06 -6.773203e-05 6.615246e-04 -6.040046e-06 +[42,] 1.667558e-05 4.968112e-04 3.361091e-04 5.717230e-05 +[43,] 2.949198e-05 9.009269e-04 8.456444e-05 1.023753e-04 +[44,] 4.209481e-05 1.310915e-03 -4.512920e-04 1.475391e-04 +[45,] 3.966891e-05 1.236477e-03 -4.506672e-04 1.390993e-04 +[46,] 3.825352e-05 1.192939e-03 -4.478434e-04 1.341691e-04 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/analogue -r 351 From noreply at r-forge.r-project.org Sat Jul 27 05:28:52 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 27 Jul 2013 05:28:52 +0200 (CEST) Subject: [Analogue-commits] r352 - pkg/R Message-ID: <20130727032853.52F5F184B9C@r-forge.r-project.org> Author: gsimpson Date: 2013-07-27 05:28:52 +0200 (Sat, 27 Jul 2013) New Revision: 352 Modified: pkg/R/prcurve.R Log: fix to the plot drawn via plotit = TRUE Modified: pkg/R/prcurve.R =================================================================== --- pkg/R/prcurve.R 2013-07-25 16:55:27 UTC (rev 351) +++ pkg/R/prcurve.R 2013-07-27 03:28:52 UTC (rev 352) @@ -40,6 +40,10 @@ ## data stats n <- NROW(X) ## number of observations m <- NCOL(X) ## number of variables + + ## fit a PCA and store in result + ord <- rda(X) + ## starting configuration config <- startConfig <- initCurve(X, method = method, rank = rank, @@ -127,8 +131,13 @@ ## Converged? converged <- (abs((dist.old - config$dist)/dist.old) <= thresh) - if(plotit) - plot(config, X, sub = paste("Iteration:", iter)) + if(plotit) { + ## plot the iteration -- need to add some components + ## because of changes to plot method + config$data <- X + config$ordination <- ord + plot(config, sub = paste("Iteration:", iter)) + } if (trace) writeLines(sprintf(paste("Iteration %", max(3, nchar(maxit)), @@ -164,8 +173,11 @@ config <- get.lam(X, s = s, stretch = stretch) class(config) <- "prcurve" if(plotit) { - ## plot the iteration - plot(config, X) + ## plot the iteration -- need to add some components + ## because of changes to plot method + config$data <- X + config$ordination <- ord + plot(config) } if (trace) writeLines(sprintf(paste("Iteration %", max(3, nchar(maxit)), @@ -182,8 +194,6 @@ } cat("\n") } - ## fit a PCA and store in result - ord <- rda(X) ## prepare objects for return names(config$tag) <- names(config$lambda) <- rownames(config$s) <- rownames(X)