[Archetypes-commits] r57 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 2 22:28:31 CEST 2012


Author: manuel
Date: 2012-05-02 22:28:30 +0200 (Wed, 02 May 2012)
New Revision: 57

Added:
   pkg/man/predict.Rd
Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/archetypes-class.R
   pkg/R/archetypes-kit.R
   pkg/man/archetypes-generics.Rd
   pkg/man/as.archetypes.Rd
Log:
predict.

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-04-26 13:33:11 UTC (rev 56)
+++ pkg/DESCRIPTION	2012-05-02 20:28:30 UTC (rev 57)
@@ -1,42 +1,42 @@
-Package: archetypes
-Type: Package
-Title: Archetypal Analysis
-Version: 2.1-0
-Date: 2011-10-25
-Depends:
-    methods,
-    stats,
-    modeltools,
-    nnls (>= 1.1)
-Suggests:
-    MASS,
-    vcd,
-    mlbench,
-    ggplot2
-Author: Manuel J. A. Eugster
-    <manuel.eugster at stat.uni-muenchen.de>
-Maintainer: Manuel J. A. Eugster
-    <manuel.eugster at stat.uni-muenchen.de>
-Description: The main function archetypes implements a
-    framework for archetypal analysis supporting arbitary
-    problem solving mechanisms for the different conceputal
-    parts of the algorithm.
-License: GPL (>= 2)
-Revision: 44
-Collate:
-    'archetypes-barplot.R'
-    'generics.R'
-    'archetypes-class.R'
-    'archetypes-kit-blocks.R'
-    'archetypes-kit.R'
-    'archetypes-movie.R'
-    'archetypes-panorama.R'
-    'pcplot.R'
-    'archetypes-pcplot.R'
-    'archetypes-robust.R'
-    'archetypes-screeplot.R'
-    'archetypes-step.R'
-    'archetypes-weighted.R'
-    'archetypes-xyplot.R'
-    'memento.R'
-    'skeletonplot.R'
+Package: archetypes
+Type: Package
+Title: Archetypal Analysis
+Version: 2.1-0
+Date: 2011-10-25
+Depends:
+    methods,
+    stats,
+    modeltools,
+    nnls (>= 1.1)
+Suggests:
+    MASS,
+    vcd,
+    mlbench,
+    ggplot2
+Author: Manuel J. A. Eugster
+    <manuel.eugster at stat.uni-muenchen.de>
+Maintainer: Manuel J. A. Eugster
+    <manuel.eugster at stat.uni-muenchen.de>
+Description: The main function archetypes implements a
+    framework for archetypal analysis supporting arbitary
+    problem solving mechanisms for the different conceputal
+    parts of the algorithm.
+License: GPL (>= 2)
+Revision: 44
+Collate:
+    'archetypes-barplot.R'
+    'generics.R'
+    'archetypes-class.R'
+    'archetypes-kit-blocks.R'
+    'archetypes-kit.R'
+    'archetypes-movie.R'
+    'archetypes-panorama.R'
+    'pcplot.R'
+    'archetypes-pcplot.R'
+    'archetypes-robust.R'
+    'archetypes-screeplot.R'
+    'archetypes-step.R'
+    'archetypes-weighted.R'
+    'archetypes-xyplot.R'
+    'memento.R'
+    'skeletonplot.R'

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2012-04-26 13:33:11 UTC (rev 56)
+++ pkg/NAMESPACE	2012-05-02 20:28:30 UTC (rev 57)
@@ -36,6 +36,7 @@
 S3method(panorama,archetypes)
 S3method(pcplot,archetypes)
 S3method(pcplot,default)
+S3method(predict,archetypes)
 S3method(print,archetypes)
 S3method(print,repArchetypes)
 S3method(print,stepArchetypes)

Modified: pkg/R/archetypes-class.R
===================================================================
--- pkg/R/archetypes-class.R	2012-04-26 13:33:11 UTC (rev 56)
+++ pkg/R/archetypes-class.R	2012-05-02 20:28:30 UTC (rev 57)
@@ -23,6 +23,7 @@
 #' @param residuals The residuals.
 #' @param weights The data weights.
 #' @param reweights The data reweights.
+#' @param scaling The scaling parameters of the data.
 #'
 #' @return A list with an element for each parameter and class attribute
 #'   \code{archetypes}.
@@ -33,7 +34,7 @@
 as.archetypes <- function(object, k, alphas, rss, iters = NULL, call = NULL,
                           history = NULL, kappas = NULL, betas = NULL, zas = NULL,
                           family = NULL, familyArgs = NULL, residuals = NULL,
-                          weights = NULL, reweights = NULL) {
+                          weights = NULL, reweights = NULL, scaling = NULL) {
 
   return(structure(list(archetypes = object,
                         k = k,
@@ -49,7 +50,8 @@
                         familyArgs = familyArgs,
                         residuals = residuals,
                         weights = weights,
-                        reweights = reweights),
+                        reweights = reweights,
+                        scaling = scaling),
                    class = c(family$class, 'archetypes')))
 }
 
