text:
### A Pluto.jl notebook ###
# v0.15.1

using Markdown
using InteractiveUtils

# ╔═╡ 78090450-7373-4824-bfe9-1283e971dda0
begin
	using InteractiveUtils
	using Pkg
	with_terminal() do
		versioninfo()
		Pkg.status()
	end
end

# ╔═╡ 5d7dc2d4-1008-11ec-2ea6-ffc13cf6dbf7
begin
	using CategoricalArrays
	using CSV
	using DataFrames
	using CairoMakie
	CairoMakie.activate!(type="svg")
	using AlgebraOfGraphics
	using MixedModels
	using MixedModelsExtras
	using MixedModelsMakie
	using Effects
	using PlutoUI
	using Random
	TableOfContents()
end

# ╔═╡ 16199f57-4b1a-4f75-a247-a3d153d01e5c
md"""

# Analysis of data contributed by Sinika Timme
-- *Phillip Alday*

"""

# ╔═╡ df9273de-28e0-42ca-8e7d-8d2fe1b9be2d
md"""
## Data loading

Including a bunch of keyword-arguments for CSV.
"""

# ╔═╡ 99546f56-7c64-4cf5-98ce-0ed48896b82c
begin
	dat = DataFrame(CSV.File("data/hexaff_all.csv";
						  comment="#",
						  delim=';',
						  missingstring=["NA",""],
						  downcast=true,
						  drop=[1,2],
						  ntasks=1, # this is due to a bug in CSV.jl-0.9 -- I'll try to get it fixed later
						  decimal=','
			))
	dropmissing!(dat, [:FS, :timepoint, :date])
end

# ╔═╡ 11cb62b7-6736-47de-8c91-67b858747004
# select(dat, Not([:FS, :HR]))

# ╔═╡ 5aa0776d-3b03-4910-a2b7-e51c7404e1ee
describe(dat)

# ╔═╡ d8d7d67a-d2aa-4fb7-8cea-f69c60de2326
md"""

## `fm1`: `timepoint` is numeric, `ID` as grouping

"""

# ╔═╡ c4a027a1-902f-48bc-8009-71653f766e8d
# fm1 = fit(MixedModel,
# 		  @formula(FS ~ 1 + timepoint + (1 + timepoint|ID)),
# 		  dat;
# 		  contrasts=Dict(:ID => Grouping()))

# ╔═╡ 88c9b542-448e-4a91-a985-24e4e8b863f5
# fm1.rePCA

# ╔═╡ 09a4adef-0d8b-4242-885b-e8dfb6d5b756
# shrinkageplot(fm1)

# ╔═╡ fab68835-d889-4bde-ad2a-80e5dc6b1983
# caterpillar(fm1)

# ╔═╡ 092c77a2-37aa-4c78-906a-322b61308b34
# VarCorr(fm1)

# ╔═╡ 9fd0c2d7-109d-4fe3-a0c6-a75839799cb7
md"""

## `fm2`: `timepoint` is numeric, `date` is categorical `ID` as grouping

"""

# ╔═╡ fd153bbb-5273-4b36-a111-2d34137b10bd
# fm2 = fit(MixedModel,
# 		  @formula(FS ~ 1 + timepoint * date + (1 + timepoint + date|ID)),
# 		  dat;
# 		  contrasts=Dict(:ID => Grouping(),
# 						 :date => HelmertCoding()))

# ╔═╡ 06703b73-e491-4112-a59d-28d2e477d0a6
# fm2.rePCA

# ╔═╡ 22e90698-2dd6-4cf3-a694-a0fabd2a0302
md"""
!!! warning
	Some planels in the shrinkage plot actually show "anti-shrinkage".
	In my experience, this is often symptomatic of a misspecified model.
"""

# ╔═╡ 60fed847-bd2c-4896-a43a-d5cca63786d3
# shrinkageplot(fm2)

# ╔═╡ d98f7985-2c65-46e4-a356-d9cb57c2b829
# qqcaterpillar(fm2)

# ╔═╡ 34151154-5ecb-4651-b519-0cb006de1d15
# VarCorr(fm2)

# ╔═╡ ea9a452a-086d-437d-9ada-47f7cbd5398c
md"""

## `fm3`: `timepoint` is numeric, `ID&date` as grouping

"""

# ╔═╡ d6887601-3f49-48b1-b527-59849fc59908
fm3 = fit(MixedModel,
		  @formula(FS ~ 1 + timepoint + (1 + timepoint|ID & date)),
		  dat;
		  contrasts=Dict(:ID => Grouping(),
						 :date => Grouping()))

# ╔═╡ 79152bfc-b75b-4aaf-bbf6-2fe14a24d315
fm3.rePCA

# ╔═╡ 5299c521-e359-4e5d-ace3-73766a323b1d
# shrinkageplot(fm3)

# ╔═╡ 2891251e-e32f-4654-9243-296f6206429c
# qqcaterpillar(fm3)

# ╔═╡ f77aa540-579e-4367-a1ab-b863a8d015d9
# VarCorr(fm3)

# ╔═╡ 0d204adc-5a4c-4276-ba83-690178bc570c
md"""

## `fm4`: `timepoint` is categorical, `ID&date` as grouping

!!! warning
	This model is probably overfit.

"""

# ╔═╡ 14b559e6-4e2a-43e3-ad92-4d90342c8835
# fm4 = fit(MixedModel,
# 		  @formula(FS ~ 1 + timepoint + zerocorr(1 + timepoint|ID & date)),
# 		  dat;
# 		  contrasts=Dict(:ID => Grouping(),
# 						 :date => Grouping(),
# 						 :timepoint => SeqDiffCoding()))

# ╔═╡ 02de86be-40ea-4b62-8e54-c7529e57fa31
# MixedModels.likelihoodratiotest(fm3, fm4)

# ╔═╡ 54e69118-d930-49ba-9bd7-afbf614dda75
# begin
# 	with_terminal() do
# 		show(fm4)
# 	end
# end

# ╔═╡ 18a6b29b-94b4-46e6-8242-45dbea143700
# aicc.([fm3, fm4])

# ╔═╡ d223139b-f209-4495-ad6a-69e91f524690
# fm4.rePCA

# ╔═╡ 2c2c3b51-426d-41ec-acad-7e6c1e6fae48
md"""
## Model Diagnostics (of `fm3`)
"""

# ╔═╡ 3198e0c5-588e-4bcd-bb62-ecba0ca129a2
fm3.optsum

# ╔═╡ 4d14f8a6-17b1-406d-8f4c-1199ee0f9966
# begin
# 	fm5 = LinearMixedModel(@formula(FS ~ 1 + timepoint + (1 + timepoint|ID & date)), dat;
# 		  contrasts=Dict(:ID => Grouping(),
# 						 :date => Grouping()))
# 	fm5.optsum.optimizer = :LN_COBYLA
# 	fit!(fm5)
# 	fm5.optsum
# end

# ╔═╡ f2a1b2d0-7bae-4ab6-a287-e42d02e01383
# scatter(fitted(fm3), response(fm3))

# ╔═╡ b16e6a8d-db29-4cc6-911b-3ebb3c8f71c0
# scatter(residuals(fm3), fitted(fm3))

# ╔═╡ ee60825b-808f-49da-9dd8-824aa85d2c76
# qqnorm(fm3)

# ╔═╡ 9f4c72f1-aa01-4666-b07b-e2fb1f0cacb3
md"""
## Things I don't really recommend but reviewers ask for
"""

# ╔═╡ fce2e257-897f-487b-b0e3-fb5942820ed2
# icc(fm3)

# ╔═╡ e4d72691-6d31-47e5-b1e0-630571988330
md"""
## Estimates and Effects (of `fm3`)
"""

# ╔═╡ e062623c-9dee-49f3-8f8a-362d0073eb60
# coefplot(fm3)

# ╔═╡ 9533ef07-6e79-4f17-8626-cc85413957b9
# boot = parametricbootstrap(MersenneTwister(42), 1000, fm3)

# ╔═╡ cb5aafb6-a724-428f-aa15-22ed30b42b08
# coefplot(boot)

# ╔═╡ 12ce0e46-fb15-4396-84d7-212c5d850423
# ridgeplot(boot)

# ╔═╡ 8f073561-8b51-4a6d-b08d-225821bf7d56
# design = Dict(:timepoint => unique(skipmissing(dat.timepoint)))

# ╔═╡ 23d494fd-52cb-4679-a186-c6d795299a97
# eff = effects(design, fm3)

# ╔═╡ fd193833-b163-4182-a85b-84085c747f71
# begin
#   # convert to 95% CIs instead of standard errors
# 	@. eff.lower = eff.FS - 1.96 * eff.err
# 	@. eff.upper = eff.FS + 1.96 * eff.err
# end

# ╔═╡ 1a36289a-4b08-4aed-adbb-de4dea5e504f
# begin
# 	plt = data(eff) * mapping(:timepoint, :FS; lower=:lower, upper=:upper) *
#       (visual(Lines) + visual(LinesFill; color=:black))
# 	draw(plt)
# end

# ╔═╡ cf4d7b94-abf0-4338-b72a-f60aaefe9a90
# begin
# 	data(dat) * mapping(:timepoint, :FS; layout=:ID) * visual(Scatter) |> draw
# end

# ╔═╡ 0aef95c5-0e48-4ff7-b8a3-58d4e8c94c0b
# begin
# 	dat2 = transform(dat, :ID => categorical; renamecols=false)
# 	dat2.fitted = fitted(fm3)
# 	# important for connecting the dots in plotting later
# 	sort!(dat2, [:date, :ID, :timepoint])
# 	describe(dat2)
# end

# ╔═╡ 6acc4e05-d650-40ca-abf9-9cccd401ed45
# begin
# 	plt2 = plt + data(dat2) * mapping(:timepoint, :FS; layout=:ID) * visual(Scatter; color=:black)
# 	# note that it's "axis" and "figure" -- each panel/facet is an axis
# 	# so each of those is width x height which means the entire figure is much bigger
# 	# but pluto has scaled it for display purposes here
# 	draw(plt2; axis=(width=150, height=150))
# end

# ╔═╡ 32d56757-1e1b-43dd-a9aa-83b5177172e9
# begin
# 	plt3 = plt2 + data(dat2) * mapping(:timepoint, :fitted; layout=:ID, color=:date) * visual(Lines)
# 	draw(plt3; axis=(width=150, height=150))
# end

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Effects = "8f03c58b-bd97-4933-a826-f71b64d2cca2"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
MixedModels = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
MixedModelsExtras = "781a26e1-49f4-409a-8f4c-c3159d78c17e"
MixedModelsMakie = "b12ae82c-6730-437f-aff9-d2c38332a376"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
AlgebraOfGraphics = "~0.5.3"
CSV = "~0.9.0"
CairoMakie = "~0.6.5"
CategoricalArrays = "~0.10.0"
DataFrames = "~1.2.2"
Effects = "~0.1.2"
MixedModels = "~4.1.1"
MixedModelsExtras = "~0.1.2"
MixedModelsMakie = "~0.3.8"
PlutoUI = "~0.7.9"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised

