#Example 1
# A British male sample on occupational status.
data(bms)
# A third degree polynomial surface with equally-spaced integer scores
m1 <- pblm(fo1=cbind(fathers,sons)~1, data=bms, weights=bms$freq,
penalty=pblm.penalty(pnl.type="ARC2",lam3=c(1e7), lam4=c(1e7),
s3=c(4), s4=c(4)))
require(lattice)
g <- expand.grid("sons"=1:6,"fathers"=1:6)
g$logGOR <- m1$coef[13:48]
oldpar <- par(no.readonly = TRUE)
wireframe(logGOR ~ sons*fathers, data = g, zlim=c(min(g$logGOR-1),max(g$logGOR+1)),
scales = list(arrows = FALSE), screen = list(z = -130, x = -70),
col.regions="magenta")
par(oldpar)
#Example 2
# an artificial data frame with two binary responses and two factors
set.seed(12)
da <- expand.grid("Y1"=0:1,"Y2"=0:1,"fat1"=0:1,"fat2"=0:1)
da$Freq <- sample(0:20,2*2*2*2,replace=TRUE)
# A quasi-independence model obtained by strongly penalizing the association intercept
# through a ridge-type penalty term
m3 <- pblm(fo1=cbind(Y1,Y2) ~ fat1 + fat2,
fo12=~ 1,
data=da, weights=da$Freq, type="ss",
proportional=pblm.prop(prop12=c(TRUE)),
penalty=pblm.penalty(pnl.type="ridge",lam3=1e12))
summary(m3)
# notice that the last coefficient is not exactly zero
coef(m3)
m3.1 <- glm(Y1 ~ fat1 + fat2, data=da, weights=Freq, family=binomial)
m3.2 <- glm(Y2 ~ fat1 + fat2, data=da, weights=Freq, family=binomial)
all.equal(logLik(m3), logLik(m3.1)[1]+logLik(m3.2)[1])
Run the code above in your browser using DataLab