-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
52 lines (38 loc) · 1.44 KB
/
README.Rmd
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
---
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%"
)
```
# solvetruncated
<!-- badges: start -->
[![R-CMD-check](https://github.com/BjarkeHautop/solvetruncated/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/BjarkeHautop/solvetruncated/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
# Overview
The goal of solvetruncated is to solve for parameters of truncated distributions
given desired mean and value of CDF at a point. It does this by numerical optimization.
This is for example useful for when
specifying a prior in Bayesian, where your belief is often with respect to a mean and
value of CDF at a point.
## Installation
You can install the development version of solvetruncated from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("BjarkeHautop/solvetruncated")
```
## Example
Here is an example where we wish to solve for the parameters
$(\mu, \sigma)$ of
$$X \sim \text{TruncNormal}(\mu, \sigma, a=0, b=\infty),$$ where we wish to have
$E[X]=0.5$ and $P(X\leq 0.75)=0.8$.
```{r example}
library(solvetruncated)
solve_truncated_normal(desired_mean = 0.5, x_value = 0.75, desired_prob = 0.8, a = 0, b = Inf)
```
which gives that the parameters should be $(\mu=0.42, \sigma=0.35)$.