Learn R Programming

distrMod (version 2.9.4)

print-methods: Common `print' Methods for S4 classes in Package `distrMod'

Description

Methods for print to the S4 classes in package distrMod;

Usage

# S4 method for ShowDetails
print(x, digits = getOption("digits"),
                show.details = c("maximal", "minimal", "medium"))

Arguments

x

object of class ShowDetails, a class union of classes OptionalNumeric, OptionalMatrix, MatrixorFunction, Estimate, MCEstimate.

digits

unchanged w.r.t. default method of package base: a non-null value for 'digits' specifies the minimum number of significant digits to be printed in values. The default, 'NULL', uses 'getOption(digits)'. (For the interpretation for complex numbers see 'signif'.) Non-integer values will be rounded down, and only values greater than or equal to 1 and no greater than 22 are accepted.

show.details

a character, controlling the degree of detailedness of the output; currently the following values are permitted: "maximal", "minimal", "medium"; for the meaning for the actual class, confer to the corresponding class help file.

Details

This method provides sort of a ''show with extra arguments'', in form of a common print method for the mentioned S4 classes. Essentially this print method just temporarily sets the global options according to the optional arguments digits and show.details, calls show and then re-sets the options to their global settings.

Examples

Run this code
## set options to maximal detailedness
show.old <- getdistrModOption("show.details")
distrModoptions("show.details" = "maximal")
## define a model
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))
}
print(param(NS))
print(param(NS), show.details = "minimal")
print(param(NS), show.details = "medium")
## Maximum likelihood estimator
res <- MLEstimator(x = x, ParamFamily = NS)
print(res) #equivalent to 'show(res)' or 'res'
print(res, digits = 4)
print(res, show.details = "minimal")
print(res, show.details = "medium")
distrModoptions("show.details" = show.old)

Run the code above in your browser using DataLab