---
title: "GEE cluster standard errors and predictions for glm objects" 
author: Klaus Holst & Thomas Scheike
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette:
    fig_caption: yes
    fig_width: 7.15
    fig_height: 5.5        
vignette: >
  %\VignetteIndexEntry{GEE cluster standard errors and predictions for glm objects}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(mets)
```

Utility functions for GLM objects
=================================

Computing odds ratios with confidence intervals using GEE (sandwich)
standard errors:

```{r}
set.seed(100)

library(mets)
data(bmt); 
bmt$id <- sample(1:100,408,replace=TRUE)

glm1 <- glm(tcell~platelet+age,bmt,family=binomial)
summaryGLM(glm1)

## GEE robust standard errors
summaryGLM(glm1,id=bmt$id)
```

Predictions are equally straightforward:

```{r}
age <- seq(-2,2,by=0.1)
nd <- data.frame(platelet=0,age=seq(-2,2,by=0.1))
pnd <- predictGLM(glm1,nd)
head(pnd$pred)
plot(age,pnd$pred[,1],type="l",ylab="predictions",xlab="age",ylim=c(0,0.3))
plotConfRegion(age,pnd$pred[,2:3],col=2)
###matlines(age,pnd$pred[,-1],col=2,lty=1)
```

SessionInfo
============


```{r}
sessionInfo()
```


