Last data update: 2014.03.03

R: ABC Estimation of P2 for Poisson Distribution
ABC_P2_poisR Documentation

ABC Estimation of P2 for Poisson Distribution

Description

This function fits offspring data to the Poisson distribution and estimates P2 based on that distribution and the specificed priors.

Usage

ABC_P2_pois(n, ObsMean, L_Lo, L_Hi, delta, iter)

Arguments

n

the number of observations.

ObsMean

the observed mean number of offspring sired by the second male.

L_Lo

minimum lambda value for the distribution.

L_Hi

maximum lambda 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.

Lambda

Vector of values for the lambda parameter.

Author(s)

M. Catherine Duryea, Andrew D. Kern, Robert M. Cox, and Ryan Calsbeek

Examples

#Fit the Lambda hyperprior to a distribution of offspring.

data(fungus)
fit_dist_pois(fungus$Total_Offspring)

#Use hyperiors and priors calculated from the data to estimate P2. 
#Plot the saved distributions for the Lambda parameter. 
#Adjust, if necessary.

fungus_P2<-ABC_P2_pois(12, 9.9, 13.24, 15.42, 0.1, 100)
hist(fungus_P2$posterior)
hist(fungus_P2$Lambda)

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_pois.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ABC_P2_pois
> ### Title: ABC Estimation of P2 for Poisson Distribution
> ### Aliases: ABC_P2_pois
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> #Fit the Lambda hyperprior to a distribution of offspring.
> 
> data(fungus)
> fit_dist_pois(fungus$Total_Offspring)
$data_pois
 [1] 20 21 14 19 12 15 16 11 13  8 20 10

$fit_pois
    lambda  
  14.333333 
 ( 1.092906)

$chi_pois

	Pearson's Chi-squared test

data:  dist and data_pois
X-squared = 64, df = 60, p-value = 0.338


Warning message:
In chisq.test(dist, data_pois) : Chi-squared approximation may be incorrect
> 
> #Use hyperiors and priors calculated from the data to estimate P2. 
> #Plot the saved distributions for the Lambda parameter. 
> #Adjust, if necessary.
> 
> fungus_P2<-ABC_P2_pois(12, 9.9, 13.24, 15.42, 0.1, 100)
> hist(fungus_P2$posterior)
> hist(fungus_P2$Lambda)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>