s-news
[Top] [All Lists]

[S] How can I fit a t-distribution to a sample?

To: s-news@wubios.wustl.edu
Subject: [S] How can I fit a t-distribution to a sample?
From: John.Gavin@ubsw.com
Date: Wed, 31 May 2000 08:50:34 +0100
Sender: owner-s-news@wubios.wustl.edu
Hi,

How can I fit a t-distribution to a sample?

For example,

dat  <- rt(1000, 5) * 5 + 10
tfit <- function(df, x) sum(log( dt( ( x - 10 ) / 5 , df) ) )
optimize(tfit, c(0,100), x = dat , max = T )$maximum

works for a random sample from t-distribution,
in that it returns an estimate of the degrees of freedom,
that seems fairly stable, when the mean and st dev are known.

If the mean, variance and degrees of freedom are unknown
then the following example doesnt seem to work well

mu <- 7 ; sd <- 3 ; df <- 10
dat       <- data.frame(xx = rt(1000, df) * sd + mu )
startVals <- list(mu = mean(dat$xx) , sd = stdev(dat$xx) , df = 20)
ms( ~ -log(dt( (xx - mu) / sd , df) ) , data = dat, start = startVals,  trace = 
F)
rm(dat, tfit, mu, sd, df, startVals)

VR3, vol 1, page 263 offers a similar example for a mixture model
but can someone suggest a way of adding partial derivatives,
improving the starting values or improving my code?

I am using SPlus 2000 R2 on NT4.

Thanks for your time.

Regards,

John.

John Gavin
Quantitative Risk: Models and Statistics
UBS Warburg, 
1st floor, 1 Finsbury Ave., London EC2M 2PP.
john.gavin@ubsw.com
+44 (0) 20 7567 4289


This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>