BANOVA.Binomial {BANOVA}R Documentation

Estimation of BANOVA with a Binomial dependent variable

Description

BANOVA.Binomial implements a Hierarchical Bayesian ANOVA for a binomial response variable using a logit link and a normal heterogeneity distribution.

Usage

BANOVA.Binomial(l1_formula = "NA", l2_formula = "NA", data,
  id, num_trials, l2_hyper = c(1, 1, 0.0001), burnin = 5000, sample = 2000, 
  thin = 10, adapt = 0, conv_speedup = F, jags = runjags.getOption('jagspath'))
## S3 method for class 'BANOVA.Binomial'
summary(object, ...)
## S3 method for class 'BANOVA.Binomial'
predict(object, newdata = NULL,...)
## S3 method for class 'BANOVA.Binomial'
print(x, ...)

Arguments

l1_formula

formula for level 1 e.g. 'Y~X1+X2'

l2_formula

formula for level 2 e.g. '~Z1+Z2', response variable must not be included

data

a data.frame in long format including all features in level 1 and level 2(covariates and categorical factors) and responses

id

subject ID of each response unit

num_trials

the number of trials of each observation(=1, if it is bernoulli), the type is forced to be 'integer'

l2_hyper

level 2 hyperparameters, c(a, b, \gamma), default c(1,1,0.0001)

burnin

the number of burn in draws in the MCMC algorithm, default 5000

sample

target samples in the MCMC algorithm after thinning, default 2000

thin

the number of samples in the MCMC algorithm that needs to be thinned, default 10

adapt

the number of adaptive iterations, default 0 (see run.jags)

conv_speedup

whether to speedup convergence, default F

jags

the system call or path for activating 'JAGS'. Default calls findjags() to attempt to locate 'JAGS' on your system

object

object of class BANOVA.Bin (returned by BANOVA.Bin)

newdata

test data, either a matrix, vector or a data frame. It must have the same format with the original data (the same column number)

x

object of class BANOVA.Bin (returned by BANOVA.Bin)

...

additional arguments,currently ignored

Details

Level 1 model:
y_i ~ Binomial(ntrials,p_i), p_i = logit^{-1}(\eta_i)
where ntrials is the binomial total for each record i, \eta_i = \sum_{p = 0}^{P}\sum_{j=1}^{J_p}X_{i,j}^p\beta_{j,s_i}^p, s_i is the subject id of response i. see BANOVA-package

Value

BANOVA.Binomial returns an object of class "BANOVA.Bin". The returned object is a list containing:

anova.table

table of effect sizes BAnova

coef.tables

table of estimated coefficients

pvalue.table

table of p-values table.pvalues

dMatrice

design matrices at level 1 and level 2

samples_l2_param

posterior samples of level 2 parameters

data

original data.frame

mf1

model.frame of level 1

mf2

model.frame of level 2

JAGSmodel

'JAGS' model

Examples

data(colorad)

# mean center Blur for effect coding
colorad$blur <- colorad$blur - mean(colorad$blur)
res <- BANOVA.Binomial(y~typic, ~color*blur, colorad, colorad$id, as.integer(16), 
burnin = 5000, sample = 2000, thin = 10)
summary(res)
# or use BANOVA.run
require(rstan)
res0 <- BANOVA.run(y~typic, ~color*blurfac, data = colorad, model_name = 'Binomial',
id = 'id', num_trials = as.integer(16), iter = 100, thin = 1, chains = 2)
summary(res0)
table.predictions(res0)
# only in-model variables(except numeric variables) will be used
predict(res0, c(1, 0, 8, 2, 1, 0.03400759))



[Package BANOVA version 1.2.1 Index]