APDREcorr: APDREcorr Correlations between Activity Patterns using APD...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/APDREcorr.R

Description

Calculates estimated relationships between activity probability density (APD) of the focal and contingent(s) using Bayesian GLMMs with 'STAN' using brm, with the option to automatically select the statistical distribution that best fits the dataset (weibull, frechet, gamma, lognormal, inverse gaussian) by loo. The function automatically ensures that MCMC chains reach convergence and that the specified minimum effective sample size from the posterior distribution is achieved.

Package: AnimalAPD Version: 1.0.0 Date: 2020-11-10

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
APDREcorr(
  focal,
  cont1,
  cont2 = NULL,
  cont3 = NULL,
  cont4 = NULL,
  RE1,
  RE2 = NULL,
  weibullGLMM = TRUE,
  frechetGLMM = TRUE,
  gammaGLMM = TRUE,
  lognormalGLMM = FALSE,
  invgaussianGLMM = TRUE,
  cores = 1,
  iter = 5000,
  minESS = 1000,
  burnin = iter/2,
  thin = 1,
  adapt_delta = 0.95,
  center = "pi",
  adjust = 1,
  Reloo = TRUE,
  plothist = TRUE,
  ploteffects = TRUE,
  histcol = "cyan4",
  effectcol = "cyan4",
  linecol = "red"
)

Arguments

focal

Vector of observations in radians of one species/group/individual/etc. for which predictions on another will be made.

cont1

Vector of observations in radians, or output from generalized circular mixture model of activity curves from GCMM, of a species/group/individual/etc. from which predictions will be made

cont2

Optional vector of observations in radians, or output from generalized circular mixture model of activity curves from GCMM, of additional species/group/individual/etc. from which predictions will be made

cont3

Optional vector of observations in radians, or output from generalized circular mixture model of activity curves from GCMM, of additional species/group/individual/etc. from which predictions will be made

cont4

Optional vector of observations in radians, or output from generalized circular mixture model of activity curves from GCMM, of additional species/group/individual/etc. from which predictions will be made

RE1

Vector identifying a random intercept for observations of the focal to control for hierarchical data (e.g. camera trap IDs)

RE2

Optional vector identifying levels of a second random effect, for data with additional hierarchical levels (e.g. study sites, sampling periods, data collection seasons); default is NULL

weibullGLMM

Specifies whether to run a weibull GLMM, using the brms package; default is TRUE for all and results from the best-fitting model are returned

frechetGLMM

Specifies whether to run a frechet GLMM, using the brms package; default is TRUE for all and results from the best-fitting model are returned

gammaGLMM

Specifies whether to run a Gamma GLMM, using the brms package; default is TRUE for all and results from the best-fitting model are returned

lognormalGLMM

Specifies whether to run a lognormal GLMM, using the brms package; default is TRUE for all and results from the best-fitting model are returned

invgaussianGLMM

Specifies whether to run a inverse.gaussian GLMM, using the brms package; default is TRUE for all and results from the best-fitting model are returned

cores

Number of cores to use when running MCMC chains in parallel; default=1

iter

Number of MCMC iteractions per chain; burnin is iter/2; default=5000

minESS

Desired minimum effective sample size; default=1000

burnin

Number of MCMC iterations to be discarded as the burn-in; default=iter/2

thin

Thinning rate for saving MCMC draws; default=1

adapt_delta

Value to use for adapt_delta with brms; default=0.95; see also brms

center

Value to use as center of graph; default=pi

adjust

Smoothing of predicted line; recommended to use default value for observed values and higher value for estimations from circular models

Reloo

Whether to use reloo when running leave-one-out cross-validation of models (loo); see also brms and loo

plothist

Whether to plot histograms of samples from the posterior distribution for the correlation parameters; default=TRUE

ploteffects

Whether to plot predicted effects; default=TRUE

histcol

Colour for histogram bars

effectcol

Colour for predicted effect plot 95% HDI

linecol

Colour for histogram lines for the 95% HDI and 0

Value

Prints results of best-fitting model and posterior samples and/or predicted effects of parameter estimates if plothist=TRUE and ploteffects=TRUE, and returns object of class APD with list of analysis results and information.

data List of data used in analysis

model Object of class brmsfit containing results and information for best-fitting model.

distribution Character vector of statistical distribution of best-fitting model

allmodels List of output for all tested models; object of class brmsfit

Author(s)

Liz AD Campbell

See Also

GCMM brm loo

Examples

1
2
3
4
data(wolfexample)
data(boarexample)
APDREcorr(focal=wolfexample$Radians,cont1=boarexample$Radians,
    RE1=wolfexample$SamplingPeriod)

AnimalAPD documentation built on March 18, 2021, 5:07 p.m.