@@ -212,20 +214,35 @@
 
 
 
-### Not implemented yet: #############################################
+#' Predict method for archetypal analysis
+#'
+#' @param object An \code{archetypes} object.
+#' @param newdata A data frame with data for which to
+#'   predict the alpha coefficients.
+#' @param ... Ignored.
+#' @return The predict alpha coefficients.
+#' @rdname predict
+#'
+#' @method predict archetypes
+#' @S3method predict archetypes
+predict.archetypes <- function(object, newdata, ...) {
+  stopifnot(object$family$which == "original")
+  
+  scale <- object$scaling
 
-predict.archetypes <- function(object, newdata = NULL,
-                               type = c('alphas', 'data'), ...) {
-  type <- match.arg(type)
+  ## HACK: use blocks!
+  x <- t(newdata)
+  x <- x - scale$mean
+  x <- x / scale$sd
+  x <- object$family$dummyfn(x, ...)
 
-  if ( is.null(newdata) )
-    return(switch(type,
-                  alphas = coef(object, type = 'alphas'),
-                  data = fitted(object)))
+  zs <- t(parameters(object))
+  zs <- zs - scale$mean
+  zs <- zs / scale$sd
+  zs <- rbind(zs, 200)
 
-  stop('Not implemented yet.')
+  alphas <- matrix(NA, ncol = ncol(x), nrow = ncol(coef(object)))
+  alphas <- object$family$alphasfn(alphas, zs, x)
 
-  ### Something like the following ...
-  #if ( type == 'alphas' )
-  #  object$family$alphasfn(NULL, t(object$archetypes), t(newdata))
+  t(alphas)
 }

Modified: pkg/R/archetypes-kit.R
===================================================================
--- pkg/R/archetypes-kit.R	2012-04-26 13:33:11 UTC (rev 56)
+++ pkg/R/archetypes-kit.R	2012-05-02 20:28:30 UTC (rev 57)
@@ -177,7 +177,8 @@
                        call = mycall, history = memento, kappas = kappas,
                        betas = t(betas), family = family,
                        familyArgs = famargs, residuals = t(resid),
-                       weights = weights, reweights = reweights))
+                       weights = weights, reweights = reweights,
+                       scaling = attr(x1, ".Meta")))
 }
 
 

Modified: pkg/man/archetypes-generics.Rd
===================================================================
--- pkg/man/archetypes-generics.Rd	2012-04-26 13:33:11 UTC (rev 56)
+++ pkg/man/archetypes-generics.Rd	2012-05-02 20:28:30 UTC (rev 57)
@@ -1,37 +1,37 @@
-\name{rss}
-\alias{bestModel}
-\alias{nparameters}
-\alias{panorama}
-\alias{pcplot}
-\alias{rss}
-\title{Defined generics}
-\usage{
-  rss(object, ...)
-
-  nparameters(object, ...)
-
-  bestModel(object, ...)
-
-  panorama(object, ...)
-
-  pcplot(x, ...)
-}
-\arguments{
-  \item{object}{An object}
-
-  \item{...}{Futher arguments}
-
-  \item{x}{An object.}
-}
-\description{
-  Generics defined by the archetypes package.
-
-  Return number of parameters
-
-  Return best model
-
-  Panorama
-
-  Parallel coordinates plot
-}
-
+\name{rss}
+\alias{bestModel}
+\alias{nparameters}
+\alias{panorama}
+\alias{pcplot}
+\alias{rss}
+\title{Defined generics}
+\usage{
+  rss(object, ...)
+
+  nparameters(object, ...)
+
+  bestModel(object, ...)
+
+  panorama(object, ...)
+
+  pcplot(x, ...)
+}
+\arguments{
+  \item{object}{An object}
+
+  \item{...}{Futher arguments}
+
+  \item{x}{An object.}
+}
+\description{
+  Generics defined by the archetypes package.
+
+  Return number of parameters
+
+  Return best model
+
+  Panorama
+
+  Parallel coordinates plot
+}
+


Property changes on: pkg/man/archetypes-generics.Rd
___________________________________________________________________
Added: svn:keywords
   + Date Revision Author URL Id
Added: svn:eol-style
   + native

