I have a data with 236 observations. After plotting the histogram, I found that it looks like non-central t distribution. I would like to get MLE for mu and df. I found an example to find MLE for gamma distribution from "fitting distributions with R": library(stats4) ## loading package stats4 ll<-function(lambda,alfa) {n<-200 x<-x.gam -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa- 1)*sum(log(x))+lambda*sum(x)} ## -log-likelihood function est<-mle(minuslog=ll, start=list(lambda=2,alfa=1)) Is anyone how how to write down -log-likelihood function for noncentral t distribution? Thanks a lot!! Kate [[alternative HTML version deleted]]
On 5/8/2008 10:34 AM, kate wrote:> I have a data with 236 observations. After plotting the histogram, I found that it looks like non-central t distribution. I would like to get MLE for mu and df. > > I found an example to find MLE for gamma distribution from "fitting distributions with R": > > library(stats4) ## loading package stats4 > ll<-function(lambda,alfa) {n<-200 > x<-x.gam > -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa- > 1)*sum(log(x))+lambda*sum(x)} ## -log-likelihood function > est<-mle(minuslog=ll, start=list(lambda=2,alfa=1)) > > Is anyone how how to write down -log-likelihood function for noncentral t distribution?dt() has a non-centrality parameter and a log parameter, so it would simply be ll <- function(x, ncp, df) sum(dt(x, ncp=ncp, df=df, log=TRUE)) Make sure you convert mu into the ncp properly; the man page says how ncp is interpreted. Duncan Murdoch
On Thu, 8 May 2008, kate wrote:> I have a data with 236 observations. After plotting the histogram, I > found that it looks like non-central t distribution. I would like to get > MLE for mu and df.So you mean 'non-central'? See ?dt.> I found an example to find MLE for gamma distribution from "fitting distributions with R": > > library(stats4) ## loading package stats4 > ll<-function(lambda,alfa) {n<-200 > x<-x.gam > -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa- > 1)*sum(log(x))+lambda*sum(x)} ## -log-likelihood function > est<-mle(minuslog=ll, start=list(lambda=2,alfa=1)) > > Is anyone how how to write down -log-likelihood function for noncentral t distribution?Just use dt. E.g.> library(MASS) > ?fitdistrshows you a worked example for location, scale and df, but note the comments. You could fit a non-central t, but it would be unusual to do so.> > Thanks a lot!! > > Kate > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
QRMlib has routines for fitting t distributions. Have a look at that package. Also sn has routines for skew-t distributions David Scott On Thu, 8 May 2008, kate wrote:> I have a data with 236 observations. After plotting the histogram, I found that it looks like non-central t distribution. I would like to get MLE for mu and df. > > I found an example to find MLE for gamma distribution from "fitting distributions with R": > > library(stats4) ## loading package stats4 > ll<-function(lambda,alfa) {n<-200 > x<-x.gam > -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa- > 1)*sum(log(x))+lambda*sum(x)} ## -log-likelihood function > est<-mle(minuslog=ll, start=list(lambda=2,alfa=1)) > > Is anyone how how to write down -log-likelihood function for noncentral t distribution? > > Thanks a lot!! > > Kate > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >_________________________________________________________________ David Scott Department of Statistics, Tamaki Campus The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 Email: d.scott at auckland.ac.nz Graduate Officer, Department of Statistics Director of Consulting, Department of Statistics