Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "multimput: Using Multiple Imputation to Address Missing Data",
"version": "0.2.14",
"version": "0.2.15",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>Accompanying package for the paper: Working with population totals in the presence of missing data comparing imputation methods in terms of bias and precision. Published in 2017 in the Journal of Ornithology volume 158 page 603–615 (doi:10.1007/s10336-016-1404-9).<\/p>",
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ identifiers:
value: 10.5281/zenodo.598331
- type: url
value: https://inbo.github.io/multimput/
version: 0.2.14
version: 0.2.15
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: multimput
Title: Using Multiple Imputation to Address Missing Data
Version: 0.2.14
Version: 0.2.15
Authors@R: c(
person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# multimput 0.2.15

* Bugfix in `hurdle_impute()` when selecting single covariates.

# multimput 0.2.14

* In case all imputed values are identical, `model_impute()` only runs a single
Expand Down
33 changes: 23 additions & 10 deletions R/hurdle_impute.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,31 @@

# prepare covariates
cv_count <- count@Data[
, !colnames(count@Data) %in% c(count@Response, count@Minimum)
, !colnames(count@Data) %in% c(count@Response, count@Minimum), drop = FALSE
]
cv_presence <- presence@Data[
, !colnames(presence@Data) %in% c(presence@Response, presence@Minimum)
, !colnames(presence@Data) %in% c(presence@Response, presence@Minimum),
drop = FALSE
]
common <- colnames(cv_count)[colnames(cv_count) %in% colnames(cv_presence)]
common <- common[apply(cv_count[, common] == cv_presence[, common], 2, all)]
extra_count <- colnames(cv_count)[!colnames(cv_count) %in% common]
extra_presence <- colnames(cv_presence)[!colnames(cv_presence) %in% common]
ren_count <- cv_count[, extra_count[extra_count %in% extra_presence]]
ren_count <- cv_count[
, extra_count[extra_count %in% extra_presence], drop = FALSE
]
colnames(ren_count) <- sprintf("count_%s", colnames(ren_count))
ren_presence <- cv_presence[, extra_presence[extra_presence %in% extra_count]]
ren_presence <- cv_presence[
, extra_presence[extra_presence %in% extra_count], drop = FALSE
]
colnames(ren_presence) <- sprintf("presence_%s", colnames(ren_presence))
cv <- cbind(
cv_count[, common],
cv_count[, extra_count[!extra_count %in% extra_presence]], ren_count,
cv_presence[, extra_presence[!extra_presence %in% extra_count]],
cv_count[, common, drop = FALSE],
cv_count[, extra_count[!extra_count %in% extra_presence], drop = FALSE],
ren_count,
cv_presence[
, extra_presence[!extra_presence %in% extra_count], drop = FALSE
],
ren_presence
)
if (nrow(count@Extra) == 0) {
Expand All @@ -80,11 +88,16 @@
count@Extra[[count@Response]], nrow = nrow(count@Extra),
ncol = ncol(count_resp)
)
ren_count <- count@Extra[, extra_count[extra_count %in% extra_presence]]
ren_count <- count@Extra[
, extra_count[extra_count %in% extra_presence], drop = FALSE

Check warning on line 92 in R/hurdle_impute.R

View check run for this annotation

Codecov / codecov/patch

R/hurdle_impute.R#L91-L92

Added lines #L91 - L92 were not covered by tests
]
colnames(ren_count) <- sprintf("count_%s", colnames(ren_count))
cv_extra <- cbind(
count@Extra[, common],
count@Extra[, extra_count[!extra_count %in% extra_presence]], ren_count
count@Extra[, common, drop = FALSE],
count@Extra[
, extra_count[!extra_count %in% extra_presence], drop = FALSE

Check warning on line 98 in R/hurdle_impute.R

View check run for this annotation

Codecov / codecov/patch

R/hurdle_impute.R#L96-L98

Added lines #L96 - L98 were not covered by tests
],
ren_count

Check warning on line 100 in R/hurdle_impute.R

View check run for this annotation

Codecov / codecov/patch

R/hurdle_impute.R#L100

Added line #L100 was not covered by tests
)
c(
extra_presence[!extra_presence %in% extra_count],
Expand Down
12 changes: 4 additions & 8 deletions R/impute_inla.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@
prob = hyperpar[[grep("zero-probability", colnames(hyperpar))]],
size = hyperpar[[grep("size for nbinomial", colnames(hyperpar))]]
),
.f = function(n, eta, prob, size) {
rzinb0(
n = length(missing_obs), mu = exp(eta), prob = prob, size = size
)
.f = function(eta, prob, size, n = length(missing_obs)) {
rzinb0(mu = exp(pmin(eta, 20)), prob = prob, size = size, n = n)

Check warning on line 112 in R/impute_inla.R

View check run for this annotation

Codecov / codecov/patch

R/impute_inla.R#L112

Added line #L112 was not covered by tests
}
),
zeroinflatednbinomial1 = pmap_dfr(
Expand All @@ -120,10 +118,8 @@
prob = hyperpar[[grep("zero-probability", colnames(hyperpar))]],
size = hyperpar[[grep("size for nbinomial", colnames(hyperpar))]]
),
.f = function(n, eta, prob, size) {
rzinb1(
n = length(missing_obs), mu = exp(eta), prob = prob, size = size
)
.f = function(eta, prob, size, n = length(missing_obs)) {
rzinb1(mu = exp(eta), prob = prob, size = size, n = n)
}
),
zeroinflatedpoisson0 = map2_dfr(
Expand Down
6 changes: 3 additions & 3 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ citHeader("To cite `multimput` in publications please use:")
# begin checklist entry
bibentry(
bibtype = "Manual",
title = "multimput: Using Multiple Imputation to Address Missing Data. Version 0.2.14",
title = "multimput: Using Multiple Imputation to Address Missing Data. Version 0.2.15",
author = c( author = c(person(given = "Thierry", family = "Onkelinx"), person(given = "Koen", family = "Devos"), person(given = "Paul", family = "Quataert"))),
year = 2024,
year = 2025,
url = "https://inbo.github.io/multimput/",
abstract = "Accompanying package for the paper: Working with population totals in the presence of missing data comparing imputation methods in terms of bias and precision. Published in 2017 in the Journal of Ornithology volume 158 page 603–615 (doi:10.1007/s10336-016-1404-9).",
textVersion = "Onkelinx, Thierry; Devos, Koen; Quataert, Paul (2024) multimput: Using Multiple Imputation to Address Missing Data. Version 0.2.14. https://inbo.github.io/multimput/",
textVersion = "Onkelinx, Thierry; Devos, Koen; Quataert, Paul (2025) multimput: Using Multiple Imputation to Address Missing Data. Version 0.2.15. https://inbo.github.io/multimput/",
keywords = "missing data, multiple imputation, Rubin",
doi = "10.5281/zenodo.598331",
)
Expand Down
1 change: 1 addition & 0 deletions multimput.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 67edd119-a857-4812-acf7-b7a36277956a

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
Loading