gcline.fn: Fit a genomic cline using maximum likelihood

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/gcline.fn.R

Description

Fit a genomic cline and compare it to a null expectation. Choices are logit-logistic cline, Barton cline, Beta cline, multinomial regression, binomial regression, and Richards cline. This function is used by Cline.fit to compare clines fit to a data set.

Usage

1
2
gcline.fn(x, n, y, start, model = "logit-logit", method = "L-BFGS-B", iterations = 99,
 SD = rep(0.01, length(start)), headstart = FALSE,Grid = TRUE)

Arguments

x

A numeric vector of genome-wide mean ancestry (or any independent variable on the unit interval).

n

A numeric vector of sample sizes for each value in x. E.g., for individual diploid data, n=2.

y

A numeric vector containing the dependent variable: usually an allele count for each x

start

A vector of starting values: u and v for the logit-logistic, μ and ν for the Beta cline, a and b for the Barton cline, and U, L, m, and b for the Richards cline.

model

Character string indicating which cline function to fit:"logit-logit", "Beta", "Barton", "multinom", "logistic" or "Richards"

method

Character string indicating which algorithm to use to find the MLE: "L-BFGS-B" and "SANN" are used by the native optimization function optim, "mcmc" is a Markov Chain Monte Carlo using Metropolis-Hastings sampling. If "mcmc" is used, the following four items are also used.

iterations

The desired number of MCMC generations. The larger this number is, the greater the chance that the chain will find the maximum likelihood.

SD

Dispersion parameters for the "mcmc" and "SANN" methods. In these methods, new parameter values are proposed by drawing values from normal distributions centered on the current value and with standard deviations from SD.

headstart

Logical: if TRUE and method="mcmc" or "SANN", starting values will be found by first using optim with "L-BFGS-B".

Grid

Logical: if TRUE and method="mcmc" and model="Beta", starting values for the Markov Chain will be found by finding the highest likelihood on a 100 x 100 grid made by mu <- seq(from=0.02,to=0.90,length.out=10); nu <- 2^(0:9)/10.

Value

A list:

model

The cline function used

method

The optimization method used

estimates

Maximum likelihood parameter estimates

lnL

The maximum likelihood and the likelihood of the data given the naive null model E(y)=x

k

The number of fitted coefficients

AICc

Akaike's information criterion with sample size correction

convergence

From optim: 0 means the algorithm thinks it did a good job, otherwise the MLE may be incorrect. If mcmc was used, this will be the full Markov Chain, which could be analyzed for convergence (e.g., see coda).

Author(s)

Benjamin M. Fitzpatrick

References

Fitzpatrick, B. M. 2012. Alternative forms for genomic clines. In prep

See Also

See Cline.fit for application to multilocus data sets and analysis of interclass heterozygosity.

Examples

1
2
3
4
5
x <- 0:50/50          # hypothetical genomic ancestry proportions
y <- rbinom(50,2,x)   # random diploid genotypes for a diagnostic marker
n=rep(2,50)			  # sample size is two alleles per diploid individual

gcline.fn(x=x,n=n,y=y,start=c(.5,2),model="logit-logit")

HIest documentation built on May 2, 2019, 10:21 a.m.