Skip to content
Back to formatted view

Raw Message

Message-ID: <13e802630905161104y384fefdalf5341bdb6f53d087@mail.gmail.com>
Date: 2009-05-16T18:04:37Z
From: Paul Johnson
Subject: fitdistr for t distribution
In-Reply-To: <23557778.post@talk.nabble.com>

On Fri, May 15, 2009 at 6:22 AM, lagreene <lagreene101 at gmail.com> wrote:
>
> Thanks Jorge,
>
> but I still don't understand where they come from. ?when I use:
> fitdistr(mydata, "t", df = 9) and get values for m and s, and the variance
> of my data should be the df/s?
>
> I jsut want to be able to confirm how m and s are calculated

I've wondered the same kind of thing and I've learned the answer is
easy!  It is not so easy for all R functions, but did you try this
with fitdistr?

> library (MASS)
> fitdistr

the output that follows is the ACTUAL FORMULA that is used to make the
calculations!

I've not yet mastered the art of getting code for some functions.

> predict
function (object, ...)
UseMethod("predict")
<environment: namespace:stats>

But I know there is a way to get that code if you know the correct way
to run getS3method().  But I usually just go read the R source code
rather than puzzle over that.



>
> mydt <- function(x, m, s, df) dt((x-m)/s, df)/s
> fitdistr(x2, mydt, list(m = 0, s = 1), df = 9, lower = c(-Inf, 0))
>
> Thanks anyway for the help!

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas