[R] Result show the values of fitting gamma parameter

Eric Berger ericjberger at gmail.com
Mon Jan 29 11:25:44 CET 2018


Capture the results of the apply command into an object and then work with
that. Here is one way to do it:

> res <- apply(C, 2, fitdist, "gamma")
> out <- c( res$A$estimate["shape"], res$B$estimate["shape"],
res$A$estimate["rate"], res$B$estimate["rate"])
> names(out) <- c("A shape","B shape","A rate","B Rate")
> print(out)

#   A shape   B shape    A rate    B Rate
# 3.702253 31.300800  1.234126  3.912649

HTH,
Eric


On Mon, Jan 29, 2018 at 10:25 AM, smart hendsome via R-help <
r-help at r-project.org> wrote:

> Hi,
> Let say I have data by two columns A and B, and I have fit each column
> using the gamma distribution by 'fitdist' . I just want the result show
> only the shape and rate only.
>
> Eg:
> library(fitdistrplus)
>
> A <-c(1,2,3,4,5)
>
> B<-c(6,7,8,9,10)
>
> C <-cbind(A,B)
> apply(C, 2, fitdist, "gamma")
> Output show like this:
> $A
> Fitting of the distribution ' gamma ' by maximum likelihood
> Parameters:
>       estimate Std. Error
> shape 3.702253  2.2440052
> rate  1.234126  0.8011369
>
> $B
> Fitting of the distribution ' gamma ' by maximum likelihood
> Parameters:
>        estimate Std. Error
> shape 31.300800   19.69176
> rate   3.912649    2.48129
>
> I want the output to be like this:
>                  A                    B
>  shape 3.702253  31.300800rate  1.234126  3.912649
> Can anyone solve my problem? Many thanks.
>
> Regards,
> Zuhri
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list