diff --git a/NAMESPACE b/NAMESPACE index d83b2be..b5caa03 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(beta0) export(dget_tb) export(get_lb) export(get_tb) diff --git a/R/beta0.R b/R/beta0.R index 06f5aaa..7c6bc06 100644 --- a/R/beta0.R +++ b/R/beta0.R @@ -1,9 +1,16 @@ -## beta0 -# particular incomplete beta function - -## -#function f = - +#' particular incomplete beta function +#' +#' \deqn{B_x1(4/3,0) - B_x0(4/3,0) = \int_x0^x1 t^(4/3-1) (1-t)^(-1) dt}{B_x1(4/3,0) - B_x0(4/3,0) = int_x0^x1 t^(4/3-1) (1-t)^(-1) dt} +#' +#' @param x0 scalar with lower boundary for integration +#' @param x1 scalar with upper boundary for integration +#' +#' @return scalar with particular incomple beta function +#' @export +#' +#' @examples +#' beta0(0.1, 0.2) +#' beta0 = function(x0,x1){ # created 2000/08/16 by Bas Kooijman; modified 2011/04/10 diff --git a/inst/MATLAB/DEBtool_examples.m b/inst/MATLAB/DEBtool_examples.m new file mode 100644 index 0000000..755f642 --- /dev/null +++ b/inst/MATLAB/DEBtool_examples.m @@ -0,0 +1,10 @@ +%DEBtool_M calculations that are used in the DEButilities R package to +%check for numerical equivalence of function outputs + +%get_ue0 example +g = 6; k = 6; kap = .8; uHb = .001; vHb = uHb/ (1 - kap); +pars = [g, k, vHb]; +[uE0, lb, info] = get_ue0(pars); + +%beta0 example +betazero = beta0(0.1,0.2); \ No newline at end of file diff --git a/man/beta0.Rd b/man/beta0.Rd new file mode 100644 index 0000000..9693308 --- /dev/null +++ b/man/beta0.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/beta0.R +\name{beta0} +\alias{beta0} +\title{particular incomplete beta function} +\usage{ +beta0(x0, x1) +} +\arguments{ +\item{x0}{scalar with lower boundary for integration} + +\item{x1}{scalar with upper boundary for integration} +} +\value{ +scalar with particular incomple beta function +} +\description{ +\deqn{B_x1(4/3,0) - B_x0(4/3,0) = \int_x0^x1 t^(4/3-1) (1-t)^(-1) dt}{B_x1(4/3,0) - B_x0(4/3,0) = int_x0^x1 t^(4/3-1) (1-t)^(-1) dt} +} +\examples{ +beta0(0.1, 0.2) + +} diff --git a/tests/testthat/test_MATLAB_numerical_equivalence.R b/tests/testthat/test_MATLAB_numerical_equivalence.R index 4223a1b..ee7e637 100644 --- a/tests/testthat/test_MATLAB_numerical_equivalence.R +++ b/tests/testthat/test_MATLAB_numerical_equivalence.R @@ -6,3 +6,12 @@ test_that("get_tb matches DEBtool", { expect_equal(get_tb(c(.1,.5,.03)), c(8.6038, 0.2658, 1), tolerance = 0.001) }) +test_that("beta0 matches DEBtool_M", { + expect_equal(beta0(0.1, 0.2), 0.062455351015153) +}) + +test_that("get_ue0 matches DEBtool_M", { + g = 6; k = 6; kap = .8; uHb = .001; vHb = uHb/ (1 - kap); + pars = c(g, k, vHb); + expect_equal(get_ue0(pars), c(0.008171217468332, 0.188067711870661, 1)) +})