trafo-methods {distrMod} | R Documentation |
Methods for function trafo in Package ‘distrMod’
Description
Methods for function trafo
in package distrMod;
there are accessor (trafo
) and replacement (trafo<-
)
versions.
Usage
trafo(object, param, ...)
## S4 method for signature 'Estimate,missing'
trafo(object,param)
## S4 method for signature 'ParamFamParameter,missing'
trafo(object,param)
## S4 method for signature 'ParamWithScaleAndShapeFamParameter,missing'
trafo(object,param)
## S4 method for signature 'ParamFamily,missing'
trafo(object,param)
## S4 method for signature 'ParamFamily,ParamFamParameter'
trafo(object,param)
## S4 method for signature 'Estimate,ParamFamParameter'
trafo(object,param)
trafo.fct(object)
trafo(object) <- value
Arguments
object |
an object of either class |
param |
an object of class |
value |
a matrix or a function; if it is a matrix, dimensions must
be consistent to the parametric setting; if it is function, it should
take one argument |
... |
additional argument(s) for methods; not used so far. |
Details
trafo
is a slot of class ParamFamParameter
, which
in turn is a slot of class ParamFamily
. It also sort of
arises in class Estimate
, i.e., all slots can be identified
by the information contained in an instance thereof.
As usual, trafo
also is the accessor and replacement method
for this slot. Its corresponding return value depends on the signature
for which the accessor / replacement method is used. More specifically,
for trafo
, we have methods for the following signatures:
- signature
Estimate,missing
: returns a list of length two with components
fct
andmat
(see below)- signature
Estimate,ParamFamParameter
: returns a list of length two with components
fct
andmat
(see below)- signature
ParamFamParameter,missing
: returns a matrix (see below)
- signature
ParamFamily,missing
: returns a matrix (see below)
- signature
ParamFamily,ParamFamParameter
: returns a list of length two with components
fct
andmat
(see below)
trafo
realizes partial influence curves; i.e.; we are only
interested in some possibly lower dimensional smooth (not necessarily
linear or even coordinate-wise) aspect/transformation \tau
of the parameter \theta
.
For the this function \tau()
, we provide an accessor
trafo.fct
for signature ParamFamily-method
returning this function.
To be coherent with the corresponding nuisance implementation, we make the following convention:
The full parameter \theta
is split up coordinate-wise
in a main parameter \theta'
and a nuisance parameter
\theta''
(which is unknown, too, hence has to be
estimated, but only is of secondary interest) and a fixed,
known part \theta'''
.
Without loss of generality, we restrict ourselves to the case that
transformation \tau
only acts on the main parameter
\theta'
— if we want to transform the whole
parameter, we only have to assume that both nuisance parameter
\theta''
and fixed, known part of the parameter
\theta'''
have length 0.
To the implementation:
Slot trafo
can either contain a (constant) matrix
D_\theta
or a function
\tau\colon \Theta' \to \tilde \Theta,\qquad \theta \mapsto \tau(\theta)
mapping main parameter
\theta'
to some range \tilde \Theta
.
If slot value trafo
is a function, besides \tau(\theta)
,
it will also return the corresponding derivative matrix
\frac{\partial}{\partial \theta}\tau(\theta)
.
More specifically, the return value of this function theta
is a
list with entries fval
, the function value \tau(\theta)
,
and mat
, the derivative matrix.
In case trafo
is a matrix D
, we interpret it as such a derivative
matrix \frac{\partial}{\partial \theta}\tau(\theta)
,
and, correspondingly, \tau(\theta)
as the linear mapping
\tau(\theta)=D\,\theta
.
According to the signature, method trafo
will return different
return value types. For signature
Estimate,missing
:it will return a list with entries
fct
, the function\tau
, andmat
, the matrix\frac{\partial}{\partial \theta}\tau(\theta)
. function\tau
will then return the listlist(fval, mat)
mentioned above.Estimate,ParamFamParameter
:as signature
Estimate,missing
.ParamFamParameter,missing
:it will just return the corresponding matrix.
ParamFamily,missing
:is just wrapper to signature
ParamFamParameter,missing
.ParamFamily,ParamFamParameter
:as signature
Estimate,missing
.
Examples
## Gaussian location and scale
NS <- NormLocationScaleFamily(mean=2, sd=3)
## generate data out of this situation
x <- r(distribution(NS))(30)
## want to estimate mu/sigma, sigma^2
## -> new trafo slot:
trafo(NS) <- function(param){
mu <- param["mean"]
sd <- param["sd"]
fval <- c(mu/sd, sd^2)
nfval <- c("mu/sig", "sig^2")
names(fval) <- nfval
mat <- matrix(c(1/sd,0,-mu/sd^2,2*sd),2,2)
dimnames(mat) <- list(nfval,c("mean","sd"))
return(list(fval=fval, mat=mat))
}
## Maximum likelihood estimator
(res <- MLEstimator(x = x, ParamFamily = NS))
## confidence interval
confint(res)