Skip to content
Snippets Groups Projects
Select Git revision
  • test-ci2
  • teste-ci
  • issue#10
  • master default protected
4 results

vignette-01.Rmd

Blame
  • vignette-01.Rmd 5.18 KiB
    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}
    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; }
    ##----------------------------------------------------------------------
    
    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.

    library(devtools)
    install_git("http://git.leg.ufpr.br/wbonat/mcglm.git")
    library(mcglm)
    packageVersion("mcglm")
    library(mcglm)
    packageVersion("mcglm")

    The Australian Health Survey

    ##----------------------------------------------------------------------
    ## 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)")
        )
    )