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 estimates P2 based on that distribution and the specificed priors.
the observed mean number of offspring sired by the second male.
S_Lo
minimum shape value for the distribution.
S_Hi
maximum shape value for the distribution.
R_Lo
minimum rate value for the distribution.
R_Hi
maximum rate value for the distribution.
delta
maximum allowed difference between the estimated mean and observed mean number of offspring produced by the second male.
iter
number of iterations used to build the posterior.
Value
posterior
Posterior distribution of P2 values.
Shape
Vector of values for the shape parameter.
Rate
Vector of values for the rate parameter.
Author(s)
M. Catherine Duryea, Andrew D. Kern, Robert M. Cox, and Ryan Calsbeek
Examples
#Fit the Shape and Rate hyperpriors to a distribution of offspring.
data(fungus)
fit_dist_gamma(fungus$Total_Offspring)
#Use hyperiors and priors calculated from the data to estimate P2.
#Plot the saved distributions for the Shape and Rate parameters.
#Adjust, if necessary.
fungus_P2<-ABC_P2_gamma(12, 9.9, 1.14, 2.52, 0.06, 0.18, 0.1, 100)
hist(fungus_P2$posterior)
hist(fungus_P2$Shape)
hist(fungus_P2$Rate)
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/ABC_P2_gamma.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ABC_P2_gamma
> ### Title: ABC Estimation of P2 for Gamma Distribution
> ### Aliases: ABC_P2_gamma
> ### Keywords: ~kwd1 ~kwd2
>
> ### ** Examples
>
> #Fit the Shape and Rate hyperpriors to a distribution of offspring.
>
> data(fungus)
> fit_dist_gamma(fungus$Total_Offspring)
$data_gamma
[1] 15 18 6 13 8 19 14 5 29 17 8 17
$fit_gamma
shape rate
1.83470164 0.12800243
(0.69165781) (0.05542993)
$chi_gamma
Pearson's Chi-squared test
data: dist and data_gamma
X-squared = 62, df = 54, p-value = 0.2124
Warning message:
In chisq.test(dist, data_gamma) :
Chi-squared approximation may be incorrect
>
> #Use hyperiors and priors calculated from the data to estimate P2.
> #Plot the saved distributions for the Shape and Rate parameters.
> #Adjust, if necessary.
>
> fungus_P2<-ABC_P2_gamma(12, 9.9, 1.14, 2.52, 0.06, 0.18, 0.1, 100)
> hist(fungus_P2$posterior)
> hist(fungus_P2$Shape)
> hist(fungus_P2$Rate)
>
>
>
>
>
>
> dev.off()
null device
1
>