Skip to content
Prev 44407 / 398506 Next

problem with fitdistr ?

Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
Odd things are happening for me with r-devel, though:
Error in dn[[2]] : subscript out of bounds
Error in fitdistr(rnorm(100), "Normal", start = list(mean = 0, sd =
supplying pars for the Normal is not supported
Error in dn[[2]] : subscript out of bounds
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]])