diff --git a/vignettes/vignette-01.Rmd b/vignettes/vignette-01.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..9812fb1824aec2ee95588d39fe59b28f16c73796 --- /dev/null +++ b/vignettes/vignette-01.Rmd @@ -0,0 +1,238 @@ +--- +title: "Multivariate Covariance Generalized Linear Models" +author: "Wagner Hugo Bonat" +date: "`r paste('mcglm', packageVersion('mcglm'), Sys.Date())`" +output: + rmarkdown::html_vignette: + fig_width: 6 + fig_height: 6 + toc: true + toc_dep: 3 +vignette: > + %\VignetteIndexEntry{Multivariate Covariance Generalized Linear Models} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +<style type="text/css"> +body, td, caption { + font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif; + background-color: white; + font-size: 16px; +} + +tt, code, pre { + font-family: "Inconsolata", "Andale Mono", monospace; +} + +code { + font-size: 16px; +} + +pre code { + font-size: 14px; +} + +pre:not([class]) code { + background-color: #92BFB1; +} +pre, code { + background-color: #62BFB1; + border-radius: 3px; + color: #333; +} + +/* R output */ +pre:not([class]) code { + background-color: #D4D4D4; +} +pre:not([class]), code { + background-color: #D4D4D4; +} + +/* R input */ +pre, code { + border-radius: 3px; + background-color: #EDEDED; + color: #333; +} + +img { + max-width: 100% !important; + display: block; + margin: auto; +} + +.MathJax { + font-size: 80% !important; +} + +</style> + +```{r setup, include=FALSE} +##---------------------------------------------------------------------- + +library(knitr) + +opts_chunk$set( + dev.args=list(family="Palatino")) + +options(width=68) + +##---------------------------------------------------------------------- + +library(latticeExtra) +rm(list=ls()) + +## Color palette. +mycol <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", + "#FFFF33") +dput(mycol) + +## Trellis graphical style. +ps <- list( + box.rectangle=list(col=1, fill=c("gray70")), + box.umbrella=list(col=1, lty=1), + dot.symbol=list(col=1, pch=19), + dot.line=list(col="gray50", lty=3), + plot.symbol=list(col=1, cex=0.8), + plot.line=list(col=1), + plot.polygon=list(col="gray95"), + superpose.line=list(col=mycol, lty=1), + superpose.symbol=list(col=mycol, pch=1), + superpose.polygon=list(col=mycol), + strip.background=list(col=c("gray80","gray50")) + ) +trellis.par.set(ps) +## show.settings() + +``` + +**** + +To install the stable version of [`mcglm`][], use +`devtools::install_git()`. For more information, visit [mcglm/README]. + +```{r, eval=FALSE} +library(devtools) +install_git("http://git.leg.ufpr.br/wbonat/mcglm.git") +``` + +```{r, eval=FALSE, error=FALSE, message=FALSE, warning=FALSE} +library(mcglm) +packageVersion("mcglm") +``` + +```{r, echo=FALSE, error=FALSE, message=FALSE, warning=FALSE} +library(mcglm) +packageVersion("mcglm") +``` + +**** +## The Australian Health Survey + +```{r} +##---------------------------------------------------------------------- +## Loadin the Australian Health Survey data. + +data(ahs) + +## Object structure. +str(ahs) + +## Descriptive measures. +summary(ahs) + +##---------------------------------------------------------------------- +## Frequency tables. + +names(ahs)[c(1, 4:7, 10)] + +par(mfrow=c(2,3)) +## sapply(ahs[, c(1, 4:7, 10)], +## FUN=function(x){ +## ## pie(table(x)) +## barplot(prop.table(table(x))) +## }) + +barplot(prop.table(xtabs(~sex, data=ahs)), + ylab="Sample proportion", + xlab="Sex") + +barplot(prop.table(xtabs(~levyplus, data=ahs)), + ylab="Sample proportion", + xlab="levyplus") + +barplot(prop.table(xtabs(~freepoor, data=ahs)), + ylab="Sample proportion", + xlab="freepoor") + +barplot(prop.table(xtabs(~freerepa, data=ahs)), + ylab="Sample proportion", + xlab="freerepa") + +barplot(prop.table(xtabs(~illness, data=ahs)), + ylab="Sample proportion", + xlab="illness") + +barplot(prop.table(xtabs(~chcond, data=ahs)), + ylab="Sample proportion", + xlab="chcond") +layout(1) + +xt <- xtabs(~age+sex, data=ahs) +mosaicplot(xt) + +xt <- xtabs(~age+chcond, data=ahs) +mosaicplot(xt) + +xt <- xtabs(~sex+chcond, data=ahs) +mosaicplot(xt) + +##---------------------------------------------------------------------- + +library(lattice) +library(latticeExtra) + +useOuterStrips( + combineLimits( + xyplot(Ndoc+Nndoc+Nadm+Nhosp+Nmed~age|sex, + outer=TRUE, data=ahs, + jitter.x=TRUE, amount=0.01, + type=c("p", "a"), + scales=list(y=list(relation="free")), + ylab="Number or occurences", + xlab="Age (years/100)") + ) +) + +useOuterStrips( + combineLimits( + xyplot(Ndoc+Nndoc+Nadm+Nhosp+Nmed~income|sex, + outer=TRUE, data=ahs, + jitter.x=TRUE, amount=0.01, + type=c("p", "a"), + scales=list(y=list(relation="free")), + ylab="Number or occurences", + xlab="Income") + ) +) + +useOuterStrips( + combineLimits( + xyplot(Ndoc+Nndoc+Nadm+Nhosp+Nmed~age|chcond, + groups=sex, outer=TRUE, data=ahs, + jitter.x=TRUE, amount=0.01, + type=c("p", "a"), + scales=list(y=list(relation="free")), + ylab="Number or occurences", + xlab="Age (years/100)") + ) +) + +``` + +<!---------------------------------------------------------------------- --> + +[`mcglm`]: http://git.leg.ufpr.br/wbonat/mcglm +[mcglm/README]: http://git.leg.ufpr.br/wbonat/mcglm/blob/master/README.md