diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 14f5eaa1..d9800b5d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,9 +14,10 @@ jobs: fail-fast: false matrix: version: - - '1.6' + - 'min' + - 'lts' - '1' - - 'nightly' + - 'pre' os: - ubuntu-latest arch: diff --git a/Project.toml b/Project.toml index 2759d394..2673c385 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MCMCDiagnosticTools" uuid = "be115224-59cd-429b-ad48-344e309966f0" authors = ["David Widmann", "Seth Axen"] -version = "0.3.11" +version = "0.3.12" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" @@ -44,7 +44,7 @@ StatsBase = "0.33.7, 0.34" StatsFuns = "1" Tables = "1.11" Test = "1.6" -julia = "1.6" +julia = "1.8" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" diff --git a/src/mcse.jl b/src/mcse.jl index 3bc12728..c2b41886 100644 --- a/src/mcse.jl +++ b/src/mcse.jl @@ -95,6 +95,9 @@ end function _mcse_quantile(x, p, Seff) Seff === missing && return missing + if isnan(Seff) + return oftype(oneunit(eltype(x)) / 1, NaN) + end S = length(x) # quantile error distribution is asymptotically normal; estimate σ (mcse) with 2 # quadrature points: xl and xu, chosen as quantiles so that xu - xl = 2σ @@ -133,6 +136,10 @@ function _mcse_sbm(f, x, batch_size) any(x -> x === missing, x) && return missing n = length(x) i1 = firstindex(x) + if allequal(x) + y1 = f(view(x, i1:(i1 + batch_size - 1))) + return oftype(y1, NaN) + end v = Statistics.var( f(view(x, i:(i + batch_size - 1))) for i in i1:(i1 + n - batch_size); corrected=false, diff --git a/test/mcse.jl b/test/mcse.jl index 4a8c2e48..35a7d408 100644 --- a/test/mcse.jl +++ b/test/mcse.jl @@ -83,6 +83,23 @@ using StatsBase end end + @testset "mcse for scalar array is always a NaN" begin + x = ones(100) + @testset for kind in [ + mean, + median, + std, + mad, + # uses sbm + x -> mean(x), + x -> median(x), + x -> std(x), + x -> mad(x), + ] + @test isnan(mcse(x; kind)) + end + end + @testset "estimand is within interval defined by MCSE estimate" begin # we check the MCSE estimates by simulating uncorrelated, correlated, and # anticorrelated chains, mapping the draws to a target distribution, computing the