Last data update: 2014.03.03

R: ABC Extimation of P2 for Normal Distribution
ABC_P2_normR Documentation

ABC Extimation of P2 for Normal Distribution

Description

This function fits offspring data to a special case of the normal distribution, in which zero and negative values of offspring are excluded, and estimates P2 based on that distribution and the specificed priors.

Usage

ABC_P2_norm(n, ObsMean, M_Lo, M_Hi, SD_Lo, SD_Hi, delta, iter)

Arguments

n

number of observations.

ObsMean

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

M_Lo

minimum mean value for the distribution.

M_Hi

maximum mean value for the distribution.

SD_Lo

minimum standard deviation value for the distribution.

SD_Hi

maximum standard deviation 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.

Avg

Vector of values for the mean parameter.

Std

Vector of values for the standard deviation parameter.

Author(s)

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

Examples

#Fit the Mean and Standard Deviation hyperpriors to a distribution of offspring. 

data(fungus)
fit_dist_norm(fungus$Total_Offspring)

#Use hyperiors and priors calculated from the data to estimate P2. 
#Plot the saved distributions for the Mean and Standard Deviation parameters.
#Adjust, if necessary.

fungus_P2<-ABC_P2_norm(12, 9.9, 11.35, 17.31, 8.22, 12.44, 0.1, 100)
hist(fungus_P2$posterior)
hist(fungus_P2$Avg)
hist(fungus_P2$Std)

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_norm.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ABC_P2_norm
> ### Title: ABC Extimation of P2 for Normal Distribution
> ### Aliases: ABC_P2_norm
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> #Fit the Mean and Standard Deviation hyperpriors to a distribution of offspring. 
> 
> data(fungus)
> fit_dist_norm(fungus$Total_Offspring)
$data_norm
 [1] 11 10  9 13  4 38 22 10 19 36  8 20

$fit_norm
     mean         sd    
  14.333333   10.330645 
 ( 2.982200) ( 2.108734)

$chi_norm

	Pearson's Chi-squared test

data:  dist and data_norm
X-squared = 63, df = 60, p-value = 0.3707


Warning message:
In chisq.test(dist, data_norm) : Chi-squared approximation may be incorrect
> 
> #Use hyperiors and priors calculated from the data to estimate P2. 
> #Plot the saved distributions for the Mean and Standard Deviation parameters.
> #Adjust, if necessary.
> 
> fungus_P2<-ABC_P2_norm(12, 9.9, 11.35, 17.31, 8.22, 12.44, 0.1, 100)
> hist(fungus_P2$posterior)
> hist(fungus_P2$Avg)
> hist(fungus_P2$Std)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>