Description Usage Arguments Details Value Examples
The Box-Cox transform is often used to normalize precipitation
data. In practice, the best value of the lambda parameter (the
exponent) is usually zero, but the best value of the gamma (shift)
parameter is unpredictable. This function finds the best value of
gamma by maximizing the entropy of the PDF of the transformed
data. This works because (of all distribution on the real line
with a given variance) the normal distribution has the maximum
possible entropy, which is calculated as minus the integral of
p log p
. Entropy can therefore be used as a measure of how
close a distribution is to normal.
1 | megamma(x)
|
x |
A vector of values |
This function calculates entropy by estimating the PDF of the
(transformed) data using KernSmooth::bkde
and summing
-p log p
of the result. Note that because bkde
uses
a fixed number of bins and uses the variance of the data to scale
the gaussian kernel to fit the range of the data, there is no need
to explicitly rescale the data to have unit variance or to divide
the sum by the bin width; these factors have already been taken
into account by the kernel density estimation. This function uses
stats::optimize
to find the maximum-entropy value of gamma.
A more general optimization can be done over both gamma and lambda
using optim
instead, but it is much, much slower, and tests
on real data showed that the lambda parameter strongly tends
towards zero in all cases except when the number of data points is
very small.
The maximum entropy value of gamma
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.