# How can I fit the parametres of t-distribution if I know the number of degrees of freedom in R?

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!

• You might also want to mention which parameters you're interested in. Are we talking about some sort of shifted t-distribution? Do you want to estimate a non-centrality parameter? What are you trying to estimate? Sep 10, 2012 at 14:29
• See the fitdistr function in the MASS package -- especially the second example in ?fitdistr ... Sep 10, 2012 at 14:31
• I want to estimate mean = mu and variance = sigma like the function fit.st of the QRM-packages does it, but this function also estimate the number of degrees of freedom but I just know this number.
– Kim Müller
Sep 10, 2012 at 14:44

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.