gam.gradients: A function to calculate selection gradients from generalized...

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

View source: R/gam.gradients.R

Description

gam.gradients uses numerical approximations to the first and second order partial derivatives of population mean fitness with respect to population mean phenotype to obtain directional and quadratic selection gradients.

Usage

1
2
3
gam.gradients(mod, phenotype, covariates = NULL, standardized = FALSE, 
          se.method = "boot.para", n.boot = 1000, 
          parallel = "no", ncpus = 1, refit.smooth = FALSE)

Arguments

mod

a gam object. Must include predictor variables specified by phenotype

phenotype

a vector of one or two character strings specifying predictor variables in selection gradients are to be calculated

covariates

a character vector listing any covariates in the model mod for which selection gradients are not to be cacluated

se.method

the method by which to obtain standard errors and P-values of the selection gradients. Options are 'n' for none, 'boot.para' for parametric bootstrapping (default), 'boot.case' for case bootstrapping, 'posterior' for an algorithm based on simulation from the multivariate normal approximation to the posterior distribution of the model parameters, and 'permute' for permutation-based P-values (no SEs).

n.boot

number of bootstrap replicates for evaluating statistical uncertainty in the selection gradients.

standardized

whether or not to standardize to unit variance to obtain selection gradient estimates that are comparable across traits and populations

parallel

whether or not to use parallel processing to speed up computation of bootstrap standard errors. Default in 'no' for no parallel computing. Under linux only, parallel='multicore' allows parallel processing, using the number of processors specified by ncpus

ncpus

the number of cpus to be used for parallel processing of bootstrap standard errors. Only used under linux.

refit.smooth

whether or not to re-estiamte smoothing parameters when gam objects are refitted in bootstrapping and permutation algorithms

Value

A list. Element 1 is a table of estimates, standard errors and P-values, and element 2 contains the bootstrap or permutation values.

Author(s)

Michael Morrissey michael.morrissey@st-andrews.ac.uk

References

M.B. Morrissey and K. Sakrejda. 2013. Unification of regression-based methods for the analysis of natural selection. Evolution 67: 2094-2100.

See Also

gam.gradients,moments.differentials,gam

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# simulated data (stabilizing selection)
z<-rnorm(200,0,2)
W<-rpois(200,exp(1-0.3*z^2))
d<-as.data.frame(list(W=W,z=z))

# characterize the fitness function
library(mgcv)
ff<-gam(W~s(z),family='poisson',data=d)

# derive selection gradients
gam.gradients(mod=ff,phenotype="z",se.method='n',standardized=FALSE)$ests

# or gam.gradients() can be used to do the
# equivalent of a basic Lande and Arnold
# 1983 regression

LA<-gam(W~z+I(z^2),family='gaussian',data=d)
gam.gradients(mod=LA,phenotype="z",se.method='n',standardize=FALSE)$ests

gsg documentation built on May 2, 2019, 9:37 a.m.