[[AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "1.0.1"

[[AbstractTrees]]
git-tree-sha1 = "03e0550477d86222521d254b741d470ba17ea0b5"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.3.4"

[[Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "84918055d15b3114ede17ac6a7182f68870c16f7"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.3.1"

[[AlgebraOfGraphics]]
deps = ["Colors", "Dates", "FileIO", "GLM", "GeoInterface", "GeometryBasics", "GridLayoutBase", "KernelDensity", "Loess", "Makie", "PlotUtils", "PooledArrays", "RelocatableFolders", "StatsBase", "StructArrays", "Tables"]
git-tree-sha1 = "40446e661ffe7a33c31980ec6438181daa41deff"
uuid = "cbdf2221-f076-402e-a563-3d30da359d67"
version = "0.5.3"

[[Animations]]
deps = ["Colors"]
git-tree-sha1 = "e81c509d2c8e49592413bfb0bb3b08150056c79d"
uuid = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
version = "0.4.1"

[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

[[ArrayInterface]]
deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"]
git-tree-sha1 = "019303a0f26d6012f35ecdfa4618551d145fb9f2"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.1.31"

[[Arrow]]
deps = ["ArrowTypes", "BitIntegers", "CodecLz4", "CodecZstd", "DataAPI", "Dates", "Mmap", "PooledArrays", "SentinelArrays", "Tables", "TimeZones", "UUIDs"]
git-tree-sha1 = "b00e6eaba895683867728e73af78a00218f0db10"
uuid = "69666777-d1a9-59fb-9406-91d4454c9d45"
version = "1.6.2"

[[ArrowTypes]]
deps = ["UUIDs"]
git-tree-sha1 = "a0633b6d6efabf3f76dacd6eb1b3ec6c42ab0552"
uuid = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
version = "1.2.1"

[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[Automa]]
deps = ["Printf", "ScanByte", "TranscodingStreams"]
git-tree-sha1 = "d50976f217489ce799e366d9561d56a98a30d7fe"
uuid = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b"
version = "0.8.2"

[[AxisAlgorithms]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
git-tree-sha1 = "a4d07a1c313392a77042855df46c5f534076fab9"
uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
version = "1.0.0"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BenchmarkTools]]
deps = ["JSON", "Logging", "Printf", "Statistics", "UUIDs"]
git-tree-sha1 = "42ac5e523869a84eac9669eaceed9e4aa0e1587b"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.1.4"

[[BitIntegers]]
deps = ["Random"]
git-tree-sha1 = "f50b5a99aa6ff9db7bf51255b5c21c8bc871ad54"
uuid = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1"
version = "0.2.5"

[[Bzip2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.8+0"

[[CEnum]]
git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.4.1"

[[CSV]]
deps = ["CodecZlib", "Dates", "FilePathsBase", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode", "WeakRefStrings"]
git-tree-sha1 = "24e8646b28d573b10be1c6dab18fb336846a955c"
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
version = "0.9.0"

[[Cairo]]
deps = ["Cairo_jll", "Colors", "Glib_jll", "Graphics", "Libdl", "Pango_jll"]
git-tree-sha1 = "d0b3f8b4ad16cb0a2988c6788646a5e6a17b6b1b"
uuid = "159f3aea-2a34-519c-b102-8c37f9878175"
version = "1.0.5"

[[CairoMakie]]
deps = ["Base64", "Cairo", "Colors", "FFTW", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "SHA", "StaticArrays"]
git-tree-sha1 = "8664989955daccc90002629aa80193e44893bb45"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
version = "0.6.5"

[[Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
git-tree-sha1 = "f2202b55d816427cd385a9a4f3ffb226bee80f99"
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
version = "1.16.1+0"

[[CategoricalArrays]]
deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "RecipesBase", "Statistics", "StructTypes", "Unicode"]
git-tree-sha1 = "1562002780515d2573a4fb0c3715e4e57481075e"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.10.0"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "30ee06de5ff870b45c78f529a6b093b3323256a3"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.3.1"

[[CodecBzip2]]
deps = ["Bzip2_jll", "Libdl", "TranscodingStreams"]
git-tree-sha1 = "2e62a725210ce3c3c2e1a3080190e7ca491f18d7"
uuid = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
version = "0.7.2"

[[CodecLz4]]
deps = ["Lz4_jll", "TranscodingStreams"]
git-tree-sha1 = "59fe0cb37784288d6b9f1baebddbf75457395d40"
uuid = "5ba52731-8f18-5e0d-9241-30f10d1ec561"
version = "0.4.0"

[[CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.0"

[[CodecZstd]]
deps = ["TranscodingStreams", "Zstd_jll"]
git-tree-sha1 = "d19cd9ae79ef31774151637492291d75194fc5fa"
uuid = "6b39b394-51ab-5f42-8807-6242bab2b4c2"
version = "0.7.0"

[[ColorBrewer]]
deps = ["Colors", "JSON", "Test"]
git-tree-sha1 = "61c5334f33d91e570e1d0c3eb5465835242582c4"
uuid = "a2cac450-b92f-5266-8821-25eda20663c8"
version = "0.4.0"

[[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random"]
git-tree-sha1 = "9995eb3977fbf67b86d0a0a0508e83017ded03f2"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.14.0"

[[ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "32a2b8af383f11cbb65803883837a149d10dfe8a"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.10.12"

[[ColorVectorSpace]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "LinearAlgebra", "SpecialFunctions", "Statistics", "StatsBase"]
git-tree-sha1 = "4d17724e99f357bfd32afa0a9e2dda2af31a9aea"
uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
version = "0.8.7"

[[Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
git-tree-sha1 = "417b0ed7b8b838aa6ca0a87aadf1bb9eb111ce40"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.8"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "727e463cfebd0c7b999bbf3e9e7e16f254b94193"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.34.0"

[[CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"

[[Contour]]
deps = ["StaticArrays"]
git-tree-sha1 = "9f02045d934dc030edad45944ea80dbd1f0ebea7"
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.5.7"

[[Crayons]]
git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.0.4"

[[DataAPI]]
git-tree-sha1 = "bec2532f8adb82005476c141ec23e921fc20971b"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.8.0"

[[DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "d785f42445b63fc86caa08bb9a9351008be9b765"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.2.2"

[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "7d9d316f04214f7efdbb6398d545446e246eff02"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.10"

[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[Distances]]
deps = ["LinearAlgebra", "Statistics", "StatsAPI"]
git-tree-sha1 = "9f46deb4d4ee4494ffb5a40a27a2aced67bdd838"
uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
version = "0.10.4"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[Distributions]]
deps = ["ChainRulesCore", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "f4efaa4b5157e0cdb8283ae0b5428bc9208436ed"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.16"

[[DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "a32185f5428d3986f47c2ab78b1f216d5e6cc96f"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.5"

[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[EarCut_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "3f3a2501fa7236e9b911e0f7a588c657e822bb6d"
uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
version = "2.2.3+0"

[[Effects]]
deps = ["DataFrames", "LinearAlgebra", "Statistics", "StatsBase", "StatsModels", "Tables"]
git-tree-sha1 = "989a9cb80952d2d3d36bccbe7c0001fd9ef5dfa2"
uuid = "8f03c58b-bd97-4933-a826-f71b64d2cca2"
version = "0.1.2"

[[EllipsisNotation]]
deps = ["ArrayInterface"]
git-tree-sha1 = "8041575f021cba5a099a456b4163c9a08b566a02"
uuid = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
version = "1.1.0"

[[Expat_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "b3bfd02e98aedfa5cf885665493c5598c350cd2f"
uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
version = "2.2.10+0"

[[ExprTools]]
git-tree-sha1 = "b7e3d17636b348f005f11040025ae8c6f645fe92"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.6"

[[FFMPEG]]
deps = ["FFMPEG_jll"]
git-tree-sha1 = "b57e3acbe22f8484b4b5ff66a7499717fe1a9cc8"
uuid = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
version = "0.4.1"

[[FFMPEG_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "Pkg", "Zlib_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
git-tree-sha1 = "d8a578692e3077ac998b50c0217dfd67f21d1e5f"
uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
version = "4.4.0+0"

[[FFTW]]
deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"]
git-tree-sha1 = "f985af3b9f4e278b1d24434cbb546d6092fca661"
uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
version = "1.4.3"

[[FFTW_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "3676abafff7e4ff07bbd2c42b3d8201f31653dcc"
uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a"
version = "3.3.9+8"

[[FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "937c29268e405b6808d958a9ac41bfe1a31b08e7"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.11.0"

[[FilePathsBase]]
deps = ["Dates", "Mmap", "Printf", "Test", "UUIDs"]
git-tree-sha1 = "0f5e8d0cb91a6386ba47bd1527b240bd5725fbae"
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
version = "0.9.10"

[[FillArrays]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"]
git-tree-sha1 = "a3b7b041753094f3b17ffa9d2e2e07d8cace09cd"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.12.3"

[[FixedPointNumbers]]
deps = ["Statistics"]
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.8.4"

[[Fontconfig_jll]]
deps = ["Artifacts", "Bzip2_jll", "Expat_jll", "FreeType2_jll", "JLLWrappers", "Libdl", "Libuuid_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "21efd19106a55620a188615da6d3d06cd7f6ee03"
uuid = "a3f928ae-7b40-5064-980b-68af3947d34b"
version = "2.13.93+0"

[[Formatting]]
deps = ["Printf"]
git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.2"

[[FreeType]]
deps = ["CEnum", "FreeType2_jll"]
git-tree-sha1 = "cabd77ab6a6fdff49bfd24af2ebe76e6e018a2b4"
uuid = "b38be410-82b0-50bf-ab77-7b57e271db43"
version = "4.0.0"

[[FreeType2_jll]]
deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "87eb71354d8ec1a96d4a7636bd57a7347dde3ef9"
uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7"
version = "2.10.4+0"

[[FreeTypeAbstraction]]
deps = ["ColorVectorSpace", "Colors", "FreeType", "GeometryBasics", "StaticArrays"]
git-tree-sha1 = "19d0f1e234c13bbfd75258e55c52aa1d876115f5"
uuid = "663a7486-cb36-511b-a19d-713bb74d65c9"
version = "0.9.2"

[[FriBidi_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "aa31987c2ba8704e23c6c8ba8a4f769d5d7e4f91"
uuid = "559328eb-81f9-559d-9380-de523a88c83c"
version = "1.0.10+0"

[[Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[GLM]]
deps = ["Distributions", "LinearAlgebra", "Printf", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "StatsModels"]
git-tree-sha1 = "f564ce4af5e79bb88ff1f4488e64363487674278"
uuid = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
version = "1.5.1"

[[GeoInterface]]
deps = ["RecipesBase"]
git-tree-sha1 = "38a649e6a52d1bea9844b382343630ac754c931c"
uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
version = "0.5.5"

[[GeometryBasics]]
deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "58bcdf5ebc057b085e58d95c138725628dd7453c"
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
version = "0.4.1"

[[Gettext_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
uuid = "78b55507-aeef-58d4-861c-77aaff3498b1"
version = "0.21.0+0"

[[Glib_jll]]
deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "7bf67e9a481712b3dbe9cb3dac852dc4b1162e02"
uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
version = "2.68.3+0"

[[Graphics]]
deps = ["Colors", "LinearAlgebra", "NaNMath"]
git-tree-sha1 = "2c1cf4df419938ece72de17f368a021ee162762e"
uuid = "a2bd30eb-e257-5431-a919-1863eab51364"
version = "1.1.0"

[[Graphite2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "344bf40dcab1073aca04aa0df4fb092f920e4011"
uuid = "3b182d85-2403-5c21-9c21-1e1f0cc25472"
version = "1.3.14+0"

[[GridLayoutBase]]
deps = ["GeometryBasics", "InteractiveUtils", "Match", "Observables"]
git-tree-sha1 = "e2f606c87d09d5187bb6069dab8cee0af7c77bdb"
uuid = "3955a311-db13-416c-9275-1d80ed98e5e9"
version = "0.6.1"

[[Grisu]]
git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.2"

[[HarfBuzz_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
git-tree-sha1 = "8a954fed8ac097d5be04921d595f741115c1b2ad"
uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
version = "2.8.1+0"

[[IfElse]]
git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef"
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
version = "0.1.0"

[[ImageCore]]
deps = ["AbstractFFTs", "Colors", "FixedPointNumbers", "Graphics", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "Reexport"]
git-tree-sha1 = "db645f20b59f060d8cfae696bc9538d13fd86416"
uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534"
version = "0.8.22"

[[ImageIO]]
deps = ["FileIO", "Netpbm", "PNGFiles"]
git-tree-sha1 = "0d6d09c28d67611c68e25af0c2df7269c82b73c7"
uuid = "82e4d734-157c-48bb-816b-45c225c6df19"
version = "0.4.1"

[[IndirectArrays]]
git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f"
uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
version = "1.0.0"

[[IntelOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "d979e54b71da82f3a65b62553da4fc3d18c9004c"
uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0"
version = "2018.0.3+2"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Interpolations]]
deps = ["AxisAlgorithms", "ChainRulesCore", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "Requires", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"]
git-tree-sha1 = "61aa005707ea2cebf47c8d780da8dc9bc4e0c512"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.13.4"

[[IntervalSets]]
deps = ["Dates", "EllipsisNotation", "Statistics"]
git-tree-sha1 = "3cc368af3f110a767ac786560045dceddfc16758"
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
version = "0.5.3"

[[InvertedIndices]]
git-tree-sha1 = "bee5f1ef5bf65df56bdd2e40447590b272a5471f"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.1.0"

[[IrrationalConstants]]
git-tree-sha1 = "f76424439413893a832026ca355fe273e93bce94"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.1.0"

[[Isoband]]
deps = ["isoband_jll"]
git-tree-sha1 = "f9b6d97355599074dc867318950adaa6f9946137"
uuid = "f1662d9f-8043-43de-a69a-05efc1cc6ff4"
version = "0.1.1"

[[IterTools]]
git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18"
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
version = "1.3.0"

[[IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"

[[JLLWrappers]]
deps = ["Preferences"]
git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.3.0"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.2"

[[JSON3]]
deps = ["Dates", "Mmap", "Parsers", "StructTypes", "UUIDs"]
git-tree-sha1 = "b3e5984da3c6c95bcf6931760387ff2e64f508f3"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.9.1"

[[KernelDensity]]
deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"]
git-tree-sha1 = "591e8dc09ad18386189610acafb970032c519707"
uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
version = "0.6.3"

[[LAME_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "f6250b16881adf048549549fba48b1161acdac8c"
uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d"
version = "3.100.1+0"

[[LZO_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e5b909bcf985c5e2605737d2ce278ed791b89be6"
uuid = "dd4b983a-f0e5-5f8d-a1b7-129d4a5fb1ac"
version = "2.10.1+0"

[[LaTeXStrings]]
git-tree-sha1 = "c7f1c695e06c01b95a67f0cd1d34994f3e7db104"
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
version = "1.2.1"

[[LazyArtifacts]]
deps = ["Artifacts", "Pkg"]
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"

[[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"

[[LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[Libffi_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "761a393aeccd6aa92ec3515e428c26bf99575b3b"
uuid = "e9f186c6-92d2-5b65-8a66-fee21dc1b490"
version = "3.2.2+0"

[[Libgcrypt_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgpg_error_jll", "Pkg"]
git-tree-sha1 = "64613c82a59c120435c067c2b809fc61cf5166ae"
uuid = "d4300ac3-e22c-5743-9152-c294e39db1e4"
version = "1.8.7+0"

[[Libgpg_error_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "c333716e46366857753e273ce6a69ee0945a6db9"
uuid = "7add5ba3-2f88-524e-9cd5-f83b8a55f7b8"
version = "1.42.0+0"

[[Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "42b62845d70a619f063a7da093d995ec8e15e778"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.16.1+1"

[[Libmount_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "9c30530bf0effd46e15e0fdcf2b8636e78cbbd73"
uuid = "4b2f31a3-9ecc-558c-b454-b3730dcb73e9"
version = "2.35.0+0"

[[Libuuid_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "7f3efec06033682db852f8b3bc3c1d2b0a0ab066"
uuid = "38a345b3-de98-5d2b-a5d3-14cd9215e700"
version = "2.36.0+0"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Loess]]
deps = ["Distances", "LinearAlgebra", "Statistics"]
git-tree-sha1 = "b5254a86cf65944c68ed938e575f5c81d5dfe4cb"
uuid = "4345ca2d-374a-55d4-8d30-97f9976e7612"
version = "0.5.3"

[[LogExpFunctions]]
deps = ["ChainRulesCore", "DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "86197a8ecb06e222d66797b0c2d2f0cc7b69e42b"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.2"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Lz4_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "5d494bc6e85c4c9b626ee0cab05daa4085486ab1"
uuid = "5ced341a-0733-55b8-9ab6-a4889d929147"
version = "1.9.3+0"

[[MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
git-tree-sha1 = "c253236b0ed414624b083e6b72bfe891fbd2c7af"
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
version = "2021.1.1+1"

[[Makie]]
deps = ["Animations", "Base64", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "Distributions", "DocStringExtensions", "FFMPEG", "FileIO", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "IntervalSets", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MakieCore", "Markdown", "Match", "MathTeXEngine", "Observables", "Packing", "PlotUtils", "PolygonOps", "Printf", "Random", "RelocatableFolders", "Serialization", "Showoff", "SignedDistanceFields", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "UnicodeFun"]
git-tree-sha1 = "7e49f989e7c7f50fe55bd92d45329c9cf3f2583d"
uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
version = "0.15.2"

[[MakieCore]]
deps = ["Observables"]
git-tree-sha1 = "7bcc8323fb37523a6a51ade2234eee27a11114c8"
uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
version = "0.1.3"

[[MappedArrays]]
git-tree-sha1 = "e8b359ef06ec72e8c030463fe02efe5527ee5142"
uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
version = "0.4.1"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Match]]
git-tree-sha1 = "5cf525d97caf86d29307150fcba763a64eaa9cbe"
uuid = "7eb4fadd-790c-5f42-8a69-bfa0b872bfbf"
version = "1.1.0"

[[MathOptInterface]]
deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "JSON", "LinearAlgebra", "MutableArithmetics", "OrderedCollections", "Printf", "SparseArrays", "Test", "Unicode"]
git-tree-sha1 = "debba84c7060716b0737504b59aabe976c9b91cb"
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
version = "0.10.0"

[[MathProgBase]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "9abbe463a1e9fc507f12a69e7f29346c2cdc472c"
uuid = "fdba3010-5040-5b88-9595-932c9decdf73"
version = "0.7.8"

[[MathTeXEngine]]
deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "Test"]
git-tree-sha1 = "f5c8789464aed7058107463e5cef53e6ad3f1f3e"
uuid = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
version = "0.2.0"

[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"

[[Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "2ca267b08821e86c5ef4376cffed98a46c2cb205"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "1.0.1"

[[MixedModels]]
deps = ["Arrow", "DataAPI", "Distributions", "GLM", "JSON3", "LazyArtifacts", "LinearAlgebra", "Markdown", "NLopt", "PooledArrays", "ProgressMeter", "Random", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "StatsFuns", "StatsModels", "StructTypes", "Tables"]
git-tree-sha1 = "f318e42a48ec0a856292bafeec6b07aed3f6d600"
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
version = "4.1.1"

[[MixedModelsExtras]]
deps = ["MixedModels", "Statistics", "StatsBase"]
git-tree-sha1 = "3b01c97c288924fd67958ab12b8a5ea541edc5e5"
uuid = "781a26e1-49f4-409a-8f4c-c3159d78c17e"
version = "0.1.2"

[[MixedModelsMakie]]
deps = ["DataFrames", "Distributions", "KernelDensity", "LinearAlgebra", "Makie", "MixedModels", "Printf", "SpecialFunctions", "StatsBase"]
git-tree-sha1 = "e2ae99b3b4675ddc91e9c421a775eff52a784696"
uuid = "b12ae82c-6730-437f-aff9-d2c38332a376"
version = "0.3.8"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Mocking]]
deps = ["ExprTools"]
git-tree-sha1 = "748f6e1e4de814b101911e64cc12d83a6af66782"
uuid = "78c3b35d-d492-501b-9361-3d52fe80e533"
version = "0.7.2"

[[MosaicViews]]
deps = ["MappedArrays", "OffsetArrays", "PaddedViews", "StackViews"]
git-tree-sha1 = "b34e3bc3ca7c94914418637cb10cc4d1d80d877d"
uuid = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
version = "0.3.3"

[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[MutableArithmetics]]
deps = ["LinearAlgebra", "SparseArrays", "Test"]
git-tree-sha1 = "3927848ccebcc165952dc0d9ac9aa274a87bfe01"
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
version = "0.2.20"

[[NLopt]]
deps = ["MathOptInterface", "MathProgBase", "NLopt_jll"]
git-tree-sha1 = "f115030b9325ca09ef1619ba0617b2a64101ce84"
uuid = "76087f3c-5699-56af-9a33-bf431cd00edd"
version = "0.6.4"

[[NLopt_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "2b597c46900f5f811bec31f0dcc88b45744a2a09"
uuid = "079eb43e-fd8e-5478-9966-2cf3e3edb778"
version = "2.7.0+0"

[[NaNMath]]
git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.5"

[[Netpbm]]
deps = ["ColorVectorSpace", "FileIO", "ImageCore"]
git-tree-sha1 = "09589171688f0039f13ebe0fdcc7288f50228b52"
uuid = "f09324ee-3d7c-5217-9330-fc30815ba969"
version = "1.0.1"

[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[Observables]]
git-tree-sha1 = "fe29afdef3d0c4a8286128d4e45cc50621b1e43d"
uuid = "510215fc-4207-5dde-b226-833fc4488ee2"
version = "0.4.0"

[[OffsetArrays]]
deps = ["Adapt"]
git-tree-sha1 = "c870a0d713b51e4b49be6432eff0e26a4325afee"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.10.6"

[[Ogg_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "7937eda4681660b4d6aeeecc2f7e1c81c8ee4e2f"
uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051"
version = "1.3.5+0"

[[OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "15003dcb7d8db3c6c857fda14891a539a8f2705a"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "1.1.10+0"

[[OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
version = "0.5.5+0"

[[Opus_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "51a08fb14ec28da2ec7a927c4337e4332c2a4720"
uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.2+0"

[[OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"

[[PCRE_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "b2a7af664e098055a7529ad1a900ded962bca488"
uuid = "2f80f16e-611a-54ab-bc61-aa92de5b98fc"
version = "8.44.0+0"

[[PDMats]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "4dd403333bcf0909341cfe57ec115152f937d7d8"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.11.1"

[[PNGFiles]]
deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"]
git-tree-sha1 = "e14c485f6beee0c7a8dcf6128bf70b85f1fe201e"
uuid = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
version = "0.3.9"

[[Packing]]
deps = ["GeometryBasics"]
git-tree-sha1 = "1155f6f937fa2b94104162f01fa400e192e4272f"
uuid = "19eb6ba3-879d-56ad-ad62-d5c202156566"
version = "0.4.2"

[[PaddedViews]]
deps = ["OffsetArrays"]
git-tree-sha1 = "646eed6f6a5d8df6708f15ea7e02a7a2c4fe4800"
uuid = "5432bcbf-9aad-5242-b902-cca2824c8663"
version = "0.5.10"

[[Pango_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "FriBidi_jll", "Glib_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "9bc1871464b12ed19297fbc56c4fb4ba84988b0d"
uuid = "36c8627f-9965-5494-a995-c6b170f724f3"
version = "1.47.0+0"

[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "438d35d2d95ae2c5e8780b330592b6de8494e779"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.0.3"

[[Pixman_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "b4f5d02549a10e20780a24fce72bea96b6329e29"
uuid = "30392449-352a-5448-841d-b1acce4e97dc"
version = "0.40.1+0"

[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "9ff1c70190c1c30aebca35dc489f7411b256cd23"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.0.13"

[[PlutoUI]]
deps = ["Base64", "Dates", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "Suppressor"]
git-tree-sha1 = "44e225d5837e2a2345e69a1d1e01ac2443ff9fcb"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
version = "0.7.9"

[[PolygonOps]]
git-tree-sha1 = "c031d2332c9a8e1c90eca239385815dc271abb22"
uuid = "647866c9-e3ac-4575-94e7-e3d426903924"
version = "0.1.1"

[[PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "a193d6ad9c45ada72c14b731a318bedd3c2f00cf"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.3.0"

[[Preferences]]
deps = ["TOML"]
git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.2.2"

[[PrettyTables]]
deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"]
git-tree-sha1 = "0d1245a357cc61c8cd61934c07447aa569ff22e6"
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
version = "1.1.0"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[ProgressMeter]]
deps = ["Distributed", "Printf"]
git-tree-sha1 = "afadeba63d90ff223a6a48d2009434ecee2ec9e8"
uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "1.7.1"

[[QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "12fbe86da16df6679be7521dfb39fbc861e1dc7b"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.4.1"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Ratios]]
deps = ["Requires"]
git-tree-sha1 = "7dff99fbc740e2f8228c6878e2aad6d7c2678098"
uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
version = "0.4.1"

[[RecipesBase]]
git-tree-sha1 = "44a75aa7a527910ee3d1751d1f0e4148698add9e"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.1.2"

[[Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"

[[RelocatableFolders]]
deps = ["SHA", "Scratch"]
git-tree-sha1 = "0529f4188bc8efee85a7e580aca1c7dff6b103f8"
uuid = "05181044-ff0b-4ac5-8273-598c1e38db00"
version = "0.1.0"

[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"

[[Rmath]]
deps = ["Random", "Rmath_jll"]
git-tree-sha1 = "bf3188feca147ce108c76ad82c2792c57abe7b1f"
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
version = "0.7.0"

[[Rmath_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "68db32dff12bb6127bac73c209881191bf0efbb7"
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
version = "0.3.0+0"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[SIMD]]
git-tree-sha1 = "9ba33637b24341aba594a2783a502760aa0bff04"
uuid = "fdea26ae-647d-5447-a871-4b548cad5224"
version = "3.3.1"

[[ScanByte]]
deps = ["Libdl", "SIMD"]
git-tree-sha1 = "9cc2955f2a254b18be655a4ee70bc4031b2b189e"
uuid = "7b38b023-a4d7-4c5e-8d43-3f3097f304eb"
version = "0.3.0"

[[Scratch]]
deps = ["Dates"]
git-tree-sha1 = "0b4b7f1393cff97c33891da2a0bf69c6ed241fda"
uuid = "6c6a2e73-6563-6170-7368-637461726353"
version = "1.1.0"

[[SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "54f37736d8934a12a200edea2f9206b03bdf3159"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.3.7"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[ShiftedArrays]]
git-tree-sha1 = "22395afdcf37d6709a5a0766cc4a5ca52cb85ea0"
uuid = "1277b4bf-5013-50f5-be3d-901d8477a67a"
version = "1.0.0"

[[Showoff]]
deps = ["Dates", "Grisu"]
git-tree-sha1 = "91eddf657aca81df9ae6ceb20b959ae5653ad1de"
uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
version = "1.0.3"

[[SignedDistanceFields]]
deps = ["Random", "Statistics", "Test"]
git-tree-sha1 = "d263a08ec505853a5ff1c1ebde2070419e3f28e9"
uuid = "73760f76-fbc4-59ce-8f25-708e95d2df96"
version = "0.4.0"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SortingAlgorithms]]
deps = ["DataStructures"]
git-tree-sha1 = "b3363d7460f7d098ca0912c69b082f75625d7508"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "1.0.1"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[SpecialFunctions]]
deps = ["ChainRulesCore", "LogExpFunctions", "OpenSpecFun_jll"]
git-tree-sha1 = "a322a9493e49c5f3a10b50df3aedaf1cdb3244b7"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "1.6.1"

[[StackViews]]
deps = ["OffsetArrays"]
git-tree-sha1 = "46e589465204cd0c08b4bd97385e4fa79a0c770c"
uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15"
version = "0.1.1"

[[Static]]
deps = ["IfElse"]
git-tree-sha1 = "854b024a4a81b05c0792a4b45293b85db228bd27"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.3.1"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "3240808c6d463ac46f1c1cd7638375cd22abbccb"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.12"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[StatsAPI]]
git-tree-sha1 = "1958272568dc176a1d881acb797beb909c785510"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.0.0"

[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "8cbbc098554648c84f79a463c9ff0fd277144b6c"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.10"

[[StatsFuns]]
deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
git-tree-sha1 = "46d7ccc7104860c38b11966dd1f72ff042f382e4"
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
version = "0.9.10"

[[StatsModels]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Printf", "ShiftedArrays", "SparseArrays", "StatsBase", "StatsFuns", "Tables"]
git-tree-sha1 = "3fa15c1f8be168e76d59097f66970adc86bfeb95"
uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
version = "0.6.25"

[[StructArrays]]
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
git-tree-sha1 = "1700b86ad59348c0f9f68ddc95117071f947072d"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.6.1"

[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "8445bf99a36d703a09c601f9a57e2f83000ef2ae"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.7.3"

[[SuiteSparse]]
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"

[[Suppressor]]
git-tree-sha1 = "a819d77f31f83e5792a76081eee1ea6342ab8787"
uuid = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
version = "0.2.0"

[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[[TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"

[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "368d04a820fe069f9080ff1b432147a6203c3c89"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.5.1"

[[Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TimeZones]]
deps = ["Dates", "Future", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "6c9040665b2da00d30143261aea22c7427aada1c"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.5.7"

[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.6"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[UnicodeFun]]
deps = ["REPL"]
git-tree-sha1 = "53915e50200959667e78a92a418594b428dffddf"
uuid = "1cfade01-22cf-5700-b092-accc4b62d6e1"
version = "0.4.1"

[[WeakRefStrings]]
deps = ["DataAPI", "Parsers", "Random", "Serialization", "Test"]
git-tree-sha1 = "4cd606838f91a9c3c7404df41173e132bdb09e82"
uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
version = "1.2.2"

[[WoodburyMatrices]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "59e2ad8fd1591ea019a5259bd012d7aee15f995c"
uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
version = "0.5.3"

[[XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "1acf5bdf07aa0907e0a37d3718bb88d4b687b74a"
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
version = "2.9.12+0"

[[XSLT_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "Pkg", "XML2_jll", "Zlib_jll"]
git-tree-sha1 = "91844873c4085240b95e795f692c4cec4d805f8a"
uuid = "aed1982a-8fda-507f-9586-7b0439959a61"
version = "1.1.34+0"

[[Xorg_libX11_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
git-tree-sha1 = "5be649d550f3f4b95308bf0183b82e2582876527"
uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc"
version = "1.6.9+4"

[[Xorg_libXau_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4e490d5c960c314f33885790ed410ff3a94ce67e"
uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec"
version = "1.0.9+4"

[[Xorg_libXdmcp_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4fe47bd2247248125c428978740e18a681372dd4"
uuid = "a3789734-cfe1-5b06-b2d0-1dd0d9d62d05"
version = "1.1.3+4"

[[Xorg_libXext_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
git-tree-sha1 = "b7c0aa8c376b31e4852b360222848637f481f8c3"
uuid = "1082639a-0dae-5f34-9b06-72781eeb8cb3"
version = "1.3.4+4"

[[Xorg_libXrender_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libX11_jll"]
git-tree-sha1 = "19560f30fd49f4d4efbe7002a1037f8c43d43b96"
uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa"
version = "0.9.10+4"

[[Xorg_libpthread_stubs_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "6783737e45d3c59a4a4c4091f5f88cdcf0908cbb"
uuid = "14d82f49-176c-5ed1-bb49-ad3f5cbd8c74"
version = "0.1.0+3"

[[Xorg_libxcb_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"]
git-tree-sha1 = "daf17f441228e7a3833846cd048892861cff16d6"
uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b"
version = "1.13.0+3"

[[Xorg_xtrans_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "79c31e7844f6ecf779705fbc12146eb190b7d845"
uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10"
version = "1.4.0+3"

[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"

[[Zstd_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "cc4bf3fdde8b7e3e9fa0351bdeedba1cf3b7f6e6"
uuid = "3161d3a3-bdf6-5164-811a-617609db77b4"
version = "1.5.0+0"

[[isoband_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "a1ac99674715995a536bbce674b068ec1b7d893d"
uuid = "9a68df92-36a6-505f-a73e-abb412b6bfb4"
version = "0.2.2+0"

[[libass_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "5982a94fcba20f02f42ace44b9894ee2b140fe47"
uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0"
version = "0.15.1+0"

[[libfdk_aac_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "daacc84a041563f965be61859a36e17c4e4fcd55"
uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280"
version = "2.0.2+0"

[[libpng_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "94d180a6d2b5e55e447e2d27a29ed04fe79eb30c"
uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f"
version = "1.6.38+0"

[[libvorbis_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"]
git-tree-sha1 = "c45f4e40e7aafe9d086379e5578947ec8b95a8fb"
uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a"
version = "1.3.7+0"

[[nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"

[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"

[[x264_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4fea590b89e6ec504593146bf8b988b2c00922b2"
uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a"
version = "2021.5.5+0"

[[x265_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "ee567a171cce03570d77ad3a43e90218e38937a9"
uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76"
version = "3.5.0+0"
"""

# ╔═╡ Cell order:
# ╟─16199f57-4b1a-4f75-a247-a3d153d01e5c
# ╠═5d7dc2d4-1008-11ec-2ea6-ffc13cf6dbf7
# ╟─df9273de-28e0-42ca-8e7d-8d2fe1b9be2d
# ╠═99546f56-7c64-4cf5-98ce-0ed48896b82c
# ╠═11cb62b7-6736-47de-8c91-67b858747004
# ╠═5aa0776d-3b03-4910-a2b7-e51c7404e1ee
# ╟─d8d7d67a-d2aa-4fb7-8cea-f69c60de2326
# ╠═c4a027a1-902f-48bc-8009-71653f766e8d
# ╠═88c9b542-448e-4a91-a985-24e4e8b863f5
# ╠═09a4adef-0d8b-4242-885b-e8dfb6d5b756
# ╠═fab68835-d889-4bde-ad2a-80e5dc6b1983
# ╠═092c77a2-37aa-4c78-906a-322b61308b34
# ╟─9fd0c2d7-109d-4fe3-a0c6-a75839799cb7
# ╠═fd153bbb-5273-4b36-a111-2d34137b10bd
# ╠═06703b73-e491-4112-a59d-28d2e477d0a6
# ╟─22e90698-2dd6-4cf3-a694-a0fabd2a0302
# ╠═60fed847-bd2c-4896-a43a-d5cca63786d3
# ╠═d98f7985-2c65-46e4-a356-d9cb57c2b829
# ╠═34151154-5ecb-4651-b519-0cb006de1d15
# ╟─ea9a452a-086d-437d-9ada-47f7cbd5398c
# ╠═d6887601-3f49-48b1-b527-59849fc59908
# ╠═79152bfc-b75b-4aaf-bbf6-2fe14a24d315
# ╠═5299c521-e359-4e5d-ace3-73766a323b1d
# ╠═2891251e-e32f-4654-9243-296f6206429c
# ╠═f77aa540-579e-4367-a1ab-b863a8d015d9
# ╟─0d204adc-5a4c-4276-ba83-690178bc570c
# ╠═14b559e6-4e2a-43e3-ad92-4d90342c8835
# ╠═02de86be-40ea-4b62-8e54-c7529e57fa31
# ╠═54e69118-d930-49ba-9bd7-afbf614dda75
# ╠═18a6b29b-94b4-46e6-8242-45dbea143700
# ╠═d223139b-f209-4495-ad6a-69e91f524690
# ╟─2c2c3b51-426d-41ec-acad-7e6c1e6fae48
# ╠═3198e0c5-588e-4bcd-bb62-ecba0ca129a2
# ╠═4d14f8a6-17b1-406d-8f4c-1199ee0f9966
# ╠═f2a1b2d0-7bae-4ab6-a287-e42d02e01383
# ╠═b16e6a8d-db29-4cc6-911b-3ebb3c8f71c0
# ╠═ee60825b-808f-49da-9dd8-824aa85d2c76
# ╟─9f4c72f1-aa01-4666-b07b-e2fb1f0cacb3
# ╠═fce2e257-897f-487b-b0e3-fb5942820ed2
# ╟─e4d72691-6d31-47e5-b1e0-630571988330
# ╠═e062623c-9dee-49f3-8f8a-362d0073eb60
# ╠═9533ef07-6e79-4f17-8626-cc85413957b9
# ╠═cb5aafb6-a724-428f-aa15-22ed30b42b08
# ╠═12ce0e46-fb15-4396-84d7-212c5d850423
# ╠═8f073561-8b51-4a6d-b08d-225821bf7d56
# ╠═23d494fd-52cb-4679-a186-c6d795299a97
# ╠═fd193833-b163-4182-a85b-84085c747f71
# ╠═1a36289a-4b08-4aed-adbb-de4dea5e504f
# ╠═cf4d7b94-abf0-4338-b72a-f60aaefe9a90
# ╠═0aef95c5-0e48-4ff7-b8a3-58d4e8c94c0b
# ╠═6acc4e05-d650-40ca-abf9-9cccd401ed45
# ╠═32d56757-1e1b-43dd-a9aa-83b5177172e9
# ╠═78090450-7373-4824-bfe9-1283e971dda0
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002


text:
"""
    F = JopNormalize(spc, c)

where `F` is the 'normalize by maximuam value of integral' operator F(t) = x(t) / int_0^T [ x(t) dt ]
Note the integration is along the 1st (fastest) dimension.
"""
function JopNormalize(spc::JetSpace{T}; α=1.0) where {T}
    tmp1 = zeros(spc)
    tmp2 = zeros(spc)
    A = JopLeakyIntegration(spc, α=α)
    JopNl(dom = spc, rng = spc, f! = JopNormalize_f!, df! = JopNormalize_df!, df′! = JopNormalize_df′!, s = (tmp1=tmp1, tmp2=tmp2, A=A))
end
export JopNormalize

function JopNormalize_f!(d::AbstractArray, m::AbstractArray; tmp1, tmp2, A)
    d .= m ./ sum(m, dims=1)
end

# For normalized integral method:
#   f   = I[m] / I_t[m]
#   df  = [ I[m]' I_t[m] - I[m] I_t[m]' ] / I_t[m]^2
#   df  = (I_t[m] I[dm] - I_t[dm] I[m]) / (I_t[m])^2
#   dfᵀ = (I_t[m] Iᵀ[δd] - I_tᵀ[mᵀ Iᵀ δd]) / (I_t[m])^2
#
# For normalization only:
#   f   = m / I_t[m]
#   df  = [ m' I_t[m] - m I_t[m]' ] / I_t[m]^2
#   df  = ( I_t[m] dm - I_t[dm] m) / (I_t[m])^2
#   dfᵀ = (I_t[m] δd - I_tᵀ[mᵀ δd]) / (I_t[m])^2

function JopNormalize_df!(δd::AbstractArray{T}, δm::AbstractArray{T}; mₒ, tmp1, tmp2, A) where {T}
    δd .= (sum(mₒ,dims=1) .* δm .- sum(δm,dims=1) .* mₒ) ./ sum(mₒ,dims=1).^2
end

function JopNormalize_df′!(δm::AbstractArray{T}, δd::AbstractArray{T}; mₒ, tmp1, tmp2, A) where {T}
    δm .= conj.((sum(mₒ,dims=1) .* conj.(δd) .- sum(mₒ .* conj.(δd),dims=1)) ./ sum(mₒ,dims=1).^2)
end

ext: jl


text:
module GLMPriors

using SparseArrays, LinearAlgebra

export ridge_prior, smoothing_prior, null_prior, get_prior!, get_lambda, nlambda
export allocate_prior, AbstractPrior

const SPMat = SparseMatrixCSC{Float64,Int}
# ============================================================================ #
abstract type AbstractPrior{N,T} end
struct GLMPrior{N,T} <: AbstractPrior{N,T}
    d::SPMat
    filter_len::NTuple{N,Int}
    lambda::NTuple{T,Vector{Float64}}
    lambda_len::NTuple{T,Int}
end
function GLMPrior{N,T}(d::SPMat, x::NTuple{N,<:Integer},
    lm::NTuple{T,AbstractVector{<:Real}}) where {N,T}
    if ((T < N) && T != 1)
        error("Invalid number of lambda parameters")
    elseif T >= N
        T2 = N
    else
        T2 = T
    end

    return GLMPrior{N,T2}(d, x, lm[1:T2], map(length, lm[1:T2]))
end
# ============================================================================ #
struct NullPrior{N} <: AbstractPrior{N, 0}
    filter_len::NTuple{N,Int}
end
# ============================================================================ #
struct LassoPrior{N,T} <: AbstractPrior{N,T}
    filter_len::NTuple{N,Int}
    lambda::NTuple{T,Vector{Float64}}
    lambda_len::NTuple{T,Int}
end
struct Lasso{T<:Real}
    x::Vector{T}
end
Base.:*(v::AbstractArray{<:Number}, l::Lasso) = sign.(v) .* reshape(l.x, size(v))
Base.:*(l::Lasso, v::AbstractArray{<:Number}) = sign.(v) .* reshape(l.x, size(v))
# ============================================================================ #
@inline nlambda(gp::GLMPrior{N,T}) where {N,T} = T
@inline nlambda(gp::NullPrior) = 0
@inline nlambda(gp::LassoPrior{N,T}) where {N,T} = T
# ---------------------------------------------------------------------------- #
@inline Base.length(gp::AbstractPrior) = prod(gp.lambda_len)
@inline Base.length(gp::NullPrior) = 1
# ---------------------------------------------------------------------------- #
function get_prior!(x::SPMat, gp::NullPrior, k::Integer)
    knz = findall(!iszero, x)
    x[knz] .= 0.0
    return x
end
# ---------------------------------------------------------------------------- #
function get_prior!(x::SPMat, gp::GLMPrior{N,T}, k::Integer) where {N,T}
    kstart = 0
    kend = 1

    kp = CartesianIndices(gp.lambda_len)[k]
    inc = 1
    for kl in (T < N ? fill(1, N) : 1:N)
        kstart = kend + 1
        kend = kstart + gp.filter_len[inc] - 1
        slice = kstart:kend
        x[:, slice] .= gp.d[:, slice] .* gp.lambda[kl][kp[kl]]
        inc += 1
    end
    return x
end
# ---------------------------------------------------------------------------- #
function get_prior!(l::Lasso, gp::LassoPrior{N,T}, k::Integer) where {N,T}
    kstart = 0
    kend = 1

    kp = CartesianIndices(gp.lambda_len)[k]
    inc = 1
    for kl in (T < N ? fill(1, N) : 1:N)
        kstart = kend + 1
        kend = kstart + gp.filter_len[inc] - 1
        slice = kstart:kend
        l.x[slice] .= gp.lambda[kl][kp[kl]]
        inc += 1
    end
    return l
end
# ---------------------------------------------------------------------------- #
function allocate_prior(gp::AbstractPrior)
    n = sum(gp.filter_len)+1
    return spzeros(n, n)
end
# ---------------------------------------------------------------------------- #
function allocate_prior(gp::LassoPrior)
    n = sum(gp.filter_len)+1
    return Lasso(zeros(n))
end
# ---------------------------------------------------------------------------- #
function get_lambda(gp::AbstractPrior, k::Integer)
    kp = CartesianIndices(gp.lambda_len)[k]
    out = Vector{Float64}(undef, length(gp.lambda))
    for k in eachindex(out)
        out[k] = gp.lambda[k][kp[k]]
    end
    return out
end
get_lambda(gp::NullPrior, k::Integer) = [0.0]
# ============================================================================ #
@inline null_prior(x::NTuple{N,<:Integer}) where N = NullPrior(x)
# ---------------------------------------------------------------------------- #
function ridge_prior(x::NTuple{N,<:Integer},
    lm::NTuple{T,AbstractVector{<:Real}}) where {N,T}
    n = sum(x)
    return GLMPrior{N,T}(blockdiag(spzeros(1,1), sparse(I, n, n)), x, lm)
end
# ---------------------------------------------------------------------------- #
function smoothing_prior(x::NTuple{N,<:Integer},
    lm::NTuple{T,AbstractVector{<:Real}}) where {N,T}

    tmp = Vector{SparseMatrixCSC}(undef, length(x))
    for k in eachindex(x)
        d = spdiagm(0 => fill(-1.0, x[k]), 1 => fill(1.0, x[k]-1))
        tmp[k] = d'*d
        tmp[k][end,end] = 1.0
    end
    bd = blockdiag(spzeros(1,1), tmp...)
    return GLMPrior{N,T}(blockdiag(spzeros(1,1), tmp...), x, lm)
end
# ---------------------------------------------------------------------------- #
function lasso_prior(x::NTuple{N,<:Integer},
    lm::NTuple{T,AbstractVector{<:Real}}) where {N,T}

    return LassoPrior(x, map(collect, lm), map(length, lm))
end
# ============================================================================ #
end


text:
"""
    Pkg NSG
---
# Objectives
This package is to organize genotypes of NSG sheep on various platforms.
The functions include:

1. Management of raw genotypes
2. Data QC to filter out low quality ID and/or loci
3. Imputation of sparser platforms to denser ones.
4. Calculation of a **G** matrix with imputed genotypes

This package was written only for Linux OS
"""
module NSG

work_dir = pwd()                # all data and results are relative to work_dir
bin_dir, cpp_dir = begin
    t = splitdir(pathof(NSG))[1]
    l = findlast('/', t) - 1
    joinpath(t[1:l], "bin"), joinpath(t[1:l], "src")
end
beagle = joinpath(bin_dir, "beagle.jar")
plink = joinpath(bin_dir, "plink")
global nsNe = 100
set_ne(ne) = (global nsNe=ne)
global _nthreads = 8
set_nthreads(n) = (global _nthreads=n)

include("styled-messages.jl")
include("update.jl")
include("raw.jl")
include("misc.jl")
include("QC.jl")
include("imputation.jl")
include("gmatrix.jl")
include("genotypes.jl")
include("comp-refs.jl")

NSG.title("Updating binaries")
NSG.Update()
end # module


text:
module FinancialModels
using Random, Distributions, ProgressMeter, Printf
include("common.jl")
include("JacobLeal/JacobLeal.jl")
include("api.jl")
export SimulationResults, Options, JacobLealParameters, Simulate, prices, trace
end

max_stars_repo_name: IvanJericevich/FinancialModels

max_issues_repo_name: IvanJericevich/FinancialModels

max_forks_repo_name: IvanJericevich/FinancialModels


text:
using ZMQ
using ProtoBuf

include("./proto/matrix_io.jl")

"""
    Base type for Matrix Core drivers

# Fields
- baseport : base port for the driver
- host : host
- configsocket : ZMQ socket to send config data
- errsocket : ZMQ socket for receiving errors
- datasocket : ZMQ socket for receiving data
- keepalivesocket : ZMQ socket for sending keep alive pings
- datachannel : channel for receiving data as protobuf messages
- errchannel : channel for receiving error messages
"""
abstract type Driver end

"""
    Print the content of a message
"""
function printmessage(m)
    j = typeof(m)
    if typeof(m) == matrix_io.malos.v1.sense.Humidity
        println("Humidity $(m.humidity)% $(m.temperature)°C $(m.temperature_is_calibrated) $(m.temperature_raw)")
    elseif typeof(m) == matrix_io.malos.v1.sense.Pressure
        println("Pressure $(m.pressure) Pa $(m.altitude) m $(m.temperature) °C")
    elseif typeof(m) == matrix_io.malos.v1.sense.UV
        println("UV $(m.uv_index), $(m.oms_risk)")
    elseif typeof(m) == matrix_io.malos.v1.sense.Imu
        println("Imu $(m.yaw) ° $(m.pitch) ° $(m.roll) ° $(m.accel_x) m/s^2 $(m.accel_y) m/s^2 $(m.accel_z) m/s^2")
    elseif typeof(m) == matrix_io.malos.v1.io.EverloopImage
        println("Everloop $(m.everloop_length)")
    elseif typeof(m) == matrix_io.malos.v1.io.GpioParams
        println("GPIO $(m.values)")
    end
end

"""
    close(::<Driver)

Close all the sockets and channels of the driver
"""
function Base.close(d::T) where {T<:Driver}
    close(d.errsocket)
    close(d.datasocket)
    close(d.keepalivesocket)
    close(d.configsocket)
    close(d.datachannel)
    close(d.errchannel)
end

"""
    connecterror(::<Driver)

Connect to the error port for the driver and start a task to put the received messages in the
error channel of the driver.
Used in the [`start`](@ref) function.

# Returns
The started task
"""
function connecterror(d::T) where {T<:Driver}
    port = d.baseport+2
    connect(d.errsocket,"tcp://$(d.host):$port")
    subscribe(d.errsocket,"")
    @async while isopen(d.errsocket)
                try
                    m = recv(d.errsocket, String)
                    put!(d.errchannel, m)
                catch e
                    if typeof(e)!=ZMQ.StateError &&
                        typeof(e)!=EODError
                        println("caught exception $e")
                    end
                end
            end
end # function

"""
    connectdata(::<Driver)

Open the data socket and start a task to receive data messages and put them in the data channel.
Used in the [`start`](@ref) function

# Returns
The started task
"""
function connectdata(d::T) where {T<:Driver}
    port = d.baseport+3
    connect(d.datasocket,"tcp://$(d.host):$port")
    subscribe(d.datasocket,"")
    @async while isopen(d.datasocket)
                try
                    m = recv(d.datasocket, String)
                    put!(d.datachannel, decodedata(d,m))
                catch e
                    if typeof(e)!=ZMQ.StateError &&
                        typeof(e)!=EODError
                        println("caught exception $e")
                    end
                end
            end
end # function

"""
    connectkeepalive(::<Driver)

Open the keep alive socket and start a task to send empty messages to the driver.
Used in the [`start`](@ref) function

# Arguments
- d : driver

# Returns
The started task

# Named arguments
- time : time interval in seconds between messages
"""
function connectkeepalive(d::T; time::Number = 2) where {T<:Driver}
    port = d.baseport+1
    connect(d.keepalivesocket,"tcp://$(d.host):$port")
    @async while isopen(d.keepalivesocket)
                send(d.keepalivesocket,"")
                sleep(time)
            end
end # function

"""
    start(<:Driver, datafunc::Function, errfunc::Function, katime::Number)

Start tasks to receive and process messages from the driver

# Arguments
- `driver` : The driver to use
- `datafunc` : The function to process the incoming data messages.
    Must take a ProtoBuf message as unique parameter. Default behavior is to print the
    received message
- `errfunc` : The function to process the incoming error messages.
    Must take a unique parameter. Default behavior is to print the error message
- `katime` : Time interval in seconds for the keep alive messages

# Returns
 tuple of started tasks (t1, t2, t3, t4, t5), with
- t1 : data reception task
- t2 : error reception task
- t3 : keep alive send task
- t4 : data processing task
- t5 : error processing task

# Example
```julia
h = HumidityDriver("192.168.42.1")
configure(h; delay=2)
(t1, t2, t3, t4, t5) = start(h)
```
```julia
h = EverloopDriver("192.168.42.1")
for i=1:200
    n::UInt32=256
    red=rand(UInt32,35).%n
    green=rand(UInt32,35).%n
    blue=rand(UInt32,35).%n
    configure(h,red,green,blue)
    sleep(0.1)
end
red=zeros(UInt32,35)
configure(h,red,red,red)
closedriver(h)
```
"""
function start(driver::T, datafunc::Function=printmessage, errfunc::Function=println, katime::Number=2) where {T<:Driver}
    t1=connectdata(driver)
    t2=connecterror(driver)
    t3=connectkeepalive(driver; time=katime)
    t4=Task( () -> begin
            while true
                m = take!(driver.datachannel)
                datafunc(m)
            end
        end )
    schedule(t4)
    t5=Task( () -> begin
            while true
                m = take!(driver.errchannel)
                errfunc(m)
            end
        end )
    schedule(t5)
    (t1, t2, t3, t4, t5)
end

"""
    configure(<:Driver)

Send configuration data to the driver. Each driver has its own method using a specific set of arguments.

# Methods
```julia
configure(d::HumidityDriver; delay=2, timeout= 6, temp=21)
configure(d::IMUDriver; delay=2, timeout=6)
configure(d::UVDriver; delay=2, timeout=6)
configure(d::PressureDriver; delay=2, timeout=6)
configure(d::EverloopDriver,red::Array{UInt32},green::Array{UInt32},blue::Array{UInt32};nbleds=35)
configure(d::GPIODriver; delay=2, timeout=6, pin=1, isinput=false, value=0)
```

# Arguments
- `d` : driver

# Named arguments
- `delay` : period in seconds for data refresh
- `timeout` : delay in seconds to stop sending data messages after last keep alive message
- `temp` : calibration temperature for the humidity sensor
- `red`,`green`,`blue` : color arrays for the everloop driver
- `nbleds` : number of leds for the everloop driver
"""
function configure(::T) where {T<:Driver}
    error("abstract method")
end

function decodedata(::T, ::AbstractString) where {T<:Driver}
    error("abstract method")
end

"""
    HumidityDriver <: Driver

Driver for the humidity sensor
"""
struct HumidityDriver <: Driver
    baseport
    host::String
    configsocket::Socket
    errsocket::Socket
    keepalivesocket::Socket
    datasocket::Socket
    datachannel::Channel{ProtoType}
    errchannel::Channel
    function HumidityDriver(h)
        d=new(20017, h, Socket(PUSH), Socket(SUB), Socket(PUSH), Socket(SUB), Channel{ProtoType}(typemax(Int)), Channel(Inf))
        connect(d.configsocket, "tcp://$(d.host):$(d.baseport)")
        d
    end
end

function configure(d::HumidityDriver; delay=2, timeout= 6, temp=21)
    config = matrix_io.malos.v1.driver.DriverConfig(
        delay_between_updates=delay,
        timeout_after_last_ping=timeout,
        humidity=matrix_io.malos.v1.sense.HumidityParams(current_temperature=temp)
    )
    io = IOBuffer()
    writeproto(io, config)
    msg = String(take!(io))
    send(d.configsocket,msg)
end

function decodedata(d::HumidityDriver, buffer::AbstractString)
    io = IOBuffer(buffer)
    readproto(io, matrix_io.malos.v1.sense.Humidity())
end

"""
    IMUDriver <: Driver

Driver for the IMU sensor
"""
struct IMUDriver <: Driver
    baseport
    host::String
    configsocket::Socket
    errsocket::Socket
    keepalivesocket::Socket
    datasocket::Socket
    datachannel::Channel{ProtoType}
    errchannel::Channel
    function IMUDriver(h)
        d=new(20013, h, Socket(PUSH), Socket(SUB), Socket(PUSH), Socket(SUB), Channel{ProtoType}(typemax(Int)), Channel(Inf))
        connect(d.configsocket, "tcp://$(d.host):$(d.baseport)")
        d
    end
end

function configure(d::IMUDriver; delay=2, timeout=6)
    config = matrix_io.malos.v1.driver.DriverConfig(
        delay_between_updates=delay,
        timeout_after_last_ping=timeout
    )
    io = IOBuffer()
    writeproto(io, config)
    m = String(take!(io))
    send(d.configsocket,msg)
end

function decodedata(d::IMUDriver, buffer::AbstractString)
    io = IOBuffer(buffer)
    readproto(io, matrix_io.malos.v1.sense.Imu())
end

"""
    UVDriver <: Driver

Driver for the UV sensor
"""
struct UVDriver <: Driver
    baseport
    host::String
    configsocket::Socket
    errsocket::Socket
    keepalivesocket::Socket
    datasocket::Socket
    datachannel::Channel{ProtoType}
    errchannel::Channel
    function UVDriver(h)
        d=new(20029, h, Socket(PUSH), Socket(SUB), Socket(PUSH), Socket(SUB), Channel{ProtoType}(typemax(Int)), Channel(Inf))
        connect(d.configsocket, "tcp://$(d.host):$(d.baseport)")
        d
    end
end

function configure(d::UVDriver; delay=2, timeout=6)
    config = matrix_io.malos.v1.driver.DriverConfig(
        delay_between_updates=delay,
        timeout_after_last_ping=timeout
    )
    io = IOBuffer()
    writeproto(io, config)
    msg = String(take!(io))
    send(d.configsocket,msg)
end

function decodedata(d::UVDriver, buffer::AbstractString)
    io = IOBuffer(buffer)
    readproto(io, matrix_io.malos.v1.sense.UV())
end

"""
    PressureDriver <: Driver

Driver for the Pressure sensor
"""
struct PressureDriver <: Driver
    baseport
    host::String
    configsocket::Socket
    errsocket::Socket
    keepalivesocket::Socket
    datasocket::Socket
    datachannel::Channel{ProtoType}
    errchannel::Channel
    function PressureDriver(h)
        d=new(20025, h, Socket(PUSH), Socket(SUB), Socket(PUSH), Socket(SUB), Channel{ProtoType}(typemax(Int)), Channel(Inf))
        connect(d.configsocket, "tcp://$(d.host):$(d.baseport)")
        d
    end
end

function configure(d::PressureDriver; delay=2, timeout=6)
    config = matrix_io.malos.v1.driver.DriverConfig(
        delay_between_updates=delay,
        timeout_after_last_ping=timeout
    )
    io = IOBuffer()
    writeproto(io, config)
    msg = String(take!(io))
    send(d.configsocket,msg)
end

function decodedata(d::PressureDriver, buffer::String)
    io = IOBuffer(buffer)
    readproto(io, matrix_io.malos.v1.sense.Pressure())
end

"""
    EverloopDriver <: Driver

Driver for the Everloop
"""
struct EverloopDriver <: Driver
    baseport
    host::String
    configsocket::Socket
    errsocket::Socket
    keepalivesocket::Socket
    datasocket::Socket
    datachannel::Channel{ProtoType}
    errchannel::Channel
    function EverloopDriver(h)
        d=new(20021, h, Socket(PUSH), Socket(SUB), Socket(PUSH), Socket(SUB), Channel{ProtoType}(typemax(Int)), Channel(Inf))
        connect(d.configsocket, "tcp://$(d.host):$(d.baseport)")
        d
    end
end

function configure(d::EverloopDriver,r::Array{UInt32},g::Array{UInt32},b::Array{UInt32};nbleds=35)
    config = matrix_io.malos.v1.driver.DriverConfig(
        image=matrix_io.malos.v1.io.EverloopImage()
    )
    nb=min(size(r,1),size(g,1),size(b,1),nbleds)
    config.image.led=Vector{matrix_io.malos.v1.io.LedValue}(undef,nbleds)
    z::UInt32=0
    for i=1:nb
        config.image.led[i]=matrix_io.malos.v1.io.LedValue(red=r[i],green=g[i],blue=b[i],white=z)
    end
    for i=nb+1:nbleds
        config.image.led[i]=matrix_io.malos.v1.io.LedValue(red=z,green=z,blue=z,white=z)
    end
    io = IOBuffer()
    writeproto(io, config)
    msg = String(take!(io))
    send(d.configsocket,msg)
end

function decodedata(d::EverloopDriver, buffer::String)
    io = IOBuffer(buffer)
    readproto(io, matrix_io.malos.v1.io.EverloopImage())
end

"""
    GPIODriver <: Driver

Driver for the GPIO
"""
struct GPIODriver <: Driver
    baseport
    host::String
    configsocket::Socket
    errsocket::Socket
    keepalivesocket::Socket
    datasocket::Socket
    datachannel::Channel{ProtoType}
    errchannel::Channel
    function GPIODriver(h)
        d=new(20049, h, Socket(PUSH), Socket(SUB), Socket(PUSH), Socket(SUB), Channel{ProtoType}(typemax(Int)), Channel(Inf))
        connect(d.configsocket, "tcp://$(d.host):$(d.baseport)")
        d
    end
end

function configure(d::GPIODriver; delay=2, timeout=6, pin=1, isinput=false, value=0)
    config = matrix_io.malos.v1.driver.DriverConfig(
        delay_between_updates=delay,
        timeout_after_last_ping=timeout,
        gpio=matrix_io.malos.v1.io.GpioParams(
            pin=pin,
            mode=isinput ? 0 : 1,
            value=value
        )
    )
    io = IOBuffer()
    writeproto(io, config)
    msg = String(take!(io))
    send(d.configsocket,msg)
end

function decodedata(d::GPIODriver, buffer::String)
    io = IOBuffer(buffer)
    readproto(io, matrix_io.malos.v1.io.GpioParams())
end


text:
# LazyArrays._copyto!(::LazyArrays.DiagonalLayout, dest::Diagonal, M::LazyArrays.MatMulMat{<:LazyArrays.DiagonalLayout}) =
#     copyto!(dest, M.factors[1]*M.factors[2])
# Base.similar(M::LazyArrays.MatMulMat{<:LazyArrays.DiagonalLayout}) = Diagonal(Vector{eltype(M)}(undef,size(M,1)))
# LazyArrays._materialize(M:: LazyArrays.ArrayMuls, ::Tuple{Base.OneTo}) = LazyArrays.rmaterialize(M)
# LazyArrays._materialize(M:: LazyArrays.Mul, ::Tuple{Base.OneTo}) = LazyArrays.rmaterialize(M)
# LazyArrays._materialize(M:: LazyArrays.ArrayMulArray, ::Tuple{Base.OneTo}) = copyto!(similar(M), M)


text:
# on-device functionality

export AbstractDeviceArray, @LocalMemory

## device array

"""
    AbstractDeviceArray{T, N} <: DenseArray{T, N}

Supertype for `N`-dimensional GPU arrays (or array-like types) with elements of type `T`.
Instances of this type are expected to live on the device, see [`AbstractGPUArray`](@ref)
for device-side objects.
"""
abstract type AbstractDeviceArray{T, N} <: DenseArray{T, N} end

Base.IndexStyle(::AbstractDeviceArray) = IndexLinear()

@inline function Base.iterate(A::AbstractDeviceArray, i=1)
    if (i % UInt) - 1 < length(A)
        (@inbounds A[i], i + 1)
    else
        nothing
    end
end

function Base.sum(A::AbstractDeviceArray{T}) where T
    acc = zero(T)
    for elem in A
        acc += elem
    end
    acc
end

## thread-local array

const shmem_counter = Ref{Int}(0)

"""
Creates a local static memory shared inside one block.
Equivalent to `__local` of OpenCL or `__shared__ (<variable>)` of CUDA.
"""
macro LocalMemory(state, T, N)
    id = (shmem_counter[] += 1)
    quote
        LocalMemory($(esc(state)), $(esc(T)), Val($(esc(N))), Val($id))
    end
end

"""
Creates a block local array pointer with `T` being the element type
and `N` the length. Both T and N need to be static! C is a counter for
approriately get the correct Local mem id in CUDAnative.
This is an internal method which needs to be overloaded by the GPU Array backends
"""
function LocalMemory(state, ::Type{T}, ::Val{dims}, ::Val{id}) where {T, dims, id}
    error("Not implemented") # COV_EXCL_LINE
end


text:
# GA

#=

LeetCode 198. House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

=#

# Import Packages

# GA Parameters

NP = 20
L = 10
Pc = 0.8
Pv = 0.2
G = 100

# Example

house = Int64.(floor.(rand(1, L) * 10) .+ 1)

# Initalization

f = Int64.(zeros(NP, L))
money = zeros(NP, 1)
moneyFit = zeros(NP, 1)
fBest = Int64.(zeros(1, L))

for ii = 1: NP

    f[ii, :] = Int64.(floor.(rand(1, L) .+ 0.5))

end

# Start

nf = Int64.(zeros(NP, L))

for ii = 1: G

    for jj = 1: NP

        global moneyFit, fBest, f, nf

        # Fitness (money)

        for kk = 1: (L - 1)

            if f[jj, kk] & f[jj, kk + 1] == 1

                money[jj, 1] = 0

                break

            else

                money[jj, 1] = sum(f[jj, :] .* house[1, :])

            end

        end

        moneyMin = minimum(money[:, 1]) # Max
        moneyMax = maximum(money[:, 1]) # Min

        if money[jj, 1] == moneyMax

            fBest[1, :] = f[jj, :] # Best

        end

        moneyFit[jj, 1] = (money[jj, 1] - moneyMin) / (moneyMax - moneyMin) # Normalization

        # Roulette

        sumFit = sum(moneyFit)
        fitValue = moneyFit ./ sumFit
        cumFitValue = cumsum(fitValue[:, 1])

        for mm = 1: NP

            roll = rand()

            for nn = 1: (length(cumFitValue) - 1)

                if cumFitValue[mm] < roll < cumFitValue[mm + 1]

                    nf[mm, :] =  f[nn, :]

                else

                    nf[mm, :] =  f[1, :]

                end

            end

        end

        # Crossing

        for kk = 1: 2: NP

            c = rand()

            if c < Pc

                selection = Int64.(floor.(rand(1, L) .+ 0.5))
                new1 = nf[kk, :] .* selection[1, :] .+ nf[kk + 1, :] .* (1 .- selection[1, :])
                new2 = nf[kk, :] .* (1 .- selection[1, :]) .+ nf[kk + 1, :] .* selection[1, :]
                nf[kk, :] = new1
                nf[kk + 1, :] = new2

            end
        end

        # Variation

        for pp = 1: NP

            for qq = 1: L

                v = rand()

                if v < Pv

                    nf[pp, qq] = 1 - nf[pp, qq]

                end

            end

        end

        # Replacing

        f = nf
        nf[1, :] = fBest[1, :]

    end

end

moneyBest = sum(fBest[1, :] .* house[1, :])

println("Best Selection is $(fBest), money is $(moneyBest).")

max_stars_repo_name: mizu-bai/Try-Julia

max_issues_repo_name: mizu-bai/Data-Science-Demos

max_forks_repo_name: mizu-bai/Data-Science-Demos


text:
using Pkg;
Pkg.activate(".");
using JLD2, Plots, SolverBenchmark

name = "2022-04-02_ARCqKOp10204_ARCqKOp10201_ARCqKOp102005_ARCqKOp10203_ARCqKOp10202_cutest_277_1000000"
@load "$name.jld2" stats
#=
stats1 = copy(stats)
name = "2022-03-21_trunk_tron_ipopt_lbfgs_cutest_277_1000000"
@load "$name.jld2" stats
stats = merge(stats, stats1)
=#
solved(df) = (df.status .== :first_order) .| (df.status .== :unbounded)

open("$name.dat", "w") do io
    for solver in keys(stats)
        # Number of problems solved
        println(io, solver)
        println(io, size(stats[solver][solved(stats[solver]), [:name]], 1))
        println(
            io,
            stats[solver][
                .!solved(stats[solver]),
                [:name, :nvar, :status, :elapsed_time, :dual_feas],
            ],
        )
    end
end

costs =
    [df -> .!solved(df) * Inf + df.elapsed_time, df -> .!solved(df) * Inf + df.neval_obj]
costnames = ["Time", "Evaluations of f"]
p = profile_solvers(stats, costs, costnames)
png(p, "$name")

for solver in keys(stats)
    open("$(name)_result_$(solver).dat", "w") do io
        print(
            io,
            stats[solver][
                !,
                [
                    :name,
                    :nvar,
                    :ncon,
                    :status,
                    :objective,
                    :elapsed_time,
                    :iter,
                    :primal_feas,
                    :dual_feas,
                    :neval_obj,
                    :neval_grad,
                    :neval_hprod,
                    :neval_hess,
                ],
            ],
        )
    end
end

nmins = [0, 100, 1000, 10000]
for nmin in nmins
    # Same figure with minimum number of variables
    stats2 = copy(stats)
    for solver in keys(stats)
        stats2[solver] = stats[solver][stats[solver].nvar.>=nmin, :]
    end

    nb_problems = length(stats2[first(keys(stats))][!, :name])

    # Figures comparing two results:
    costs_all = [
        df -> .!solved(df) * Inf + df.elapsed_time,
        df -> .!solved(df) * Inf + df.neval_obj,
        df -> .!solved(df) * Inf + df.neval_grad,
        df -> .!solved(df) * Inf + df.neval_hprod,
        df -> .!solved(df) * Inf + df.neval_obj + df.neval_grad + df.neval_hprod,
    ]
    costnames_all = [
        "time",
        "objective evals",
        "gradient evals",
        "hessian-vector products",
        "obj + grad + hprod",
    ]
    p = profile_solvers(stats2, costs_all, costnames_all)
    png(p, "$(name)_all($(nb_problems))_min_$(nmin)")
end


text:
"""
```
function metropolis_hastings(propdist::Distribution,
                             loglikelihood::Function,
                             parameters::ParameterVector{S},
                             data::Matrix{T},
                             cc0::T,
                             cc::T;
                             n_blocks::Int = 1,
                             n_sim::Int    = 100,
                             n_burn::Int   = 0,
                             mhthin::Int   = 1,
                             verbose::Symbol=:low,
                             savepath::String = "mhsave.h5",
                             rng::MersenneTwister = MersenneTwister(0),
                             testing::Bool = false) where {S<:Number, T<:AbstractFloat}
```

Implements the Metropolis-Hastings MCMC algorithm for sampling from the posterior
distribution of the parameters.

### Arguments

- `propdist`: The proposal distribution that Metropolis-Hastings begins sampling from.
- `m`: The model object
- `data`: Data matrix for observables
- `cc0`: Jump size for initializing Metropolis-Hastings.
- `cc`: Jump size for the rest of Metropolis-Hastings.

### Optional Arguments

- `n_blocks::Int = 1`: Number of blocks (for memory-management purposes)
- `n_param_blocks::Int = 1`: Number of parameter blocks
- `n_sim::Int    = 100`: Number of simulations. Note: # saved observations will be
    n_sim * n_param_blocks * (n_blocks - b_burn).
- `n_burn::Int   = 0`: Length of burn-in period
- `mhthin::Int   = 1`: Thinning parameter (for mhthin = d, keep only every dth draw)
- `adaptive_accpt::Bool = false`: Whether or not to adaptively adjust acceptance prob.
- `α::T = 1.0`: Tuning parameter for proposal density computation in adaptive case
- `c::T = 1.0`:  Tuning parameter for proposal density computation in adaptive case
- `verbose::Bool`: The desired frequency of function progress messages printed to
  standard out. One of:
```
   - `:none`: No status updates will be reported.
   - `:low`: Status updates provided at each block.
   - `:high`: Status updates provided at each draw.
```
- `savepath::String = "mhsave.h5"`: String specifying path to output file
- `rng::MersenneTwister = MersenneTwister(0)`: Chosen seed (overridden if testing = true)
- `testing::Bool = false`: Conditional for use when testing (determines fixed seeding)
"""
function metropolis_hastings(propdist::Distribution,
                             loglikelihood::Function,
                             parameters::ParameterVector{S},
                             data::Matrix{T},
                             cc0::T,
                             cc::T;
                             n_blocks::Int64       = 1,
                             n_param_blocks::Int64 = 1,  # TODO: give these kwargs better names
                             n_sim::Int64          = 100,
                             n_burn::Int64         = 0,
                             mhthin::Int64         = 1,
                             adaptive_accpt::Bool  = false,
                             α::T = 1.0,      c::T = 1.0,
                             verbose::Symbol       = :low,
                             savepath::String      = "mhsave.h5",
                             rng::MersenneTwister  = MersenneTwister(0),
                             testing::Bool = false) where {S<:Number, T<:AbstractFloat}

    # If testing, set the random seeds at fixed numbers
    if testing
        Random.seed!(rng, 654)
    end

    # Initialize algorithm by drawing para_old from normal distribution centered at the
    # posterior mode, until parameters within bounds (indicated by posterior value > -∞)
    para_old = rand(propdist, rng; cc = cc0)
    post_old = -Inf

    initialized = false
    while !initialized
        post_old = posterior!(loglikelihood, parameters, para_old, data; sampler = true)
        if post_old > -Inf
            propdist.μ = para_old
            initialized = true
        else
            para_old = rand(propdist, rng; cc=cc0)
        end
    end

    # New feature: Parameter Blocking
    free_para_inds = findall([!θ.fixed for θ in parameters])
    n_free_para    = length(free_para_inds)
    n_params       = length(parameters)
    param_blocks   = SMC.generate_param_blocks(n_params, n_param_blocks)

    # Report number of blocks that will be used
    println(verbose, :low, "Blocks: $n_blocks")
    println(verbose, :low, "Draws per block: $n_sim")
    println(verbose, :low, "Parameter blocks: $n_param_blocks")

    # For n_sim*mhthin iterations within each block, generate a new parameter draw.
    # Decide to accept or reject, and save every (mhthin)th draw that is accepted.
    all_rejections = 0

    # Initialize matrices for parameter draws and transition matrices
    mhparams = zeros(n_sim * n_param_blocks, n_params)

    # Open HDF5 file for saving parameter draws
    simfile     = h5open(savepath, "w")
    n_saved_obs = n_sim * n_param_blocks * (n_blocks - n_burn)
    parasim     = d_create(simfile, "mhparams", datatype(Float64),
                           dataspace(n_saved_obs, n_params),
                           "chunk", (n_sim * n_param_blocks, n_params))

    # Keep track of how long metropolis_hastings has been sampling
    total_sampling_time = 0.

    for block = 1:n_blocks

        begin_time = time_ns()
        block_rejections = 0

        for j = 1:(n_sim * mhthin)

            for (k, p_block) in enumerate(param_blocks)

                # Draw para_new from the proposal distribution
                para_subset = para_old[p_block]
                d_subset    = DegenerateMvNormal(propdist.μ[p_block],
                                                 propdist.σ[p_block, p_block])
                para_draw = rand(d_subset, rng; cc = cc)

                para_new          = deepcopy(para_old)
                para_new[p_block] = para_draw

                q0, q1 = if adaptive_accpt
                    SMC.compute_proposal_densities(para_draw, para_subset, d_subset;
                                                   α = α, c = c)
                else
                    0.0, 0.0
                end

                # Solve the model (checking that parameters are within bounds and
                # gensys returns a meaningful system) and evaluate the posterior
                post_new = posterior!(loglikelihood, parameters, para_new, data;
                                      sampler = true)

                println(verbose, :high, "Block $block, Iteration $j, Parameter Block " *
                        "$k/$(n_param_blocks): posterior = $post_new")

                # Choose to accept or reject the new parameter by calculating the
                # ratio (r) of the new posterior value relative to the old one We
                # compare min(1, r) to a number drawn randomly from a uniform (0, 1)
                # distribution. This allows us to always accept the new draw if its
                # posterior value is greater than the previous draw's, but it gives
                # some probability to accepting a draw with a smaller posterior
                # value, so that we may explore tails and other local modes.
                r = exp((post_new - post_old) + (q0 - q1))
                x = rand(rng)

                if x < min(1.0, r)
                    # Accept proposed jump
                    para_old = para_new
                    post_old = post_new
                    propdist.μ = para_new

                    println(verbose, :high, "Block $block, Iteration $j, Parameter Block " *
                        "$k/$(n_param_blocks): accept proposed jump")
                else
                    # Reject proposed jump
                    block_rejections += 1

                    println(verbose, :high, "Block $block, Iteration $j, Parameter Block " *
                        "$k/$(n_param_blocks): reject proposed jump")
                end

                # Save every (mhthin)th draw
                if j % mhthin == 0
                    draw_index = convert(Int, j / mhthin)
                    mhparams[draw_index, :]  = para_old'
                end
            end # of block

            all_rejections += block_rejections
            block_rejection_rate = block_rejections / (n_sim * mhthin * n_param_blocks)

            ## Once every iblock times, write parameters to a file

            # Calculate starting, ending indices for this block (corresponds to new chunk in memory)
            block_start = n_sim * n_param_blocks * (block - n_burn - 1)+1
            block_end   = block_start + (n_sim * n_param_blocks) - 1

            # Write parameters to file if we're past n_burn blocks
            if block > n_burn
                parasim[block_start:block_end, :] = map(Float64, mhparams)
            end

            # Calculate time to complete this block, average block time, and
            # expected time to completion
            block_time                      = (time_ns() - begin_time) / 1e9
            total_sampling_time            += block_time
            total_sampling_time_minutes     = total_sampling_time / 60
            expected_time_remaining_sec     = (total_sampling_time / block) * (n_blocks - block)
            expected_time_remaining_minutes = expected_time_remaining_sec / 60

            println(verbose, :low, "Completed $block of $n_blocks blocks.")
            println(verbose, :low, "Total time to compute $block blocks: " *
                    "$total_sampling_time_minutes minutes")
            println(verbose, :low, "Expected time remaining for Metropolis-Hastings: " *
                    "$expected_time_remaining_minutes minutes")
            println(verbose, :low, "Block $block rejection rate: $block_rejection_rate \n")

        end # of loop over parameter blocks
    end # of loop over blocks
    close(simfile)

    rejection_rate = all_rejections / (n_blocks * n_sim * mhthin * n_param_blocks)
    println(verbose, :low, "Overall rejection rate: $rejection_rate")
end

"""
```
metropolis_hastings(propdist::Distribution, m::AbstractDSGEModel,
    data::Matrix{T}, cc0::T, cc::T; verbose::Symbol = :low) where {T<:AbstractFloat}
```

Wrapper function for DSGE models which calls Metropolis-Hastings MCMC algorithm for
sampling from the posterior distribution of the parameters.

### Arguments

- `propdist`: The proposal distribution that Metropolis-Hastings begins sampling from.
- `m`: The model object
- `data`: Data matrix for observables
- `cc0`: Jump size for initializing Metropolis-Hastings.
- `cc`: Jump size for the rest of Metropolis-Hastings.

### Optional Arguments

- `verbose`: The desired frequency of function progress messages printed to
  standard out. One of:

```
   - `:none`: No status updates will be reported.
   - `:low`: Status updates provided at each block.
   - `:high`: Status updates provided at each draw.
```
"""
function metropolis_hastings(propdist::Distribution,
       m::AbstractDSGEModel,
       data::Matrix{T},
       cc0::T,
       cc::T;
       verbose::Symbol=:low,
       filestring_addl::Vector{String} = Vector{String}(undef, 0)) where {T<:AbstractFloat}

    n_blocks = n_mh_blocks(m)
    n_sim    = n_mh_simulations(m)
    n_burn   = n_mh_burn(m)
    mhthin   = mh_thin(m)
    rng      = m.rng
    testing  = m.testing
    savepath = rawpath(m, "estimate", "mhsave.h5", filestring_addl)

    # To check: Defaulting to using Chandrasekhar recursions if no missing data
    use_chand_recursion = !any(isnan.(data))

    function loglikelihood(p::ParameterVector, data::Matrix{Float64})::Float64
        update!(m, p)
        likelihood(m, data; sampler = true, catch_errors = false,
                   use_chand_recursion = use_chand_recursion)
    end
    return metropolis_hastings(propdist, loglikelihood, m.parameters, data, cc0, cc;
                               n_blocks = n_blocks, n_sim = n_sim, n_burn = n_burn,
                               mhthin = mhthin, verbose = verbose, savepath = savepath,
                               rng = rng, testing = testing)
end


text:
@testset "Constraints" begin
    #TODO needs to be updated for the new constraint design and interaction with Core
    T = Float64
    N = 3

    # Test extreme constraints
    c1(x) = x[1] < 1
    c2(x) = x[1] + x[3] > 1
    c3(x) = x[2] > 0

    p1(x) = x[1] < 1 ? 0 : x[1] - 1
    p2(x) = x[1] + x[3] > 1 ? 0 : 1 - x[1] + x[3]
    p3(x) = x[2] > 0 ? 0 : -x[2]

    C = DS.Constraints{T}()
    @testset "Constraints" begin
        @test C.count == length(C.collections) == 2
        @test typeof(C.collections[1]) == DS.ConstraintCollection{T, DS.ExtremeConstraint}
        @test typeof(C.collections[2]) == DS.ConstraintCollection{T, DS.ProgressiveConstraint}
    end

    @testset "DefaultConstraintCollection" begin
        ex = C.collections[1]
        pr = C.collections[2]

        # Extreme barrier constraint default collection
        @test length(ex.constraints) == ex.count ==  0
        @test typeof(ex.constraints) == Vector{DS.ExtremeConstraint}
        @test ex.h_max == 0.0

        # Extreme barrier constraint default collection
        @test length(pr.constraints) == pr.count == 0
        @test typeof(pr.constraints) == Vector{DS.ProgressiveConstraint}
        @test pr.h_max == Inf

        # TODO: Test default update functions
    end

    C = DS.Constraints{T}()
    @testset "AddExtremeConstraint" begin
        c1_ref = DS.AddExtremeConstraint(C, c1)
        @test c1_ref.value == 1
        @test typeof(c1_ref) == DS.ConstraintIndex

        # Can't push an extreme constraint to a progressive collection
        @test_throws MethodError DS.AddExtremeConstraint(C, c1, index=DS.CollectionIndex(2))
        @test_throws ErrorException DS.AddExtremeConstraint(C, c1, index=DS.CollectionIndex(3))

        vec_ref = DS.AddExtremeConstraint(C, [c2, c3])
        @test length(vec_ref) == 2
        @test vec_ref[1].value == 2
        @test vec_ref[2].value == 3
    end

    @testset "AddProgressiveConstraint" begin
        p1_ref = DS.AddProgressiveConstraint(C, p1)
        @test p1_ref.value == 1
        @test typeof(p1_ref) == DS.ConstraintIndex

        # Can't push an extreme constraint to a progressive collection
        @test_throws MethodError DS.AddProgressiveConstraint(C, p1, index=DS.CollectionIndex(1))
        @test_throws ErrorException DS.AddProgressiveConstraint(C, p1, index=DS.CollectionIndex(3))

        vec_ref = DS.AddProgressiveConstraint(C, [c2, c3])
        @test length(vec_ref) == 2
        @test vec_ref[1].value == 2
        @test vec_ref[2].value == 3
    end

    C = DS.Constraints{T}()
    @testset "AddProgressiveCollection" begin
        c_ref = DS.AddProgressiveCollection(C)
        @test typeof(c_ref) == DS.CollectionIndex
        @test c_ref.value == 3

        @test typeof(C.collections[3]) == DS.ConstraintCollection{T, DS.ProgressiveConstraint}
        @test length(C.collections[3].constraints) == C.collections[3].count == 0

        p_ref = DS.AddProgressiveConstraint(C, p2, index=c_ref)
        @test length(C.collections[3].constraints) == C.collections[3].count == 1
    end

    #TODO constraint evaluation
end


text:
using DReal

a = Var(Float64,"aexpop2",0.,1.)
b2 = (a < 0.1) | (a > 0.9)
push_ctx!()
add!(b2)
is_satisfiable()
pop_ctx!()
push_ctx!()
b3 = !b2
#b3 = (a >= 0.1) & (a <= 0.9)
add!(b3)
is_satisfiable()


text:
using BranchTests
using Test

Code = quote
    @testbranch "Vector" begin
        println("in 'Vector'")
        v = Vector{Int}()
        @test isempty(v)

        @testbranch "adds one element" begin
            println("in 'adds one element'")
            push!(v, 1)
            @test length(v) == 1

            @testbranch "adds another element" begin
                println("in 'adds another element'")
                push!(v, 2)
                @test length(v) == 2
            end

            @testbranch DefaultTestSet "removes one" begin # test set type
                println("in 'removes one'")
                pop!(v)
                @test isempty(v)
            end
        end

        @testbranch begin # no name
            println("in 'equality'")
            @test v == v
        end
    end
end

eval(Code)

#@testset "vector" begin
#    v = Vector{Int}()
#
#    @testset "adds one element" begin
#        push!(v, 1)
#        @test length(v) == 1
#
#        @testset "adds another element" begin
#            push!(v, 1)
#            @test length(v) == 2
#        end
#
#        @testset "removes - empty" begin
#            pop!(v)
#            @test isempty(v)
#        end
#    end
#end