[R] problem with fitdistr ?
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Feb 18 00:28:56 CET 2004
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]])
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list