R: Fit Offspring Distribution to the Gamma Distribution
fit_dist_gamma
R Documentation
Fit Offspring Distribution to the Gamma Distribution
Description
This function fits offspring data to a special case of the gamma distribution, in which zero values of offspring are excluded and all values are rounded to a whole number, and tests the goodness of fit using the chi-squared test.
Usage
fit_dist_gamma(dist)
Arguments
dist
a numeric vector of data values for number of offspring per dam.
Value
estimate
Shape and rate parameters estimated from the supplied distribution.
sd
Standard deviation of the shape and rate estimates.
vcov
Variance/covariance matrix of the shape and rate estimates.
loglik
the log-likelihood of the shape and rate estimates.
n
The number of observations.
statistic
The chi-squared test statistic.
parameter
Degrees of freedom for the chi-squared test.
p.value
P-value for the chi-squared test.
data_gamma
Vector of values generated from a special case of the gamma distribution.
Author(s)
M. Catherine Duryea, Andrew D. Kern, Robert M. Cox, and Ryan Calsbeek
Examples
#Fit the Shape and Rate parameters to a distribution of offspring.
#Test the goodness of fit.
data(fungus)
fungus_fit<-fit_dist_gamma(fungus$Total_Offspring)
fungus_fit$fit_gamma
fungus_fit$chi_gamma
hist(fungus_fit$data_gamma)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ABCp2)
Loading required package: MASS
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ABCp2/fit_dist_gamma.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fit_dist_gamma
> ### Title: Fit Offspring Distribution to the Gamma Distribution
> ### Aliases: fit_dist_gamma
> ### Keywords: ~kwd1 ~kwd2
>
> ### ** Examples
>
> #Fit the Shape and Rate parameters to a distribution of offspring.
> #Test the goodness of fit.
>
> data(fungus)
> fungus_fit<-fit_dist_gamma(fungus$Total_Offspring)
Warning message:
In chisq.test(dist, data_gamma) :
Chi-squared approximation may be incorrect
> fungus_fit$fit_gamma
shape rate
1.83470164 0.12800243
(0.69165781) (0.05542993)
> fungus_fit$chi_gamma
Pearson's Chi-squared test
data: dist and data_gamma
X-squared = 51, df = 54, p-value = 0.5908
> hist(fungus_fit$data_gamma)
>
>
>
>
>
> dev.off()
null device
1
>