[Analogue-commits] r287 - in pkg: . R inst man tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 9 13:42:43 CEST 2012


Author: gsimpson
Date: 2012-09-09 13:42:42 +0200 (Sun, 09 Sep 2012)
New Revision: 287

Modified:
   pkg/NAMESPACE
   pkg/R/stdError.R
   pkg/inst/ChangeLog
   pkg/man/stdError.Rd
   pkg/tests/Examples/analogue-Ex.Rout.save
Log:
properly sort out the weighted standard deviation, plus adds print method and new computation function to avoid repeating code. Allows a weighted or unweighted SD to be used.

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2012-09-07 22:47:59 UTC (rev 286)
+++ pkg/NAMESPACE	2012-09-09 11:42:42 UTC (rev 287)
@@ -199,6 +199,7 @@
 S3method(print, residuals.bootstrap.mat)
 S3method(print, residuals.mat)
 S3method(print, roc)
+S3method(print, stdError)
 S3method(print, summary.analog)
 S3method(print, summary.bootstrap.mat)
 S3method(print, summary.cma)

Modified: pkg/R/stdError.R
===================================================================
--- pkg/R/stdError.R	2012-09-07 22:47:59 UTC (rev 286)
+++ pkg/R/stdError.R	2012-09-09 11:42:42 UTC (rev 287)
@@ -6,49 +6,61 @@
     UseMethod("stdError")
 }
 
