# Use fitdist parameters in variables

I'm sure this is a simple problem, but I'm not sure how to search and find the answer.

I have a set of parameters that I've estimated using 'fitdist':

Fitting of the distribution ' gamma ' by matching moments
Parameters:
estimate
shape 0.2018062
rate  3.1255336


now I want to pull those parameters and store them in variables. But I can't figure out how to separate them. I've tried:

> gamma.fit$estimate shape rate 0.2018062 3.1255336  but how do I pull the specific elements? (e.g. shape = 0.2018062 and rate = 3.1255336) I've tried using normal data frame tools but I get an 'incorrect number of dimensions' error. Any ideas would be greatly appreciated, sorry if this is covering old territory. Nick - add comment ## 1 Answer Using the fitdistr function from MASS, you can access the estimated parameters like I did it below. The same holds for fitdistrplus:::fitdist. op <- options(digits = 3) set.seed(123) x <- rgamma(100, shape = 5, rate = 0.1) ft <- fitdistr(x, "gamma") ft$estimate["shape"]
shape
6.486991
# or
ft$estimate[1] shape 6.486991  Same goes for rate. If you do str(ft$estimate) you will see that this is a named vector. Since it's named, you can call it by name (["shape"]) or by index ([1]).

 Named num [1:2] 6.487 0.137
- attr(*, "names")= chr [1:2] "shape" "rate"

-
Exactly what I needed. Thanks! –  nickrobison Feb 23 '12 at 13:59