betabin {sensR} | R Documentation |
Fits the beta binomial model and the chance corrected beta binomial model to binomial data.
betabin(data, start = c(.5,.5), method = c("mu-gamma", "alpha-beta"), vcov = TRUE, corrected = TRUE, pGuess = 1/2, gradTol = 1e-4, ...) ## S3 method for class 'betabin': summary(object, alpha=.05, ...)
object |
an object of class "betabin", i.e. the result of
betabin() . |
alpha |
the allowed type I error for confidence intervals |
data |
matrix or data.frame with two columns; first column contains the number of success and the second the total number of cases. The number of rows should correspond to the number of observations. |
start |
starting values to be used in the optimization |
vcov |
logical, should the variance-covariance matrix of the parameters be computed? |
method |
the desired representation. Optimization is performed in the "mu-gamma" parameterization and subsequently transformed to the "alpha-beta" scale if needed. |
corrected |
should the chance corrected or the standard beta binomial model be estimated? |
pGuess |
the guessing probability in the test protocol, i.e. the point at which the probability scale is truncated in the chance corrected model. The argument is further used in the likelihood ratio test of association reported by the summary method for both models. |
gradTol |
a warning is issued if max|gradient| < gradTol, where 'gradient' is the gradient at the values at which the optimizer terminates. This is not used as a termination or convergence criterion during model fitting. |
... |
betabin : The only recognized (hidden) argument is
doFit (boolean) which by default is TRUE . When
FALSE betabin returns an environment which facilitates
examination of the likelihood surface via the (hidden) functions
getParBB and setParBB .
Not used in summary.betabin . |
The following additional methods are implemented objects of class
betabin
:
print
, vcov
, logLik
and coef
.
The bounded optimization is performed with the "L-BFGS-B" optimizer in
optim
.
Observe that standard errors and confidence intervals are often not appropriate for parameter close to the boundaries of the parameter space. The likelihood ratio tests reported by the summary method are more accurate.
Variance-covariance matrix (and standard errors) is based on the inverted
Hessian at the optimum. The Hessian is obtained with the hessian
function from the numDeriv package.
The summary method provides a likelihood ratio test of over-dispersion on one degree of freedom and a likelihood ratio test of association (i.e. of the hypothesis if "no difference") on two degrees of freedom (chi-square tests). Since the gamma parameter is tested on the boundary of the parameter space, the correct degree of freedom for the first test is probably 1/2 rather than one, or somewhere in between, and the latter test is probably also on less than two degrees of freedom. Research is needed to determine the appropriate no. degrees of freedom to use in each case. The choices used here are believed to be conservative, so the stated p-values are probably a little too large.
The parameters of the standard (i.e. corrected = FALSE) beta-binomial model refers to the mean (i.e. probability) and dispersion on the scale of the observations, i.e. on the scale where we talk of a probability of a correct answer. The parameters of the chance corrected (i.e. corrected = TRUE) beta-binomial model refers to the mean and dispersion on the scale of "proportion of discriminators" in the population of interest. The mean parameter (mu) is therefore restricted to the interval from zero to one in both models, but the has different interpretations.
The log-likelihood of the standard beta-binomial model is
ell(α, β; x, n) = - N log Beta(α, β) + sum_{j=1}^N log Beta(α + x_j, β - x_j + n_j)
and the log-likelihood of the chance corrected beta-binomial model is
ell(α, β; x, n) = - N log Beta(α, β) + sum_{j=1}^N log ( sum_{i=1}^x_j {x_j choose i} (1-p_g)^{n_j-x_j+i} p_g^{x_j-i} Beta(α + i, n_j - x_j + β) )
where μ = α/(α + β),
gamma = 1/(α + β + 1), Beta is the Beta
function, cf. beta
,
N is the number of independent binomial observations, i.e. the
number of rows in data
, and p_g is the guessing
probability, pGuess
.
The gradient at the optimum is evaluated with gradient
from the
numDeriv package.
An object of class betabin
with elements
coefficients |
named vector of coefficients |
vcov |
variance-covariance matrix of the parameter estimates if
vcov = TRUE |
data |
the data supplied to the function |
call |
the matched call |
logLik |
the value of the log-likelihood at the MLEs |
method |
the method used for the fit |
convergence |
0 indicates convergence. For other error messages,
see ?optim . |
message |
possible error message - see ?optim for
details |
counts |
the number of iterations used in the optimization - see
?optim for details |
corrected |
Is the chance corrected model estimated? |
logLikNull |
log-likelihood of the binomial model with prop = pGuess |
logLikMu |
log-likelihood of a binomial model with prop = sum(x)/sum(n) |
Rune Haubo B Christensen
Brockhoff, P.B. (2003). The statistical power of replications in difference tests. Food Quality and Preference, 14, pp. 405–417.
triangle
, twoAFC
,
threeAFC
, duotrio
,
discrimPwr
, discrimSim
,
discrimSS
, samediff
,
AnotA
, findcr
## Create data: x <- c(3,2,6,8,3,4,6,0,9,9,0,2,1,2,8,9,5,7) n <- c(10,9,8,9,8,6,9,10,10,10,9,9,10,10,10,10,9,10) dat <- data.frame(x, n) (bb <- betabin(dat, method = "mu-gamma")) (bb <- betabin(dat, corrected = FALSE, method = "mu-gamma")) summary(bb) vcov(bb) logLik(bb) AIC(bb) coef(bb)