On Dec 17, 2011, at 10:57 , Steinar wrote: > I was playing around with the ghyp package and simulated series of > t-distributed variables when suddenly i was not able to reproduce the log > likelihood values reported by the package. When trying to reproduce the > likelihood values, I summed the log(dt(x,v)) values and it worked with some > simulated series but not all. > > Is there any obvious flaws with this script?
Try rethinking your definition of the likelihood. I would expect that the likelihood depends on the scale and position parameters via (x-mu)/sigma or so. As far as I can tell, you are de facto setting mu=0 and sigma=1, which might sort of work if you are simulating with mu=0 and sigma=1, but not when sigma=5. > library("ghyp") > series_1=rt(10000,4) > > #simulating 10000 relation of student t variables with df=4 > #Which implies a standrad deviation equal to sqrt(2) > > series_2=series_1/sqrt(2)*5 > > #To get student t distributed variabler with standard > #deviation equal to 5 I rescale the first series > > #When i check the first series with the ghyp package, the result coincides > with > #the sum of log likelihood calculated with dt(x, df, ncp, log = FALSE) > > fit_1=fit.tuv(series_1, silent=T, symmetric=T) > fit_1 > sum(log(dt(series_1,coef(fit_1)$nu,0))) > > #The two log likelihood estimates is approximatly equal, and the parameters > are > #sensible. > > #When I check series 2, i get a very different result. The estimate for mu > and nu > #is still sensible, but the log likelihood is very different from what i get > with > #dt(x, df, ncp, log = FALSE) > > fit_2=fit.tuv(series_2, silent=T, symmetric=T) > fit_2 > sum(log(dt(series_2,coef(fit_2)$nu,0))) > > #This is very different > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Problem-with-reproducing-log-likelihood-estimated-with-ghyp-package-tp4207833p4207833.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@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.