...
 
Commits (3)
Package: HandTill2001
Type: Package
Title: Multiple Class Area under ROC Curve
Version: 1.0.0
Version: 1.0.0.9000
[email protected]: c(person(given = c("Andreas", "Dominik"), family = "Cullmann",
email = "[email protected]", role = c("aut","cre")),
person(given = c("Edgar"), family=c("Kublin"), role = c("ctb"))
......@@ -19,3 +19,4 @@ Suggests:
mda,
nnet
License: GPL (>= 2)
RoxygenNote: 7.0.2
# Generated by roxygen2: do not edit by hand
export(bincap)
exportClasses(bincap)
exportClasses(cap)
exportClasses(multcap)
exportMethods(auc)
export(multcap)
import(methods)
import(utils)
#' Class \code{"cap"} in Package \pkg{HandTill2001}
#'
#' A virtual class for \code{"bincap"} and \code{"multcap"}.
#'
#'
#' @name cap-class
#' @docType class
#' @section Objects from the Class: A virtual Class: No objects may be created
#' from it.
#' @author Andreas Dominik Cullmann
#' @seealso \code{"\link[=bincap-class]{class?bincap}"},
#' \code{"\link[=multcap-class]{class?multcap}"}
#' @keywords classes
setClass(Class = "cap"
, representation = representation(
response = "factor"
......@@ -8,6 +21,33 @@ setClass(Class = "cap"
}
)
#' Class \code{"bincap"} in Package \pkg{HandTill2001}
#'
#' S4 class for a two class response and corresponding (predicted)
#' probabilities.
#'
#'
#' @name bincap-class
#' @docType class
#' @note No defaults are set. Especially, you have to explicitly initialize
#' \code{true}, there is no trying to guess it from the \code{levels} of
#' \code{response}.
#' @section Objects from the Class: Objects can be created by calls of the form
#' \code{new("bincap", ...)}. They are used to store a two class response (one
#' of the two \code{levels} of which is supposed to be \code{true}), the
#' information which of the two \code{levels} of the two class response is
#' thought of as 'true'/'positive'/'present' (the other one would then be
#' thought of as 'false'/'negative'/'absence') and the predicted probabilities
#' that \code{response} is \code{true}.
#' @author Andreas Dominik Cullmann
#' @seealso \code{"\link[=cap-class]{class?cap}"} ,
#' \code{"\link[=multcap-class]{class?multcap}"} ,
#' \code{"\link[=bincap]{?bincap}"}
#' @keywords classes
#' @examples
#'
#' showClass("bincap")
#'
setClass(Class = "bincap"
, contains = "cap"
, representation = representation(
......@@ -26,6 +66,28 @@ setClass(Class = "bincap"
return("response has to be a two class factor.")
}
)
#' Class \code{"multcap"} in Package \pkg{HandTill2001}
#'
#' S4 class for a multiple class response and corresponding (predicted)
#' probabilities.
#'
#'
#' @name multcap-class
#' @docType class
#' @section Objects from the Class: Objects can be created by calls of the form
#' \code{new("multcap", ...)}. They are used to store a multiple class response
#' and the predicted probabilities for each of the \code{levels(response)}.
#' @author Andreas Dominik Cullmann
#' @seealso \code{"\link[=cap-class]{class?cap}"} ,
#' \code{"\link[=bincap-class]{class?bincap}"} ,
#' \code{"\link[=multcap]{?multcap}"}
#' @keywords classes
#' @examples
#'
#' showClass("multcap")
#'
setClass(Class = "multcap"
, contains = "cap"
, representation = representation(
......
#' a ui-constructor for Class \code{"bincap"} in Package \pkg{HandTill2001}
#'
#' \code{bincap(\dots{})} is an alias to \code{new("bincap", \dots{})}.
#'
#' There is no casting or conversion of data. \code{bincap(\dots{})} is just an
#' alias to \code{new("bincap",\dots{})}.
#'
#' @param response Object of class \code{"factor"}.
#' @param predicted Object of class \code{"numeric"}.
#' @param true Object of class \code{"character"}.
#' @return An object of class \code{"bincap"}
#' @author Andreas Dominik Cullmann
#' @seealso \code{"\link[=bincap-class]{class?bincap}"}
#' @keywords ui-constructor
#' @examples
#'
#' library(HandTill2001)
#' data(ht01.twoclass)
#' str(ht01.twoclass$observed)
#' message("note that ht01.twoclass$observed is not a factor; we have to convert it.")
#' bincap(
#' response = as.factor(ht01.twoclass$observed)
#' , predicted = ht01.twoclass$predicted
#' , true = c("1")
#' )
#'
#'
#' @export bincap
bincap <-
function (response, predicted, true = "1")
{
......@@ -6,6 +34,34 @@ function (response, predicted, true = "1")
}
#' a ui-constructor for Class \code{"multcap"} in Package \pkg{HandTill2001}
#'
#' \code{multcap(\dots{})} is an alias to \code{new("multcap", \dots{})}.
#'
#' There is no casting or conversion of data. \code{multcap(\dots{})} is just
#' an alias to \code{new("multcap", \dots{})}.
#'
#' @param response Object of class \code{"factor"}.
#' @param predicted Object of class \code{"matrix"}.
#' @return An object of class \code{"bincap"}
#' @author Andreas Dominik Cullmann
#' @seealso \code{"\link[=multcap-class]{class?multcap}"}
#' @keywords ui-constructor
#' @examples
#'
#' library(HandTill2001)
#' data(ht01.multipleclass)
#' str(ht01.multipleclass$observed)
#' message("note that ht01.multipleclass$observed is a factor; we do not have to convert it.")
#' multcap(
#' response = ht01.multipleclass$observed
#' , predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
#' )
#'
#'
#' @export multcap
multcap <-
function (response, predicted)
{
......
#' Multiple Class Area under ROC Curve
#'
#' A very lean package implementing merely \eqn{M} given by \cite{Hand and Till
#' (2001)}, Eq. (7).
#'
#' \eqn{M} given by \cite{Hand and Till (2001)} defines a multiple class
#' version of the area under curve of the receiver operating characteristic.
#'
#' @name HandTill2001-package
#' @aliases HandTill2001-package HandTill2001
#' @docType package
#' @seealso \code{help(package="HandTill2001")}, especially
#' \code{"\link[=auc-methods]{methods?auc}"}; various packages that calculate
#' two class AUC (\code{"\link[ROCR:performance]{ROCR}"}) or multiple class AUC
#' (pROC, \code{"\link[caTools:caTools-package]{caTools}"}).
#' @references \cite{David J. Hand and Robert J. Till (2001). A Simple
#' Generalisation of the Area Under the ROC Curve for Multiple Class
#' Classification Problems. \emph{Machine Learning} \bold{45}(2), p. 171--186.
#' DOI:
#' \href{http://dx.doi.org/10.1023/A:1010920819831}{10.1023/A:1010920819831}}.
#' @keywords AUC, ROC
#' @examples
#'
#' library(HandTill2001)
#' data(ht01.multipleclass)
#' auc(
#' multcap(
#' response = ht01.multipleclass$observed
#' , predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
#' )
#' )
#'
NULL
#' Methods for Function \code{auc} in Package \pkg{HandTill2001}
#'
#' Calculate area under curve of the receiver operating characteristic for two
#' or more prediction classes.
#'
#' Depending on whether \code{object} is of class \code{"bincap"} or of class
#' \code{"multcap"}, a two class or multiple class AUC is calculated.
#'
#' @name auc-methods
#' @aliases auc-methods auc auc,bincap-method auc,multcap-method
#' @docType methods
#' @return An object of class \code{"numeric"}.
#' @section Methods: \describe{
#'
#' \item{list("signature(object = \"bincap\")")}{ calculates the AUC statistic
#' for a two class response following \cite{Hand and Till (2001)}, Eq. (3). }
#'
#' \item{list("signature(object = \"multcap\")")}{ calculates the AUC statistic
#' for a multiple class response following \cite{Hand and Till (2001)}, Eq.
#' (7). } }
#' @seealso \code{"\link[=bincap-class]{class?bincap}"},
#' \code{"\link[=multcap-class]{class?multcap}"}
#' @references \cite{David J. Hand and Robert J. Till (2001). A Simple
#' Generalisation of the Area Under the ROC Curve for Multiple Class
#' Classification Problems. \emph{Machine Learning} \bold{45}(2), p. 171--186.
#' DOI:
#' \href{http://dx.doi.org/10.1023/A:1010920819831}{10.1023/A:1010920819831}}.
#' @keywords methods auc
#' @examples
#'
#' library(HandTill2001)
#' data(ht01.twoclass)
#' data(ht01.multipleclass)
#' message(" == AUC for a two class response")
#' \dontrun{
#' message(" == == ROCR result:")
#' library(ROCR)
#' performance(prediction(labels=ht01.twoclass$observed
#' , predictions=ht01.twoclass$predicted
#' )
#' , measure = "auc")
#' }
#' message(" == == HandTill2001 result:")
#' auc(bincap(
#' response = as.factor(ht01.twoclass$observed)
#' , predicted = ht01.twoclass$predicted
#' , true = "1"
#' ))
#' message(" == AUC for a multiple class response")
#' auc(multcap(
#' response = ht01.multipleclass$observed
#' , predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
#' ))
#'
setMethod(f = "auc"
, signature(object = "bincap")
, function(object){
......
#' ht01.multipleclass data in Package \pkg{HandTill2001}
#'
#' multiple class data and probability predictions thereof.
#'
#' multiple class data ('observed': \code{MASS::fgl$type}) and probability
#' predictions (\code{predict(fgl.rp4)}, cf. Venables and Ripley (2002), p. 264
#' and \sQuote{Source}) from \code{rpart::rpart}.
#'
#' @name ht01.multipleclass
#' @docType data
#' @format A data frame with 214 observations on the following 7 variables.
#' \describe{ \item{list("observed")}{a factor with levels \code{Con}
#' \code{Head} \code{Tabl} \code{Veh} \code{WinF} \code{WinNF}}
#' \item{list("WinF")}{a numeric vector} \item{list("WinNF")}{a numeric vector}
#' \item{list("Veh")}{a numeric vector} \item{list("Con")}{a numeric vector}
#' \item{list("Tabl")}{a numeric vector} \item{list("Head")}{a numeric vector}
#' }
#' @references Venables, W. N and Ripley, B. D. (2002), \emph{Modern Applied
#' Statistics with S} (4th edition). Springer, ISBN 0-387-95457-0
#' @source \preformatted{ ## From: Forensic glass example Venables and Ripley
#' (2002) pp. 261--265 library(MASS);library(rpart);data(fgl);set.seed(123)
#' fgl.rp4 <- rpart(type ~ ., data = fgl, cp = 0.03 , parms = list(split =
#' "information")) ht01.multipleclass <- data.frame(observed = fgl$type,
#' predict(fgl.rp4)) write.table(ht01.multipleclass, file =
#' "ht01.multipleclass.txt") }
#' @keywords datasets
#' @examples
#'
#' library(HandTill2001)
#' data(ht01.multipleclass)
#' str(ht01.multipleclass)
#'
NULL
#' ht01.twoclass data in Package \pkg{HandTill2001}
#'
#' two class data and probability predictions thereof.
#'
#' two class data ('observed': \code{MASS::birthwt$low}) and probability
#' predictions
#'
#' (\code{predict(birthwt.step2, type = "response")}, cf. Venables and Ripley
#' (2002), pp. 195f and \sQuote{Source}) from \code{stats::glm}.
#'
#' @name ht01.twoclass
#' @docType data
#' @format A data frame with 189 observations on the following 2 variables.
#' \describe{ \item{list("observed")}{a numeric vector}
#' \item{list("predicted")}{a numeric vector} }
#' @references Venables, W. N and Ripley, B. D. (2002), \emph{Modern Applied
#' Statistics with S} (4th edition). Springer, ISBN 0-387-95457-0
#' @source \preformatted{ ## From: A two class data example Venables and Ripley
#' pp. 194--199 library(MASS); data("birthwt"); attach(birthwt) race <-
#' (factor(race, labels = c("white", "black", "other"))) ptd <- factor(ptl > 0)
#' ftv <- factor(ftv) levels(ftv)[-(1:2)] <- "2+" bwt <- data.frame(low =
#' factor(low), age, lwt, race, smoke = (smoke > 0) , ptd, ht = (ht > 0), ui =
#' (ui > 0), ftv) detach(birthwt) birthwt.glm <- glm(low ~ .,
#' family=binomial(link=logit), data=bwt) birthwt.step2 <- stepAIC(birthwt.glm,
#' ~ .^2 + I(scale(age)^2) + I(scale(lwt)^2), trace = F ) ht01.twoclass <-
#' data.frame(observed = bwt$low , predicted = predict(birthwt.step2 , type =
#' "response")) write.table(ht01.twoclass, file = "ht01.twoclass.txt") }
#' @keywords datasets
#' @examples
#'
#' library(HandTill2001)
#' data(ht01.twoclass)
#' str(ht01.twoclass)
#'
NULL
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/HandTill2001-package.R
\docType{package}
\name{HandTill2001-package}
\alias{HandTill2001-package}
\alias{HandTill2001}
\docType{package}
\title{
Multiple Class Area under ROC Curve
}
\title{Multiple Class Area under ROC Curve}
\description{
A very lean package implementing merely \eqn{M} given by \cite{Hand and Till (2001)}, Eq. (7).
A very lean package implementing merely \eqn{M} given by \cite{Hand and Till
(2001)}, Eq. (7).
}
\details{
\eqn{M} given by \cite{Hand and Till (2001)} defines a multiple class
\eqn{M} given by \cite{Hand and Till (2001)} defines a multiple class
version of the area under curve of the receiver operating characteristic.
}
\references{
\cite{David J. Hand and Robert J. Till (2001). A Simple Generalisation of
the Area Under the ROC Curve for Multiple Class Classification
Problems. \emph{Machine Learning} \bold{45}(2), p. 171--186. DOI:
\href{http://dx.doi.org/10.1023/A:1010920819831}{10.1023/A:1010920819831}}.
}
\keyword{AUC, ROC }
\seealso{
\code{help(package="HandTill2001")}, especially \code{"\link[=auc-methods]{methods?auc}"};
various packages that calculate two class AUC (\code{"\link[ROCR:performance]{ROCR}"})
or multiple class AUC (pROC, \code{"\link[caTools:caTools-package]{caTools}"}).
}
\examples{
library(HandTill2001)
data(ht01.multipleclass)
auc(
......@@ -34,4 +23,20 @@ auc(
, predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
)
)
}
\references{
\cite{David J. Hand and Robert J. Till (2001). A Simple
Generalisation of the Area Under the ROC Curve for Multiple Class
Classification Problems. \emph{Machine Learning} \bold{45}(2), p. 171--186.
DOI:
\href{http://dx.doi.org/10.1023/A:1010920819831}{10.1023/A:1010920819831}}.
}
\seealso{
\code{help(package="HandTill2001")}, especially
\code{"\link[=auc-methods]{methods?auc}"}; various packages that calculate
two class AUC (\code{"\link[ROCR:performance]{ROCR}"}) or multiple class AUC
(pROC, \code{"\link[caTools:caTools-package]{caTools}"}).
}
\keyword{AUC,}
\keyword{ROC}
\name{auc-methods}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/auc-methods.R
\docType{methods}
\name{auc-methods}
\alias{auc-methods}
\alias{auc}
\alias{auc,bincap-method}
\alias{auc,multcap-method}
\title{Methods for Function \code{auc} in Package \pkg{HandTill2001}}
\description{
Calculate area under curve of the receiver operating characteristic for two or more prediction classes.
}
\section{Methods}{
\describe{
\item{\code{signature(object = "bincap")}}{
calculates the AUC statistic for a two class response following \cite{Hand and Till (2001)}, Eq. (3).
\usage{
\S4method{auc}{bincap}(object)
}
\item{\code{signature(object = "multcap")}}{
calculates the AUC statistic for a multiple class response following \cite{Hand and Till (2001)}, Eq. (7).
}
}}
\value{
An object of class \code{"numeric"}.
An object of class \code{"numeric"}.
}
\description{
Calculate area under curve of the receiver operating characteristic for two
or more prediction classes.
}
\details{
Depending on whether \code{object} is of class \code{"bincap"} or of class \code{"multcap"}, a two class or multiple class AUC is calculated.
Depending on whether \code{object} is of class \code{"bincap"} or of class
\code{"multcap"}, a two class or multiple class AUC is calculated.
}
\section{Methods}{
\describe{
\references{
\cite{David J. Hand and Robert J. Till (2001). A Simple Generalisation of
the Area Under the ROC Curve for Multiple Class Classification
Problems. \emph{Machine Learning} \bold{45}(2), p. 171--186. DOI:
\href{http://dx.doi.org/10.1023/A:1010920819831}{10.1023/A:1010920819831}}.
\item{list("signature(object = \"bincap\")")}{ calculates the AUC statistic
for a two class response following \cite{Hand and Till (2001)}, Eq. (3). }
\item{list("signature(object = \"multcap\")")}{ calculates the AUC statistic
for a multiple class response following \cite{Hand and Till (2001)}, Eq.
(7). } }
}
\seealso{
\code{"\link[=bincap-class]{class?bincap}"}, \code{"\link[=multcap-class]{class?multcap}"}
}
\examples{
library(HandTill2001)
data(ht01.twoclass)
data(ht01.multipleclass)
......@@ -61,7 +57,18 @@ auc(multcap(
response = ht01.multipleclass$observed
, predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
))
}
\references{
\cite{David J. Hand and Robert J. Till (2001). A Simple
Generalisation of the Area Under the ROC Curve for Multiple Class
Classification Problems. \emph{Machine Learning} \bold{45}(2), p. 171--186.
DOI:
\href{http://dx.doi.org/10.1023/A:1010920819831}{10.1023/A:1010920819831}}.
}
\seealso{
\code{"\link[=bincap-class]{class?bincap}"},
\code{"\link[=multcap-class]{class?multcap}"}
}
\keyword{methods}
\keyword{auc}
\keyword{methods}
\name{bincap-class}
\Rdversion{1.1}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllClasses.R
\docType{class}
\name{bincap-class}
\alias{bincap-class}
\title{Class \code{"bincap"} in Package \pkg{HandTill2001}}
\description{
S4 class for a two class response and corresponding (predicted) probabilities.
S4 class for a two class response and corresponding (predicted)
probabilities.
}
\section{Objects from the Class}{
Objects can be created by calls of the form \code{new("bincap", ...)}.
They are used to store a two class response (one of the two \code{levels} of which is supposed to be \code{true}), the information which of the two \code{levels} of the two class response is thought of as 'true'/'positive'/'present' (the other one would then be thought of as 'false'/'negative'/'absence') and the predicted probabilities that \code{response} is \code{true}.
\note{
No defaults are set. Especially, you have to explicitly initialize
\code{true}, there is no trying to guess it from the \code{levels} of
\code{response}.
}
\section{Slots}{
\describe{
\item{\code{predicted}:}{Object of class \code{"numeric"}, probabilities for \code{response}. Of length \emph{n}}
\item{\code{true}:}{Object of class \code{"character"}, indicating which of the two \emph{levels} of \code{response} is to be treated as 'true'/'positive'/'presence' (the other one would then accordingly be called 'false'/'negative'/'absence'). Of length 1.}
\item{\code{response}:}{Object of class \code{"factor"}, two class observations. Of length \emph{n}.}}
}
\section{Extends}{
Class \code{"\linkS4class{cap}"}, directly.
\section{Objects from the Class}{
Objects can be created by calls of the form
\code{new("bincap", ...)}. They are used to store a two class response (one
of the two \code{levels} of which is supposed to be \code{true}), the
information which of the two \code{levels} of the two class response is
thought of as 'true'/'positive'/'present' (the other one would then be
thought of as 'false'/'negative'/'absence') and the predicted probabilities
that \code{response} is \code{true}.
}
\section{Methods}{
\describe{
\item{auc}{\code{signature(object = "bincap")}: ... }
}
\examples{
showClass("bincap")
}
\note{No defaults are set. Especially, you have to explicitly initialize \code{true}, there is no trying to guess it from the \code{levels} of \code{response}.
\seealso{
\code{"\link[=cap-class]{class?cap}"} ,
\code{"\link[=multcap-class]{class?multcap}"} ,
\code{"\link[=bincap]{?bincap}"}
}
\author{
Andreas Dominik Cullmann
}
\seealso{
\code{"\link[=cap-class]{class?cap}"}
, \code{"\link[=multcap-class]{class?multcap}"}
, \code{"\link[=bincap]{?bincap}"}
}
\examples{
showClass("bincap")
}
\keyword{classes}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllConstructors.R
\name{bincap}
\alias{bincap}
\title{
a ui-constructor for Class \code{"bincap"} in Package \pkg{HandTill2001}
}
\description{
\code{bincap(\dots)} is an alias to \code{new("bincap", \dots)}.
}
\title{a ui-constructor for Class \code{"bincap"} in Package \pkg{HandTill2001}}
\usage{
bincap(response, predicted, true = "1")
}
\arguments{
\item{response}{Object of class \code{"factor"}.}
\item{predicted}{Object of class \code{"numeric"}.}
\item{true}{Object of class \code{"character"}.}
}
\details{
There is no casting or conversion of data. \code{bincap(\dots)} is just an alias to \code{new("bincap",\dots)}.
\item{response}{Object of class \code{"factor"}.}
\item{predicted}{Object of class \code{"numeric"}.}
\item{true}{Object of class \code{"character"}.}
}
\value{
An object of class \code{"bincap"}
An object of class \code{"bincap"}
}
\author{
Andreas Dominik Cullmann
\description{
\code{bincap(\dots{})} is an alias to \code{new("bincap", \dots{})}.
}
\seealso{
\code{"\link[=bincap-class]{class?bincap}"}
\details{
There is no casting or conversion of data. \code{bincap(\dots{})} is just an
alias to \code{new("bincap",\dots{})}.
}
\examples{
library(HandTill2001)
data(ht01.twoclass)
str(ht01.twoclass$observed)
......@@ -37,5 +35,12 @@ bincap(
, true = c("1")
)
}
\seealso{
\code{"\link[=bincap-class]{class?bincap}"}
}
\author{
Andreas Dominik Cullmann
}
\keyword{ui-constructor}
\name{cap-class}
\Rdversion{1.1}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllClasses.R
\docType{class}
\name{cap-class}
\alias{cap-class}
\title{Class \code{"cap"} in Package \pkg{HandTill2001}}
\description{
A virtual class for \code{"bincap"} and \code{"multcap"}.
A virtual class for \code{"bincap"} and \code{"multcap"}.
}
\section{Objects from the Class}{A virtual Class: No objects may be created from it.}
\section{Slots}{
\describe{
\item{\code{response}:}{Object of class \code{"factor"}, typically two class or multiple class observations.}
}
\section{Objects from the Class}{
A virtual Class: No objects may be created
from it.
}
\section{Methods}{
No methods defined with class "cap" in the signature.
\seealso{
\code{"\link[=bincap-class]{class?bincap}"},
\code{"\link[=multcap-class]{class?multcap}"}
}
\author{
Andreas Dominik Cullmann
}
\seealso{
\code{"\link[=bincap-class]{class?bincap}"}, \code{"\link[=multcap-class]{class?multcap}"}
Andreas Dominik Cullmann
}
\keyword{classes}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{ht01.multipleclass}
\alias{ht01.multipleclass}
\docType{data}
\title{ht01.multipleclass data in Package \pkg{HandTill2001}}
\description{multiple class data and probability predictions thereof.}
\usage{data(ht01.multipleclass)}
\format{
A data frame with 214 observations on the following 7 variables.
\describe{
\item{\code{observed}}{a factor with levels \code{Con} \code{Head} \code{Tabl} \code{Veh} \code{WinF} \code{WinNF}}
\item{\code{WinF}}{a numeric vector}
\item{\code{WinNF}}{a numeric vector}
\item{\code{Veh}}{a numeric vector}
\item{\code{Con}}{a numeric vector}
\item{\code{Tabl}}{a numeric vector}
\item{\code{Head}}{a numeric vector}
}
}
\details{
multiple class data ('observed': \code{MASS::fgl$type}) and probability predictions (\code{predict(fgl.rp4)}, cf. Venables and Ripley (2002), p. 264 and \sQuote{Source}) from \code{rpart::rpart}.
}
\format{A data frame with 214 observations on the following 7 variables.
\describe{ \item{list("observed")}{a factor with levels \code{Con}
\code{Head} \code{Tabl} \code{Veh} \code{WinF} \code{WinNF}}
\item{list("WinF")}{a numeric vector} \item{list("WinNF")}{a numeric vector}
\item{list("Veh")}{a numeric vector} \item{list("Con")}{a numeric vector}
\item{list("Tabl")}{a numeric vector} \item{list("Head")}{a numeric vector}
}}
\source{
\preformatted{
## From: Forensic glass example Venables and Ripley (2002) pp. 261--265
library(MASS);library(rpart);data(fgl);set.seed(123)
fgl.rp4 <- rpart(type ~ ., data = fgl, cp = 0.03
, parms = list(split = "information"))
ht01.multipleclass <- data.frame(observed = fgl$type, predict(fgl.rp4))
write.table(ht01.multipleclass, file = "ht01.multipleclass.txt")
\preformatted{ ## From: Forensic glass example Venables and Ripley
(2002) pp. 261--265 library(MASS);library(rpart);data(fgl);set.seed(123)
fgl.rp4 <- rpart(type ~ ., data = fgl, cp = 0.03 , parms = list(split =
"information")) ht01.multipleclass <- data.frame(observed = fgl$type,
predict(fgl.rp4)) write.table(ht01.multipleclass, file =
"ht01.multipleclass.txt") }
}
\description{
multiple class data and probability predictions thereof.
}
\references{
Venables, W. N and Ripley, B. D. (2002), \emph{Modern Applied Statistics with S} (4th edition). Springer, ISBN 0-387-95457-0
\details{
multiple class data ('observed': \code{MASS::fgl$type}) and probability
predictions (\code{predict(fgl.rp4)}, cf. Venables and Ripley (2002), p. 264
and \sQuote{Source}) from \code{rpart::rpart}.
}
\examples{
library(HandTill2001)
data(ht01.multipleclass)
str(ht01.multipleclass)
}
\references{
Venables, W. N and Ripley, B. D. (2002), \emph{Modern Applied
Statistics with S} (4th edition). Springer, ISBN 0-387-95457-0
}
\keyword{datasets}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{ht01.twoclass}
\alias{ht01.twoclass}
\docType{data}
\title{ht01.twoclass data in Package \pkg{HandTill2001}}
\description{two class data and probability predictions thereof.}
\usage{data(ht01.twoclass)}
\format{
A data frame with 189 observations on the following 2 variables.
\describe{
\item{\code{observed}}{a numeric vector}
\item{\code{predicted}}{a numeric vector}
}
}
\details{
two class data ('observed': \code{MASS::birthwt$low}) and probability predictions
(\code{predict(birthwt.step2, type = "response")}, cf. Venables and Ripley (2002), pp. 195f and \sQuote{Source}) from \code{stats::glm}.
}
\format{A data frame with 189 observations on the following 2 variables.
\describe{ \item{list("observed")}{a numeric vector}
\item{list("predicted")}{a numeric vector} }}
\source{
\preformatted{
## From: A two class data example Venables and Ripley pp. 194--199
library(MASS); data("birthwt"); attach(birthwt)
race <- (factor(race, labels = c("white", "black", "other")))
ptd <- factor(ptl > 0)
ftv <- factor(ftv)
levels(ftv)[-(1:2)] <- "2+"
bwt <- data.frame(low = factor(low), age, lwt, race, smoke = (smoke > 0)
, ptd, ht = (ht > 0), ui = (ui > 0), ftv)
detach(birthwt)
birthwt.glm <- glm(low ~ ., family=binomial(link=logit), data=bwt)
birthwt.step2 <- stepAIC(birthwt.glm, ~ .^2
+ I(scale(age)^2) + I(scale(lwt)^2), trace = F )
ht01.twoclass <- data.frame(observed = bwt$low
, predicted = predict(birthwt.step2
, type = "response"))
write.table(ht01.twoclass, file = "ht01.twoclass.txt")
}
\preformatted{ ## From: A two class data example Venables and Ripley
pp. 194--199 library(MASS); data("birthwt"); attach(birthwt) race <-
(factor(race, labels = c("white", "black", "other"))) ptd <- factor(ptl > 0)
ftv <- factor(ftv) levels(ftv)[-(1:2)] <- "2+" bwt <- data.frame(low =
factor(low), age, lwt, race, smoke = (smoke > 0) , ptd, ht = (ht > 0), ui =
(ui > 0), ftv) detach(birthwt) birthwt.glm <- glm(low ~ .,
family=binomial(link=logit), data=bwt) birthwt.step2 <- stepAIC(birthwt.glm,
~ .^2 + I(scale(age)^2) + I(scale(lwt)^2), trace = F ) ht01.twoclass <-
data.frame(observed = bwt$low , predicted = predict(birthwt.step2 , type =
"response")) write.table(ht01.twoclass, file = "ht01.twoclass.txt") }
}
\references{
Venables, W. N and Ripley, B. D. (2002), \emph{Modern Applied Statistics with S} (4th edition). Springer, ISBN 0-387-95457-0
\description{
two class data and probability predictions thereof.
}
\details{
two class data ('observed': \code{MASS::birthwt$low}) and probability
predictions
(\code{predict(birthwt.step2, type = "response")}, cf. Venables and Ripley
(2002), pp. 195f and \sQuote{Source}) from \code{stats::glm}.
}
\examples{
library(HandTill2001)
data(ht01.twoclass)
str(ht01.twoclass)
}
\references{
Venables, W. N and Ripley, B. D. (2002), \emph{Modern Applied
Statistics with S} (4th edition). Springer, ISBN 0-387-95457-0
}
\keyword{datasets}
\name{multcap-class}
\Rdversion{1.1}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllClasses.R
\docType{class}
\name{multcap-class}
\alias{multcap-class}
\title{Class \code{"multcap"} in Package \pkg{HandTill2001} }
\title{Class \code{"multcap"} in Package \pkg{HandTill2001}}
\description{
S4 class for a multiple class response and corresponding (predicted) probabilities.
S4 class for a multiple class response and corresponding (predicted)
probabilities.
}
\section{Objects from the Class}{
Objects can be created by calls of the form \code{new("multcap", ...)}.
They are used to store a multiple class response and the predicted probabilities for each of the \code{levels(response)}.
}
\section{Slots}{
\describe{
\item{\code{predicted}:}{Object of class \code{"matrix"}, probabilities for \code{response}. Of dimension (\emph{n},\code{length(unique(response))}).
The columns (dimnames()[[2]]) of the prediction matrix have to be named with the values of \code{unique(response)}.This is the default for example with
\code{predict.rpart(type="prob",...)}.)
}
\item{\code{response}:}{Object of class \code{"factor"}, multiple class observations. Of length \emph{n}.}
}
Objects can be created by calls of the form
\code{new("multcap", ...)}. They are used to store a multiple class response
and the predicted probabilities for each of the \code{levels(response)}.
}
\section{Extends}{
Class \code{"\linkS4class{cap}"}, directly.
\examples{
showClass("multcap")
}
\section{Methods}{
\describe{
\item{auc}{\code{signature(object = "multcap")}: ... }
}
\seealso{
\code{"\link[=cap-class]{class?cap}"} ,
\code{"\link[=bincap-class]{class?bincap}"} ,
\code{"\link[=multcap]{?multcap}"}
}
\author{
Andreas Dominik Cullmann
}
\seealso{
\code{"\link[=cap-class]{class?cap}"}
, \code{"\link[=bincap-class]{class?bincap}"}
, \code{"\link[=multcap]{?multcap}"}
}
\examples{
showClass("multcap")
}
\keyword{classes}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllConstructors.R
\name{multcap}
\alias{multcap}
\title{
a ui-constructor for Class \code{"multcap"} in Package \pkg{HandTill2001}
}
\description{
\code{multcap(\dots)} is an alias to \code{new("multcap", \dots)}.
}
\title{a ui-constructor for Class \code{"multcap"} in Package \pkg{HandTill2001}}
\usage{
multcap(response, predicted)
}
\arguments{
\item{response}{Object of class \code{"factor"}.}
\item{predicted}{Object of class \code{"matrix"}.}
}
\details{
There is no casting or conversion of data. \code{multcap(\dots)} is just an alias to \code{new("multcap", \dots)}.
\item{response}{Object of class \code{"factor"}.}
\item{predicted}{Object of class \code{"matrix"}.}
}
\value{
An object of class \code{"bincap"}
An object of class \code{"bincap"}
}
\author{
Andreas Dominik Cullmann
\description{
\code{multcap(\dots{})} is an alias to \code{new("multcap", \dots{})}.
}
\seealso{
\code{"\link[=multcap-class]{class?multcap}"}
\details{
There is no casting or conversion of data. \code{multcap(\dots{})} is just
an alias to \code{new("multcap", \dots{})}.
}
\examples{
library(HandTill2001)
data(ht01.multipleclass)
str(ht01.multipleclass$observed)
......@@ -35,5 +32,12 @@ multcap(
, predicted = as.matrix(ht01.multipleclass[, levels(ht01.multipleclass$observed)])
)
}
\seealso{
\code{"\link[=multcap-class]{class?multcap}"}
}
\author{
Andreas Dominik Cullmann
}
\keyword{ui-constructor}