Modified: pkg/man/as.archetypes.Rd
===================================================================
--- pkg/man/as.archetypes.Rd	2012-04-26 13:33:11 UTC (rev 56)
+++ pkg/man/as.archetypes.Rd	2012-05-02 20:28:30 UTC (rev 57)
@@ -1,65 +1,67 @@
-\name{as.archetypes}
-\alias{as.archetypes}
-\title{Archetypes object constructor}
-\usage{
-  as.archetypes(object, k, alphas, rss, iters = NULL,
-    call = NULL, history = NULL, kappas = NULL,
-    betas = NULL, zas = NULL, family = NULL,
-    familyArgs = NULL, residuals = NULL, weights = NULL,
-    reweights = NULL)
-}
-\arguments{
-  \item{object}{The archetypes; a \eqn{p \times m} matrix,
-  see \code{\link{parameters}}.}
-
-  \item{k}{The number of archetypes;}
-
-  \item{alphas}{The coefficients; a \eqn{n \times p}
-  matrix, see \code{\link{coef}}.}
-
-  \item{rss}{The residual sum of squares; see
-  \code{\link{rss.archetypes}}.}
-
-  \item{iters}{The number of iterations to the
-  convergence.}
-
-  \item{call}{The call of the \code{\link{archetypes}}
-  function.}
-
-  \item{history}{If \code{saveHistory} set then an
-  environment with the archetypes object for each execution
-  step;}
-
-  \item{kappas}{The kappas for each system of linear
-  equations.}
-
-  \item{betas}{The data coefficients; a \eqn{p \times n}
-  matrix.}
-
-  \item{zas}{The temporary archetypes.}
-
-  \item{family}{The archetypes family.}
-
-  \item{familyArgs}{Additional arguments for family
-  blocks.}
-
-  \item{residuals}{The residuals.}
-
-  \item{weights}{The data weights.}
-
-  \item{reweights}{The data reweights.}
-}
-\value{
-  A list with an element for each parameter and class
-  attribute \code{archetypes}.
-}
-\description{
-  Archetypes object constructor
-}
-\seealso{
-  Other archetypes: \code{\link{archetypes}},
-  \code{\link{archetypesFamily}},
-  \code{\link{robustArchetypes}},
-  \code{\link{weightedArchetypes}}
-}
-
+\name{as.archetypes}
+\alias{as.archetypes}
+\title{Archetypes object constructor}
+\usage{
+  as.archetypes(object, k, alphas, rss, iters = NULL,
+    call = NULL, history = NULL, kappas = NULL,
+    betas = NULL, zas = NULL, family = NULL,
+    familyArgs = NULL, residuals = NULL, weights = NULL,
+    reweights = NULL, scaling = NULL)
+}
+\arguments{
+  \item{object}{The archetypes; a \eqn{p \times m} matrix,
+  see \code{\link{parameters}}.}
+
+  \item{k}{The number of archetypes;}
+
+  \item{alphas}{The coefficients; a \eqn{n \times p}
+  matrix, see \code{\link{coef}}.}
+
+  \item{rss}{The residual sum of squares; see
+  \code{\link{rss.archetypes}}.}
+
+  \item{iters}{The number of iterations to the
+  convergence.}
+
+  \item{call}{The call of the \code{\link{archetypes}}
+  function.}
+
+  \item{history}{If \code{saveHistory} set then an
+  environment with the archetypes object for each execution
+  step;}
+
+  \item{kappas}{The kappas for each system of linear
+  equations.}
+
+  \item{betas}{The data coefficients; a \eqn{p \times n}
+  matrix.}
+
+  \item{zas}{The temporary archetypes.}
+
+  \item{family}{The archetypes family.}
+
+  \item{familyArgs}{Additional arguments for family
+  blocks.}
+
+  \item{residuals}{The residuals.}
+
+  \item{weights}{The data weights.}
+
+  \item{reweights}{The data reweights.}
+
+  \item{scaling}{The scaling parameters of the data.}
+}
+\value{
+  A list with an element for each parameter and class
+  attribute \code{archetypes}.
+}
+\description{
+  Archetypes object constructor
+}
+\seealso{
+  Other archetypes: \code{\link{archetypes}},
+  \code{\link{archetypesFamily}},
+  \code{\link{robustArchetypes}},
+  \code{\link{weightedArchetypes}}
+}
+

Added: pkg/man/predict.Rd
===================================================================
--- pkg/man/predict.Rd	                        (rev 0)
+++ pkg/man/predict.Rd	2012-05-02 20:28:30 UTC (rev 57)
@@ -0,0 +1,21 @@
+\name{predict.archetypes}
+\alias{predict.archetypes}
+\title{Predict method for archetypal analysis}
+\usage{
+  \method{predict}{archetypes} (object, newdata, ...)
+}
+\arguments{
+  \item{object}{An \code{archetypes} object.}
+
+  \item{newdata}{A data frame with data for which to
+  predict the alpha coefficients.}
+
+  \item{...}{Ignored.}
+}
+\value{
+  The predict alpha coefficients.
+}
+\description{
+  Predict method for archetypal analysis
+}
+


Property changes on: pkg/man/predict.Rd
___________________________________________________________________
Added: svn:eol-style
   + native



More information about the Archetypes-commits mailing list