---
title: "pinbasic: An R Package for Fast and Stable Estimation of Static Models for the Probability of Informed Trading"
author: "Andreas Recktenwald"
date: "`r Sys.Date()`"
output:
  rmarkdown::html_document:
    theme: spacelab
    highlight: haddock
    toc: true
    md_extensions: +raw_tex+latex_macros
    fig_caption: false
    toc_float: true
    df_print: paged
bibliography: references.bib
vignette: >
  %\VignetteIndexEntry{pinbasic: An R Package for Fast and Stable Estimation of Static Models for the Probability of Informed Trading}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>

\newcommand{\Rfunc}[1]{\emph{#1}}
\newcommand{\Rcode}[1]{\texttt{#1}}
\newcommand{\Rpkg}[1]{\textbf{#1}}

\newcommand{\pintext}{\operatorname{PIN}}
\newcommand{\probinfevent}{\alpha}
\newcommand{\probbadnews}{\delta}
\newcommand{\intensuninf}{\epsilon}
\newcommand{\intensuninfbuys}{\epsilon_b}
\newcommand{\intensuninfsells}{\epsilon_s}
\newcommand{\intensinf}{\mu}

\newcommand{\prsym}{\operatorname{Pr}}

<!-- \newcommand{\thetaekop}{\theta = \left(\probinfevent, \probbadnews,\intensuninf, \intensinf \right)} -->
<!-- \newcommand{\thetaekopshort}{\theta} -->
\newcommand{\thetaeho}{\theta = \left(\probinfevent, \probbadnews,\intensuninfbuys, \intensuninfsells, \intensinf \right)}
\newcommand{\thetaehoshort}{\theta}
\newcommand{\sgn}{\operatorname{sgn}}
\newcommand{\expect}{\mathbb{E}}

\newcommand{\lambdabuys}{\lambda_{k, \text{uninf. Buys}}(t)}
\newcommand{\lambdabuysconst}{\lambda_{\text{uninf. Buys}}}
\newcommand{\lambdabuysinf}{\lambda_{k, \text{inf. Buys}}(t)}
\newcommand{\lambdabuysinfconst}{\lambda_{\text{inf. Buys}}}

\newcommand{\lambdasells}{\lambda_{k, \text{uninf. Sells}}(t)}
\newcommand{\lambdasellsconst}{\lambda_{\text{uninf. Sells}}}
\newcommand{\lambdasellsinf}{\lambda_{k, \text{inf. Sells}}(t)}
\newcommand{\lambdasellsinfconst}{\lambda_{\text{inf. Sells}}}
\newcommand{\daysym}{d}
\newcommand{\totaldays}{D}

\newcommand{\nonews}{\mathcal{N}}
\newcommand{\goodnews}{\mathcal{G}}
\newcommand{\badnews}{\mathcal{B}}

\newcommand{\states}{Q = \{\nonews, \goodnews, \badnews\}}
\newcommand{\statesabbrv}{Q}

\newcommand{\originmarket}{t_{0,m}}
\newcommand{\closemarket}{T_m}

\newcommand{\intevent}[2]{N_{(#1, #2]}}
\newcommand{\likelihood}{\mathcal{L}}
\newcommand{\datasymbs}{\mathcal{M}}

\newcommand{\thetaehoinishort}{\theta^0}
\newcommand{\orderimb}{\operatorname{OI}_d}
\newcommand{\statesset}{\{\mathcal{N}, \mathcal{G}, \mathcal{B}\}}
\newcommand{\eventsymb}{\mathcal{E}}

\newcommand{\midcond}{\;\middle\vert\;}

```{r insert_fun, echo = FALSE}
library(knitr)
library(pinbasic)
library(formatR)

insert_fun = function(name, env = parent.frame()) {
  read_chunk(lines = capture.output(dump(name, '', envir = env)), labels = paste(name, 'source', sep = '-'))
}

knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```

```{r intro, child = "Introduction/Introduction.Rmd"}
```

```{r intro, child = "General/GenAssumptions.Rmd"}
```

```{r static, child = "staticPINmodels/StaticEHOshort.Rmd"}
```

```{r opt, child = "OptimizationStaticModels/OptimizationStaticModels.Rmd"}
```

```{r postprob, child = "PostProbs/PostProbs.Rmd"}
```

```{r examples, child = "Examples/Examples.Rmd"}
```


## References