% \VignetteIndexEntry{Birth Data - Bivariate Binary Regression} % \VignetteDepends{VGAM} %\VignetteEngine{knitr::knitr} %\VignetteEncoding{UTF-8} \documentclass[a4paper]{article} \title{Birth Data - Bivariate Binary Regression} \begin{document} \maketitle <>= options(width=80) @ First the Birth data are loaded from package "catdata". <>= library(catdata) data(birth) attach(birth) @ Now the original variable "Intensive" is converted into the binary variable "Intensive" indicating whether the child spent time in intensive care or not. <>= intensive <- rep(0,length(Intensive)) intensive[Intensive>0] <- 1 Intensive <- intensive @ Now "Previous" is reduced to 3 categories by merging two and more previous pregnancies to level "2". <>= previous <- Previous previous[previous>1] <- 2 Previous <- previous @ <>= library(VGAM) @ The data set "Birth" is built as data set containing the variables for the model but without missing values. <>= Birth <- as.data.frame(na.omit(cbind(Intensive, Cesarean, Sex, Weight, Previous, AgeMother))) detach(birth) @ With that data set the model can be fitted. The option "binom2.or" is needed to fit a bivariate binary model. <>= bivarlogit <- vglm(cbind(Intensive , Cesarean) ~ as.factor(Sex) + Weight + as.factor(Previous) + AgeMother, binom2.or(zero=NULL), data=Birth) summary(bivarlogit) @ <>= detach(package:VGAM) @ \end{document}