---
title: "Tmp Stuff"
output:
  html_document: default
  pdf_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, error=TRUE,                       message = TRUE, warning = TRUE)
st=function() knitr::knit_exit()
library(MDgof)
B=100
```

```{r}
source("C:/Users/wolfg/Dropbox/MDgof/MDgof/R/hybrid_test.R")
source("C:/Users/wolfg/Dropbox/MDgof/MDgof/R/hybrid_power.R")
```

```{r}
tmpTF=case.studies(1, T, F)
tmpTT=case.studies(1, T, T)
tmpFF=case.studies(1, F, F)
tmpFT=case.studies(1, F, T)
tmp5=case.studies(1, T, F, 5)
```

```{r}
TSextra=list(which="statistic", nbins=c(3,4))
x=tmpTF$ralt(tmpTF$param_alt[2])
hybrid_test(x, tmpTF$rnull, nMC=2, TS=MD2sample::chiTS.cont,            TSextra=TSextra, B=100)
hybrid_power(tmpTF$rnull, tmpTF$ralt, tmpTF$param_alt[2], nMC=2, TS=MD2sample::chiTS.cont,  TSextra=TSextra, B=100)
TSextra=list(which="pvalue", nbins=c(3,4))
hybrid_power(tmpTF$rnull, tmpTF$ralt, tmpTF$param_alt[2], nMC=2,
             TS=MD2sample::chiTS.cont,
            TSextra=TSextra, With.p.value=TRUE,B=100)
```


```{r}
st()
```

## Testing

```{r}
x=tmpTF$ralt(tmpTF$param_alt[2])
hybrid_test(x, tmpTF$rnull, nMC=2, B=100)
x=tmpTT$ralt(tmpTT$param_alt[2])
hybrid_test(x, tmpTT$rnull, tmpTT$phat, B=100)
x=tmpFF$ralt(tmpFF$param_alt[2])
hybrid_test(x, tmpFF$rnull, nMC=200, B=100)
x=tmpFT$ralt(tmpFT$param_alt[2])
hybrid_test(x, tmpFT$rnull, tmpFT$phat, B=100)
x=tmp5$ralt(tmp5$param_alt[2])
hybrid_test(x, tmp5$rnull, B=100)
```

## Power

```{r}
hybrid_power(tmpTF$rnull, tmpTF$ralt, tmpTF$param_alt[2], nMC=2, B=100)
hybrid_power(tmpTT$rnull, tmpTT$ralt, tmpTT$param_alt[2], 
             tmpTT$phat, alpha=0.1, B=100)
hybrid_power(tmpFF$rnull, tmpFF$ralt, tmpFF$param_alt[2], nMC=200, B=100)
hybrid_power(tmpFT$rnull, tmpFT$ralt, tmpFT$param_alt[2], 
             tmpFT$phat, alpha=0.1, B=100)
hybrid_power(tmp5$rnull, tmp5$ralt, tmp5$param_alt[2], B=100)
```

