[R] problem with fitdistr ?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Feb 18 09:10:57 CET 2004
It works under the versions 7.2-0 dated Jan 22 or later: that on CRAN is
dated Jan 14 and predates 7.1-14.
Since R-devel is `under development', the pieces are not at all times in
sync.
On 18 Feb 2004, Peter Dalgaard wrote:
> Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
>
> > Which version of MASS (not that you gave me any credit)? This works in
> > the current 7.1-14.
>
> Odd things are happening for me with r-devel, though:
>
> > library(MASS)
> > fitdistr(rnorm(100),"Normal")
> Error in dn[[2]] : subscript out of bounds
> > fitdistr(rnorm(100),"Normal",start=list(mean=0,sd=1))
> Error in fitdistr(rnorm(100), "Normal", start = list(mean = 0, sd =
> > 1)) :
> supplying pars for the Normal is not supported
> > x <- fitdistr(rnorm(100),"normal")
> > x
> Error in dn[[2]] : subscript out of bounds
> > str(x)
> List of 2
> $ estimate: num 0.217
> $ sd : num 0.99
> - attr(*, "class")= chr "fitdistr"
>
> And the rest of the story is that this bit of print.fitdistr computes
> "ans" without dimnames and thus refers to dn[[2]] before there's
> anything there:
>
> ans <- format(rbind(x$estimate, x$sd), digits = digits)
> ans[1, ] <- sapply(ans[1, ], function(x) paste("", x))
> ans[2, ] <- sapply(ans[2, ], function(x) paste("(", x, ")",
> sep = ""))
> dn <- dimnames(ans)
> dn[[1]] <- rep("", 2)
> dn[[2]] <- paste(substring(" ", 1, (nchar(ans[2, ]) -
> nchar(dn[[2]]))%/%2), dn[[2]])
>
>
>
>
>
--
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
More information about the R-help
mailing list