predict_cline: Predict allele frequencies or mean phenotypes for a cline

Description Usage Arguments Value Examples

Description

Uses the cline parameters from your stanfit object to predict the allele frequency (for genetic clines) or the mean phenotype value (for phenotypic clines) at the distance(s) along the transect specified by the user. Returns best-fit cline values estimated using both the mean of the posterior distribution of each parameter and the median of the posterior distribution of each parametet. Optionally, can also calculate credible intervals around these best-fit estimates. To save computation time, this function use the memoise package to save past results and avoid recalculations. To clear the cache of saved results, use clear.cache = F or clear_bahz_cache.

Usage

1
2
predict_cline(stanfit, distance, confidence = F, prob = 0.95,
  method = "HPDI", progress = T, clear.cache = F)

Arguments

stanfit

A stanfit object holding your model results.

distance

The x value(s) (distance along the transect) at which to predict allele frequencies or mean phenotypes for the fitted cline. Must be a numeric vector.

confidence

Calculate credible intervals around the cline? TRUE or FALSE, default FALSE.

prob

The probability interval to calculate for the cline. Default is .95. Numeric, between 0 and 1.

method

The method for calculating credible intervals. Either "ET" for equal-tail probability intervals, or "HPDI" for highest posterior density intervals. Default is "HPDI".

progress

Show progress bar when calculating credible intervals? TRUE or FALSE, default TRUE.

clear.cache

Clear the cache of saved results to ensure recalculation of predicted cline? TRUE or FALSE, default FALSE.

Value

A data frame with either 2 (confidence = F) or 4 (confidence = T) columns:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 

# Predict at one distance
predict_cline(yourStanfit, distance = 50)

# Predict at a range of distances
predict_cline(yourStanfit, distance = 0:100)


## End(Not run)

tjthurman/BAHZ documentation built on May 30, 2020, 8:28 a.m.