Add documentation and vignette
This commit is contained in:
parent
31e16ab68d
commit
4f4b33b9e9
|
@ -116,7 +116,10 @@ head(model.difft$difft)
|
|||
tr.class <- vt.tree("class",
|
||||
vt.difft = vt.f.rf,
|
||||
sens = ">",
|
||||
threshold = quantile(vt.f.rf$difft, seq(.5, .8, .1)))
|
||||
threshold = quantile(vt.f.rf$difft, seq(.5, .8, .1)),
|
||||
maxdepth = 3,
|
||||
cp = 0,
|
||||
maxcompete = 2)
|
||||
# tr.class is a list if threshold is a vectoor
|
||||
class(tr.class)
|
||||
# acce trees with treeXX
|
||||
|
@ -130,6 +133,34 @@ tr.reg <- vt.tree("reg",
|
|||
threshold = quantile(vt.f.rf$difft, seq(.5, .8, .1)))
|
||||
# tr.class is a list if threshold is a vectoor
|
||||
class(tr.reg)
|
||||
# acce trees with treeXX
|
||||
# access trees with treeXX
|
||||
class(tr.reg$tree1)
|
||||
|
||||
## ------------------------------------------------------------------------
|
||||
# use tr.class computed previously
|
||||
vt.sbgrps <- vt.subgroups(tr.class)
|
||||
# print tables with knitr package
|
||||
library(knitr)
|
||||
knitr::kable(vt.sbgrps)
|
||||
|
||||
## ---- echo=F, fig.align='center', fig.height=4, fig.width=6--------------
|
||||
library(rpart.plot)
|
||||
rpart.plot(tr.class$tree2$tree, type = 1, extra = 1)
|
||||
|
||||
## ------------------------------------------------------------------------
|
||||
tr.class$tree2$createCompetitors()
|
||||
head(tr.class$tree2$competitors)
|
||||
|
||||
## ------------------------------------------------------------------------
|
||||
vt.o$getIncidences("PRAPACHE >= 26 & AGE >= 52")
|
||||
# or
|
||||
# tr.class$tree2$getIncidences("PRAPACHE >= 26 & AGE >= 52")
|
||||
|
||||
## ------------------------------------------------------------------------
|
||||
tr.class$tree2$getInfos()
|
||||
# access Ahat
|
||||
# tr.class$tree2$Ahat
|
||||
|
||||
## ------------------------------------------------------------------------
|
||||
tr.class$tree2$run(maxdepth = 2)
|
||||
|
||||
|
|
|
@ -10,6 +10,18 @@ vignette: >
|
|||
%\VignetteEncoding{UTF-8}
|
||||
---
|
||||
|
||||
# Contents
|
||||
|
||||
1. <a href="#introduction">Introduction</a>
|
||||
2. <a href="#quick-preview">Quick preview</a>
|
||||
3. <a href="#sepsis-dataset">Sepsis dataset</a>
|
||||
4. <a href="#create-object-virtualtwins">Create object virtual twins</a>
|
||||
5. <a href="#step-1-compute-hatp_1i-and-hatp_0i">Step 1 : compute probabilities</a>
|
||||
6. <a href="#step-2-estimate-a-regression-or-classification-tree">Step 2 : Estimate a decision tree</a>
|
||||
7. <a href="#subgroups-and-results">Subgroups and results</a>
|
||||
8. <a href="#questions">Questions</a>
|
||||
|
||||
|
||||
# Introduction
|
||||
|
||||
The goal of this vignette is to show most of all possibilies with *aVT* (for *aVirtualTwins* meaning *a*daptation of *Virtual Twins* method) package.
|
||||
|
@ -310,7 +322,7 @@ Anyway, aVirtualTwins package can be used. To do so, you can use `VT.difft()` cl
|
|||
|
||||
* `vt.object` : return of `vt.data()` function
|
||||
* `twin1` : estimate of $P(Y_{i} = 1 | T = T_{i})$ : meaning response probability under the correct treatment.
|
||||
* `twin1` : estimate of $P(Y_{i} = 1 | T = 1-T_{i})$ : meaning response probability under the other treatment.
|
||||
* `twin2` : estimate of $P(Y_{i} = 1 | T = 1-T_{i})$ : meaning response probability under the other treatment.
|
||||
* `method` : _absolute_ (default), _relative_ or _logit_. See `?VT.difft` for details.
|
||||
|
||||
```{r}
|
||||
|
@ -360,7 +372,10 @@ See `?VT.tree` for details.
|
|||
tr.class <- vt.tree("class",
|
||||
vt.difft = vt.f.rf,
|
||||
sens = ">",
|
||||
threshold = quantile(vt.f.rf$difft, seq(.5, .8, .1)))
|
||||
threshold = quantile(vt.f.rf$difft, seq(.5, .8, .1)),
|
||||
maxdepth = 3,
|
||||
cp = 0,
|
||||
maxcompete = 2)
|
||||
# tr.class is a list if threshold is a vectoor
|
||||
class(tr.class)
|
||||
# acce trees with treeXX
|
||||
|
@ -382,13 +397,80 @@ tr.reg <- vt.tree("reg",
|
|||
threshold = quantile(vt.f.rf$difft, seq(.5, .8, .1)))
|
||||
# tr.class is a list if threshold is a vectoor
|
||||
class(tr.reg)
|
||||
# acce trees with treeXX
|
||||
# access trees with treeXX
|
||||
class(tr.reg$tree1)
|
||||
```
|
||||
|
||||
-----------
|
||||
|
||||
## Subgroups and results
|
||||
|
||||
# Subgroups and results
|
||||
|
||||
Once trees have been computed, you surely want to see what are the subgroups. This package provides a wrapper function of intern methods of `VT.tree` class : `vt.subgroups()`.
|
||||
|
||||
This function takes in argument :
|
||||
|
||||
* `vt.tree` : object or list of class `VT.tree`. Return of the `vt.tree()` function.
|
||||
* `only.leaf` : logical. Set `TRUE` (default) to visualize only terminal nodes.
|
||||
* `only.fav` : logical. Set `TRUE` (default) to visualize only class 1 nodes. ($\hat{A}$)
|
||||
* `tables` : logical. Set `FALSE` (default) to prevent tables of incidences from being printed.
|
||||
* `verbose` : logical. Set `FALSE` (default) to prevent detailed stuffs from being printed.
|
||||
* `compete` : logical. Set `TRUE` to print competitors rules thanks to competitors split. `FALSE` is default value.
|
||||
|
||||
If `vt.tree` is a list, unique subgroups are printed.
|
||||
|
||||
```{r}
|
||||
# use tr.class computed previously
|
||||
vt.sbgrps <- vt.subgroups(tr.class)
|
||||
# print tables with knitr package
|
||||
library(knitr)
|
||||
knitr::kable(vt.sbgrps)
|
||||
```
|
||||
|
||||
You can plot one tree with package `rpart.plot`
|
||||
|
||||
```{r, echo=F, fig.align='center', fig.height=4, fig.width=6}
|
||||
library(rpart.plot)
|
||||
rpart.plot(tr.class$tree2$tree, type = 1, extra = 1)
|
||||
```
|
||||
|
||||
If you want to see competitors split :
|
||||
|
||||
```{r}
|
||||
tr.class$tree2$createCompetitors()
|
||||
head(tr.class$tree2$competitors)
|
||||
```
|
||||
|
||||
If you want to print incidence of a subgroup :
|
||||
```{r}
|
||||
vt.o$getIncidences("PRAPACHE >= 26 & AGE >= 52")
|
||||
# or
|
||||
# tr.class$tree2$getIncidences("PRAPACHE >= 26 & AGE >= 52")
|
||||
```
|
||||
|
||||
If you want to get infos about the tree
|
||||
|
||||
```{r}
|
||||
tr.class$tree2$getInfos()
|
||||
# access Ahat
|
||||
# tr.class$tree2$Ahat
|
||||
```
|
||||
|
||||
You can re-run rpart computation:
|
||||
|
||||
```{r}
|
||||
tr.class$tree2$run(maxdepth = 2)
|
||||
```
|
||||
|
||||
Type `?VT.tree` for details.
|
||||
|
||||
-----------
|
||||
|
||||
# Questions
|
||||
|
||||
This vignette is a bit messy right now, therefore feel free to ask anything to the repository issue reports :
|
||||
|
||||
1. https://github.com/prise6/aVirtualTwins
|
||||
2. read documentation with `?aVirtualTwins`
|
||||
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,6 +20,9 @@ favorable label of the tree). TRUE is default.}
|
|||
default.}
|
||||
|
||||
\item{verbose}{print infos during computation. FALSE is default.}
|
||||
|
||||
\item{compete}{print competitors rules thanks to competitors computation of
|
||||
the tree}
|
||||
}
|
||||
\value{
|
||||
data.frame of rules
|
||||
|
|
Loading…
Reference in New Issue