-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
61 lines (41 loc) · 2.44 KB
/
README.Rmd
File metadata and controls
61 lines (41 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Regression models for clustered exchangeable binary data
<!-- badges: start -->
<!-- badges: end -->
The goal of the `exchreg` is to fit semi-parametric relative-risk and generalized linear regression models for exchangeable clustered binary data with between-cluster covariates. You can browse its [source code](https://github.com/anikoszabo/exchreg).
## Installation
In the future, this package will be released on CRAN, but currently the development version is available on [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("anikoszabo/exchreg")
```
## Example: developmental toxicology study
The `boric_acid` dataset contains the outcomes of a developmental toxicity experiment of boric acid by the National Toxicology Program. Pregnant mice were provided feed containing boric acid at different concentrations. At the end of the study, each mouse's uterus was examined to evaluate the fetal outcomes. The data contains the size of each litter, the number of fetuses with an adverse event (resorption, intra-uterine death, or malformation), as well as the dose group. Since the same combination of clustersize/response count can occur multiple times, a frequency count column records the number of such replicates.
```{r DataExtract}
library(exchreg)
library(CorrBin)
head(boric_acid)
```
The goal is to model the effect of the covariates (here, treatment dose) on the probability of adverse event, while providing predictions for the entire distribution of the outcomes, ie the probability of observing $x$ events in a cluster (litter) of size $n$.
### Semi-parametric GLM
We can fit a semi-parametric GLM with a logit-link
```{r SPGLMexample}
mod1 <- spglm(cbind(NResp, ClusterSize - NResp) ~ Trt, data=boric_acid, weights=Freq)
mod1
```
The prediction method can be used to obtain the predicted probabilities for any given outcome. For example, we estimate the probability of having 0 - 5 affected fetuses in a litter of size 5 at dose level 0.4:
```{r PredictModel}
pred <- predict(mod1, newdata = data.frame(Trt = rep("0.4", 6)), newn=5, newevents = 0:5, type="prob")
plot(0:5, pred, type="h", xlab="Number affected", ylab="Probability", ylim=c(0,max(pred)))
```