I have the following code:
x <- c(
0.367141764080875, 0.250037975705769, 0.167204185003365, 0.299794433447383,
0.366885973041269, 0.300453205296379, 0.333686861081341, 0.33301168850398,
0.400142004893329, 0.399433677388411, 0.366077304765104, 0.166402979455671,
0.466624230750293, 0.433499934139897, 0.300017278751768, 0.333673696762895,
0.29973685692478
)
fn <- fitdistrplus::fitdist(x,"norm")
summary(fn)
#> Fitting of the distribution ' norm ' by maximum likelihood
#> Parameters :
#> estimate Std. Error
#> mean 0.32846024 0.01918923
#> sd 0.07911922 0.01355908
#> Loglikelihood: 19.00364 AIC: -34.00727 BIC: -32.34084
#> Correlation matrix:
#> mean sd
#> mean 1 0
#> sd 0 1
Basically, it takes a vector and tried to fit the distribution using fitdistrplus package.
I tried looking at the broom package, but it doesn't have a function that covers that.
Not sure exactly what you need, but you can try:
https://stats.stackexchange.com/questions/23539/use-fitdist-parameters-in-variables
When you call
broom::tidy(fn)
you receive an error that says:This is because this function from
broom
only has a finite number objects that are "good to use", seemethods(tidy)
for the complete list. (Read more about S3 methods in R. More here).So the function doesn't work for an object
fitdist
but works for afitdistr
object fromMASS
(more "famous").We can then assign to
fn
thatclass
, and then usebroom
:Note that you can only see the
parameters
. If you wish to see more and organize everything as "tidy", you should tell us more about your expected output.broom::tidy()
gets you this far, if you want more I'd start by defining my own method function that works for aclass
fitdist
object using as reference thetidy.fitdistr
method, and adapting it.Example of how I'd adapt from the original
broom::tidy()
code, using the S3 method for the classfitdist
.Define your own method (similar to how you define your own function):
This is how you can call this new
method
now:Notice that the
class
is:So now you don't actually need to assign the
fitdistr
(fromMASS
) class as before.