diff --git a/NAMESPACE b/NAMESPACE
index 51e0929..7623e4a 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -35,6 +35,7 @@ importFrom(stats,coef)
importFrom(stats,ecdf)
importFrom(stats,integrate)
importFrom(stats,nls)
+importFrom(stats,nls.control)
importFrom(stats,optim)
importFrom(stats,plot.ecdf)
importFrom(stats,ppoints)
diff --git a/R/cdfe.R b/R/cdfe.R
index 2400522..340c571 100644
--- a/R/cdfe.R
+++ b/R/cdfe.R
@@ -3,11 +3,12 @@
#' Triangle parameter estimates using a non-linear fit of the empirical CDF
#'
#' @param x the triangle distributed sample
+#' @param control an object created by \code{stats::nls.control}
#'
#' @return an object of class \code{nls}
#' @export
#'
-#' @importFrom stats nls
+#' @importFrom stats nls nls.control
#'
#' @examples
#' set.seed(10304)
@@ -17,9 +18,9 @@
#' summary(cdfe)
#' coef(cdfe)
#' \dontrun{
-#' MASS::confint(cdfe)
+#' confint(cdfe)
#' }
-triangle_cdfe <- function(x)
+triangle_cdfe <- function(x, control = stats::nls.control(maxiter = 100, warnOnly = TRUE))
{
# x <- rtriangle(100, 0, 1, .3)
n <- length(x)
@@ -35,6 +36,7 @@ triangle_cdfe <- function(x)
c = 3*mean(x) - minx - maxx),
algorithm = "port",
lower = c(minx - 2*rangex, maxx, minx),
- upper = c(minx, maxx + 2*rangex, maxx))
+ upper = c(minx, maxx + 2*rangex, maxx),
+ control = control)
return(nls1)
}
diff --git a/docs/articles/triangledistributionmath.html b/docs/articles/triangledistributionmath.html
index 1f2f32d..30b0283 100644
--- a/docs/articles/triangledistributionmath.html
+++ b/docs/articles/triangledistributionmath.html
@@ -86,7 +86,7 @@
Triangle Distribution Math
Rob
Carnell
- 2022-12-11
+ 2022-12-12
Source: vignettes/triangledistributionmath.Rmd
triangledistributionmath.Rmd
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index d8e585f..7bfc201 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -3,5 +3,5 @@ pkgdown: 2.0.6
pkgdown_sha: ~
articles:
triangledistributionmath: triangledistributionmath.html
-last_built: 2022-12-12T02:13Z
+last_built: 2022-12-13T00:58Z
diff --git a/docs/reference/triangle_cdfe.html b/docs/reference/triangle_cdfe.html
index dd79d56..4dd90e7 100644
--- a/docs/reference/triangle_cdfe.html
+++ b/docs/reference/triangle_cdfe.html
@@ -60,7 +60,7 @@ Triangle parameter estimates using a non-linear fit of the empirical CDF
-
+
triangle_cdfe(x, control = stats::nls.control(maxiter = 100, warnOnly = TRUE))
@@ -68,6 +68,10 @@
Arguments
- x
the triangle distributed sample
+
+- control
+an object created by stats::nls.control
+
Value
@@ -112,7 +116,7 @@
Examples
#> a b c
#> 0.7848163 5.3555055 2.1058729
if (FALSE) {
-
MASS::confint(cdfe)
+
confint(cdfe)
}
diff --git a/man/triangle_cdfe.Rd b/man/triangle_cdfe.Rd
index 8ec86a1..9265779 100644
--- a/man/triangle_cdfe.Rd
+++ b/man/triangle_cdfe.Rd
@@ -4,10 +4,12 @@
\alias{triangle_cdfe}
\title{Triangle parameter estimates using a non-linear fit of the empirical CDF}
\usage{
-triangle_cdfe(x)
+triangle_cdfe(x, control = stats::nls.control(maxiter = 100, warnOnly = TRUE))
}
\arguments{
\item{x}{the triangle distributed sample}
+
+\item{control}{an object created by \code{stats::nls.control}}
}
\value{
an object of class \code{nls}
@@ -23,6 +25,6 @@ print(cdfe)
summary(cdfe)
coef(cdfe)
\dontrun{
- MASS::confint(cdfe)
+ confint(cdfe)
}
}
diff --git a/tests/testthat/test-fit-plots.R b/tests/testthat/test-fit-plots.R
index b7c0a4f..02c0dd3 100644
--- a/tests/testthat/test-fit-plots.R
+++ b/tests/testthat/test-fit-plots.R
@@ -1,11 +1,13 @@
test_that("qqtriangle works", {
- xtest <- c(0.1, 0.25, 0.3, 0.4, 0.45, 0.6, 0.75, 0.8)
+ set.seed(10304)
+ xtest <- rtriangle(100, 1, 5, 2)
theta <- coef(triangle_mle(xtest))
expect_no_error(qqtriangle(xtest, theta[1], theta[2], theta[3]))
})
test_that("compare_triangle_fit works", {
- xtest <- c(0.1, 0.25, 0.3, 0.4, 0.45, 0.6, 0.75, 0.8)
+ set.seed(10304)
+ xtest <- rtriangle(100, 1, 5, 2)
expect_no_error(compare_triangle_fit(xtest))
})