MLE for noncentral t distribution

View: New views
8 Messages — Rating Filter:   Alert me  

MLE for noncentral t distribution

by kate-26 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... 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.

Re: MLE for noncentral t distribution

by Duncan Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

______________________________________________
R-help@... 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.

Re: MLE for noncentral t distribution

by Prof Brian Ripley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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)
> ?fitdistr

shows 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@... 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@...
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

______________________________________________
R-help@... 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.

Re: MLE for noncentral t distribution

by kate-26 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your quick reply.

I try the command as follows,

library(stats4) ## loading package stats4
ll <- function(change, ncp, df) {-sum(dt(x, ncp=ncp, df=df,
log=TRUE))}#-log-likelihood function
est<-mle(minuslog=ll, start=list(ncp=-0.3,df=2))

But the warnings appears as follows,

invalid class "mle" object: invalid object for slot "fullcoef" in class
"mle": got class "list", should be or extend class "numeric"

When I typed warnings(), I get

In dt(x, ncp = ncp, df = df, log = TRUE) :
  full precision was not achieved in 'pnt'

Does anyone know how to solve it?

Thanks,

Kate


----- Original Message -----
From: "Duncan Murdoch" <murdoch@...>
To: "kate" <yhsu6@...>
Cc: <r-help@...>
Sent: Thursday, May 08, 2008 9:46 AM
Subject: Re: [R] MLE for noncentral t distribution


> 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

______________________________________________
R-help@... 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.

Re: MLE for noncentral t distribution

by kate-26 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In my data,  sample mean =-0.3 and the histogram looks like t distribution;
therefore, I thought non-central t distribution may be a good fit. Anyway, I
try t distribution to get MLE. I found some warnings as follows; besides, I
got three parameter estimators: m=0.23, s=4.04, df=1.66. I want to simulate
the data with sample size 236 and this parameter estimates. Is the command
rt(236, df=1.66)? Where should I put m and s when I do simulation?

       m           s          df
  0.2340746   4.0447124   1.6614823
 (0.3430796) (0.4158891) (0.2638703)
Warning messages:
1: In dt(x, df, log) : generates NaNs
2: In dt(x, df, log) : generates NaNs
3: In dt(x, df, log) :generates NaNs
4: In log(s) : generates NaNs
5: In dt(x, df, log) : generates NaNs
6: In dt(x, df, log) : generates NaNs

Thanks a lot,

Kate

----- Original Message -----
From: "Prof Brian Ripley" <ripley@...>
To: "kate" <yhsu6@...>
Cc: <r-help@...>
Sent: Thursday, May 08, 2008 10:02 AM
Subject: Re: [R] MLE for noncentral t distribution


> 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)
>> ?fitdistr
>
> shows 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@... 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@...
> 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

______________________________________________
R-help@... 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.

Re: MLE for noncentral t distribution

by David Scott-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



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@... 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@...

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

______________________________________________
R-help@... 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.

Re: MLE for noncentral t distribution

by Martin Maechler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>>>> "k" == kate  <yhsu6@...>
>>>>>     on Thu, 8 May 2008 10:45:04 -0500 writes:

    k> In my data,  sample mean =-0.3 and the histogram looks like t distribution;
    k> therefore, I thought non-central t distribution may be a good fit. Anyway, I
    k> try t distribution to get MLE. I found some warnings as follows; besides, I
    k> got three parameter estimators: m=0.23, s=4.04, df=1.66. I want to simulate
    k> the data with sample size 236 and this parameter estimates. Is the command
    k> rt(236, df=1.66)? Where should I put m and s when I do simulation?

 m  +  s * rt(n, df= df)

[I still hope this isn't a student homework problem...]

Martin Maechler, ETH Zurich

    k> m           s          df
    k> 0.2340746   4.0447124   1.6614823
    k> (0.3430796) (0.4158891) (0.2638703)
    k> Warning messages:
    k> 1: In dt(x, df, log) : generates NaNs
    k> 2: In dt(x, df, log) : generates NaNs
    k> 3: In dt(x, df, log) :generates NaNs
    k> 4: In log(s) : generates NaNs
    k> 5: In dt(x, df, log) : generates NaNs
    k> 6: In dt(x, df, log) : generates NaNs

    k> Thanks a lot,

    k> Kate

    k> ----- Original Message -----
    k> From: "Prof Brian Ripley" <ripley@...>
    k> To: "kate" <yhsu6@...>
    k> Cc: <r-help@...>
    k> Sent: Thursday, May 08, 2008 10:02 AM
    k> Subject: Re: [R] MLE for noncentral t distribution


    >> 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)
    >>> ?fitdistr
    >>
    >> shows 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

______________________________________________
R-help@... 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.

Re: MLE for noncentral t distribution

by Spencer Graves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, Martin and Kate:

KATE:  Do you really want the noncentral t?  It has mean zero but
strange tails created by a denominator following a noncentral
chi-square.  The answer Martin gave is for a scaled but otherwise
standard t, which sounds like what you want, since you said the "sample
mean = 0.23, s = 4.04, etc.  A noncentral t has an additional
"noncenrality parameter".

Hope this helps.
Spencer

Martin Maechler wrote:

>>>>>> "k" == kate  <yhsu6@...>
>>>>>>     on Thu, 8 May 2008 10:45:04 -0500 writes:
>>>>>>            
>
>     k> In my data,  sample mean =-0.3 and the histogram looks like t distribution;
>     k> therefore, I thought non-central t distribution may be a good fit. Anyway, I
>     k> try t distribution to get MLE. I found some warnings as follows; besides, I
>     k> got three parameter estimators: m=0.23, s=4.04, df=1.66. I want to simulate
>     k> the data with sample size 236 and this parameter estimates. Is the command
>     k> rt(236, df=1.66)? Where should I put m and s when I do simulation?
>
>  m  +  s * rt(n, df= df)
>
> [I still hope this isn't a student homework problem...]
>
> Martin Maechler, ETH Zurich
>
>     k> m           s          df
>     k> 0.2340746   4.0447124   1.6614823
>     k> (0.3430796) (0.4158891) (0.2638703)
>     k> Warning messages:
>     k> 1: In dt(x, df, log) : generates NaNs
>     k> 2: In dt(x, df, log) : generates NaNs
>     k> 3: In dt(x, df, log) :generates NaNs
>     k> 4: In log(s) : generates NaNs
>     k> 5: In dt(x, df, log) : generates NaNs
>     k> 6: In dt(x, df, log) : generates NaNs
>
>     k> Thanks a lot,
>
>     k> Kate
>
>     k> ----- Original Message -----
>     k> From: "Prof Brian Ripley" <ripley@...>
>     k> To: "kate" <yhsu6@...>
>     k> Cc: <r-help@...>
>     k> Sent: Thursday, May 08, 2008 10:02 AM
>     k> Subject: Re: [R] MLE for noncentral t distribution
>
>
>     >> 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)
>     >>> ?fitdistr
>     >>
>     >> shows 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
>
> ______________________________________________
> R-help@... 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.
>

______________________________________________
R-help@... 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.