-`stdError.mat` <- function(object, k, ...) {
-    getOrd <- function(dis) {
-        nas <- is.na(dis)
-        order(dis[!nas])
-    }
-    getWts <- function(i, dis, ords, k.seq) {
-        nas <- is.na(dis[,i])
-        dis[!nas, i][ords[,i]][k.seq]
-    }
-    getEnv <- function(i, dis, ords, k.seq, y){
-        nas <- is.na(dis[,i])
-        y[!nas][ords[,i]][k.seq]
-    }
+`stdError.mat` <- function(object, k, weighted = FALSE, ...) {
     if(missing(k)) {
-        k <- getK(object, ...)
-        auto <- object$auto
+        k <- getK(object, weighted = weighted, ...)
     } else {
-        auto <- FALSE
+        attr(k, "weighted") <- weighted
+        attr(k, "auto") <- FALSE
     }
-    ## create k sequence
-    k.seq <- seq_len(k)
-    ## ordering of objects in terms of dissim
-    ords <- apply(object$Dij, 2, getOrd)
-    SEQ <- seq_len(ncol(ords))
-    ## weights = 1/Dij
-    wi <- 1 / sapply(SEQ, getWts, object$Dij, ords, k.seq, USE.NAMES = FALSE)
-    ## produce matrix of Env data for each site
-    env <- sapply(SEQ, getEnv, object$Dij, ords, k.seq,
-                  object$orig.y, USE.NAMES = FALSE)
-    ## mean of env of k closest analogues
-    ybar <- colMeans(env)
-    ## sum weights
-    sum.wi <- colSums(wi)
-    sum.wi2 <- colSums(wi^2)
-    sum2.wi <- sum.wi^2
-    frac <- sum.wi / (sum2.wi - sum.wi2)
-    wtdSD <- sqrt(frac * colSums(wi * sweep(env, 2, ybar, "-")^2))
+    wtdSD <- .stdError(object$Dij, k, object$orig.y, weighted = weighted)
     names(wtdSD) <- names(object$orig.y)
     class(wtdSD) <- "stdError"
+    attr(wtdSD, "k") <- k
+    attr(wtdSD, "weighted") <- attr(k, "weighted")
+    attr(wtdSD, "auto") <- attr(k, "auto")
     wtdSD
 }
 
-`stdError.predict.mat` <- function(object, k, ...) {
+`stdError.predict.mat` <- function(object, k, weighted = FALSE, ...) {
+    if(missing(k)) {
+        k <- getK(object, weighted = weighted, ...)
+    } else {
+        attr(k, "weighted") <- weighted
+        attr(k, "auto") <- FALSE
+    }
+    wtdSD <- .stdError(object$Dij, k, object$observed, weighted = weighted)
+    names(wtdSD) <- colnames(object$predictions$model$predicted)
+    class(wtdSD) <- "stdError"
+    attr(wtdSD, "k") <- k
+    attr(wtdSD, "weighted") <- attr(k, "weighted")
+    attr(wtdSD, "auto") <- attr(k, "auto")
+    wtdSD
+}
+
+`print.stdError` <- function(x, digits = min(4, getOption("digits")),
+                             ...) {
+    wtd <- attr(x, "weighted")
+    cat("\n")
+    writeLines(strwrap(paste(ifelse(wtd, "Weighted standard", "Standard"),
+                              "deviation of MAT predictions"),
+                       prefix = "\t"))
+    cat("\n")
+    writeLines(paste(" k-analogues:", attr(x, "k")))
+    writeLines(paste(" Weighted   :", wtd))
+    cat("\n")
+    nams <- attr(x, "names")
+    attributes(x) <- NULL
+    names(x) <- nams
+    print.default(zapsmall(x), digits = digits, ...)
+}
+
+##' Interal computation function for the weighted SD
+##'
+##' @param dis matrix; dissimilarity matrix in full matrix form
+##' @param k numeric; the number of analogues to use
+##' @param y numeric; vector of observed responses
+.stdError <- function(dis, k, y, weighted = FALSE) {
     getOrd <- function(dis) {
         nas <- is.na(dis)
         order(dis[!nas])
@@ -61,33 +73,28 @@
         nas <- is.na(dis[,i])
         y[!nas][ords[,i]][k.seq]
     }
-    if(missing(k)) {
-        k <- getK(object, ...)
-        auto <- object$auto
-    } else {
-        auto <- FALSE
-    }
     ## create k sequence
     k.seq <- seq_len(k)
     ## ordering of objects in terms of dissim
-    ords <- apply(object$Dij, 2, getOrd)
+    ords <- apply(dis, 2, getOrd)
     SEQ <- seq_len(ncol(ords))
-    ## weights = 1/Dij
-    wi <- 1 / sapply(SEQ, getWts, object$Dij, ords, k.seq, USE.NAMES = FALSE)
     ## produce matrix of Env data for each site
-    env <- sapply(SEQ, getEnv, object$Dij, ords, k.seq,
-                  object$observed, USE.NAMES = FALSE)
-    ## mean of env of k closest analogues
-    ybar <- colMeans(env)
-    ## sum weights
-    sum.wi <- colSums(wi)
-    sum.wi2 <- colSums(wi^2)
-    sum2.wi <- sum.wi^2
-    frac <- sum.wi / (sum2.wi - sum.wi2)
-    wtdSD <- sqrt(frac * colSums(wi * sweep(env, 2, ybar, "-")^2))
-    names(wtdSD) <- colnames(object$predictions$model$predicted)
-    class(wtdSD) <- "stdError"
-    attr(wtdSD, "k") <- k
-    attr(wtdSD, "auto") <- object$auto
-    wtdSD
+    env <- sapply(SEQ, getEnv, dis, ords, k.seq,
+                  y, USE.NAMES = FALSE)
+    res <- if(weighted) {
+        ## weights = 1/Dij
+        wi <- 1 / sapply(SEQ, getWts, dis, ords, k.seq, USE.NAMES = FALSE)
+        ## sum weights
+        sum.wi <- colSums(wi)
+        sum.wi2 <- colSums(wi^2)
+        sum2.wi <- sum.wi^2
+        frac <- sum.wi / (sum2.wi - sum.wi2)
+        ## weighted mean of env of k closest analogues
+        ybar <- colSums(env * wi) / sum.wi ## colMeans(env)
+        ## weighted standard deviation for weights not summing to 1
+        sqrt(frac * colSums(wi * sweep(env, 2, ybar, "-")^2))
+    } else {
+        apply(env, 2, sd)
+    }
+    res
 }

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2012-09-07 22:47:59 UTC (rev 286)
+++ pkg/inst/ChangeLog	2012-09-09 11:42:42 UTC (rev 287)
@@ -2,8 +2,19 @@
 
 Version 0.9-10
 
-	* stdError: calculation assumed weights summed to 1.
+	* stdError: Several changes and enhancements:
 
+	Calculation assumed weights summed to 1. New formula as
+	described in Simpson (2012) is now used. (Reported by Steve
+	Juggins)
+
+	Now have a choice whether to use the weighted SD or not. For
+	predictions based on the mean of the k-closest analogues it
+	would be odd to then use a weighted SD to compute the standard
+	error.
+
+	Gained a print method.
+
 	* caterpillarPlot: can now be called by the shorter name
 	caterpillar().
 

Modified: pkg/man/stdError.Rd
===================================================================
--- pkg/man/stdError.Rd	2012-09-07 22:47:59 UTC (rev 286)
+++ pkg/man/stdError.Rd	2012-09-09 11:42:42 UTC (rev 287)
@@ -4,16 +4,17 @@
 \alias{stdError.predict.mat}
 \title{Standard error of MAT fitted and predicted values}
 \description{
-  Computes the weighted standard deviation of the environment for the
-  \emph{k}-closest analogues for each sample. This measure is proposed
-  as a measure of reconstruction uncertainty for MAT models.
+  Computes the (weighted) standard deviation of the environment for the
+  \emph{k}-closest analogues for each sample. This was proposed as one
+  measure of reconstruction uncertainty for MAT models (ter Braak,
+  1995).
 }
 \usage{
 stdError(object, ...)
 
-\method{stdError}{mat}(object, k, ...)
+\method{stdError}{mat}(object, k, weighted = FALSE, ...)
 
-\method{stdError}{predict.mat}(object, k, ...)
+\method{stdError}{predict.mat}(object, k, weighted = FALSE, ...)
 }
 \arguments{
   \item{object}{Object for which the uncertainty measure is to be
@@ -21,12 +22,20 @@
     \code{\link{predict.mat}}.}
   \item{k}{numeric; how many analogues to take? If missing, the default,
     \code{k} is chosen using \code{\link{getK}}.}
+  \item{weighted}{logical; use a weighted computation?}
   \item{\dots}{Additional arguments passed to other methods. Currently
     not used.}
 }
-%\details{
-%  TODO
-%}
+\details{
+  Two types of standard error can be produced depending upon whether the
+  mean or weighted mean of \eqn{y} for the \eqn{k} closest analogues is
+  used for the MAT predictions. If \code{weighted = FALSE} then the
+  usual standard deviation of the response for the \eqn{k} closest
+  analogues is returned, whereas for \code{weighted = TRUE} a weighted
+  standard deviation is used. The weights are the inverse of the
+  dissimilarity between the target observation and each of the \eqn{k}
+  closest analogues.
+}
 \value{
   A named numeric vector of weighted standard deviations of the
   environment for the \emph{k} closest analogues used to compute the MAT
@@ -36,11 +45,20 @@
   indicating the number of analogues used and whether this was
   determined from \code{object} or supplied by the user.
 }
-%\references{ ~put references to the literature/web site here ~ }
+\references{
+  Simpson, G.L. (2012) Analogue methods in palaeolimnology. In Birks,
+  H.J.B, Lotter, A.F. Juggins S., and Smol, J.P. (Eds) \emph{Tracking
+  Environmental Change Using Lake Sediments, Volume 5: Data Handling and
+  Numerical Techniques}. Springer, Dordrecht. 
+  
+  ter Braak, C.J.F. (1995) Non-linear methods for multivariate
+  statistical calibration and their use in palaeoecology: a comparison
+  of inverse (\emph{k}-nearest neighbours, partial least squares, and
+  weighted averaging partial least squares) and classical
+  approaches. \emph{Chemometrics and Intelligent Laboratory Systems}
+  \strong{28}:165--180.
+}
 \author{Gavin L. Simpson}
-%\note{ ~~further notes~~ 
-%
-%}
 \seealso{\code{\link{minDC}}, \code{\link{mat}},
   \code{\link{predict.mat}}.}
 \examples{
@@ -59,9 +77,15 @@
 ## fit the MAT model using the squared chord distance measure
 ik.mat <- mat(ImbrieKipp, SumSST, method = "SQchord")
 
-## standard errors
+## standard errors - unweighted
 stdError(ik.mat)
+## standard errors - weighted version for above
+stdError(ik.mat, k = getK(ik.mat), weighted = TRUE)
 
+## standard errors - weighted; note this uses more (7) analogues
+## than the above as this model had lowest LOO error
+stdError(ik.mat, weighted = TRUE)
+
 ## reconstruct for the V12-122 core data
 coreV12.mat <- predict(ik.mat, V12.122, k = 3)
 ## standard errors

Modified: pkg/tests/Examples/analogue-Ex.Rout.save
===================================================================
--- pkg/tests/Examples/analogue-Ex.Rout.save	2012-09-07 22:47:59 UTC (rev 286)
+++ pkg/tests/Examples/analogue-Ex.Rout.save	2012-09-09 11:42:42 UTC (rev 287)
@@ -1,5 +1,5 @@
 
-R version 2.15.1 Patched (2012-08-29 r60485) -- "Roasted Marshmallows"
+R version 2.15.1 Patched (2012-07-27 r60002) -- "Roasted Marshmallows"
 Copyright (C) 2012 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 Platform: x86_64-unknown-linux-gnu (64-bit)
@@ -30,7 +30,7 @@
 Loading required package: MASS
 Loading required package: princurve
 Loading required package: mgcv
-This is mgcv 1.7-19. For overview type 'help("mgcv-package")'.
+This is mgcv 1.7-6. For overview type 'help("mgcv-package")'.
 This is analogue 0.9-10
 > 
 > assign(".oldSearch", search(), pos = 'CheckExEnv')
@@ -4950,25 +4950,25 @@
 wa> ## residuals for the training set
 wa> residuals(mod4)
      V14.61     V17.196     V18.110     V16.227      V14.47      V23.22 
--3.89845110 -0.95914236 -0.57577610  0.83646773 -1.12654865  1.85855684 
+-3.89845110 -0.95914237 -0.57577610  0.83646773 -1.12654866  1.85855684 
       V2.12      V23.29      V12.43        R9.7      A157.3      V23.81 
- 4.93907447 -1.56332718  1.02901346 -2.01091601  0.72379237 -2.30397582 
+ 4.93907447 -1.56332718  1.02901346 -2.01091600  0.72379238 -2.30397581 
      V23.82      V12.53      V23.83      V12.56     A152.84      V16.50 
--1.16893886 -1.90464621  0.99721685 -1.39764003  1.29346294 -0.29234573 
+-1.16893885 -1.90464620  0.99721686 -1.39764003  1.29346295 -0.29234573 
     V22.122      V16.41       V4.32      V12.66     V19.245        V4.8 
- 2.13000055 -4.44031821 -0.92783839  0.99172654 -1.49152688  1.88724027 
+ 2.13000056 -4.44031822 -0.92783840  0.99172654 -1.49152689  1.88724026 
     A180.15      V18.34     V20.213     V19.222     A180.39     V16.189 
- 2.78850049 -0.63727536  0.33475038 -0.01275751 -1.65993108 -2.09930701 
+ 2.78850048 -0.63727536  0.33475037 -0.01275751 -1.65993109 -2.09930701 
      V12.18       V7.67     V17.165     V19.310     V16.190    A153.154 
--0.97538682  2.31383515  1.87380536  2.64327583  0.01900072  0.13747169 
+-0.97538682  2.31383514  1.87380535  2.64327583  0.01900071  0.13747169 
     V19.308     V22.172      V10.98     V22.219      V16.33     V22.204 
--0.26612390 -2.21647192  2.40270759  0.25826513 -1.69856608  0.20738893 
+-0.26612390 -2.21647192  2.40270758  0.25826513 -1.69856608  0.20738893 
     V20.167      V10.89      V12.79     V19.216      V14.90     A180.72 
 -0.92731700 -0.84954530 -0.55321548  0.80956624  0.66973330  0.70524398 
      V16.21     A180.76     V15.164     A180.78       V14.5      V3.128 
 -0.23696237 -0.14589252 -0.26826158  0.54819699 -0.32786314  1.64879299 
     A179.13       V9.31     V20.230       V20.7     V20.234      V18.21 
- 1.53212229  0.96958483  0.44047759 -0.17038549 -0.21308146 -0.39014886 
+ 1.53212230  0.96958483  0.44047759 -0.17038549 -0.21308146 -0.39014885 
     V12.122 
  0.72061292 
 > 
@@ -6525,73 +6525,111 @@
 > ## fit the MAT model using the squared chord distance measure
 > ik.mat <- mat(ImbrieKipp, SumSST, method = "SQchord")
 > 
-> ## standard errors
+> ## standard errors - unweighted
 > stdError(ik.mat)
-   V14.61   V17.196   V18.110   V16.227    V14.47    V23.22     V2.12    V23.29 
-3.7017647 2.7940379 2.4904961 3.5144020 2.7300757 3.0418167 2.9199864 1.0952777 
-   V12.43      R9.7    A157.3    V23.81    V23.82    V12.53    V23.83    V12.56 
-2.4168224 3.8347560 1.6422409 1.8922602 1.9662188 2.6825814 0.5043179 2.9932954 
-  A152.84    V16.50   V22.122    V16.41     V4.32    V12.66   V19.245      V4.8 
-3.3706748 2.2382896 2.0969686 3.0440301 0.0000000 1.0495554 2.6358967 2.1929384 
-  A180.15    V18.34   V20.213   V19.222   A180.39   V16.189    V12.18     V7.67 
-2.9604059 1.6382546 2.5610904 2.2776091 0.9980639 0.6977540 0.1364087 1.0693862 
-  V17.165   V19.310   V16.190  A153.154   V19.308   V22.172    V10.98   V22.219 
-1.1469297 1.0946184 2.0219976 0.6101154 0.6061351 0.5269860 1.4875516 0.5643260 
-   V16.33   V22.204   V20.167    V10.89    V12.79   V19.216    V14.90   A180.72 
-1.5194344 1.4172128 1.3626793 1.1202298 0.5381647 1.0771118 0.8011406 0.6104648 
-   V16.21   A180.76   V15.164   A180.78     V14.5    V3.128   A179.13     V9.31 
-0.6381386 0.3198533 0.4701962 0.7742820 0.5714590 1.4633510 0.5972338 0.3021622 
-  V20.230     V20.7   V20.234    V18.21   V12.122 
-0.2980597 0.5809639 0.5854821 0.5723716 0.0000000 
-attr(,"class")
-[1] "stdError"
+
+	Standard deviation of MAT predictions
+
+ k-analogues: 3
+ Weighted   : FALSE
+
+  V14.61  V17.196  V18.110  V16.227   V14.47   V23.22    V2.12   V23.29 
+  3.3292   2.5658   2.5166   3.3292   2.5658   3.0000   2.5658   1.2583 
+  V12.43     R9.7   A157.3   V23.81   V23.82   V12.53   V23.83   V12.56 
+  2.7839   3.2146   1.5000   2.0817   2.0207   2.6458   0.5000   3.0551 
+ A152.84   V16.50  V22.122   V16.41    V4.32   V12.66  V19.245     V4.8 
+  3.4641   2.3629   2.1794   2.5166   0.0000   1.0408   2.2546   2.2546 
+ A180.15   V18.34  V20.213  V19.222  A180.39  V16.189   V12.18    V7.67 
+  3.0551   1.5275   2.5981   2.2546   1.0000   0.6429   0.1155   1.1547 
+ V17.165  V19.310  V16.190 A153.154  V19.308  V22.172   V10.98  V22.219 
+  1.1547   1.1547   2.0000   0.6429   0.6429   0.5292   1.5275   0.5774 
+  V16.33  V22.204  V20.167   V10.89   V12.79  V19.216   V14.90  A180.72 
+  1.5535   1.5000   1.4434   1.1676   0.5000   1.0408   0.7638   0.5774 
+  V16.21  A180.76  V15.164  A180.78    V14.5   V3.128  A179.13    V9.31 
+  0.5292   0.2887   0.4619   0.7638   0.5774   1.5044   0.5774   0.2887 
+ V20.230    V20.7  V20.234   V18.21  V12.122 
+  0.2887   0.5774   0.5774   0.5774   0.0000 
+> ## standard errors - weighted version for above
+> stdError(ik.mat, k = getK(ik.mat), weighted = TRUE)
+
+	Weighted standard deviation of MAT predictions
+
+ k-analogues: 3
+ Weighted   : TRUE
+
+  V14.61  V17.196  V18.110  V16.227   V14.47   V23.22    V2.12   V23.29 
+  3.6236   2.6922   2.4905   3.4762   2.7156   2.9827   2.8185   1.0950 
+  V12.43     R9.7   A157.3   V23.81   V23.82   V12.53   V23.83   V12.56 
+  2.3923   3.5829   1.6044   1.7100   1.7521   2.5962   0.4759   2.9924 
+ A152.84   V16.50  V22.122   V16.41    V4.32   V12.66  V19.245     V4.8 
+  3.3505   2.2243   2.0883   2.7274   0.0000   1.0314   2.3222   2.1879 
+ A180.15   V18.34  V20.213  V19.222  A180.39  V16.189   V12.18    V7.67 
+  2.9545   1.6056   2.5588   2.2645   0.9839   0.6838   0.1276   1.0083 
+ V17.165  V19.310  V16.190 A153.154  V19.308  V22.172   V10.98  V22.219 
+  1.1467   1.0698   2.0196   0.5636   0.5709   0.5259   1.4834   0.5630 
+  V16.33  V22.204  V20.167   V10.89   V12.79  V19.216   V14.90  A180.72 
+  1.5190   1.4169   1.3391   1.1180   0.5088   1.0723   0.8010   0.6063 
+  V16.21  A180.76  V15.164  A180.78    V14.5   V3.128  A179.13    V9.31 
+  0.5797   0.3105   0.4611   0.7731   0.5710   1.4630   0.5954   0.3002 
+ V20.230    V20.7  V20.234   V18.21  V12.122 
+  0.2970   0.5809   0.5851   0.5700   0.0000 
 > 
+> ## standard errors - weighted; note this uses more (7) analogues
+> ## than the above as this model had lowest LOO error
+> stdError(ik.mat, weighted = TRUE)
+
+	Weighted standard deviation of MAT predictions
+
+ k-analogues: 7
+ Weighted   : TRUE
+
+  V14.61  V17.196  V18.110  V16.227   V14.47   V23.22    V2.12   V23.29 
+  3.2045   3.8607   3.7093   3.8413   3.6463   3.3567   2.5745   1.8870 
+  V12.43     R9.7   A157.3   V23.81   V23.82   V12.53   V23.83   V12.56 
+  2.1729   2.6576   2.6189   2.5574   2.0575   2.5081   1.9093   3.3261 
+ A152.84   V16.50  V22.122   V16.41    V4.32   V12.66  V19.245     V4.8 
+  3.3846   2.1971   2.8468   2.3900   1.8478   1.9721   3.1867   2.3264 
+ A180.15   V18.34  V20.213  V19.222  A180.39  V16.189   V12.18    V7.67 
+  3.0681   1.9150   1.9977   2.7098   1.9177   0.6841   0.7857   1.2002 
+ V17.165  V19.310  V16.190 A153.154  V19.308  V22.172   V10.98  V22.219 
+  1.0991   1.3316   1.4314   0.5048   0.9144   0.5466   1.3659   0.6610 
+  V16.33  V22.204  V20.167   V10.89   V12.79  V19.216   V14.90  A180.72 
+  1.2663   1.0450   1.2885   1.0775   1.0370   1.0816   1.0877   0.6390 
+  V16.21  A180.76  V15.164  A180.78    V14.5   V3.128  A179.13    V9.31 
+  0.7313   0.4802   0.8549   0.8869   0.4255   1.0753   0.4841   0.7742 
+ V20.230    V20.7  V20.234   V18.21  V12.122 
+  0.4281   0.5189   0.4316   0.5208   0.1722 
+> 
 > ## reconstruct for the V12-122 core data
 > coreV12.mat <- predict(ik.mat, V12.122, k = 3)
 > ## standard errors
 > stdError(coreV12.mat)
-         0         10         20         30         40         50         60 
-72.3307103  0.6391695  0.6113086  1.6025626  1.3348327  1.3084087  0.8978862 
-        70         80         90        100        110        120        130 
- 1.2413641  1.4600559  1.3768654  0.4941674  0.2879595  1.6022391  0.2934360 
-       140        150        160        170        180        190        200 
- 1.7397088  0.9275737  0.7977268  0.8014461  1.1946764  0.2943270  1.7023691 
-       210        220        230        240        250        260        270 
- 2.2240272  0.5164777  0.6192205  1.4696838  1.3014299  1.2840133  1.5909909 
-       280        290        300        310        320        330        340 
- 1.8396982  0.5974174  1.2814680  1.1491139  1.5922597  1.4498985  1.2714704 
-       350        360        370        380        390        400        410 
- 0.7462475  1.2643008  1.2826104  0.4937233  2.2117480  0.4924661  1.4086468 
-       420        430        440        450        460        470        480 
- 0.2979207  0.5081370  0.3230163  0.0000000  1.4923076  1.2789171  0.2864583 
-       490        500        510        520        530        540        550 
- 1.1551482  0.5925977  0.5086959  0.4774772  1.2652373  0.1148866  1.0407605 
-       560        570        580        590        600        610        620 
- 0.2967980  0.2796920  0.4972385  1.2027792  0.2835480  0.9006515  0.4014728 
-       630        640        650        660        670        680        690 
- 0.2813064  0.5873118  0.7853038  0.2875564  0.4981700  2.2594850  1.2891113 
-       700        710        720        730        740        750        760 
- 0.9713892  1.4526717  1.5179814  1.0454000  0.4918791  0.2977649  0.2869260 
-       770        780        790        800        810        820        830 
- 1.4679702  1.1750746  0.5846293  0.5960886  1.7904245  0.2851860  1.4506051 
-       840        850        860        870        880        890        900 
- 1.0694963  0.5053518  1.3027428  1.2888246  1.5458275  2.0294194  0.7310171 
-       910        920        930        940        950        960        970 
- 1.0429069  1.2370137  0.2763181  0.3011330  0.4632124  0.4977645  0.2866663 
-       980        990       1000       1010       1020       1030       1040 
- 0.2804741  0.2868464  1.4217870  0.2919910  1.0469965  1.4342437  0.5022240 
-      1050       1060       1070       1080       1090 
- 1.3229458  0.2985295  1.3235215  1.7766052  1.3336282 
-attr(,"class")
-[1] "stdError"
-attr(,"k")
-[1] 3
-attr(,"k")attr(,"auto")
-[1] FALSE
-attr(,"k")attr(,"weighted")
-[1] FALSE
-attr(,"auto")
-[1] FALSE
+
+	Standard deviation of MAT predictions
+
+ k-analogues: 3
+ Weighted   : FALSE
+
+     0     10     20     30     40     50     60     70     80     90    100 
+0.5774 0.5774 0.5774 1.6073 1.2767 1.2767 0.8660 1.2583 1.4434 1.3229 0.5000 
+   110    120    130    140    150    160    170    180    190    200    210 
+0.2887 1.6073 0.2887 1.7321 0.9292 0.8145 0.8145 1.1676 0.2887 1.7321 2.2546 
+   220    230    240    250    260    270    280    290    300    310    320 
+0.5000 0.5774 1.4189 1.3229 1.2767 1.6073 1.8028 0.5774 1.2767 1.1547 1.6073 
+   330    340    350    360    370    380    390    400    410    420    430 
+1.4434 1.2583 0.7506 1.2767 1.2767 0.5000 2.2546 0.5000 1.4189 0.2887 0.5000 
+   440    450    460    470    480    490    500    510    520    530    540 
+0.2887 0.0000 1.4422 1.2767 0.2887 1.1547 0.5774 0.5000 0.5000 1.2767 0.1155 
+   550    560    570    580    590    600    610    620    630    640    650 
+1.0408 0.2887 0.2887 0.5000 1.2767 0.2887 0.9019 0.4041 0.2887 0.5774 0.7638 
+   660    670    680    690    700    710    720    730    740    750    760 
+0.2887 0.5000 2.2546 1.2583 0.9644 1.4422 1.5275 1.0408 0.5000 0.2887 0.2887 
+   770    780    790    800    810    820    830    840    850    860    870 
+1.4422 1.1547 0.5774 0.5774 1.8028 0.2887 1.3229 1.0408 0.5000 1.3229 1.2767 
+   880    890    900    910    920    930    940    950    960    970    980 
+1.6073 2.0000 0.7638 1.0408 1.3229 0.2887 0.2887 0.4619 0.5000 0.2887 0.2887 
+   990   1000   1010   1020   1030   1040   1050   1060   1070   1080   1090 
+0.2887 1.4434 0.2887 1.0408 1.4434 0.5000 1.3229 0.2887 1.3229 1.8028 1.3229 
 > 
 > 
 > 
@@ -7086,25 +7124,25 @@
 > ## residuals for the training set
 > residuals(mod4)
      V14.61     V17.196     V18.110     V16.227      V14.47      V23.22 
--3.89845110 -0.95914236 -0.57577610  0.83646773 -1.12654865  1.85855684 
+-3.89845110 -0.95914237 -0.57577610  0.83646773 -1.12654866  1.85855684 
       V2.12      V23.29      V12.43        R9.7      A157.3      V23.81 
- 4.93907447 -1.56332718  1.02901346 -2.01091601  0.72379237 -2.30397582 
+ 4.93907447 -1.56332718  1.02901346 -2.01091600  0.72379238 -2.30397581 
      V23.82      V12.53      V23.83      V12.56     A152.84      V16.50 
--1.16893886 -1.90464621  0.99721685 -1.39764003  1.29346294 -0.29234573 
+-1.16893885 -1.90464620  0.99721686 -1.39764003  1.29346295 -0.29234573 
     V22.122      V16.41       V4.32      V12.66     V19.245        V4.8 
- 2.13000055 -4.44031821 -0.92783839  0.99172654 -1.49152688  1.88724027 
+ 2.13000056 -4.44031822 -0.92783840  0.99172654 -1.49152689  1.88724026 
     A180.15      V18.34     V20.213     V19.222     A180.39     V16.189 
- 2.78850049 -0.63727536  0.33475038 -0.01275751 -1.65993108 -2.09930701 
+ 2.78850048 -0.63727536  0.33475037 -0.01275751 -1.65993109 -2.09930701 
      V12.18       V7.67     V17.165     V19.310     V16.190    A153.154 
--0.97538682  2.31383515  1.87380536  2.64327583  0.01900072  0.13747169 
+-0.97538682  2.31383514  1.87380535  2.64327583  0.01900071  0.13747169 
     V19.308     V22.172      V10.98     V22.219      V16.33     V22.204 
--0.26612390 -2.21647192  2.40270759  0.25826513 -1.69856608  0.20738893 
+-0.26612390 -2.21647192  2.40270758  0.25826513 -1.69856608  0.20738893 
     V20.167      V10.89      V12.79     V19.216      V14.90     A180.72 
 -0.92731700 -0.84954530 -0.55321548  0.80956624  0.66973330  0.70524398 
      V16.21     A180.76     V15.164     A180.78       V14.5      V3.128 
 -0.23696237 -0.14589252 -0.26826158  0.54819699 -0.32786314  1.64879299 
     A179.13       V9.31     V20.230       V20.7     V20.234      V18.21 
- 1.53212229  0.96958483  0.44047759 -0.17038549 -0.21308146 -0.39014886 
+ 1.53212230  0.96958483  0.44047759 -0.17038549 -0.21308146 -0.39014885 
     V12.122 
  0.72061292 
 > 
@@ -7254,7 +7292,7 @@
 > ### * <FOOTER>
 > ###
 > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed:  18.418 0.198 19.118 0 0 
+Time elapsed:  15.918 0.228 16.336 0 0 
 > grDevices::dev.off()
 null device 
           1 



More information about the Analogue-commits mailing list