scoregllm {gllm} | R Documentation |
Generalized log-linear modelling via Fisher scoring
Description
Fits log-linear models for incomplete contingency tables, including some latent class models, via Fisher scoring approaches.
Usage
scoregllm(y,s,X,m,tol=1e-5)
Arguments
y |
is the observed contingency table. |
s |
is a vector of indices, one for each cell of the full (unobserved)
contingency table, representing the appropriate cell of |
X |
is the design matrix or a formula. |
m |
is a vector of starting values for the full (unobserved) contingency table. |
tol |
is the convergence criterion for the LR criterion. |
Details
The generalized log-linear model allows for modelling of incomplete contingency tables, that is tables where one or more dimensions have been collapsed over. These include situations where imprecise measures have been calibrated using a "perfect" gold standard, and the true association between imperfectly measured variables is to be estimated; where data is missing for a subsample of the population; latent variable models where latent variables are "errorless" functions of observed variables - eg ML gene frequency estimation from counts of observed phenotypes; specialised measurement models eg where observed counts are mixtures due to perfect measures and error prone measures; standard latent class analysis; symmetry and quasi-symmetry models for square tables.
The general framework underlying these models is summarised by Espeland
(1986), and Espeland & Hui (1987), and is originally due to Thompson &
Baker (1981). An observed contingency table y
, which will be
treated as a vector, is modelled as arising from an underlying complete
table z
, where observed count y_j
is the sum of a number of
elements of z
, such that each z_i
contributes to no more
than one y_j
. Therefore one can write y=F'z
, where F
is made up of orthogonal columns of ones and zeros.
We then specify a loglinear model for z
, so that
log(E(z))=X'b
, where X
is a design matrix, and b
a
vector of loglinear parameters. The loglinear model for z
and
thus y
, can be fitted by a Fisher scoring approach, presented in
Espeland (1986).
The gllm
function is actually a simple wrapper for scoregllm()
.
Value
A list with components:
iter |
the number of scoring iterations until convergence |
deviance |
the final model deviance (-2 log likelihood) |
df |
the model degrees of freedom |
coefficients |
the model parameter estimates |
se |
the standard errors for the model parameter estimates |
V |
the variance-covariance matrix for the model parameter estimates |
observed.values |
the observed counts in |
fitted.values |
the expected counts under the fitted model |
residuals |
Pearsonian residuals under the fitted model |
full.table |
the expected counts for the full (unobserved) table. |
References
Espeland MA (1986). A general class of models for discrete multivariate data. Commun. Statist.-Simula 15:405-424.
Espeland MA, Hui SL (1987). A general approach to analyzing epidemiologic data that contains misclassification errors. Biometrics 43:1001-1012.
Thompson R, Baker RJ (1981). Composite link functions in generalized linear models. Appl Statist 30: 125-131.
Examples
#
# An example of model fitting: gametic association between two diallelic loci
# Data matrix
#
y<-c( 187,386,156,
352,310,20,
136,0 ,0)
#
# Scatter matrix
#
s<- c( 1, 2, 2, 3,
4, 5, 5, 6,
4, 5, 5, 6,
7, 8, 8, 9)
#
# Design matrix
#
X<- matrix(c( 1,0,0,0,0,0,1,
1,0,1,0,0,0,0,
1,0,1,0,0,0,0,
1,0,2,0,1,0,0,
1,1,0,0,0,0,0,
1,1,1,0,0,1,0,
1,1,1,0,0,0,1,
1,1,2,0,1,1,1,
1,1,0,0,0,0,0,
1,1,1,0,0,0,1,
1,1,1,0,0,1,0,
1,1,2,0,1,1,1,
1,2,0,1,0,0,0,
1,2,1,1,0,1,1,
1,2,1,1,0,1,1,
1,2,2,1,1,2,2), byrow=TRUE, ncol=7)
colnames(X)<-c("Intercept", "A", "B", "P1", "P2", "Delta", "Epsilon")
res<-scoregllm(y,s,X[,c(1:6)],
c(255,176,176,121,164,37,113,25,164,113,37,25,90,20,20,5))
summary(res)
#