fitBinomialModel: Fit a model to binomial data

Description Usage Arguments Value Usage notes See Also Examples

View source: R/functions.R

Description

Fit a model to binomial data

Usage

1
2
fitBinomialModel(n, r, inits = list(list(a = 2, b = 4), list(a = 9, b =
  1)), modelString = NULL, autoRun = TRUE, raw = FALSE, ...)

Arguments

n

the vector holding the number of observations

r

the vector holding the number of responders

inits

a list containing the initial values of the hyperparameters. See Usage Notes below.

modelString

The JAGS model string that defines the model to be fitted

autoRun

Logical. If TRUE, use autorun.jags. Otherwise, use run.jags.

raw

logical if TRUE, the mcmc object created by JAGS is returned. Otherwise, a tibble containing the concatenation of elements of the mcmc.list created by JAGS is returned

...

passed to JAGS

Value

Either the mcmc (or mcmc.list) object returned by JAGS or a tibble containing the MCMC samples from the posterior distribution

Usage notes

If modelString == NULL, the model string is obtained by calling getModelString("binomial").

If raw == FALSE, the chain from which each observation is drawn is indicated by Chain and the dataset is transformed into tidy format, with the model parameter indicated by Parameter.

The inits parameter can be used to define the number of chains created my JAGS. If a list of lists, the number of elements in the outer list defines the number of chains and the elements of each sub-list define the initial value for each hyperparameter. For example, the default value of inits requests two chains. The initial values of a and b in the first chain are 2 and 4, respectively. In the second chain, the corresponding values are 9 and 1. If the MCMC model has converged and is stationary, the initial values of the hyperparameters will be irrelevant. To check for convergence, it is necessary - but not sufficient - to obtain more than one chain and to use different initial values for each chain.

See Also

fitPoissonModel, fitBinaryModel, fitTteModel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#Simple use
b <- createBerryData() 
m <- fitBinomialModel(b$Subjects, b$Events) %>% dplyr::filter(Index == 10)
#Passing parameters to run.jags()
inits1 <- list(a=4, b=2)
inits2 <- list(a=1, b=1)
inits3 <- list(a=2, b=10)
m <- fitBinomialModel(b$Subjects, b$Events,
                      inits=list(inits1, inits2, inits3),
                      thin=2)

PuzzledFace/qtlr documentation built on March 19, 2020, 1:17 a.m.