[Distr-commits] r226 - in branches/distr-2.0/pkg/distrMod: R chm man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Aug 1 12:21:39 CEST 2008
Author: ruckdeschel
Date: 2008-08-01 12:21:39 +0200 (Fri, 01 Aug 2008)
New Revision: 226
Modified:
branches/distr-2.0/pkg/distrMod/R/AllGeneric.R
branches/distr-2.0/pkg/distrMod/R/MLEstimator.R
branches/distr-2.0/pkg/distrMod/R/confint.R
branches/distr-2.0/pkg/distrMod/chm/00Index.html
branches/distr-2.0/pkg/distrMod/chm/Confint-class.html
branches/distr-2.0/pkg/distrMod/chm/confint-methods.html
branches/distr-2.0/pkg/distrMod/chm/distrMod.chm
branches/distr-2.0/pkg/distrMod/chm/distrMod.toc
branches/distr-2.0/pkg/distrMod/man/Confint-class.Rd
branches/distr-2.0/pkg/distrMod/man/confint-methods.Rd
Log:
confint gains a second argument "method" to dispatch on;
not yet used...
Modified: branches/distr-2.0/pkg/distrMod/R/AllGeneric.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/AllGeneric.R 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/R/AllGeneric.R 2008-08-01 10:21:39 UTC (rev 226)
@@ -201,9 +201,9 @@
setGeneric("main", function(object,... ) standardGeneric("main"))
}
-if(!isGeneric("confint")){
- setGeneric("confint", function(object, ... ) standardGeneric("confint"))
-}
+#if(!isGeneric("confint")){
+setGeneric("confint", function(object, method, ... ) standardGeneric("confint"))
+#}
if(!isGeneric("validParameter")){
setGeneric("validParameter", function(object, ... ) standardGeneric("validParameter"))
Modified: branches/distr-2.0/pkg/distrMod/R/MLEstimator.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/MLEstimator.R 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/R/MLEstimator.R 2008-08-01 10:21:39 UTC (rev 226)
@@ -49,9 +49,10 @@
trafo0 <- diag(lnx+lmx)
- res <- MCEstimator(x = x, ParamFamily = ParamFamily, criterion = negLoglikelihood,
- interval = interval, par = par, trafo = trafo0, penalty = penalty,
- validity.check = FALSE, ...)
+ res <- MCEstimator(x = x,
+ ParamFamily = ParamFamily, criterion = negLoglikelihood,
+ interval = interval, par = par, trafo = trafo0,
+ penalty = penalty, validity.check = FALSE, ...)
if(!is.null(res at nuis.idx))
idx <- -res at nuis.idx
@@ -60,7 +61,8 @@
res at estimate.call <- es.call
res at name <- "Maximum likelihood estimate"
- param <- ParamFamParameter(name = names(res at estimate), main = res at estimate[idx],
+ param <- ParamFamParameter(name = names(res at estimate),
+ main = res at estimate[idx],
nuisance = res at estimate[-idx])
if(missing(trafo)||is.null(trafo))
Modified: branches/distr-2.0/pkg/distrMod/R/confint.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/confint.R 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/R/confint.R 2008-08-01 10:21:39 UTC (rev 226)
@@ -2,16 +2,16 @@
## confint methods
###############################################################################
-#setMethod("confint", signature(object="ANY"),
-# function(object, parm, level = 0.95, ...) {
-# if(hasArg(parm))
-# stats::confint(object = object, parm = parm, level = level, ...)
-# else
-# stats::confint(object = object, level = level, ...)
-#})
+setMethod("confint", signature(object="ANY", method="missing"),
+ function(object, method, parm, level = 0.95, ...) {
+ if(hasArg(parm))
+ stats::confint(object = object, parm = parm, level = level, ...)
+ else
+ stats::confint(object = object, level = level, ...)
+})
-setMethod("confint", signature(object="Estimate"),
- function(object, level = 0.95) {
+setMethod("confint", signature(object="Estimate", method="missing"),
+ function(object, method, level = 0.95) {
objN <- paste(deparse(substitute(object)),sep="",collapse="")
if(is.null(object at asvar))
@@ -45,8 +45,9 @@
confint = ci)
})
-setMethod("confint", signature(object="Confint"),
- function(object) object at confint)
+setMethod("confint", signature(object="Confint", method="missing"),
+ function(object, method) object at confint)
+
setMethod("estimate.call", signature(object="Confint"),
function(object) object at estimate.call)
setMethod("name.estimate", signature(object="Confint"),
Modified: branches/distr-2.0/pkg/distrMod/chm/00Index.html
===================================================================
--- branches/distr-2.0/pkg/distrMod/chm/00Index.html 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/chm/00Index.html 2008-08-01 10:21:39 UTC (rev 226)
@@ -125,11 +125,11 @@
<td>L2 differentiable parametric family</td></tr>
<tr><td width="25%"><a href="confint-methods.html">confint</a></td>
<td>Methods for function confint in Package ‘distrMod’ </td></tr>
-<tr><td width="25%"><a href="confint-methods.html">confint,ANY-method</a></td>
+<tr><td width="25%"><a href="confint-methods.html">confint,ANY,missing-method</a></td>
<td>Methods for function confint in Package ‘distrMod’ </td></tr>
-<tr><td width="25%"><a href="Confint-class.html">confint,Confint-method</a></td>
+<tr><td width="25%"><a href="Confint-class.html">confint,Confint,missing-method</a></td>
<td>Confint-class</td></tr>
-<tr><td width="25%"><a href="confint-methods.html">confint,Estimate-method</a></td>
+<tr><td width="25%"><a href="confint-methods.html">confint,Estimate,missing-method</a></td>
<td>Methods for function confint in Package ‘distrMod’ </td></tr>
<tr><td width="25%"><a href="Confint-class.html">Confint-class</a></td>
<td>Confint-class</td></tr>
Modified: branches/distr-2.0/pkg/distrMod/chm/Confint-class.html
===================================================================
--- branches/distr-2.0/pkg/distrMod/chm/Confint-class.html 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/chm/Confint-class.html 2008-08-01 10:21:39 UTC (rev 226)
@@ -8,7 +8,7 @@
<param name="keyword" value="R: Confint-class">
<param name="keyword" value="R: type,Confint-method">
<param name="keyword" value="R: estimate.call,Confint-method">
-<param name="keyword" value="R: confint,Confint-method">
+<param name="keyword" value="R: confint,Confint,missing-method">
<param name="keyword" value="R: name.estimate">
<param name="keyword" value="R: name.estimate,Confint-method">
<param name="keyword" value="R: trafo.estimate">
@@ -67,7 +67,7 @@
accessor function for slot <code>type</code>. </dd>
-<dt>confint</dt><dd><code>signature(object = "Confint")</code>:
+<dt>confint</dt><dd><code>signature(object = "Confint", method = "missing")</code>:
accessor function for slot <code>type</code>. </dd>
Modified: branches/distr-2.0/pkg/distrMod/chm/confint-methods.html
===================================================================
--- branches/distr-2.0/pkg/distrMod/chm/confint-methods.html 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/chm/confint-methods.html 2008-08-01 10:21:39 UTC (rev 226)
@@ -7,8 +7,8 @@
<table width="100%"><tr><td>confint-methods(distrMod)</td><td align="right">R Documentation</td></tr></table><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="R: confint-methods">
<param name="keyword" value="R: confint">
-<param name="keyword" value="R: confint,ANY-method">
-<param name="keyword" value="R: confint,Estimate-method">
+<param name="keyword" value="R: confint,ANY,missing-method">
+<param name="keyword" value="R: confint,Estimate,missing-method">
<param name="keyword" value=" Methods for function confint in Package ‘distrMod’">
</object>
@@ -32,10 +32,10 @@
<pre>
confint(object, ...)
-## S4 method for signature 'ANY':
-confint(object, parm, level = 0.95, ...)
-## S4 method for signature 'Estimate':
-confint(object, level = 0.95, ...)
+## S4 method for signature 'ANY, missing':
+confint(object, method, parm, level = 0.95, ...)
+## S4 method for signature 'Estimate, missing':
+confint(object, method, level = 0.95, ...)
</pre>
@@ -56,6 +56,10 @@
<tr valign="top"><td><code>level</code></td>
<td>
the confidence level required.</td></tr>
+<tr valign="top"><td><code>method</code></td>
+<td>
+not yet used (only as <code>missing</code>; later to allow
+for various methods</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
additional argument(s) for methods.</td></tr>
@@ -67,10 +71,10 @@
<code>confint</code> is a generic function. Its behavior differs according to
its arguments.
<ul>
-<dt>signature <code>ANY</code>:</dt><dd>the default method;
+<dt>signature <code>ANY,missing</code>:</dt><dd>the default method;
uses the S3 generic of package <span class="pkg">stats</span>,
see <code><a onclick="findlink('stats', 'confint.html')" style="text-decoration: underline; color: blue; cursor: hand">confint</a></code>.</dd>
-<dt>signature <code>Estimate</code>:</dt><dd>will return a corresponding confidence interval assuming
+<dt>signature <code>Estimate,missing</code>:</dt><dd>will return a corresponding confidence interval assuming
asymptotic normality, and hence needs suitably filled slot <code>asvar</code>
in argument <code>object</code>. Besides the actual bounds, organized in
an array just as in the S3 generic, the return value also captures
@@ -82,18 +86,18 @@
<h3>Value</h3>
<table summary="R argblock">
-<tr valign="top"><td><code>signature <code>ANY</code>:</code></td>
+<tr valign="top"><td><code>signature <code>ANY,missing</code>:</code></td>
<td>
A matrix (or vector) with columns giving lower and upper confidence
limits for each parameter. These will be labelled as (1-level)/2 and
1 - (1-level)/2 in % (by default 2.5% and 97.5%).</td></tr>
-<tr valign="top"><td><code>signature <code>Estimate</code>:</code></td>
+<tr valign="top"><td><code>signature <code>Estimate,missing</code>:</code></td>
<td>
An object of class <code>Confint</code></td></tr>
</table>
<p>
-normal-bracket39bracket-normal</p>
+normal-bracket42bracket-normal</p>
<h3>See Also</h3>
@@ -118,6 +122,33 @@
(res <- MLEstimator(x = x, ParamFamily = G))
confint(res)
+
+### for comparison:
+require(MASS)
+(res1 <- fitdistr(x, "gamma"))
+## ad a convenient (albeit wrong)
+## S3-method for vcov:
+## --- wrong as in general cov-matrix
+## will not be diagonal
+## but for conf-interval this does
+## not matter...
+ vcov.fitdistr <- function(object, ...){
+ v<-diag(object$sd^2)
+ rownames(v) <- colnames(v) <- names(object$estimate)
+ v}
+res1
+confint(res1)
+
+mtrafo <- function(x){
+ nms <- c("shape","rate")
+ fval0 <- c(x[2], 1/x[1])
+ names(fval0) <- nms
+ mat0 <- matrix( c(0, -1/x[1]^2, 1, 0), nrow = 2, ncol = 2,
+ dimnames = list(nms,nms))
+ list(fval = fval0, mat = mat0)}
+(res2 <- MLEstimator(x = x, ParamFamily = G, trafo = mtrafo))
+ confint(res2)
+
</pre>
<script Language="JScript">
Modified: branches/distr-2.0/pkg/distrMod/chm/distrMod.chm
===================================================================
(Binary files differ)
Modified: branches/distr-2.0/pkg/distrMod/chm/distrMod.toc
===================================================================
--- branches/distr-2.0/pkg/distrMod/chm/distrMod.toc 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/chm/distrMod.toc 2008-08-01 10:21:39 UTC (rev 226)
@@ -182,15 +182,15 @@
<param name="Local" value="confint-methods.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
-<param name="Name" value="confint,ANY-method">
+<param name="Name" value="confint,ANY,missing-method">
<param name="Local" value="confint-methods.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
-<param name="Name" value="confint,Confint-method">
+<param name="Name" value="confint,Confint,missing-method">
<param name="Local" value="Confint-class.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
-<param name="Name" value="confint,Estimate-method">
+<param name="Name" value="confint,Estimate,missing-method">
<param name="Local" value="confint-methods.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
Modified: branches/distr-2.0/pkg/distrMod/man/Confint-class.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/Confint-class.Rd 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/man/Confint-class.Rd 2008-08-01 10:21:39 UTC (rev 226)
@@ -3,7 +3,7 @@
\alias{Confint-class}
\alias{type,Confint-method}
\alias{estimate.call,Confint-method}
-\alias{confint,Confint-method}
+\alias{confint,Confint,missing-method}
\alias{name.estimate}
\alias{name.estimate,Confint-method}
\alias{trafo.estimate}
@@ -44,7 +44,7 @@
\item{type}{\code{signature(object = "Confint")}:
accessor function for slot \code{type}. }
- \item{confint}{\code{signature(object = "Confint")}:
+ \item{confint}{\code{signature(object = "Confint", method = "missing")}:
accessor function for slot \code{type}. }
\item{estimate.call}{\code{signature(object = "Confint")}:
Modified: branches/distr-2.0/pkg/distrMod/man/confint-methods.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/confint-methods.Rd 2008-08-01 04:25:07 UTC (rev 225)
+++ branches/distr-2.0/pkg/distrMod/man/confint-methods.Rd 2008-08-01 10:21:39 UTC (rev 226)
@@ -2,8 +2,8 @@
\docType{methods}
\alias{confint-methods}
\alias{confint}
-\alias{confint,ANY-method}
-\alias{confint,Estimate-method}
+\alias{confint,ANY,missing-method}
+\alias{confint,Estimate,missing-method}
\title{ Methods for function confint in Package `distrMod' }
\description{
Methods for function \code{confint} in package \pkg{distrMod};
@@ -15,8 +15,8 @@
}
\usage{
confint(object, \dots)
-\S4method{confint}{ANY}(object, parm, level = 0.95, \dots)
-\S4method{confint}{Estimate}(object, level = 0.95, \dots)
+\S4method{confint}{ANY,missing}(object, method, parm, level = 0.95, \dots)
+\S4method{confint}{Estimate,missing}(object, method, level = 0.95, \dots)
}
\arguments{
@@ -27,25 +27,27 @@
confidence intervals, either a vector of numbers or a vector of
names. If missing, all parameters are considered.}
\item{level}{the confidence level required.}
+ \item{method}{not yet used (only as \code{missing}; later to allow
+ for various methods}
\item{\dots}{additional argument(s) for methods.}
}
\value{
\itemize{
- \item{signature \code{ANY}:}{
+ \item{signature \code{ANY,missing}:}{
A matrix (or vector) with columns giving lower and upper confidence
limits for each parameter. These will be labelled as (1-level)/2 and
1 - (1-level)/2 in \% (by default 2.5\% and 97.5\%).}
- \item{signature \code{Estimate}:}{An object of class \code{Confint}}
+ \item{signature \code{Estimate,missing}:}{An object of class \code{Confint}}
}
}
\details{
\code{confint} is a generic function. Its behavior differs according to
its arguments.
\itemize{
- \item{signature \code{ANY}:}{the default method;
+ \item{signature \code{ANY,missing}:}{the default method;
uses the S3 generic of package \pkg{stats},
see \code{\link[stats]{confint}}.}
- \item{signature \code{Estimate}:}{
+ \item{signature \code{Estimate,missing}:}{
will return a corresponding confidence interval assuming
asymptotic normality, and hence needs suitably filled slot \code{asvar}
in argument \code{object}. Besides the actual bounds, organized in
@@ -72,5 +74,32 @@
(res <- MLEstimator(x = x, ParamFamily = G))
confint(res)
+
+### for comparison:
+require(MASS)
+(res1 <- fitdistr(x, "gamma"))
+## ad a convenient (albeit wrong)
+## S3-method for vcov:
+## --- wrong as in general cov-matrix
+## will not be diagonal
+## but for conf-interval this does
+## not matter...
+ vcov.fitdistr <- function(object, ...){
+ v<-diag(object$sd^2)
+ rownames(v) <- colnames(v) <- names(object$estimate)
+ v}
+res1
+confint(res1)
+
+mtrafo <- function(x){
+ nms <- c("shape","rate")
+ fval0 <- c(x[2], 1/x[1])
+ names(fval0) <- nms
+ mat0 <- matrix( c(0, -1/x[1]^2, 1, 0), nrow = 2, ncol = 2,
+ dimnames = list(nms,nms))
+ list(fval = fval0, mat = mat0)}
+(res2 <- MLEstimator(x = x, ParamFamily = G, trafo = mtrafo))
+ confint(res2)
+
}
\keyword{models}
More information about the Distr-commits
mailing list