Skip to contents

This base::print() method is a utility to display value and revisability of an "mi" object obtained with mutualinfo().

Usage

# S3 method for class 'mi'
print(x, digits = TRUE, edigits = 2, unit = NULL, ...)

Arguments

x

Object of class "mi", obtained with mutualinfo().

digits

positive integer or NULL or TRUE (default): minimal number of significant digits, see base::print.default(). If value is TRUE, then the significant digits for element $value is determined from is respective $MCaccuracy (see mutualinfo()), according to the rules of the Guide to the expression of Uncertainty in Measurement, keeping as many digits as given in parameter edigits; whereas $quantiles elements uses edigits significant digits.

edigits

positive integer, default 2: number of significant digits for element $value and $quantiles, if digits = TRUE.

unit

Either NULL, or one of 'Sh' for shannon (default), 'Hart' for hartley, 'nat' for natural unit, or a positive real indicating the base of the logarithms to be used; see analogous argument in mutualinfo(). If NULL (default), the same unit as in the object x is used. Unit conversion is internally performed if this unit is different from that of the object x.

...

Other parameters to be passed to base::print().

Value

Its x argument, invisibly; see base::print().

See also

mutualinfo() to calculate mutual information.

hist.mi() to plot the revisability of the mutual information.

Examples

# \donttest{
### WARNING: the following example, if run, might even take a minute or more.

## Load the example `K`nowledge object calculated from the "penguins" dataset;
## variates: 'species' and 'bill_len'
K <- Kexample

## Calculate the mutual information between variates 'species' and 'bill_len'
MI <- mutualinfo(Y1names = 'species', Y2names = 'bill_len', K = K)

## display the value and revisability of the mutual information
print(MI)
#> value/Sh    Q5.5%     Q25%     Q75%   Q94.5% 
#>    0.747     0.33     0.62     0.93      1.1 

## convert to hartleys (base-10 logarithms):
print(MI, unit = 'Hart')
#> value/Hart      Q5.5%       Q25%       Q75%     Q94.5% 
#>     0.2250      0.099       0.19       0.28       0.32 
# }