I have some data. Does anybody know a function which can fit the parameters of a t-distribution of this data when I know the numbers of degrees of freedom?
Thanks!
I have some data. Does anybody know a function which can fit the parameters of a t-distribution of this data when I know the numbers of degrees of freedom?
Thanks!
Expanding @Ben Bolker's comment:
You may use the fitdistr function in R MASS package.
See the second example in ?fitdistr function help. Also in this pdf, page 50.
library(MASS)
#generate a random sample with t distribution, where the degrees of freedom = 9.
set.seed(123)
x2 <- rt(250, df = 9)
#find the parameters for the t distribution
fitdistr(x2, "t", df = 9)
the output is:
m s
-0.01069496 1.04410551
( 0.07222623) ( 0.05434369)
where the second line represents the parameter estimates, and the numbers inside brackets are their standard deviations.
fitdistr uses the Maximum Likelihood Estimation (MLE) method to adjust the parameters of a given distribution.
For a theoretical insight about MLE, you might find @Glen_b's answer helpful.
Reference.
Venables, W. N., & Ripley, B. D. (2002). Modern Applied Statistics with S (4a ed., p. 495).
fitdistrfunction in theMASSpackage -- especially the second example in?fitdistr... – Ben Bolker Sep 10 '12 at 14:31