https://github.com/bertcarnell/triangle
Provides the standard distribution functions for the triangle distribution
https://github.com/bertcarnell/triangle
r r-package triangle triangle-distribution
Last synced: 3 months ago
JSON representation
Provides the standard distribution functions for the triangle distribution
- Host: GitHub
- URL: https://github.com/bertcarnell/triangle
- Owner: bertcarnell
- Created: 2018-12-01T20:09:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T01:48:54.000Z (over 1 year ago)
- Last Synced: 2024-03-15T06:04:14.386Z (about 1 year ago)
- Topics: r, r-package, triangle, triangle-distribution
- Language: R
- Homepage: https://bertcarnell.github.io/triangle/
- Size: 4.88 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: ChangeLog
Awesome Lists containing this project
README
---
title: "triangle"
output:
md_document:
variant: gfm
---
![]()
© Copyright 2024 Robert Carnell```{r setup, echo=FALSE, include=FALSE}
require(knitr)
require(triangle)
knitr::opts_chunk$set(fig.path = "man/figures/")
```# triangle
An R package to work with the triangle distribution and logarithmic triangle distribution
```{r badges, echo=FALSE, results = 'asis'}
cat(paste0("|",
paste0(
c("Github Actions", "Windows", "Code Coverage", "CRAN Downloads", "CRAN"),
collapse="|"),
"|\n"))
cat(paste0("|", paste0(rep(":---:", 5), collapse="|"), "|\n"))
cat(paste0("|",
paste0(c("[](https://github.com/bertcarnell/triangle/actions/workflows/r-cmd-check.yml)",
"[](https://ci.appveyor.com/project/bertcarnell/triangle)",
"[](https://codecov.io/github/bertcarnell/triangle?branch=master)",
"[](https://cran.r-project.org/package=triangle)",
"[](https://cran.r-project.org/package=triangle)"),
collapse="|"),
"|"))```
See the package documentation [here:](https://bertcarnell.github.io/triangle/)
## Getting Started
Install the R package:
```{r echo=TRUE, eval=FALSE}
# Stable CRAN version
install.packages("triangle")# OR development version from GitHub
require(devtools)
devtools::install_github("bertcarnell/triangle")
```use the functions:
- `a` = minimum
- `b` = maximum
- `c` = mode```{r echo=TRUE, eval=FALSE}
require(triangle)
```### Triangle distribution
```{r echo=TRUE}
# rtriangle(n, a, b, c)
set.seed(42)
rtriangle(5, 1, 5, 2)# ptriangle(x, a, b, c)
ptriangle(0:5, 0, 10, 5)# qtriangle(p, a, b, c)
qtriangle(seq(0, 1, by = 0.2), 1, 10, 3)# dtriangle(x, a, b, c)
dtriangle(0:4, 0, 10, 5)
```### Logarithmic triangle distribution
```{r echo=TRUE}
# rltriangle(n, a, b, c, logbase)
set.seed(2001)
rltriangle(5, 1, 100, 10)# pltriangle(x, a, b, c, logbase)
pltriangle(10^(0:3), 1, 1000, 10)# qltriangle(p, a, b, c, logbase)
qltriangle(seq(0, 1, by = 0.2), 1, 100, 20)# dltriangle(x, a, b, c, logbase)
dltriangle(0:5, 1, 10, 5)
```### Parameter estimates
#### triangle method of moments estimates
```{r echo=TRUE}
x <- rtriangle(20, 0, 2, 1.5)
triangle_mom(x)
```#### triangle maximum likelihood estimates
```{r echo=TRUE}
x <- c(0.1, 0.25, 0.3, 0.4, 0.45, 0.6, 0.75, 0.8)
# triangle_mle(x, debug = FALSE, maxiter = 100)
triangle_mle(x)# standard triangle (0,1) likelihood estimates
standard_triangle_mle(x)set.seed(1976)
x <- rtriangle(100, 1, 5, 3.5)
triangle_mle(x)
```