Skip to content

Commit

Permalink
Fix a bug in StatStMoE class
Browse files Browse the repository at this point in the history
- Fix a bug in `StatStMoE$EStep`: when trying to integrate (case `calcE3 = TRUE`), a vector of characters was returned in some cases instead of numerics.
- Update NEWS.md.
  • Loading branch information
Florian-Lecocq committed Jan 10, 2020
1 parent 8c6bf2b commit c84f8e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
* Added a `cran-comments.md` file.

* Added a `NEWS.md` file to track changes to the package.

## Bug fixes

* Fix a bug in `StatStMoE$EStep`: when trying to integrate (case `calcE3 = TRUE`),
a vector of characters was returned in some case instead of numerics.
2 changes: 1 addition & 1 deletion R/StatStMoE.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ StatStMoE <- setRefClass(

if (calcE3) {

Integgtx[, k] <- sapply(mik[, k], function(x) try(integrate(f = fx, lower = -Inf, upper = x)$value, silent = TRUE))
Integgtx[, k] <- as.numeric(sapply(mik[, k], function(x) try(integrate(f = fx, lower = -Inf, upper = x)$value, silent = TRUE)))
E3ik[, k] <<- wik[, k] - log((paramStMoE$nu[k] + dik[, k] ^ 2) / 2) - (paramStMoE$nu[k] + 1) / (paramStMoE$nu[k] + dik[, k] ^ 2) + psigamma((paramStMoE$nu[k] + 1) / 2) + ((paramStMoE$lambda[k] * dik[, k] * (dik[, k] ^ 2 - 1)) / sqrt((paramStMoE$nu[k] + 1) * ((paramStMoE$nu[k] + dik[, k] ^ 2) ^ 3))) * dt(mik[, k], paramStMoE$nu[k] + 1) / pt(mik[, k], paramStMoE$nu[k] + 1) + (1 / pt(mik[, k], paramStMoE$nu[k] + 1)) * Integgtx[, k]
}

Expand Down

0 comments on commit c84f8e7

Please sign in to comment.