[R] Help with function "fitdistr" in "MASS"

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Jan 3 09:43:20 CET 2010


Please read the footer of this message.  ?fitdistr says

        x: A numeric vector.

and setting the class does not make it a numeric vector (it is just a 
label).  And fitdistr early on does

     if (missing(x) || length(x) == 0L || mode(x) != "numeric")
         stop("'x' must be a non-empty numeric vector")

so you do have a non-empty numeric vector.

It is likely that your data contains NAs, in which case the quoted 
result is correct.  But despite the posting guide we have no details 
of your 'mydata' and have to guess.

On Sat, 2 Jan 2010, Saji Ren wrote:

>
> Hi, R users:
>
> I want to fit my data into a normal distribution by using the command
> "fitdistr" in "MASS".
> I changed my data class from "ts" to "numeric" by
>
>> class(mydata)="numeric"
>
> but after using "fitdistr", I got the result below
>
>> fitdistr(mydata,"normal")
>  mean    sd
>  NA     NA
> (NA)   (NA)
>
> the help doc of "fitdistr" does not mention anything about that, thus I need
> your help.

The help page is not intended to be a very basic statistics/R textbook.

> Thank you in advanced,
> Saji from Shanghai
> -- 
> View this message in context: http://n4.nabble.com/Help-with-function-fitdistr-in-MASS-tp997609p997609.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>

-- 
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