# fit a saturated model to a four-way table
fit <- cvam( ~ Sex*CenRace*Hisp*Party, data=abortion2000,
saturated=TRUE )
# add a flattening constant
fit <- cvam( ~ Sex*CenRace*Hisp*Party, data=abortion2000,
saturated=TRUE, prior=cvamPrior( flatten=10 ) )
# fit with saturated=FALSE and no prior information, and
# notice how large the SEs are
fit <- cvam( ~ Sex*CenRace*Hisp*Party, data=abortion2000,
saturated=FALSE )
head( get.coef(fit, withSE=TRUE) )
# add a very mild ridge factor and notice how the SEs
# have become reasonable
fit <- cvam( ~ Sex*CenRace*Hisp*Party, data=abortion2000,
saturated=FALSE, prior=cvamPrior( ridge=.1 ) )
head( get.coef(fit, withSE=TRUE) )
# add s few prior nuggets to stabilize the distribution
# of Party within a rare category
nuggetList <- list(
list( CenRace="Black", Hisp="Hisp", Party="Dem", freq=1 ),
list( CenRace="Black", Hisp="Hisp", Party="Rep", freq=1 ),
list( CenRace="Black", Hisp="Hisp", Party="Ind/Oth", freq=1 ) )
myPrior <- cvamPrior( nuggetList, flatten=10 )
summary(myPrior)
fit <- cvam( ~ Sex*CenRace*Hisp*Party, data=abortion2000,
saturated=FALSE, prior=myPrior )
Run the code above in your browser using DataLab