[R] fitdistr for t distribution

Martin Maechler maechler at stat.math.ethz.ch
Sat May 16 14:49:37 CEST 2009

>>>>> "l" == lagreene  <lagreene101 at gmail.com>
>>>>>     on Fri, 15 May 2009 04:22:59 -0700 (PDT) writes:

    l> Thanks Jorge,

    l> but I still don't understand where they come from.  when I use: 
    l> fitdistr(mydata, "t", df = 9) and get values for m and s, and the variance
    l> of my data should be the df/s?

definitely *not*;  How did you get to this completely wrong formula?
    l> I jsut want to be able to confirm how m and s are calculated
by maximum likelihood.
And, of course, only for the normal (aka Gaussian) are the ML
estimates of mu the artithmetic mean and of sigma  (n-1)/n * sd(x)
{i.e. even *there* the ML estimate of s is *not* the SD}

As you can read on  ?dt,
the variance of a (0,1)-t-distribution is  df / (df - 2)
and hence only defined for df > 2.
Consequently, the variance of a  (mu,sigma)-t-distribution is

   sigma^2 * df / (df - 2)

    l> mydt <- function(x, m, s, df) dt((x-m)/s, df)/s
    l> fitdistr(x2, mydt, list(m = 0, s = 1), df = 9, lower = c(-Inf, 0))

{this is copy-pasted from example(dt);
 the examples have nice comments there....}

    l> Jorge Ivan Velez wrote:
    >> Dear lagreene,
    >> See the second example in
    >> require(MASS)
    >> ?fitdistr
    >> HTH,
    >> Jorge
    >> On Thu, May 14, 2009 at 7:15 PM, lagreene <lagreene101 at gmail.com> wrote:
    >>> Hi,
    >>> I was wondering if anyone could tell me how m and s are calculated for a
    >>> t
    >>> distribution?
    >>> I thought m was the sample mean and s the standard deviation- but
    >>> obviously
    >>> I'm wrong as this doesn'y give the same answer.
    >>> Thank you

More information about the R-help mailing list