Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d7e3dc6
add verbose flag to simplex optimization
thijsjanzen Mar 4, 2025
bf0e747
update
thijsjanzen Mar 4, 2025
7f8e2da
update README
rsetienne Mar 5, 2025
ed2e451
Add verbose option
rsetienne Mar 5, 2025
73b3a8e
Version number update
rsetienne Mar 5, 2025
95c8480
make it a verbose flag again
thijsjanzen Mar 5, 2025
75ea11d
Add fifth element of optimpars
rsetienne Mar 6, 2025
48b1a30
verbose simplex once more
rsetienne Mar 7, 2025
28c32c2
Merge branch 'develop' into thijs
thijsjanzen Mar 13, 2025
c3e6389
Update test-coverage.yaml
thijsjanzen Mar 13, 2025
d7370d4
Merge branch 'thijs' of https://github.com/rsetienne/DDD into thijs
thijsjanzen Mar 13, 2025
c92ac39
fix simplex bug when verbose = TRUE
thijsjanzen Mar 27, 2025
0daed3f
update documentation
thijsjanzen Mar 27, 2025
c592c63
remove duplicate verbose output
thijsjanzen Apr 1, 2025
a1c6790
Update dd_utils.R
thijsjanzen Apr 2, 2025
c0f1c8f
Merge pull request #55 from rsetienne/thijs
rsetienne Apr 11, 2025
619901b
introduce abstol and reltol in pars2
rsetienne Jun 6, 2025
8c21042
Merge branch 'develop' of https://github.com/rsetienne/DDD into develop
rsetienne Jun 6, 2025
14a70b5
tolint in dd_ML
rsetienne Jun 6, 2025
ee5e4d9
Documentation
rsetienne Jun 6, 2025
11fbc07
abstolint and reltolint
rsetienne Jun 6, 2025
53f5e6d
abstolint, reltolint
rsetienne Jun 6, 2025
601f58d
No checkprobs for normalization
rsetienne Jun 7, 2025
128cd61
new branch
rsetienne Jun 8, 2025
426ae18
k_threshold
rsetienne Jun 9, 2025
e92b4b8
back to normal?
rsetienne Jun 9, 2025
21e6edc
integration of logprobs
rsetienne Jun 9, 2025
b37758b
Flexibility in log-integration
rsetienne Jun 9, 2025
bc6eada
Documentation
rsetienne Jun 9, 2025
1a2d986
Avoid error in matrix exponentiation
rsetienne Jun 10, 2025
6751067
Merge pull request #56 from rsetienne/dd_odeint_log
rsetienne Jun 11, 2025
b49dafc
Change default k_threshold
rsetienne Jun 21, 2025
8ba43a6
Merge pull request #57 from rsetienne/dd_odeint_log
rsetienne Jun 22, 2025
29a4d27
Documentation update and importing from optim
rsetienne Jun 23, 2025
b2c327d
Merge pull request #58 from rsetienne/dd_odeint_log
rsetienne Jun 23, 2025
dc53d04
Replacing k_threshold by probs_threshold
rsetienne Jun 24, 2025
428629f
Merge pull request #59 from rsetienne/dd_odeint_log
rsetienne Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]

