Last chance! 50% off unlimited learning
Sale ends in
binnest
is designed to handle binary and binomial data with two
levels of nesting. The first level is the individual and the second will
consist of clusters within individuals.
binnest(
response,
totals = NULL,
nest = NULL,
ccov = NULL,
tvcov = NULL,
mu = ~1,
re1 = ~1,
re2 = ~1,
preg = NULL,
pre1 = NULL,
pre2 = NULL,
binom.mix = c(10, 10),
binom.prob = c(0.5, 0.5),
fcalls = 900,
eps = 0.01,
print.level = 0
)
A list of classes binnest
is returned.
A list of three column matrices with counts, corresponding
totals (not necessary if the response is binary), and (second-level)
nesting indicator for each individual, one matrix or dataframe of such
counts, or an object of class, response (created by
restovec
) or repeated (created by
rmna
).
If response
is a matrix or dataframe, a corresponding
matrix or dataframe of totals (not necessary if the response is binary).
Ignored otherwise.
If response
is a matrix or dataframe, a corresponding
matrix or dataframe of nesting indicators. Ignored otherwise.
If response
is a matrix, dataframe, list, or object of
class, response
, a matrix of time-constant covariates or an object
of class, tccov
(created by tcctomat
). All of
these covariates are used in the fixed effects part of the model. Ignored
if response has class, repeated
.
If response
is a matrix, dataframe, list, or object of
class, response
, an object of class, tvcov
(created by
tvctomat
). All of these covariates are used in the
fixed effects part of the model. Ignored if response has class,
repeated
.
If response
has class, repeated
, a formula
beginning with ~, specifying a linear regression function for the fixed
effects, in the Wilkinson and Rogers notation, containing selected
covariates in the response object. (A logit link is assumed.)
If response
has class, repeated
, a formula
beginning with ~, specifying a linear regression function for the variance
of the first level of nesting, in the Wilkinson and Rogers notation,
containing selected covariates in the response object. If NULL, a random
effect is not fitted at this level. (A log link is assumed.)
If response
has class, repeated
, a formula
beginning with ~, specifying a linear regression function for the variance
of the second level of nesting, in the Wilkinson and Rogers notation,
containing selected covariates in the response object. If NULL, a random
effect is not fitted at this level. (A log link is assumed.)
Initial parameter estimates for the fixed effect regression
model: either the model specified by mu
or else the intercept plus
one for each covariate in ccov
and tvcov
.
Initial parameter estimates for the first level of nesting
variance model: either the model specified by re1
or just the
intercept. If NULL, a random effect is not fitted at this level.
Initial parameter estimates for the second level of nesting
variance model: either the model specified by re1
or just the
intercept. If NULL, a random effect is not fitted at this level.
A vector of two values giving the totals for the binomial distributions used as the mixing distributions at the two levels of nesting.
A vector of two values giving the probabilities in the binomial distributions used as the mixing distributions at the two levels of nesting. If they are 0.5, the mixing distributions approximate normal mixing distributions; otherwise, they are skewed.
Number of function calls allowed.
Convergence criterion.
If 1, the iterations are printed out.
T.R. Ten Have and J.K. Lindsey
The variance components at the two levels can only depend on the covariates
if response
has class, repeated
.
Ten Have, T.R., Kunselman, A.R., and Tran, L. (1999) Statistics in Medicine 18, 947-960.
gar
, read.list
,
restovec
, rmna
,
tcctomat
, tvctomat
.
#y <- rbind(matrix(rbinom(20,1,0.6), ncol=4),
# matrix(rbinom(20,1,0.4), ncol=4))
y <- matrix(c(1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,1,0,1,1,0,1,0,
1,1,1,1,1,1,1,1,0,1,1,0),nrow=10,ncol=4,byrow=TRUE)
resp <- restovec(y, nest=1:4, times=FALSE)
ccov <- tcctomat(c(rep(0,5),rep(1,5)), name="treatment")
reps <- rmna(resp, ccov=ccov)
# two random effects
binnest(reps, mu=~treatment, preg=c(1,1), pre1=2, pre2=2)
# first level random effect only
binnest(reps, mu=~treatment, preg=c(1,-1), pre1=1)
# second level random effect only
binnest(reps, mu=~treatment, preg=c(1,-1), pre2=1)
Run the code above in your browser using DataLab