sample.centralmoments {sn} | R Documentation |
Computes sample central moments up to a given order and the first moment from the origin
sample.centralmoments(x, w = rep(1, length(x)), order=4)
x |
a vector of sample values |
w |
an optional vector of weights |
order |
the maximal order of the central moments to be computed; it must be a positive integer (default value 4) |
NA
's are allowed but removed. Averaging of appropriate
quantities is actually performed by weighted.mean
A vector containing the first sample central moments,
in position [2:order]
, and the first moment from the
origin, in the first position of the returned vector
The second component of the returned vector (if order>1
)
gives the sample variance; notice that it differs from the value
returned by var(x)
, since this gives the corrected sample
variance.
Used in conjunction with st.cumulants.inversion
, this
function allows to fit a skew-t distribution by the methods
of moments; see the example below.
Adelchi Azzalini
st.cumulants.inversion, weighted.mean
data(ais, package='sn') mom <- sample.centralmoments(ais[,"bmi"]) st.cumulants.inversion(cum=c(mom[1:3], mom[4]-3*mom[2]^2)) # parameters of the fitted ST distribution