name: test-coverage
name: test-coverage-new

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '[run ci]') || (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop')"

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true


- name: Install devtools
run: install.packages("devtools")
shell: Rscript {0}

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
files: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
path: ${{ runner.temp }}/package
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Package: DDD
Type: Package
Title: Diversity-Dependent Diversification
Version: 5.2.3
Date: 2024-11-26
Version: 5.2.4
Depends: R (>= 3.5.0)
Imports:
deSolve,
Expand Down
7 changes: 7 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ dd_integrate_bw_odeint <- function(ry, times, pars, atol, rtol, stepper) {
#' @useDynLib DDD
NULL

dd_integrate_log_odeint <- function(ry, times, pars, atol, rtol, stepper) {
.Call('_DDD_dd_integrate_log_odeint', PACKAGE = 'DDD', ry, times, pars, atol, rtol, stepper)
}

#' @useDynLib DDD
NULL

dd_integrate_odeint <- function(ry, times, pars, atol, rtol, stepper) {
.Call('_DDD_dd_integrate_odeint', PACKAGE = 'DDD', ry, times, pars, atol, rtol, stepper)
}
Expand Down
4 changes: 2 additions & 2 deletions R/bd_ML.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#' @param changeloglikifnoconv if TRUE the loglik will be set to -Inf if ML
#' does not converge
#' @param optimmethod Method used in optimization of the likelihood. Current
#' default is 'subplex'. Alternative is 'simplex' (default of previous
#' default is 'simplex'. Alternative is 'subplex' (default of previous
#' versions)
#' @param num_cycles the number of cycles of opimization. If set at Inf, it will
#' do as many cycles as needed to meet the tolerance set for the target function.
Expand Down Expand Up @@ -102,7 +102,7 @@ bd_ML = function(brts,
tol = c(1E-3, 1E-4, 1E-6),
maxiter = 1000 * round((1.25)^length(idparsopt)),
changeloglikifnoconv = FALSE,
optimmethod = 'subplex',
optimmethod = 'simplex',
num_cycles = 1,
methode = 'odeint::runge_kutta_cash_karp54',
verbose = FALSE)
Expand Down
4 changes: 2 additions & 2 deletions R/dd_KI_ML.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#' @param changeloglikifnoconv if TRUE the loglik will be set to -Inf if ML
#' does not converge
#' @param optimmethod Method used in optimization of the likelihood. Current
#' default is 'subplex'. Alternative is 'simplex' (default of previous
#' default is 'simplex'. Alternative is 'subplex' (default of previous
#' versions)
#' @param num_cycles the number of cycles of opimization. If set at Inf, it will
#' do as many cycles as needed to meet the tolerance set for the target function.
Expand Down Expand Up @@ -140,7 +140,7 @@ dd_KI_ML = function(brtsM,
tol = c(1E-3, 1E-4, 1E-6),
maxiter = 1000 * round((1.25)^length(idparsopt)),
changeloglikifnoconv = FALSE,
optimmethod = 'subplex',
optimmethod = 'simplex',
num_cycles = 1,
methode = 'analytical',
correction = TRUE,
Expand Down
4 changes: 2 additions & 2 deletions R/dd_LR.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#' @param changeloglikifnoconv if TRUE the loglik will be set to -Inf if ML
#' does not converge
#' @param optimmethod Method used in optimization of the likelihood. Current
#' default is 'subplex'. Alternative is 'simplex' (default of previous
#' default is 'simplex'. Alternative is 'subplex' (default of previous
#' versions)
#' @param methode The method used to solve the master equation, default is
#' 'analytical' which uses matrix exponentiation; alternatively numerical ODE
Expand Down Expand Up @@ -120,7 +120,7 @@ dd_LR = function(
tol = c(1E-3,1E-4,1E-6),
maxiter = 2000,
changeloglikifnoconv = FALSE,
optimmethod = 'subplex',
optimmethod = 'simplex',
methode = 'analytical'
)
{
Expand Down
21 changes: 14 additions & 7 deletions R/dd_ML.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,20 @@ parsfixdefault = function(ddmodel,brts,missnumspec,idparsopt)
#' @param btorph Sets whether the likelihood is for the branching times (0) or
#' the phylogeny (1)
#' @param soc Sets whether stem or crown age should be used (1 or 2)
#' @param tol Sets the tolerances in the optimization. Consists of: \cr reltolx
#' = relative tolerance of parameter values in optimization \cr reltolf =
#' relative tolerance of function value in optimization \cr abstolx = absolute
#' tolerance of parameter values in optimization
#' @param tol Sets the tolerances in the optimization. Consists of:\cr
#' reltolx = relative tolerance of parameter values in optimization \cr
#' reltolf = relative tolerance of function value in optimization \cr
#' abstolx = absolute tolerance of parameter values in optimization
#' @param tolint Sets the tolerance of the numerical integration. Consists of: \cr
#' absoltint = absolute tolerance and \cr
#' reltolint = relative tolerance.
#' @param probs_threshold Sets the threshold of the probability below which
#' logarithmic integration must be used. Default is 0.
#' @param maxiter Sets the maximum number of iterations in the optimization
#' @param changeloglikifnoconv if TRUE the loglik will be set to -Inf if ML
#' does not converge
#' @param optimmethod Method used in optimization of the likelihood. Current
#' default is 'subplex'. Alternative is 'simplex' (default of previous
#' default is 'simplex'. Alternative is 'subplex' (default of previous
#' versions)
#' @param num_cycles the number of cycles of opimization. If set at Inf, it will
#' do as many cycles as needed to meet the tolerance set for the target function.
Expand Down Expand Up @@ -145,9 +150,11 @@ dd_ML = function(
btorph = 1,
soc = 2,
tol = c(1E-3, 1E-4, 1E-6),
tolint = c(1E-10,1E-8),
probs_threshold = 0,
maxiter = 1000 * round((1.25)^length(idparsopt)),
changeloglikifnoconv = FALSE,
optimmethod = 'subplex',
optimmethod = 'simplex',
num_cycles = 1,
methode = 'analytical',
verbose = FALSE)
Expand Down Expand Up @@ -183,7 +190,7 @@ dd_ML = function(
trparsopt[which(initparsopt == Inf)] = 1
trparsfix = parsfix/(1 + parsfix)
trparsfix[which(parsfix == Inf)] = 1
pars2 = c(res,ddmodel,cond,btorph,verbose,soc,tol,maxiter)
pars2 = c(res,ddmodel,cond,btorph,verbose,soc,tol,maxiter,abstolint = tolint[1],reltolint = tolint[2],probs_threshold = probs_threshold)
optimpars = c(tol,maxiter)
initloglik = dd_loglik_choosepar(trparsopt = trparsopt,trparsfix = trparsfix,idparsopt = idparsopt,idparsfix = idparsfix,pars2 = pars2,brts = brts,missnumspec = missnumspec, methode = methode)
cat("The loglikelihood for the initial parameter values is",initloglik,"\n")
Expand Down
4 changes: 2 additions & 2 deletions R/dd_MS_ML.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#' @param changeloglikifnoconv if TRUE the loglik will be set to -Inf if ML
#' does not converge
#' @param optimmethod Method used in optimization of the likelihood. Current
#' default is 'subplex'. Alternative is 'simplex' (default of previous
#' default is 'simplex'. Alternative is 'subplex' (default of previous
#' versions)
#' @param num_cycles the number of cycles of opimization. If set at Inf, it will
#' do as many cycles as needed to meet the tolerance set for the target function.
Expand Down Expand Up @@ -136,7 +136,7 @@ dd_MS_ML = function(brtsM,
tol = c(1E-3, 1E-4, 1E-6),
maxiter = 1000 * round((1.25)^length(idparsopt)),
changeloglikifnoconv = FALSE,
optimmethod = 'subplex',
optimmethod = 'simplex',
num_cycles = 1,
methode = 'ode45',
correction = FALSE,
Expand Down
4 changes: 2 additions & 2 deletions R/dd_SR_ML.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#' @param changeloglikifnoconv if TRUE the loglik will be set to -Inf if ML
#' does not converge
#' @param optimmethod Method used in optimization of the likelihood. Current
#' default is 'subplex'. Alternative is 'simplex' (default of previous
#' default is 'simplex'. Alternative is 'subplex' (default of previous
#' versions)
#' @param num_cycles the number of cycles of opimization. If set at Inf, it will
#' do as many cycles as needed to meet the tolerance set for the target function.
Expand Down Expand Up @@ -128,7 +128,7 @@ dd_SR_ML = function(brts,
tol = c(1E-3, 1E-4, 1E-6),
maxiter = 1000 * round((1.25)^length(idparsopt)),
changeloglikifnoconv = FALSE,
optimmethod = 'subplex',
optimmethod = 'simplex',
num_cycles = 1,
methode = 'analytical',
verbose = FALSE)
Expand Down
Loading
Loading