[Distr-commits] r205 - in branches/distr-2.0/pkg/distrMod: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jul 28 12:06:03 CEST 2008
Author: stamats
Date: 2008-07-28 12:06:03 +0200 (Mon, 28 Jul 2008)
New Revision: 205
Added:
branches/distr-2.0/pkg/distrMod/R/Estimate.R
branches/distr-2.0/pkg/distrMod/R/Estimator.R
branches/distr-2.0/pkg/distrMod/man/Estimate-class.Rd
branches/distr-2.0/pkg/distrMod/man/Estimator.Rd
branches/distr-2.0/pkg/distrMod/man/MCEstimate-class.Rd
Log:
further implementations and documentations
Added: branches/distr-2.0/pkg/distrMod/R/Estimate.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/Estimate.R (rev 0)
+++ branches/distr-2.0/pkg/distrMod/R/Estimate.R 2008-07-28 10:06:03 UTC (rev 205)
@@ -0,0 +1,34 @@
+###############################################################################
+## Functions and methods for "Estimate" classes
+###############################################################################
+
+setMethod("name", "Estimate", function(object) object at name)
+setReplaceMethod("name", "Estimate",
+ function(object, value) {object at name <- value; object})
+
+setMethod("estimate", "Estimate", function(object) object at estimate)
+
+setMethod("Infos", "Estimate", function(object) object at Infos)
+setReplaceMethod("Infos", "Estimate",
+ function(object, value){
+ object at Infos <- value
+ if(!is.character(value))
+ stop("'value' is no matrix of characters")
+ if(ncol(value)!=2)
+ stop("'value' has to be a matrix with two columns")
+ object
+ })
+
+setMethod("addInfo<-", "Estimate",
+ function(object, value){
+ object at Infos <- rbind(object at Infos, " " = value)
+ if(length(value)!=2)
+ stop("length of 'value' is != 2")
+ if(!is.character(value))
+ stop("'value' is no vector of characters")
+ object
+ })
+
+setMethod("criterion", "MCEstimate", function(object) object at criterion)
+setReplaceMethod("criterion", "MCEstimate",
+ function(object, value) {object at criterion <- value; object})
Added: branches/distr-2.0/pkg/distrMod/R/Estimator.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/Estimator.R (rev 0)
+++ branches/distr-2.0/pkg/distrMod/R/Estimator.R 2008-07-28 10:06:03 UTC (rev 205)
@@ -0,0 +1,18 @@
+###############################################################################
+## Determine estimator
+###############################################################################
+Estimator <- function(x, estimator, name, Infos, ...){
+ if(missing(name))
+ name <- "Some estimator"
+
+ if(missing(Infos))
+ Infos <- matrix(c(character(0),character(0)), ncol=2,
+ dimnames=list(character(0), c("method", "message")))
+ else{
+ Infos <- matrix(c(rep("MCEstimator", length(Infos)), Infos), ncol = 2)
+ colnames(Infos) <- c("method", "message")
+ }
+
+ new("Estimate", name = name, estimate = estimator(x, ...),
+ Infos = Infos)
+}
Added: branches/distr-2.0/pkg/distrMod/man/Estimate-class.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/Estimate-class.Rd (rev 0)
+++ branches/distr-2.0/pkg/distrMod/man/Estimate-class.Rd 2008-07-28 10:06:03 UTC (rev 205)
@@ -0,0 +1,69 @@
+\name{Estimate-class}
+\docType{class}
+\alias{Estimate-class}
+\alias{name,Estimate-method}
+\alias{name<-,Estimate-method}
+\alias{estimate}
+\alias{estimate,Estimate-method}
+\alias{Infos}
+\alias{Infos,Estimate-method}
+\alias{Infos<-}
+\alias{Infos<-,Estimate-method}
+\alias{addInfo<-}
+\alias{addInfo<-,Estimate-method}
+\alias{show,Estimate-method}
+
+\title{Estimate-class.}
+\description{Class of estimates.}
+\section{Objects from the Class}{
+ Objects can be created by calls of the form \code{new("Estimate", ...)}.
+ More frequently they are created via the generating function
+ \code{Estimator}.
+}
+\section{Slots}{
+ \describe{
+ \item{\code{name}:}{Object of class \code{"character"}:
+ name of the estimator. }
+ \item{\code{estimate}:}{Object of class \code{"ANY"}:
+ estimate.}
+ \item{\code{Infos}:}{ object of class \code{"matrix"}
+ with two columns named \code{method} and \code{message}:
+ additional informations. }
+ }
+}
+\section{Methods}{
+ \describe{
+ \item{name}{\code{signature(object = "Estimate")}:
+ accessor function for slot \code{name}. }
+
+ \item{name<-}{\code{signature(object = "Estimate")}:
+ replacement function for slot \code{name}. }
+
+ \item{estimate}{\code{signature(object = "Estimate")}:
+ accessor function for slot \code{estimate}. }
+
+ \item{Infos}{\code{signature(object = "Estimate")}:
+ accessor function for slot \code{Infos}. }
+
+ \item{Infos<-}{\code{signature(object = "Estimate")}:
+ replacement function for slot \code{Infos}. }
+
+ \item{Infos<-}{\code{signature(object = "Estimate")}:
+ replacement function for slot \code{Infos}. }
+
+ \item{addInfo<-}{\code{signature(object = "Estimate")}:
+ function to add an information to slot \code{Infos}. }
+
+ \item{show}{\code{signature(object = "Estimate")}}
+ }
+}
+%\references{}
+\author{Matthias Kohl \email{Matthias.Kohl at stamats.de}}
+%\note{}
+\seealso{\code{\link{Estimator}}}
+\examples{
+x <- rnorm(100)
+Estimator(x, estimator = mean, name = "mean")
+}
+\concept{estimate}
+\keyword{classes}
Added: branches/distr-2.0/pkg/distrMod/man/Estimator.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/Estimator.Rd (rev 0)
+++ branches/distr-2.0/pkg/distrMod/man/Estimator.Rd 2008-07-28 10:06:03 UTC (rev 205)
@@ -0,0 +1,38 @@
+\name{Estimator}
+\alias{Estimator}
+
+\title{ Function to compute estimators }
+\description{
+ The function \code{Estimator} provides a general way to compute
+ estimators.
+}
+\usage{
+Estimator(x, estimator, name, Infos, ...)
+}
+\arguments{
+ \item{x}{ (empirical) data }
+ \item{estimator}{ function: estimator to be evaluated on \code{x}. }
+ \item{name}{ optional name for estimator. }
+ \item{Infos}{ character: optional informations about estimator }
+ \item{\dots}{ further arguments to \code{estimator}. }
+}
+\details{
+ The argument \code{criterion} has to be a function with arguments the
+ empirical data as well as an object of class \code{"Distribution"}
+ and possibly \code{\dots}.
+}
+\value{
+ An object of S4-class \code{"Estimate"}.
+}
+%\references{ }
+\author{Matthias Kohl \email{Matthias.Kohl at stamats.de}}
+%\note{}
+\seealso{\code{\link{Estimate-class}} }
+\examples{
+x <- rnorm(100)
+Estimator(x, estimator = mean, name = "mean")
+
+X <- matrix(rnorm(1000), nrow = 10)
+Estimator(X, estimator = rowMeans, name = "mean")
+}
+\keyword{univar}
Added: branches/distr-2.0/pkg/distrMod/man/MCEstimate-class.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/MCEstimate-class.Rd (rev 0)
+++ branches/distr-2.0/pkg/distrMod/man/MCEstimate-class.Rd 2008-07-28 10:06:03 UTC (rev 205)
@@ -0,0 +1,54 @@
+\name{MCEstimate-class}
+\docType{class}
+\alias{MCEstimate-class}
+\alias{criterion}
+\alias{criterion,MCEstimate-method}
+\alias{criterion<-}
+\alias{criterion<-,MCEstimate-method}
+
+\title{MCEstimate-class.}
+\description{Class of minimum criterion estimates.}
+\section{Objects from the Class}{
+ Objects can be created by calls of the form \code{new("MCEstimate", ...)}.
+ More frequently they are created via the generating functions
+ \code{MCEstimator}, \code{MDEstimator} or \code{MLEstimator}.
+}
+\section{Slots}{
+ \describe{
+ \item{\code{name}:}{Object of class \code{"character"}:
+ name of the estimator. }
+ \item{\code{estimate}:}{Object of class \code{"ANY"}:
+ estimate.}
+ \item{\code{criterion}:}{Object of class \code{"numeric"}:
+ minimum value of the considered criterion.}
+ \item{\code{Infos}:}{ object of class \code{"matrix"}
+ with two columns named \code{method} and \code{message}:
+ additional informations. }
+ }
+}
+\section{Methods}{
+ \describe{
+ \item{criterion}{\code{signature(object = "MCEstimate")}:
+ accessor function for slot \code{criterion}. }
+
+ \item{criterion<-}{\code{signature(object = "MCEstimate")}:
+ replacement function for slot \code{criterion}. }
+ }
+}
+%\references{}
+\author{Matthias Kohl \email{Matthias.Kohl at stamats.de}}
+%\note{}
+\seealso{\code{\link{Estimate-class}}, \code{\link{MCEstimator}},
+ \code{\link{MDEstimator}}, \code{\link{MLEstimator}}}
+\examples{
+## (empirical) Data
+x <- rgamma(50, scale = 0.5, shape = 3)
+
+## parametric family of probability measures
+G <- GammaFamily(scale = 1, shape = 2)
+
+MDEstimator(x, G)
+MLEstimator(x, G)
+}
+\concept{estimate}
+\keyword{classes}
More information about the Distr-commits
mailing list