From cddb0c3817eb227cf1ce8a93b618232bc819c454 Mon Sep 17 00:00:00 2001 From: Tom Metherell <102831716+tom-metherell@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:56:00 +0000 Subject: [PATCH] Development --- docs/src/imputation.md | 2 +- docs/src/multithreading.md | 2 +- src/Mice.jl | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/src/imputation.md b/docs/src/imputation.md index 1014576..73e3893 100644 --- a/docs/src/imputation.md +++ b/docs/src/imputation.md @@ -169,7 +169,7 @@ plot ``` ## Binding imputations together -If you have a number of `Mids` objects that were produced in the same way (e.g. through [multithreading](#multithreading)), you can bind them together into a single `Mids` object using the function `bindImputations`. +If you have a number of `Mids` objects that were produced in the same way (e.g. through [multithreading](#multithreading)), you can bind them together into a single `Mids` object using the function `bindImputations`. Note that the log of events might not make sense in the resulting object: it is better to inspect the logs of the individual objects before binding them together. ```@docs bindImputations diff --git a/docs/src/multithreading.md b/docs/src/multithreading.md index 1fbf2e8..188139b 100644 --- a/docs/src/multithreading.md +++ b/docs/src/multithreading.md @@ -33,7 +33,7 @@ imputedData = Vector{Mids}(undef, 10); # Initialise vector of Mids outputs Threads.@threads for i in 1:10 # Number of parallel runs # Produces 5 x 10 = 50 imputed datasets in 10 separate Mids objects - imputedData[i] = mice(myData, m = 5, predictorMatrix = myPredictorMatrix, methods = myMethods, threads = false) + imputedData[i] = mice(myData, m = 5, predictorMatrix = myPredictorMatrix, methods = myMethods, threads = false, progressReports = false) end imputedData = bindImputations(imputedData) # Binds the separate Mids objects into a single output diff --git a/src/Mice.jl b/src/Mice.jl index 82bb599..0f4b4d4 100644 --- a/src/Mice.jl +++ b/src/Mice.jl @@ -337,7 +337,7 @@ module Mice ) data = mids1.data - if data != mids2.data + if data !== mids2.data throw(error(ArgumentError, "Cannot bind these Mids objects: they appear to result from different datasets.")) end @@ -362,13 +362,15 @@ module Mice end m = mids1.m + mids2.m - loggedEvents = push(mids1.loggedEvents, mids2.loggedEvents) + loggedEvents = vcat(mids1.loggedEvents, mids2.loggedEvents) # Initialise new imputations object imputations = Vector{Matrix}(undef, length(mids1.imputations)) # Concatenate imputations for i in eachindex(imputations) - imputations[i] = hcat(mids1.imputations[i], mids2.imputations[i]) + if isassigned(mids1.imputations, i) + imputations[i] = hcat(mids1.imputations[i], mids2.imputations[i]) + end end # Initialise new mean and variance traces @@ -423,7 +425,7 @@ module Mice """ bindImputations( - mids...::Mids + mids... ) Combines any number of `Mids` objects into one `Mids` object. They must all have been