In addition to seeing the code by typing the name of the function (and copying it from there into a file), you can also enter "debug(fitdistr)", for example. Then the next time you use "fitdistr", either directly or indirectly, it puts you in the environment of that function, and you can walk through it line by line, examining objects, changing them, etc.

To get the code for an S3 generic function like "predict", use the "methods" function, followed, e.g., by "getAnywhere".

Hope this helps. Spencer Graves

Paul Johnson wrote:
On Fri, May 15, 2009 at 6:22 AM, lagreene <lagreene...@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!



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to