Learn R Programming

mets (version 1.0)

binomial.twostage: Fits Clayton-Oakes or bivariate Plackett (OR) models for binary data using marginals that are on logistic form. If clusters contain more than two times, the algoritm uses a compososite likelihood based on all pairwise bivariate models.

Description

The pairwise pairwise odds ratio model provides an alternative to the alternating logistic regression (ALR).

Usage

binomial.twostage(margbin, data = sys.parent(), score.method = "nlminb",
  Nit = 60, detail = 0, clusters = NULL, silent = 1, weights = NULL,
  control = list(), theta = NULL, theta.des = NULL, var.link = 1,
  iid = 1, step = 0.5, notaylor = 1, model = "plackett",
  marginal.p = NULL, strata = NULL, max.clust = NULL,
  se.clusters = NULL, numDeriv = 0)

Arguments

margbin
Marginal binomial model
data
data frame
score.method
Scoring method
Nit
Number of iterations
detail
Detail
clusters
Cluster variable
silent
Debug information
weights
Weights for log-likelihood, can be used for each type of outcome in 2x2 tables.
control
Optimization arguments
theta
Starting values for variance components
theta.des
Variance component design
var.link
Link function for variance
iid
Calculate i.i.d. decomposition
step
Step size
notaylor
Taylor expansion
model
model
marginal.p
vector of marginal probabilities
strata
strata for fitting: considers only pairs where both are from same strata
max.clust
max clusters
se.clusters
clusters for iid decomposition for roubst standard errors
numDeriv
uses Fisher scoring aprox of second derivative if 0, otherwise numerical derivatives

Details

The reported standard errors are based on a cluster corrected score equations from the pairwise likelihoods assuming that the marginals are known. This gives correct standard errors in the case of the Plackett distribution (OR model for dependence), but incorrect standard errors for the Clayton-Oakes types model.

References

Two-stage binomial modelling

Examples

Run this code
data(twinstut)
twinstut0 <- subset(twinstut, tvparnr<2300000)
twinstut <- twinstut0
theta.des <- model.matrix( ~-1+factor(zyg),data=twinstut)
margbin <- glm(stutter~factor(sex)+age,data=twinstut,family=binomial())
bin <- binomial.twostage(margbin,data=twinstut,
		         clusters=twinstut$tvparnr,theta.des=theta.des,detail=0,
	                 score.method="fisher.scoring")
summary(bin)

twinstut$cage <- scale(twinstut$age)
theta.des <- model.matrix( ~-1+factor(zyg)+cage,data=twinstut)
bina <- binomial.twostage(margbin,data=twinstut,
		         clusters=twinstut$tvparnr,theta.des=theta.des,detail=0,
	                 score.method="fisher.scoring")
summary(bina)

theta.des <- model.matrix( ~-1+factor(zyg)+factor(zyg)*cage,data=twinstut)
bina <- binomial.twostage(margbin,data=twinstut,
		         clusters=twinstut$tvparnr,theta.des=theta.des,detail=0,
	                 score.method="fisher.scoring")
summary(bina)

twinstut$binstut <- (twinstut$stutter=="yes")*1
## refers to zygosity of first subject in eash pair : zyg1
## could also use zyg2 (since zyg2=zyg1 within twinpair's))
out <- easy.binomial.twostage(stutter~factor(sex)+age,data=twinstut,
                          response="binstut",id="tvparnr",
	             	      theta.formula=~-1+factor(zyg1),
                          score.method="fisher.scoring")
summary(out)

## refers to zygosity of first subject in eash pair : zyg1
## could also use zyg2 (since zyg2=zyg1 within twinpair's))
desfs<-function(x,num1="zyg1",num2="zyg2")
    c(x[num1]=="dz",x[num1]=="mz",x[num1]=="os")*1

out3 <- easy.binomial.twostage(binstut~factor(sex)+age,
      data=twinstut,response="binstut",id="tvparnr",
      score.method="fisher.scoring",theta.formula=desfs,desnames=c("mz","dz","os"))
summary(out3)

Run the code above in your browser using DataLab