From 4ba83169e88c31a68a554cb98d1ae8cc69491c92 Mon Sep 17 00:00:00 2001 From: droodman Date: Fri, 22 Dec 2023 20:46:28 -0500 Subject: [PATCH] Minimize matrix inversion and use Cholesky exclusively for inversion for ldiv-ing --- Manifest.toml | 257 +++++++++++++++++++++++++++---------------- Project.toml | 8 +- src/WRE.jl | 52 ++++----- src/WildBootTests.jl | 3 +- src/estimators.jl | 108 +++++++++--------- src/interface.jl | 27 +++-- src/nonWRE.jl | 11 +- src/precompiler.jl | 4 +- src/structs.jl | 14 ++- src/utilities.jl | 130 ++++++++++++---------- test/Manifest.toml | 147 ++++++++++++------------- test/runtests.jl | 2 +- test/tests.jl | 2 +- test/unittests.log | 4 +- 14 files changed, 428 insertions(+), 341 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 3fa524e..0cb48cd 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,14 +1,14 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.1" +julia_version = "1.9.4" manifest_format = "2.0" -project_hash = "71566088d360bf7fc9aa7a95f7221cbcea1e360a" +project_hash = "5975652355b39c9845db54c6d26369a01b2fcab5" [[deps.Adapt]] deps = ["LinearAlgebra", "Requires"] -git-tree-sha1 = "76289dc51920fdc6e0013c872ba9551d54961c24" +git-tree-sha1 = "cde29ddf7e5726c9fb511f340244ea3481267608" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "3.6.2" +version = "3.7.2" [deps.Adapt.extensions] AdaptStaticArraysExt = "StaticArrays" @@ -27,9 +27,9 @@ version = "1.1.1" [[deps.ArrayInterface]] deps = ["Adapt", "LinearAlgebra", "Requires", "SparseArrays", "SuiteSparse"] -git-tree-sha1 = "f83ec24f76d4c8f525099b2ac475fc098138ec31" +git-tree-sha1 = "247efbccf92448be332d154d6ca56b9fcdd93c31" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.11" +version = "7.6.1" [deps.ArrayInterface.extensions] ArrayInterfaceBandedMatricesExt = "BandedMatrices" @@ -47,12 +47,6 @@ version = "7.4.11" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" -[[deps.ArrayInterfaceCore]] -deps = ["LinearAlgebra", "SnoopPrecompile", "SparseArrays", "SuiteSparse"] -git-tree-sha1 = "e5f08b5689b1aad068e01751889f2f615c7db36d" -uuid = "30b0a656-2188-435a-8636-2ec0e6a096e2" -version = "0.1.29" - [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -92,9 +86,9 @@ version = "0.1.5" [[deps.CPUSummary]] deps = ["CpuId", "IfElse", "PrecompileTools", "Static"] -git-tree-sha1 = "89e0654ed8c7aebad6d5ad235d6242c2d737a928" +git-tree-sha1 = "601f7e7b3d36f18790e2caf83a882d88e9b71ff1" uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" -version = "0.2.3" +version = "0.2.4" [[deps.Calculus]] deps = ["LinearAlgebra"] @@ -110,9 +104,9 @@ version = "0.1.12" [[deps.Compat]] deps = ["UUIDs"] -git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957" +git-tree-sha1 = "886826d76ea9e72b35fcd000e535588f7b60f21d" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.6.1" +version = "4.10.1" weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] @@ -121,7 +115,7 @@ weakdeps = ["Dates", "LinearAlgebra"] [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.2+0" +version = "1.0.5+0" [[deps.CompositionsBase]] git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad" @@ -136,9 +130,9 @@ version = "0.1.2" [[deps.ConstructionBase]] deps = ["LinearAlgebra"] -git-tree-sha1 = "738fec4d684a9a6ee9598a8bfee305b26831f28c" +git-tree-sha1 = "c53fc348ca4d40d7b371e71fd52251839080cbc9" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" -version = "1.5.2" +version = "1.5.4" [deps.ConstructionBase.extensions] ConstructionBaseIntervalSetsExt = "IntervalSets" @@ -154,16 +148,27 @@ git-tree-sha1 = "fcbb72b032692610bfbdb15018ac16a36cf2e406" uuid = "adafc99b-e345-5852-983c-f28acb93d879" version = "0.3.1" +[[deps.Crayons]] +git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15" +uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" +version = "4.1.1" + [[deps.DataAPI]] git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" version = "1.15.0" +[[deps.DataFrames]] +deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] +git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8717bdb8" +uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +version = "1.6.1" + [[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0" +git-tree-sha1 = "3dbd312d370723b6bb43ba9d02fc36abade4518d" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.13" +version = "0.18.15" [[deps.DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -184,18 +189,20 @@ deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" [[deps.Distributions]] -deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns", "Test"] -git-tree-sha1 = "4ed4a6df2548a72f66e03f3a285cd1f3b573035d" +deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"] +git-tree-sha1 = "9242eec9b7e2e14f9952e8ea1c7e31a50501d587" uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" -version = "0.25.96" +version = "0.25.104" [deps.Distributions.extensions] DistributionsChainRulesCoreExt = "ChainRulesCore" DistributionsDensityInterfaceExt = "DensityInterface" + DistributionsTestExt = "Test" [deps.Distributions.weakdeps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d" + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[deps.DocStringExtensions]] deps = ["LibGit2"] @@ -218,10 +225,16 @@ version = "0.6.8" uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" [[deps.FillArrays]] -deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"] -git-tree-sha1 = "e17cc4dc2d0b0b568e80d937de8ed8341822de67" +deps = ["LinearAlgebra", "Random"] +git-tree-sha1 = "5b93957f6dcd33fc343044af3d48c215be2562f1" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "1.2.0" +version = "1.9.3" +weakdeps = ["PDMats", "SparseArrays", "Statistics"] + + [deps.FillArrays.extensions] + FillArraysPDMatsExt = "PDMats" + FillArraysSparseArraysExt = "SparseArrays" + FillArraysStatisticsExt = "Statistics" [[deps.Future]] deps = ["Random"] @@ -229,15 +242,15 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" [[deps.HostCPUFeatures]] deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"] -git-tree-sha1 = "d38bd0d9759e3c6cfa19bdccc314eccf8ce596cc" +git-tree-sha1 = "eb8fed28f4994600e29beef49744639d985a04b2" uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0" -version = "0.1.15" +version = "0.1.16" [[deps.HypergeometricFunctions]] deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"] -git-tree-sha1 = "0ec02c648befc2f94156eaef13b0f38106212f3f" +git-tree-sha1 = "f218fe3736ddf977e0e772bc9a586b2383da2685" uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a" -version = "0.3.17" +version = "0.3.23" [[deps.IfElse]] git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1" @@ -249,10 +262,21 @@ git-tree-sha1 = "4da0f88e9a39111c2fa3add390ab15f3a44f3ca3" uuid = "22cec73e-a1b8-11e9-2c92-598750a2cf9c" version = "0.3.1" +[[deps.InlineStrings]] +deps = ["Parsers"] +git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461" +uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" +version = "1.4.0" + [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +[[deps.InvertedIndices]] +git-tree-sha1 = "0dc7b50b8d436461be01300fd8cd45aa0274b038" +uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" +version = "1.3.0" + [[deps.IrrationalConstants]] git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" @@ -264,26 +288,31 @@ uuid = "82899510-4779-5014-852e-03e436cf321d" version = "1.0.0" [[deps.JLLWrappers]] -deps = ["Preferences"] -git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.4.1" +version = "1.5.0" + +[[deps.LaTeXStrings]] +git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec" +uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +version = "1.3.1" [[deps.LayoutPointers]] deps = ["ArrayInterface", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static", "StaticArrayInterface"] -git-tree-sha1 = "88b8f66b604da079a627b6fb2860d3704a6729a1" +git-tree-sha1 = "62edfee3211981241b57ff1cedf4d74d79519277" uuid = "10f19ff3-798f-405d-979b-55457f8fc047" -version = "0.1.14" +version = "0.1.15" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" +version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" +version = "8.4.0+0" [[deps.LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] @@ -292,7 +321,7 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" +version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -303,9 +332,9 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[deps.LogExpFunctions]] deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] -git-tree-sha1 = "c3ce8e7420b3a6e071e0fe4745f5d4300e37b13f" +git-tree-sha1 = "7d6dd4e9212aebaeed356de34ccf262a3cd415aa" uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" -version = "0.3.24" +version = "0.3.26" [deps.LogExpFunctions.extensions] LogExpFunctionsChainRulesCoreExt = "ChainRulesCore" @@ -321,10 +350,10 @@ version = "0.3.24" uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[deps.LoopVectorization]] -deps = ["ArrayInterface", "ArrayInterfaceCore", "CPUSummary", "CloseOpenIntervals", "DocStringExtensions", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "PrecompileTools", "SIMDTypes", "SLEEFPirates", "Static", "StaticArrayInterface", "ThreadingUtilities", "UnPack", "VectorizationBase"] -git-tree-sha1 = "3bb62b5003bc7d2d49f26663484267dc49fa1bf5" +deps = ["ArrayInterface", "CPUSummary", "CloseOpenIntervals", "DocStringExtensions", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "PrecompileTools", "SIMDTypes", "SLEEFPirates", "Static", "StaticArrayInterface", "ThreadingUtilities", "UnPack", "VectorizationBase"] +git-tree-sha1 = "0f5648fbae0d015e3abe5867bca2b362f67a5894" uuid = "bdcacae8-1622-11e9-2a5c-532679323890" -version = "0.12.159" +version = "0.12.166" [deps.LoopVectorization.extensions] ForwardDiffExt = ["ChainRulesCore", "ForwardDiff"] @@ -337,9 +366,9 @@ version = "0.12.159" [[deps.MacroTools]] deps = ["Markdown", "Random"] -git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" +git-tree-sha1 = "9ee1618cbf5240e6d4e0371d6f24065083f60c48" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.10" +version = "0.5.11" [[deps.ManualMemory]] git-tree-sha1 = "bcaef4fc7a0cfe2cba636d84cda54b5e4e4ca3cd" @@ -386,9 +415,9 @@ version = "1.2.0" [[deps.OffsetArrays]] deps = ["Adapt"] -git-tree-sha1 = "82d7c9e310fe55aa54996e6f7f94674e2a38fcb4" +git-tree-sha1 = "2ac17d29c523ce1cd38e27785a7d23024853a4bb" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.12.9" +version = "1.12.10" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] @@ -407,20 +436,26 @@ uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" version = "0.5.5+0" [[deps.OrderedCollections]] -git-tree-sha1 = "d321bf2de576bf25ec4d3e4360faca399afca282" +git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.6.0" +version = "1.6.3" [[deps.PDMats]] deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"] -git-tree-sha1 = "67eae2738d63117a196f497d7db789821bce61d1" +git-tree-sha1 = "949347156c25054de2db3b166c52ac4728cbad65" uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" -version = "0.11.17" +version = "0.11.31" + +[[deps.Parsers]] +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "a935806434c9d4c506ba941871b327b96d41f2bf" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "2.8.0" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.9.0" +version = "1.9.2" [[deps.PolyesterWeave]] deps = ["BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "Static", "ThreadingUtilities"] @@ -428,17 +463,29 @@ git-tree-sha1 = "240d7170f5ffdb285f9427b92333c3463bf65bf6" uuid = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad" version = "0.2.1" +[[deps.PooledArrays]] +deps = ["DataAPI", "Future"] +git-tree-sha1 = "36d8b4b899628fb92c2749eb488d884a926614d3" +uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" +version = "1.4.3" + [[deps.PrecompileTools]] deps = ["Preferences"] -git-tree-sha1 = "9673d39decc5feece56ef3940e5dafba15ba0f81" +git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -version = "1.1.2" +version = "1.2.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" +git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.0" +version = "1.4.1" + +[[deps.PrettyTables]] +deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] +git-tree-sha1 = "88b895d13d53b5577fd53379d913b9ab9ac82660" +uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" +version = "2.3.1" [[deps.Printf]] deps = ["Unicode"] @@ -446,9 +493,9 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" [[deps.QuadGK]] deps = ["DataStructures", "LinearAlgebra"] -git-tree-sha1 = "6ec7ac8412e83d57e313393220879ede1740f9ee" +git-tree-sha1 = "9ebcd48c498668c7fa0e97a9cae873fbee7bfee1" uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" -version = "2.8.2" +version = "2.9.1" [[deps.REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] @@ -498,9 +545,15 @@ version = "0.1.0" [[deps.SLEEFPirates]] deps = ["IfElse", "Static", "VectorizationBase"] -git-tree-sha1 = "4b8586aece42bee682399c4c4aee95446aa5cd19" +git-tree-sha1 = "3aac6d68c5e57449f5b9b865c9ba50ac2970c4cf" uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa" -version = "0.6.39" +version = "0.6.42" + +[[deps.SentinelArrays]] +deps = ["Dates", "Random"] +git-tree-sha1 = "0e7508ff27ba32f26cd459474ca2ede1bc10991f" +uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c" +version = "1.4.1" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -515,20 +568,14 @@ version = "1.1.1" deps = ["Distributed", "Mmap", "Random", "Serialization"] uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" -[[deps.SnoopPrecompile]] -deps = ["Preferences"] -git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" -uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" -version = "1.0.3" - [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "c60ec5c62180f27efea3ba2908480f8055e17cee" +git-tree-sha1 = "5165dfb9fd131cf0c6957a3a7605dede376e7b63" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.1.1" +version = "1.2.0" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] @@ -536,9 +583,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.SpecialFunctions]] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] -git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880" +git-tree-sha1 = "e2cfc4012a19088254b3950b85c3c1d8882d864d" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "2.2.0" +version = "2.3.1" [deps.SpecialFunctions.extensions] SpecialFunctionsChainRulesCoreExt = "ChainRulesCore" @@ -554,21 +601,21 @@ version = "0.1.15" [[deps.StableRNGs]] deps = ["Random", "Test"] -git-tree-sha1 = "3be7d49667040add7ee151fefaf1f8c04c8c8276" +git-tree-sha1 = "ddc1a7b85e760b5285b50b882fa91e40c603be47" uuid = "860ef19b-820b-49d6-a774-d7a799459cd3" -version = "1.0.0" +version = "1.0.1" [[deps.Static]] deps = ["IfElse"] -git-tree-sha1 = "dbde6766fc677423598138a5951269432b0fcc90" +git-tree-sha1 = "f295e0a1da4ca425659c57441bcb59abb035a4bc" uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" -version = "0.8.7" +version = "0.8.8" [[deps.StaticArrayInterface]] -deps = ["ArrayInterface", "Compat", "IfElse", "LinearAlgebra", "Requires", "SnoopPrecompile", "SparseArrays", "Static", "SuiteSparse"] -git-tree-sha1 = "33040351d2403b84afce74dae2e22d3f5b18edcb" +deps = ["ArrayInterface", "Compat", "IfElse", "LinearAlgebra", "PrecompileTools", "Requires", "SparseArrays", "Static", "SuiteSparse"] +git-tree-sha1 = "5d66818a39bb04bf328e92bc933ec5b4ee88e436" uuid = "0d7ed370-da01-4f52-bd93-41d350b8b718" -version = "1.4.0" +version = "1.5.0" [deps.StaticArrayInterface.extensions] StaticArrayInterfaceOffsetArraysExt = "OffsetArrays" @@ -579,9 +626,9 @@ version = "1.4.0" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [[deps.StaticArraysCore]] -git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a" +git-tree-sha1 = "36b3d696ce6366023a0ea192b4cd442268995a0d" uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" -version = "1.4.0" +version = "1.4.2" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] @@ -590,15 +637,15 @@ version = "1.9.0" [[deps.StatsAPI]] deps = ["LinearAlgebra"] -git-tree-sha1 = "45a7769a04a3cf80da1c1c7c60caf932e6f4c9f7" +git-tree-sha1 = "1ff449ad350c9c4cbc756624d6f8a8c3ef56d3ed" uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0" -version = "1.6.0" +version = "1.7.0" [[deps.StatsBase]] deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "75ebe04c5bed70b91614d684259b661c9e6274a4" +git-tree-sha1 = "1d77abd07f617c4868c33d4f5b9e1dbb2643c9cf" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.34.0" +version = "0.34.2" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] @@ -614,6 +661,12 @@ version = "1.3.0" ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112" +[[deps.StringManipulation]] +deps = ["PrecompileTools"] +git-tree-sha1 = "a04cabe79c5f01f4d723cc6704070ada0b9d46d5" +uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e" +version = "0.3.4" + [[deps.SuiteSparse]] deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" @@ -635,10 +688,10 @@ uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" version = "1.0.1" [[deps.Tables]] -deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"] -git-tree-sha1 = "1544b926975372da01227b382066ab70e574a3ec" +deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"] +git-tree-sha1 = "cb76cf677714c095e535e3501ac7954732aeea2d" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "1.10.1" +version = "1.11.1" [[deps.Tar]] deps = ["ArgTools", "SHA"] @@ -651,9 +704,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[deps.ThreadingUtilities]] deps = ["ManualMemory"] -git-tree-sha1 = "c97f60dd4f2331e1a495527f80d242501d2f9865" +git-tree-sha1 = "eda08f7e9818eb53661b3deb74e3159460dfbc27" uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5" -version = "0.5.1" +version = "0.5.2" [[deps.ThreadsX]] deps = ["ArgCheck", "BangBang", "ConstructionBase", "InitialValues", "MicroCollections", "Referenceables", "Setfield", "SplittablesBase", "Transducers"] @@ -662,10 +715,24 @@ uuid = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d" version = "0.1.11" [[deps.Transducers]] -deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"] -git-tree-sha1 = "25358a5f2384c490e98abd565ed321ffae2cbb37" +deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "ConstructionBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"] +git-tree-sha1 = "e579d3c991938fecbb225699e8f611fa3fbf2141" uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999" -version = "0.4.76" +version = "0.4.79" + + [deps.Transducers.extensions] + TransducersBlockArraysExt = "BlockArrays" + TransducersDataFramesExt = "DataFrames" + TransducersLazyArraysExt = "LazyArrays" + TransducersOnlineStatsBaseExt = "OnlineStatsBase" + TransducersReferenceablesExt = "Referenceables" + + [deps.Transducers.weakdeps] + BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" + OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338" + Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e" [[deps.UUIDs]] deps = ["Random", "SHA"] @@ -681,9 +748,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[deps.VectorizationBase]] deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "IfElse", "LayoutPointers", "Libdl", "LinearAlgebra", "SIMDTypes", "Static", "StaticArrayInterface"] -git-tree-sha1 = "b182207d4af54ac64cbc71797765068fdeff475d" +git-tree-sha1 = "7209df901e6ed7489fe9b7aa3e46fb788e15db85" uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f" -version = "0.21.64" +version = "0.21.65" [[deps.Zlib_jll]] deps = ["Libdl"] @@ -698,7 +765,7 @@ version = "5.8.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" +version = "1.52.0+1" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] diff --git a/Project.toml b/Project.toml index ef6f26e..2a50f5a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "WildBootTests" uuid = "65c2e505-86ba-4c19-93f1-95506c1443d5" -authors = ["droodman "] +authors = ["droodman "] version = "0.9.11" [deps] @@ -17,10 +17,4 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d" [compat] -Distributions = "0.25.96" -StableRNGs = "1.0.0" -LoopVectorization = "0.12.159" -PrecompileTools = "1.1.2" -SortingAlgorithms = "1.1.1" -ThreadsX = "0.1.11" julia = "1.8" diff --git a/src/WRE.jl b/src/WRE.jl index 6a4506c..36df529 100644 --- a/src/WRE.jl +++ b/src/WRE.jl @@ -153,7 +153,7 @@ function InitWRE!(o::StrBootTest{T}) where T o.S⋂ȳ₁X = Array{T,3}(undef, 1, o.N⋂, o.DGP.kX) o.S⋂ReplZ̄X = Array{T,3}(undef, o.Repl.kZ, o.N⋂, o.DGP.kX) - o.S⋂XZperpinvZperpZperp = S⋂ZperpX' * o.DGP.invZperpZperp + o.S⋂XZperpinvZperpZperp = cholldiv(o.DGP.cholZperpZperp, S⋂ZperpX) o.negS✻UMZperpX = [Array{T,3}(undef, o.DGP.kX, o.N⋂, o.N✻) for _ in 0:o.Repl.kZ] _inds = o.subcluster>0 ? @@ -238,16 +238,16 @@ function InitWRE!(o::StrBootTest{T}) where T end end - o.invXXS✻XDGPZ = @panelsum(o.DGP.invXX * o.S✻⋂XDGPZ, o.info✻_✻⋂) - o.invXXS✻Xy₁ = o.DGP.invXX * o.S✻Xy₁ - o.invZperpZperpS✻ZperpY₂ = o.DGP.invZperpZperp * o.S✻ZperpY₂ - o.invZperpZperpS✻ZperpX = o.DGP.invZperpZperp * o.S✻ZperpX - o.invZperpZperpS✻Zperpy₁ = o.DGP.invZperpZperp * o.S✻Zperpy₁ - o.invZperpZperpS✻ZperpDGPZ = o.DGP.invZperpZperp * o.S✻ZperpDGPZ + o.invXXS✻XDGPZ = @panelsum(cholldiv(o.DGP.cholXX, o.S✻⋂XDGPZ), o.info✻_✻⋂) + o.invXXS✻Xy₁ = cholldiv(o.DGP.cholXX, o.S✻Xy₁) + o.invZperpZperpS✻ZperpY₂ = cholldiv(o.DGP.cholZperpZperp, o.S✻ZperpY₂ ) + o.invZperpZperpS✻ZperpX = cholldiv(o.DGP.cholZperpZperp, o.S✻ZperpX ) + o.invZperpZperpS✻Zperpy₁ = cholldiv(o.DGP.cholZperpZperp, o.S✻Zperpy₁ ) + o.invZperpZperpS✻ZperpDGPZ = cholldiv(o.DGP.cholZperpZperp, o.S✻ZperpDGPZ) if o.DGP.restricted - o.invXXS✻XDGPZR₁ = o.DGP.invXX * o.S✻XZR₁ - o.invZperpZperpS✻ZperpDGPZR₁ = o.DGP.invZperpZperp * o.S✻ZperpDGPZR₁ + o.invXXS✻XDGPZR₁ = cholldiv(o.DGP.cholXX, o.S✻XZR₁) + o.invZperpZperpS✻ZperpDGPZR₁ = cholldiv(o.DGP.cholZperpZperp, o.S✻ZperpDGPZR₁) end end end @@ -266,7 +266,7 @@ function PrepWRE!(o::StrBootTest{T}) where T o.invXXXZ̄ .= o.Repl.XZ - o.DGP.XÜ₂ * o.Repl.RparY o.XȲ .= [o.DGP.Xȳ₁ o.invXXXZ̄] - o.invXXXZ̄ .= o.Repl.invXX * o.invXXXZ̄ + o.invXXXZ̄ .= cholldiv!(o.Repl.cholXX, o.invXXXZ̄) o.ZÜ₂par .= (o.Repl.ZY₂ - o.Repl.XZ'o.DGP.Π̈ ) * o.Repl.RparY _ȲȲ = o.DGP.γ⃛'o.Repl.XZ - o.DGP.ȳ₁Ü₂ * o.Repl.RparY o.ȲȲ .= [o.DGP.ȳ₁ȳ₁ _ȲȲ @@ -280,14 +280,14 @@ function PrepWRE!(o::StrBootTest{T}) where T panelcross21!(o.S✻Xu₁, o.DGP.X₁, o.DGP.X₂, o.DGP.u⃛₁, o.info✻) panelcross21!(o.S✻XU₂par, o.DGP.X₁, o.DGP.X₂, o.Ü₂par, o.info✻) - t✻!(o.invXXS✻Xu₁ , o.DGP.invXX, o.S✻Xu₁ ) - t✻!(o.invXXS✻XU₂par, o.DGP.invXX, o.S✻XU₂par) + cholldiv!(o.invXXS✻Xu₁ , o.DGP.cholXX, o.S✻Xu₁ ) + cholldiv!(o.invXXS✻XU₂par, o.DGP.cholXX, o.S✻XU₂par) if o.willfill || o.not2SLS panelcross!(o.S✻Zperpu₁, o.DGP.Zperp, o.DGP.u⃛₁, o.info✻) panelcross!(o.S✻ZperpU₂par, o.DGP.Zperp, o.Ü₂par, o.info✻) - t✻!(o.invZperpZperpS✻Zperpu₁, o.DGP.invZperpZperp, o.S✻Zperpu₁) - t✻!(o.invZperpZperpS✻ZperpU₂par, o.DGP.invZperpZperp, o.S✻ZperpU₂par) + cholldiv!(o.invZperpZperpS✻Zperpu₁, o.DGP.cholZperpZperp, o.S✻Zperpu₁) + cholldiv!(o.invZperpZperpS✻ZperpU₂par, o.DGP.cholZperpZperp, o.S✻ZperpU₂par) if o.NFE>0 && !o.FEboot crosstabFE!(o, (@view o.CT✻FEU[1:1 ]), [o.DGP.u⃛₁], o.ID✻, o.N✻) crosstabFE!(o, (@view o.CT✻FEU[2:end]), [o.Ü₂par ], o.ID✻, o.N✻) @@ -321,7 +321,7 @@ function PrepWRE!(o::StrBootTest{T}) where T t✻!(o.S✻XU₂, o.S✻XX, o.DGP.Π̈); o.S✻XU₂ .= o.S✻XY₂ .- o.S✻XU₂; false && o.small && (o.S✻XU₂ .*= o.DGP.m₂) o.S✻XU₂par .= o.S✻XU₂ * o.Repl.RparY # use this syntax for 3-array x DesignerMatrix - t✻!(o.invXXS✻XU₂, o.DGP.invXX, o.S✻XU₂) + cholldiv!(o.invXXS✻XU₂, o.DGP.cholXX, o.S✻XU₂) o.invXXS✻XU₂par .= o.invXXS✻XU₂ * o.Repl.RparY # use this syntax for 3-array x DesignerMatrix if o.willfill || o.not2SLS t✻!(o.S✻ZperpU₂, o.S✻ZperpX, o.DGP.Π̈); o.S✻ZperpU₂ .= o.S✻ZperpY₂ .- o.S✻ZperpU₂ @@ -424,7 +424,7 @@ function PrepWRE!(o::StrBootTest{T}) where T @inbounds for j ∈ 0:o.Repl.kZ if o.Repl.Yendog[j+1] - t✻!(o.negS✻UMZperpX[j+1], o.S⋂XZperpinvZperpZperp, o.S✻ZperpU[j+1]) # S_* diag⁡(U ̈_(∥j) ) Z_⊥ (Z_⊥^' Z_⊥ )^(-1) Z_(⊥g)^' X_(∥g) + t✻!(o.negS✻UMZperpX[j+1], o.S⋂XZperpinvZperpZperp', o.S✻ZperpU[j+1]) # S_* diag⁡(U ̈_(∥j) ) Z_⊥ (Z_⊥^' Z_⊥ )^(-1) Z_(⊥g)^' X_(∥g) o.negS✻UMZperpX[j+1][o.crosstab⋂✻ind] .-= vec(j>0 ? view(o.S✻⋂XÜ₂par,:,:,j) : view(o.S✻⋂Xu₁,:,:,1)) if o.NFE>0 && !o.FEboot for i ∈ 1:o.DGP.kX @@ -735,24 +735,24 @@ function MakeWREStats!(o::StrBootTest{T}, w::Integer) where T M = Matrix{T}(undef, o.Repl.kZ+1, o.Repl.kZ+1) @inbounds for b ∈ eachindex(axes(o.κWRE,2)) - ldiv!(M, bunchkaufman(view(o.YY✻,:,b,:)), view(o.YPXY✻,:,b,:)) + ldiv!(M, _cholesky(view(o.YY✻,:,b,:)), view(o.YPXY✻,:,b,:)) o.κWRE[b] = one(T)/(one(T) - real(eigvalsNaN(M)[1])) end # view(o.κWRE,1,:,1) .= one(T) ./ (one(T) .- getindex.(real.(eigvalsNaN.(each(invsym(o.YY✻) * o.YPXY✻))), 1)) !iszero(o.fuller) && (o.κWRE .-= o.fuller / (o._Nobs - o.kX)) - o.As .= o.κWRE .* view(o.YPXY✻, 2:o.Repl.kZ+1, :, 2:o.Repl.kZ+1) .+ (1 .- o.κWRE) .* view(o.YY✻, 2:o.Repl.kZ+1, :, 2:o.Repl.kZ+1) - invsym!(o.As) - t✻!(view(o.β̈s,:,:,1:1), o.As, o.κWRE .* view(o.YPXY✻, 2:o.Repl.kZ+1, :, 1) .+ (1 .- o.κWRE) .* view(o.YY✻, 2:o.Repl.kZ+1, :, 1)) + o.As .= o.κWRE .* view(o.YPXY✻, 2:o.Repl.kZ+1, :, 2:o.Repl.kZ+1) .+ (1 .- o.κWRE) .* view(o.YY✻, 2:o.Repl.kZ+1, :, 2:o.Repl.kZ+1) + o.β̈s[:,:,1:1] .= o.κWRE .* view(o.YPXY✻, 2:o.Repl.kZ+1, :, 1 ) .+ (1 .- o.κWRE) .* view(o.YY✻, 2:o.Repl.kZ+1, :, 1 ) else HessianFixedkappa!(o, o.δnumer, collect(1:o.Repl.kZ), 0, o.κ, _jk) @inbounds for i ∈ 1:o.Repl.kZ HessianFixedkappa!(o, view(o.As, 1:i, :, i), collect(1:i), i, o.κ, _jk) end symmetrize!(o.As) - invsym!(o.As) - t✻!(view(o.β̈s,:,:,1:1), o.As, view(o.δnumer,:,:,1:1)) + o.β̈s[:,:,1:1] = view(o.δnumer,:,:,1:1) end + cholAs = _cholesky!(o.As) + cholldiv!(cholAs, view(o.β̈s,:,:,1:1)) if o.bootstrapt if o.robust @@ -776,7 +776,7 @@ function MakeWREStats!(o::StrBootTest{T}, w::Integer) where T if o.bootstrapt if o.robust # Compute denominator for this WRE test stat - t✻!(o.ARpars, o.As, o.Repl.RRpar') + cholldiv!(o.ARpars, cholAs, Matrix(o.Repl.RRpar')) t✻!(o.J⋂ARpars[1], o.J⋂s, o.ARpars) t✻!(o.denomWRE, o.clust[1].multiplier, o.J⋂ARpars[1]', o.J⋂ARpars[1]) for c ∈ 2:o.NErrClustCombs @@ -787,7 +787,7 @@ function MakeWREStats!(o::StrBootTest{T}, w::Integer) where T end else # non-robust tmp = view([fill(T(-1), 1, o.ncolsv) ; o.β̈s], :, :, 1:1) - o.denomWRE .= (o.Repl.RRpar * o.As * o.Repl.RRpar') .* (tmp'o.YY✻ * tmp) # 2nd half is sig2 of errors + o.denomWRE .= (o.Repl.RRpar * cholldiv(cholAs, Matrix(o.Repl.RRpar'))) .* (tmp'o.YY✻ * tmp) # 2nd half is sig2 of errors end if w==1 o.statDenom = o.denomWRE[:,1,:] @@ -796,9 +796,9 @@ function MakeWREStats!(o::StrBootTest{T}, w::Integer) where T if o.sqrt @storeWtGrpResults!(o.dist, o.numerWRE ./ sqrtNaN.(dropdims(o.denomWRE; dims=3))) else - invsym!(o.denomWRE) + choldenomWRE = _cholesky!(o.denomWRE) _numer = view(o.numerWRE,:,:,1:1) - @storeWtGrpResults!(o.dist, dropdims(_numer'o.denomWRE*_numer; dims=3)) # hand-code for 2-dimensional? XXX allocations + @storeWtGrpResults!(o.dist, dropdims(_numer'cholldiv(choldenomWRE,_numer); dims=3)) # hand-code for 2-dimensional? XXX allocations end else @storeWtGrpResults!(o.numer, o.numerWRE) diff --git a/src/WildBootTests.jl b/src/WildBootTests.jl index fcf8fc0..0c057f3 100644 --- a/src/WildBootTests.jl +++ b/src/WildBootTests.jl @@ -76,7 +76,8 @@ function NoNullUpdate!(o::StrBootTest{T} where T) else o.numer[:,1] = o.R * (o.ml ? o.β̈ : iszero(o.κ) ? view(o.M.β̈ ,:,1) : o.M.Rpar * view(o.M.β̈ ,:,1)) - o.r # Analytical Wald numerator; if imposing null then numer[:,1] already equals this. If not, then it's 0 before this end - o.dist[1] = isone(o.dof) ? o.numer[1] / sqrtNaN(o.statDenom[1]) : o.numer[:,1]'invsym(o.statDenom)*o.numer[:,1] + numer₁ = o.numer[:,1] + o.dist[1] = isone(o.dof) ? o.numer[1] / sqrtNaN(o.statDenom[1]) : numer₁'cholldiv!(_cholesky(o.statDenom), numer₁) nothing end diff --git a/src/estimators.jl b/src/estimators.jl index d6d0da0..a1382cb 100644 --- a/src/estimators.jl +++ b/src/estimators.jl @@ -5,7 +5,7 @@ @inline identify(X::AbstractMatrix{T}) where T = size(X,1)==size(X,2) && DesignerMatrix(X).type==selection ? Matrix{T}(I(size(X,1))) : X # try to turn square selection matrix into idnentity: same projection space function par(X::AbstractMatrix{T}) where T - F = eigen(Symmetric(X'pinv(X * X')*X)) + F = eigen(Symmetric(X'cholldiv(_cholesky!(X * X'), X))) return identify(denegate(F.vectors[:, abs.(F.values) .> 1000*eps(T)])) end @inline perp(X) = identify(denegate(nullspace(X'))) @@ -18,9 +18,9 @@ function setR!(o::StrEstimator{T}, parent::StrBootTest{T}, R₁::AbstractMatrix{ o.restricted = nrows(R₁) > 0 if o.restricted - singular, invR₁R₁ = invsymsingcheck(R₁ * R₁') - singular && throw(ErrorException("Null hypothesis or model constraints are inconsistent or redundant.")) - o.R₁invR₁R₁ = R₁'invR₁R₁ + cholR₁R₁ = _cholesky!(R₁ * R₁') + rank(cholR₁R₁)0 ? (o.Rperp * invsym(o.Rperp'H*o.Rperp) * o.Rperp') : o.invH + o.A = ncols(o.Rperp)>0 ? o.Rperp * cholldiv(_cholesky!(o.Rperp'H*o.Rperp), o.Rperp') : o.invH o.AR = o.A * o.Rpar'parent.R' o.XAR = X₁₂B(o.X₁, o.X₂, o.V * o.AR) end @@ -610,7 +618,7 @@ function EstimateIV!(o::StrEstimator{T}, parent::StrBootTest{T}, _jk::Bool, r₁ o.t₁ = o.R₁invR₁R₁ * r₁ o.y₁pary₁par = o.y₁y₁ - (o.twoZR₁y₁'r₁)[] + r₁'o.ZR₁ZR₁ * r₁ - o.Y₂y₁par .= o.Y₂y₁ - o.ZR₁Y₂'r₁ + o.Y₂y₁par .= o.Y₂y₁ - o.ZR₁Y₂'r₁ o.X₁y₁par .= o.X₁y₁ - o.X₁ZR₁ * r₁ o.X₂y₁par .= o.X₂y₁ - o.X₂ZR₁ * r₁ o.Xy₁par .= [o.X₁y₁par ; o.X₂y₁par] @@ -630,7 +638,7 @@ function EstimateIV!(o::StrEstimator{T}, parent::StrBootTest{T}, _jk::Bool, r₁ end end - o.invXXXy₁par = o.invXX * o.Xy₁par + o.invXXXy₁par = cholldiv(o.cholXX, o.Xy₁par) o.YY = ([[o.y₁pary₁par] o.Zy₁par'; o.Zy₁par o.ZZ]) if o.isDGP @@ -638,22 +646,23 @@ function EstimateIV!(o::StrEstimator{T}, parent::StrBootTest{T}, _jk::Bool, r₁ if o.liml o.YPXY = ([[o.invXXXy₁par'o.Xy₁par] o.ZXinvXXXy₁par' ; o.ZXinvXXXy₁par o.H_2SLS]) - o.κ = 1/(1 - real(eigvalsNaN(invsym(o.YY) * o.YPXY)[1])) # like Fast & Wild (81), but more stable, at least in Mata + o.κ = 1/(1 - real(eigvalsNaN(cholldiv!(_cholesky(o.YY), o.YPXY))[1])) # like Fast & Wild (81), but more stable, at least in Mata !iszero(o.fuller) && (o.κ -= o.fuller / (parent._Nobs - parent.kX)) MakeH!(o, parent) end o.β̈ = o.invH * (isone(o.κ) ? o.ZXinvXXXy₁par : o.κ * (o.ZXinvXXXy₁par - o.Zy₁par) + o.Zy₁par) if _jk - o.invXXXy₁parⱼₖ .= o.invXXⱼₖ * o.Xy₁parⱼₖ + o.invXXXy₁parⱼₖ = copy(o.Xy₁parⱼₖ); cholldiv!(o.cholXXⱼₖ, o.invXXXy₁parⱼₖ,) o.ZXinvXXXy₁parⱼₖ .= o.XZⱼₖ'o.invXXXy₁parⱼₖ o.YYⱼₖ .= [o.y₁pary₁parⱼₖ; o.Zy₁parⱼₖ ;;; o.Zy₁parⱼₖ'; o.ZZⱼₖ] if o.liml o.YPXYⱼₖ .= [o.invXXXy₁parⱼₖ'o.Xy₁parⱼₖ ; o.ZXinvXXXy₁parⱼₖ ;;; o.ZXinvXXXy₁parⱼₖ' ; o.H_2SLSⱼₖ] - o.κⱼₖ .= reshape(one(T) ./ (one(T) .- getindex.(real.(eigvalsNaN.(each(invsym(o.YYⱼₖ) * o.YPXYⱼₖ))), 1)), (1,:,1)) + o.κⱼₖ .= reshape(one(T) ./ (one(T) .- getindex.(real.(eigvalsNaN.(each(cholldiv!(_cholesky(o.YYⱼₖ), o.YPXYⱼₖ)))), 1)), (1,:,1)) !iszero(o.fuller) && (o.κⱼₖ .-= reshape(o.fuller ./ (o.Nobsⱼₖ .- parent.kX)), (1,:,1)) - o.invHⱼₖ .= o.ZZⱼₖ .+ o.κⱼₖ .* o.H_2SLSmZZⱼₖ; invsym!(o.invHⱼₖ) + o.Hⱼₖ .= o.ZZⱼₖ .+ o.κⱼₖ .* o.H_2SLSmZZⱼₖ + o.cholHⱼₖ = _cholesky!(o.Hⱼₖ) o.β̈ⱼₖ .= o.κⱼₖ .* (o.ZXinvXXXy₁parⱼₖ .- o.Zy₁parⱼₖ) .+ o.Zy₁parⱼₖ else if isone(o.κ) @@ -662,7 +671,7 @@ function EstimateIV!(o::StrEstimator{T}, parent::StrBootTest{T}, _jk::Bool, r₁ o.β̈ⱼₖ .= o.κ .* (o.ZXinvXXXy₁parⱼₖ .- o.Zy₁parⱼₖ) .+ o.Zy₁parⱼₖ end end - o.β̈ⱼₖ .= o.invHⱼₖ * o.β̈ⱼₖ + cholldiv!(o.cholHⱼₖ, o.β̈ⱼₖ) end elseif parent.WREnonARubin # if not score bootstrap of IV/GMM... o.Rt₁ = o.RR₁invR₁R₁ * r₁ @@ -690,10 +699,11 @@ function MakeResidualsOLS!(o::StrEstimator{T}, parent::StrBootTest{T}) where T _MXt₁pu = rowsubview(o.MXt₁pu, length(S)) X₁₂B!(_Xt₁, view(parent.X₁,S,:), view(parent.X₂,S,:), o.t₁) _Xt₁pu .= view(o.ü₁[1], S) .+ _Xt₁ - mul!(_MXt₁pu, o.invMjk[g], _Xt₁pu) + cholldiv!(_MXt₁pu, o.cholMjk[g], _Xt₁pu) o.ü₁[2][S] .= m .* (_MXt₁pu .- _Xt₁) else - t✻!(view(o.ü₁[2],S), m, o.invMjk[g], view(o.ü₁[1], S)) + cholldiv!(view(o.ü₁[2],S), o.cholMjk[g], view(o.ü₁[1], S)) + o.ü₁[2][S] .*= m end end else @@ -729,7 +739,7 @@ function MakeResidualsIV!(o::StrEstimator{T}, parent::StrBootTest{T}) where T Xu = o.Xy₁par - o.XZ * o.β̈ # after DGP regression, compute Y₂ residuals by regressing Y₂ on X while controlling for y₁ residuals, done through FWL negXuinvuu = Xu / -uu - o.Π̈ = invsym(o.XX + negXuinvuu * Xu') * (negXuinvuu * (o.Y₂y₁par - o.ZY₂'o.β̈ )' + o.XY₂) + o.Π̈ = cholldiv!!(o.XX + negXuinvuu * Xu', negXuinvuu * (o.Y₂y₁par - o.ZY₂'o.β̈ )' + o.XY₂) o.γ̈ = o.Rpar * o.β̈ + o.t₁ - parent.Repl.t₁ o.Ü₂Ü₂ = o.Y₂Y₂ - (o.Π̈)'o.XY₂ - o.XY₂'o.Π̈ + (o.Π̈)'o.XX*o.Π̈ @@ -759,7 +769,7 @@ function MakeResidualsIV!(o::StrEstimator{T}, parent::StrBootTest{T}) where T Xu .= view(o.Xy₁parⱼₖ,:,g,:); t✻minus!(Xu, view(o.XZⱼₖ,:,g,:), view(o.β̈ⱼₖ,:,g,1)) # after DGP regression, compute Y₂ residuals by regressing Y₂ on X while controlling for y₁ residuals, done through FWL negXuinvuu .= Xu ./ -uu - Π̈ⱼₖ .= invsym(view(o.XXⱼₖ,:,g,:) + negXuinvuu * Xu') * (negXuinvuu * (view(o.Y₂y₁parⱼₖ,:,g,:) - view(o.ZY₂ⱼₖ,:,g,:)'view(o.β̈ⱼₖ,:,g,1))' + view(o.XY₂ⱼₖ,:,g,:)) + cholldiv!(Π̈ⱼₖ, _cholesky!(view(o.XXⱼₖ,:,g,:) + negXuinvuu * Xu'), negXuinvuu * (view(o.Y₂y₁parⱼₖ,:,g,:) - view(o.ZY₂ⱼₖ,:,g,:)'view(o.β̈ⱼₖ,:,g,1))' + view(o.XY₂ⱼₖ,:,g,:)) t✻minus!(view(o.Ü₂,S,:), view(o.Xⱼₖ,S,:), Π̈ⱼₖ) t✻plus!(view(o.u⃛₁,S), view(o.Ü₂,S,:), o.RparY * view(o.β̈ⱼₖ,:,g,1) + _t₁Y) end diff --git a/src/interface.jl b/src/interface.jl index 5ab4d54..be44bc4 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -251,19 +251,9 @@ function _wildboottest(T::DataType, @assert any(auxwttype .== (:rademacher, :mammen, :webb, :gamma, :normal)) "auxwttype shoud be :rademacher, :mammen, :webb, :gamma, or :normal" @assert any(ptype .==(:symmetric, :equaltail, :lower, :upper)) "ptype should be :symmetric, :equaltail, :lower, or :upper" @assert any(madjtype .== (:none, :bonferroni, :sidak)) "madjtype should be :none, :bonferroni, or :sidak" - @assert ml || ncols(resp)==1 "resp should have one column" - @assert (length(predexog)==0 || nrows(predexog)==nrows(resp)) && - (length(predendog)==0 || nrows(predendog)==nrows(resp)) && - (length(inst)==0 || nrows(inst)==nrows(resp)) "All data vectors/matrices must have same height" - @assert ncols(inst) >= ncols(predendog) "Model has fewer instruments than instrumented variables" - @assert length(feid)==0 || nrows(feid)==nrows(resp) "feid vector must have same height as data matrices" - @assert ncols(feid)≤1 "feid should have one column" - @assert length(clustid)==0 || nrows(clustid)==nrows(resp) "clustid must have same height as data matrices" - @assert nrows(obswt)==0 || nrows(obswt)==nrows(resp) "obswt must have same height as data matrices" @assert ncols(obswt)≤1 "obswt must have one column" @assert nrows(R)==nrows(r) "R and r must have same height" @assert (ncols(R) == (ml ? nrows(beta) : ncols(predexog)+ncols(predendog)) && isone(ncols(r))) "Wrong number of columns in null specification" - @assert nrows(R1)==nrows(r1) "R₁ and r₁ must have same height" @assert length(R1)==0 || ncols(R1)==ncols(predexog)+ncols(predendog) "Wrong number of columns in model constraint specification" @assert ncols(r)==1 "r should have one column" @assert length(R1)==0 || ncols(r1)==1 "r1 should have one column" @@ -275,9 +265,22 @@ function _wildboottest(T::DataType, @assert nH0 > 0 "nH0 ≤ 0" @assert !liml || (ncols(predendog)>0 && ncols(inst)>0) "For liml, non-empty predendog and inst arguments are needed" @assert fuller==0 || (ncols(predendog)>0 && ncols(inst)>0) "For Fuller liml, non-empty predendog and inst arguments are needed" - @assert iszero(ncols(predendog)) || ncols(inst)>0 "predendog provided without inst" - @assert !arubin || ncols(predendog)>0 "Anderson-Rubin test requested but predendog not provided" + if !ml + @assert ncols(resp)==1 "resp should have one column" + @assert (length(predexog)==0 || nrows(predexog)==nrows(resp)) && + (length(predendog)==0 || nrows(predendog)==nrows(resp)) && + (length(inst)==0 || nrows(inst)==nrows(resp)) "All data vectors/matrices must have same height" + @assert ncols(inst) >= ncols(predendog) "Model has fewer instruments than instrumented variables" + @assert length(feid)==0 || nrows(feid)==nrows(resp) "feid vector must have same height as data matrices" + @assert ncols(feid)≤1 "feid should have one column" + @assert length(clustid)==0 || nrows(clustid)==nrows(resp) "clustid must have same height as data matrices" + @assert nrows(obswt)==0 || nrows(obswt)==nrows(resp) "obswt must have same height as data matrices" + @assert nrows(R1)==nrows(r1) "R₁ and r₁ must have same height" + @assert iszero(ncols(predendog)) || ncols(inst)>0 "predendog provided without inst" + @assert !arubin || ncols(predendog)>0 "Anderson-Rubin test requested but predendog not provided" + end + if getplot || getci @assert iszero(length(gridmin )) || length(gridmin )==nrows(R) "Length of gridmin doesn't match number of hypotheses being jointly tested" @assert iszero(length(gridmax )) || length(gridmax )==nrows(R) "Length of gridmax doesn't match number of hypotheses being jointly tested" diff --git a/src/nonWRE.jl b/src/nonWRE.jl index a0d18cc..25d474b 100644 --- a/src/nonWRE.jl +++ b/src/nonWRE.jl @@ -284,7 +284,7 @@ function MakeNonWRELoop1!(o::StrBootTest, tmp::Matrix, w::Integer) end end numerₖ = view(o.numerw,:,k) - o.dist[k+first(o.WeightGrp[w])-1] = numerₖ'invsym(tmp)*numerₖ # in degenerate cases, cross() would turn cross(.,.) into 0 + o.dist[k+first(o.WeightGrp[w])-1] = numerₖ'cholldiv(_cholesky(tmp),numerₖ) end nothing end @@ -336,21 +336,22 @@ function MakeNonWREStats!(o::StrBootTest{T}, w::Integer) where T isone(w) && (o.statDenom = denom) # original-sample denominator else if o.ml + choldenom = _cholesky(denom) for k ∈ 1:o.ncolsv numerₖ = view(o.numerw,:,k) - o.dist[k+first(o.WeightGrp[w])-1] = numerₖ'invsym(denom)*numerₖ + o.dist[k+first(o.WeightGrp[w])-1] = numerₖ'cholldiv(choldenom,numerₖ) end isone(w) && (o.statDenom = denom) # original-sample denominator else - invdenom = invsym(denom) + choldenom = _cholesky(denom) if o.B>0 for k ∈ 1:o.ncolsv numerₖ = view(o.numerw,:,k) u✻ₖ = view(o.u✻,:,k) - o.dist[k+first(o.WeightGrp[w])-1] = numerₖ'invdenom*numerₖ / (tmp = u✻ₖ'u✻ₖ) + o.dist[k+first(o.WeightGrp[w])-1] = numerₖ'cholldiv(choldenom, numerₖ) / (tmp = u✻ₖ'u✻ₖ) end else - o.dist[1] = (o.numerw'invdenom*o.numerw)[] / (tmp = dot(o.u✻,o.u✻)) + o.dist[1] = (o.numerw'cholldiv(choldenom, o.numerw))[] / (tmp = dot(o.u✻,o.u✻)) end isone(w) && (o.statDenom = denom * tmp) # original-sample denominator end diff --git a/src/precompiler.jl b/src/precompiler.jl index 71c4b3c..d8b35ce 100644 --- a/src/precompiler.jl +++ b/src/precompiler.jl @@ -10,7 +10,7 @@ using PrecompileTools, StableRNGs idgranular = floor.(Int, collect(0:999)/2) feid = mod.(collect(0:999), 100) - # @compile_workload begin + @compile_workload begin wildboottest(T, T[0 0 0 1] , T[.04]; resp, predexog, clustid=idcoarse) wildboottest(T, T[0 0 0 1] , T[.04]; resp, predexog, rng, clustid=idgranular, reps=100) wildboottest(T, T[0 0 0 1] , T[.04]; resp, predexog, rng, small=false) @@ -35,6 +35,6 @@ using PrecompileTools, StableRNGs wildboottest( [0 0 0 0 1], T[.04]; resp, predexog, jk=true, predendog, inst, rng, clustid=idcoarse) wildboottest( [0 0 0 0 1], T[.04]; resp, predexog, jk=true, predendog, inst, rng, clustid=idcoarse, arubin=true) wildboottest( [0 0 0 1 0], T[.04]; resp, predexog, jk=true, predendog, inst, rng, clustid=idgranular, reps=100, liml=true) - # end + end end end diff --git a/src/structs.jl b/src/structs.jl index 6cc6d08..be7296a 100644 --- a/src/structs.jl +++ b/src/structs.jl @@ -138,15 +138,16 @@ mutable struct StrEstimator{T<:AbstractFloat} kZ::Int64 y₁::Vector{T}; ü₁::Vector{Vector{T}}; u⃛₁::Vector{T}; β̈::Vector{T}; γ̈::Vector{T}; β̈₀::Vector{T}; invXXXy₁par::Vector{T} Yendog::Matrix{Bool} - invZperpZperp::Matrix{T}; invZperpZperpZperpX::Matrix{T}; XZ::Matrix{T}; YPXY::Matrix{T}; R₁invR₁R₁::Matrix{T}; R₁invR₁R₁X::DesignerMatrix{T}; R₁invR₁R₁Y::DesignerMatrix{T} + invZperpZperpZperpX::Matrix{T}; XZ::Matrix{T}; YPXY::Matrix{T}; R₁invR₁R₁::Matrix{T}; R₁invR₁R₁X::DesignerMatrix{T}; R₁invR₁R₁Y::DesignerMatrix{T} restricted::Bool; RperpX::DesignerMatrix{T}; RperpXperp::DesignerMatrix{T}; RRpar::Matrix{T}; RparX::Matrix{T}; RparY::DesignerMatrix{T}; RR₁invR₁R₁::Matrix{T} ∂β̈∂r::Matrix{T}; YY::Matrix{T}; AR::Matrix{T}; XAR::Matrix{T}; Ü₂::Matrix{T}; Rt₁::Vector{T} invXX::Matrix{T}; Y₂::Matrix{T}; X₂::Matrix{T}; invH::Matrix{T} + cholZperpZperp::CholeskyPivoted{T, Matrix{T}, Vector{Int64}}; cholXX::CholeskyPivoted{T, Matrix{T}, Vector{Int64}} y₁par::Vector{T}; Xy₁par::Vector{T} A::Matrix{T}; Zpar::Matrix{T}; Zperp::Matrix{T}; X₁::Matrix{T} CT_XAR::Vector{SparseMatrixCSC{T}} copyfromDGP::Bool - S✻XX::Array{T,3}; XinvHⱼₖ::Vector{Matrix{T}}; invMjk::Vector{Matrix{T}}; invMjkv::Vector{T}; XXt1jk::Matrix{T}; t₁::Vector{T} + S✻XX::Array{T,3}; XinvHⱼₖ::Vector{Matrix{T}}; cholMjk::Vector{CholeskyPivoted{T, Matrix{T}, Vector{Int64}}}; invMjkv::Vector{T}; XXt1jk::Matrix{T}; t₁::Vector{T} Xt₁::Matrix{T}; Xt₁pu::Matrix{T}; MXt₁pu::Matrix{T}; Xu::Vector{T} # IV/GMM only @@ -167,8 +168,11 @@ mutable struct StrEstimator{T<:AbstractFloat} Ü₂Ü₂::Matrix{T}; γ̈X::Vector{T}; γ̈Y::Vector{T}; γ⃛::Vector{T}; Xȳ₁::Vector{T}; ȳ₁ȳ₁::T; XÜ₂::Matrix{T}; ȳ₁Ü₂::Matrix{T}; Ȳ₂::Matrix{T}; ȳ₁::Vector{T} Xpar₁toZparX::DesignerMatrix{T} - Xⱼₖ::Matrix{T}; y₁ⱼₖ::Vector{T}; Y₂ⱼₖ::Matrix{T}; Zⱼₖ::Matrix{T}; ZR₁ⱼₖ::Matrix{T}; Y₂y₁ⱼₖ::Array{T,3}; Xy₁ⱼₖ::Array{T,3}; Zy₁ⱼₖ::Array{T,3}; XZⱼₖ::Array{T,3}; ZZⱼₖ::Array{T,3}; ZY₂ⱼₖ::Array{T,3}; y₁y₁ⱼₖ::Array{T,3}; XY₂ⱼₖ::Array{T,3}; invXXⱼₖ::Array{T,3}; XXⱼₖ::Array{T,3}; XZR₁ⱼₖ::Array{T,3}; ZR₁Zⱼₖ::Array{T,3}; twoZR₁y₁ⱼₖ::Array{T,3}; ZR₁ZR₁ⱼₖ::Array{T,3}; ZR₁Y₂ⱼₖ::Array{T,3} - Y₂y₁parⱼₖ::Array{T,3}; Zy₁parⱼₖ::Array{T,3}; y₁pary₁parⱼₖ::Array{T,3}; Xy₁parⱼₖ::Array{T,3}; y₁parⱼₖ::Vector{T}; H_2SLSⱼₖ::Array{T,3}; H_2SLSmZZⱼₖ::Array{T,3}; invHⱼₖ::Array{T,3} + Xⱼₖ::Matrix{T}; y₁ⱼₖ::Vector{T}; Y₂ⱼₖ::Matrix{T}; Zⱼₖ::Matrix{T}; ZR₁ⱼₖ::Matrix{T}; Y₂y₁ⱼₖ::Array{T,3}; Xy₁ⱼₖ::Array{T,3}; Zy₁ⱼₖ::Array{T,3}; XZⱼₖ::Array{T,3}; ZZⱼₖ::Array{T,3}; ZY₂ⱼₖ::Array{T,3}; y₁y₁ⱼₖ::Array{T,3}; XY₂ⱼₖ::Array{T,3} + XXⱼₖ::Array{T,3}; XZR₁ⱼₖ::Array{T,3}; ZR₁Zⱼₖ::Array{T,3}; twoZR₁y₁ⱼₖ::Array{T,3}; ZR₁ZR₁ⱼₖ::Array{T,3}; ZR₁Y₂ⱼₖ::Array{T,3} + cholXXⱼₖ::Vector{CholeskyPivoted{T, Matrix{T}, Vector{Int64}}} + Y₂y₁parⱼₖ::Array{T,3}; Zy₁parⱼₖ::Array{T,3}; y₁pary₁parⱼₖ::Array{T,3}; Xy₁parⱼₖ::Array{T,3}; y₁parⱼₖ::Vector{T}; H_2SLSⱼₖ::Array{T,3}; H_2SLSmZZⱼₖ::Array{T,3} + Hⱼₖ::Array{T,3}; cholHⱼₖ::Vector{CholeskyPivoted{T, SubArray{T, 2, Array{T, 3}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64, Base.Slice{Base.OneTo{Int64}}}, false}, Vector{Int64}}} β̈ⱼₖ::Array{T,3}; κⱼₖ::Array{T,3}; YPXYⱼₖ::Array{T,3}; YYⱼₖ::Array{T,3}; invXXXy₁parⱼₖ::Array{T,3}; ZXinvXXXy₁parⱼₖ::Array{T,3} StrEstimator{T}(isDGP, liml, fuller, κ) where T<:AbstractFloat = new(isDGP, liml, fuller, κ, Matrix{T}(undef,0,0)) @@ -274,7 +278,7 @@ mutable struct StrBootTest{T<:AbstractFloat} Vector{T}(undef,0), Vector{T}(undef,0), Matrix{T}(undef,0,0), Matrix{T}(undef,0,0), (X = Vector{T}(undef,0), p = T(NaN)), - 0, nrows(y₁), ncols(clustid), ncols(X₁), kX₂, ncols(Y₂), WREnonARubin, WREnonARubin ? boottestWRE! : boottestOLSARubin!, + 0, nrows(ml ? sc : y₁), ncols(clustid), ncols(X₁), kX₂, ncols(Y₂), WREnonARubin, WREnonARubin ? boottestWRE! : boottestOLSARubin!, v) end end diff --git a/src/utilities.jl b/src/utilities.jl index 0fa7eff..151363a 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -37,24 +37,10 @@ end # iszero(nrows(X)) && (return Symmetric(X)) # X, ipiv, info = LinearAlgebra.LAPACK.sytrf!('U', Matrix(X)) # iszero(info) && LinearAlgebra.LAPACK.sytri!('U', X, ipiv) -@inline invsym(X) = try X \ I catch _ pinv(X) end -@inline invsym!(Y,X) = try ldiv!(Y, X, I) catch _ Y .= pinv(X) end - -eigvalsNaN(X) = - try - eigvals(X) - catch _ - fill(eltype(X)(NaN), size(X)) - end - -function invsymsingcheck(X) # inverse of symmetric matrix, checking for singularity - iszero(nrows(X)) && (return (false, (X))) - X, ipiv, info = LinearAlgebra.LAPACK.sytrf!('U', Matrix(X)) - singular = info>0 - !singular && LinearAlgebra.LAPACK.sytri!('U', X, ipiv) - singular, (X) -end +@inline invsym(X) = inv(_cholesky(X)) +@inline invsym!(X) = inv(_cholesky!(X)) +eigvalsNaN(X) = try eigvals(X) catch _ fill(eltype(X)(NaN), size(X)) end @inline colsum(X::AbstractArray) = iszero(length(X)) ? similar(X, 1, size(X)[2:end]...) : sum(X, dims=1) @inline colsum(X::AbstractArray{Bool}) = iszero(length(X)) ? Array{Int}(undef, 1, size(X)[2:end]...) : sum(X, dims=1) # type-stable @@ -349,6 +335,65 @@ function t✻minus!(A::AbstractVecOrMat{T}, B::T, C::AbstractVecOrMat{T}) where nothing end +_cholesky!(X) = cholesky!(Symmetric(X), RowMaximum(), check=false) +_cholesky(X) = cholesky( Symmetric(X), RowMaximum(), check=false) + +_cholesky(X::Array{T,3}) where T = [_cholesky(view(X,:,g,:)) for g ∈ eachindex(axes(X,2))] +_cholesky!(X::Array{T,3}) where T = [_cholesky!(view(X,:,g,:)) for g ∈ eachindex(axes(X,2))] + + +# ch \ Y => Y +function cholldiv!(ch::CholeskyPivoted{T}, Y::AbstractVecOrMat{T}) where T # adapted from GLM, https://github.com/JuliaStats/GLM.jl/blob/afbb5130ab2773c4b72a3efb4737cf6c6f0c1b09/src/linpred.jl#L134C1-L134C30 + if !iszero(length(Y)) + rnk = rank(ch) + len = size(Y,1) + if rnk == len + ldiv!(ch, Y) + else + for v ∈ eachcol(Y) + permute!(v, ch.piv) + v[rnk+1:len] .= zero(T) + LAPACK.potrs!(ch.uplo, view(ch.factors, 1:rnk, 1:rnk), view(v, 1:rnk, :)) + invpermute!(v, ch.piv) + end + end + end + Y +end +cholldiv!(ch::CholeskyPivoted{T}, Y::Array{T,3}) where T = cholldiv!(ch, reshape(Y,size(Y,1),:)) + +# ch \ Y => A +cholldiv!(A, ch::CholeskyPivoted{T}, Y) where T = cholldiv!(ch, (A .= Y)) +function cholldiv!(A::AbstractArray{T,3}, vch::Vector{S} where S<:CholeskyPivoted{T}, Y::AbstractMatrix{T}) where T + @inbounds for g ∈ eachindex(axes(A,2)) + A[:,g,:] .= Y + cholldiv!(vch[g], view(A,:,g,:)) + end + A +end +# ch \ Y => Y +function cholldiv!(vch::Vector{S} where S<:CholeskyPivoted{T}, Y::AbstractArray{T,3}) where T + @inbounds for g ∈ eachindex(axes(Y,2)) + cholldiv!(vch[g], view(Y,:,g,:)) + end + Y +end + + +# ch \ Y => copy(Y) +cholldiv(ch::CholeskyPivoted{T}, Y::AbstractVecOrMat{T}) where T = cholldiv!(ch, copy(Y)) +cholldiv(ch::CholeskyPivoted{T}, Y::AbstractArray{T,3} ) where T = reshape(cholldiv(ch, reshape(Y,size(Y,1),:)), size(Y)) +function cholldiv(vch::Vector{S} where S<:CholeskyPivoted{T}, Y::AbstractArray{T,3}) where T + dest = copy(Y) + cholldiv!(vch, dest) +end +function cholldiv(vch::Vector{S} where S<:CholeskyPivoted{T}, Y::AbstractVecOrMat{T}) where T + dest = Array{T,3}(undef, size(Y,1), length(vch), size(Y,2)) + cholldiv!(dest, vch, Y) +end + +cholldiv!!(X::AbstractMatrix{T}, Y::AbstractVecOrMat{T}) where T = cholldiv!(_cholesky!(X),Y) # overwrites both args + # like Mata panelsetup() but can group on multiple columns, like sort(). But doesn't take minobs, maxobs arguments. function panelsetup(X::AbstractArray{S} where S, colinds::AbstractVector{T} where T<:Integer) @@ -392,22 +437,6 @@ function panelsetupID(X::AbstractArray{S} where S, colinds::UnitRange{T} where T info, ID end -# Given a sorted vector, generate standardized group numbering vector: 1,...,1,2... -function ID(X::AbstractVector) - N = nrows(X) - ID = Vector{Int64}(undef,N) - ID[1] = lo = p = 1 - Xlo = X[1] - @inbounds for hi ∈ 2:N - if (Xhi = X[hi]) ≠ Xlo - lo, Xlo = hi, Xhi - p += 1 - end - ID[hi] = p - end - ID -end - function panelsum!(dest::AbstractVecOrMat, X::AbstractVecOrMat, info::AbstractVector{UnitRange{T}} where T<:Integer) iszero(length(dest)) && return J = CartesianIndices(axes(X)[2:end]) @@ -846,7 +875,7 @@ macro clustAccum!(X, c, Y) # efficiently add a cluster combination-specific ter end end -import Base.*, Base.adjoint, Base.hcat, Base.vcat, Base.-, Base.size #, LinearAlgebra.pinv +import Base.*, Base.adjoint, Base.hcat, Base.vcat, Base.-, Base.size # use 3-arrays to hold single-indexed sets of matrices. Index in _middle_ dimension. @inline each(A::Array{T,3}) where T = [view(A,:,i,:) for i ∈ 1:size(A,2)] # eachslice(A; dims=2) more elegant but type-unstable @@ -973,17 +1002,7 @@ function t✻minus!(dest::AbstractArray{T,3}, A::AbstractArray{T,3}, B::Abstract nothing end -# @inline invsym!(Y::AbstractMatrix{T}, X::AbstractMatrix{T}) where T = ldiv!(Y, lu(X), I(size(X,1))) # slowerthan Y = X \ I - # in-place inverse of a set of symmetric matrices -function invsym!(A::Array{T,3}) where T - Iₖ = I(size(A,1)) - @inbounds for g ∈ eachindex(axes(A,2)) - v = view(A,:,g,:) - try ldiv!(v, qr(v), Iₖ) catch _ fill!(v, T(NaN)) end - end - nothing -end function invsym(A::Array{T,3}) where T dest = similar(A) @inbounds for g ∈ eachindex(axes(A,2)) @@ -991,17 +1010,9 @@ function invsym(A::Array{T,3}) where T end dest end -# function invsym(A::Array{T,3}) where T -# dest = similar(A) -# Iₖ = I(size(A,1)) -# @inbounds for g ∈ eachindex(axes(A,2)) -# ldiv!(view(dest,:,g,:), qr(view(A,:,g,:)), Iₖ) -# end -# dest -# end @inline (-)(A::AbstractMatrix{T}, B::Array{T,3}) where T = reshape(A, (size(A,1),1,size(A,2))) .- B # would be better to overload .-, but more complicated -@inline (-)(B::Array{T,3}, A::AbstractMatrix{T}) where T = B .- reshape(A, (size(A,1),1,size(A,2))) # would be better to overload .-, but more complicated +@inline (-)(B::Array{T,3}, A::AbstractMatrix{T}) where T = B .- reshape(A, (size(A,1),1,size(A,2))) # delete-g inner products of two vector/matrices; returns full inner product too function crossjk(A::VecOrMat{T}, B::AbstractMatrix{T}, info::Vector{UnitRange{Int64}}) where T @@ -1022,22 +1033,23 @@ function crossjk(A::VecOrMat{T}, B::Vector{T}, info::Vector{UnitRange{Int64}}) w (vec(sumt), t) end -# given data matrix X and cluster-defining info vector, compute X'X, invsym(X'X), and delete-g invsym(X'X)'s efficiently +# given data matrix X and cluster-defining info vector, compute X'X, cholesky(X'X), and delete-g invsym(X'X)'s efficiently function invsymcrossjk(X::Matrix{T}, info::Vector{UnitRange{Int64}}) where T SXX = panelcross(X,X,info) XX = sumpanelcross(SXX) - invXX = invsym(XX) + cholXX = _cholesky(XX) + invXX = inv(cholXX) for (g,S) ∈ enumerate(info) Xg = view(X,S,:) if size(Xg,1) > size(Xg,2) SXX[:,g,:] = invsym(XX - Xg'Xg) else - XginvXX = Xg * invXX - tmp = XginvXX * Xg'; tmp -= I - SXX[:,g,:] = invXX; t✻minus!(view(SXX,:,g,:), XginvXX'invsym(tmp), XginvXX) + invXXXg = cholldiv(cholXX, Xg') + tmp = Xg * invXXXg; tmp -= I + SXX[:,g,:] = invXX; t✻minus!(view(SXX,:,g,:), invXXXg, cholldiv(_cholesky!(tmp), invXXXg')) end end - (XX, invXX, SXX) + (XX, cholXX, SXX) end # Partial Zperp from A, jackknifed. A and Z are data matrices/vectors. ZZZA is a 3-array diff --git a/test/Manifest.toml b/test/Manifest.toml index 9769285..600b502 100644 --- a/test/Manifest.toml +++ b/test/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.0" +julia_version = "1.9.4" manifest_format = "2.0" project_hash = "0e6f263c8117523fc0d3c08ce8f5ebb406439a14" @@ -40,9 +40,9 @@ version = "0.10.8" [[deps.Compat]] deps = ["UUIDs"] -git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957" +git-tree-sha1 = "886826d76ea9e72b35fcd000e535588f7b60f21d" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.6.1" +version = "4.10.1" weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] @@ -51,7 +51,7 @@ weakdeps = ["Dates", "LinearAlgebra"] [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.2+0" +version = "1.0.5+0" [[deps.Crayons]] git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15" @@ -59,21 +59,21 @@ uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" version = "4.1.1" [[deps.DataAPI]] -git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630" +git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" -version = "1.14.0" +version = "1.15.0" [[deps.DataFrames]] -deps = ["Compat", "DataAPI", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SnoopPrecompile", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] -git-tree-sha1 = "aa51303df86f8626a962fccb878430cdb0a97eee" +deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] +git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8717bdb8" uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -version = "1.5.0" +version = "1.6.1" [[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0" +git-tree-sha1 = "3dbd312d370723b6bb43ba9d02fc36abade4518d" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.13" +version = "0.18.15" [[deps.DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -116,21 +116,15 @@ version = "1.16.1" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" -[[deps.Formatting]] -deps = ["Printf"] -git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8" -uuid = "59287772-0a20-5a39-b81b-1366585eb4c0" -version = "0.4.2" - [[deps.Future]] deps = ["Random"] uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" [[deps.HypergeometricFunctions]] deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"] -git-tree-sha1 = "84204eae2dd237500835990bcade263e27674a93" +git-tree-sha1 = "f218fe3736ddf977e0e772bc9a586b2383da2685" uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a" -version = "0.3.16" +version = "0.3.23" [[deps.InlineStrings]] deps = ["Parsers"] @@ -164,10 +158,10 @@ uuid = "82899510-4779-5014-852e-03e436cf321d" version = "1.0.0" [[deps.JLLWrappers]] -deps = ["Preferences"] -git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.4.1" +version = "1.5.0" [[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -176,19 +170,19 @@ uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.4" [[deps.LaTeXStrings]] -git-tree-sha1 = "f2355693d6778a178ade15952b7ac47a4ff97996" +git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec" uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" -version = "1.3.0" +version = "1.3.1" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" +version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" +version = "8.4.0+0" [[deps.LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] @@ -197,16 +191,16 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" +version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[deps.Libiconv_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "c7cb1f5d892775ba13767a87c7ada0b980ea0a71" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "f9557a255370125b405568f9767d6d195822a175" uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" -version = "1.16.1+2" +version = "1.17.0+0" [[deps.LinearAlgebra]] deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] @@ -214,9 +208,9 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[deps.LogExpFunctions]] deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] -git-tree-sha1 = "0a1b7c2863e44523180fdb3146534e265a91870b" +git-tree-sha1 = "7d6dd4e9212aebaeed356de34ccf262a3cd415aa" uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" -version = "0.3.23" +version = "0.3.26" [deps.LogExpFunctions.extensions] LogExpFunctionsChainRulesCoreExt = "ChainRulesCore" @@ -280,38 +274,44 @@ uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" version = "0.5.5+0" [[deps.OrderedCollections]] -git-tree-sha1 = "d321bf2de576bf25ec4d3e4360faca399afca282" +git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.6.0" +version = "1.6.3" [[deps.Parsers]] -deps = ["Dates", "SnoopPrecompile"] -git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf" +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.5.8" +version = "2.8.1" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.9.0" +version = "1.9.2" [[deps.PooledArrays]] deps = ["DataAPI", "Future"] -git-tree-sha1 = "a6062fe4063cdafe78f4a0a81cfffb89721b30e7" +git-tree-sha1 = "36d8b4b899628fb92c2749eb488d884a926614d3" uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" -version = "1.4.2" +version = "1.4.3" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.2.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1" +git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.0" +version = "1.4.1" [[deps.PrettyTables]] -deps = ["Crayons", "Formatting", "LaTeXStrings", "Markdown", "Reexport", "StringManipulation", "Tables"] -git-tree-sha1 = "213579618ec1f42dea7dd637a42785a608b1ea9c" +deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] +git-tree-sha1 = "88b895d13d53b5577fd53379d913b9ab9ac82660" uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" -version = "2.2.4" +version = "2.3.1" [[deps.Printf]] deps = ["Unicode"] @@ -366,9 +366,9 @@ version = "0.7.0" [[deps.SentinelArrays]] deps = ["Dates", "Random"] -git-tree-sha1 = "77d3c4726515dca71f6d80fbb5e251088defe305" +git-tree-sha1 = "0e7508ff27ba32f26cd459474ca2ede1bc10991f" uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c" -version = "1.3.18" +version = "1.4.1" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -378,20 +378,14 @@ git-tree-sha1 = "503688b59397b3307443af35cd953a13e8005c16" uuid = "1277b4bf-5013-50f5-be3d-901d8477a67a" version = "2.0.0" -[[deps.SnoopPrecompile]] -deps = ["Preferences"] -git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" -uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" -version = "1.0.3" - [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "a4ada03f999bd01b3a25dcaa30b2d929fe537e00" +git-tree-sha1 = "5165dfb9fd131cf0c6957a3a7605dede376e7b63" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.1.0" +version = "1.2.0" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] @@ -399,9 +393,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.SpecialFunctions]] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] -git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880" +git-tree-sha1 = "e2cfc4012a19088254b3950b85c3c1d8882d864d" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "2.2.0" +version = "2.3.1" [deps.SpecialFunctions.extensions] SpecialFunctionsChainRulesCoreExt = "ChainRulesCore" @@ -411,9 +405,9 @@ version = "2.2.0" [[deps.StableRNGs]] deps = ["Random", "Test"] -git-tree-sha1 = "3be7d49667040add7ee151fefaf1f8c04c8c8276" +git-tree-sha1 = "ddc1a7b85e760b5285b50b882fa91e40c603be47" uuid = "860ef19b-820b-49d6-a774-d7a799459cd3" -version = "1.0.0" +version = "1.0.1" [[deps.StatFiles]] deps = ["DataValues", "FileIO", "IterableTables", "IteratorInterfaceExtensions", "ReadStat", "TableShowUtils", "TableTraits", "TableTraitsUtils", "Test"] @@ -428,15 +422,15 @@ version = "1.9.0" [[deps.StatsAPI]] deps = ["LinearAlgebra"] -git-tree-sha1 = "45a7769a04a3cf80da1c1c7c60caf932e6f4c9f7" +git-tree-sha1 = "1ff449ad350c9c4cbc756624d6f8a8c3ef56d3ed" uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0" -version = "1.6.0" +version = "1.7.0" [[deps.StatsBase]] deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "75ebe04c5bed70b91614d684259b661c9e6274a4" +git-tree-sha1 = "1d77abd07f617c4868c33d4f5b9e1dbb2643c9cf" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.34.0" +version = "0.34.2" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] @@ -453,15 +447,16 @@ version = "1.3.0" InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112" [[deps.StatsModels]] -deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Printf", "REPL", "ShiftedArrays", "SparseArrays", "StatsBase", "StatsFuns", "Tables"] -git-tree-sha1 = "8cc7a5385ecaa420f0b3426f9b0135d0df0638ed" +deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Printf", "REPL", "ShiftedArrays", "SparseArrays", "StatsAPI", "StatsBase", "StatsFuns", "Tables"] +git-tree-sha1 = "5cf6c4583533ee38639f73b880f35fc85f2941e0" uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d" -version = "0.7.2" +version = "0.7.3" [[deps.StringManipulation]] -git-tree-sha1 = "46da2434b41f41ac3594ee9816ce5541c6096123" +deps = ["PrecompileTools"] +git-tree-sha1 = "a04cabe79c5f01f4d723cc6704070ada0b9d46d5" uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e" -version = "0.3.0" +version = "0.3.4" [[deps.SuiteSparse_jll]] deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] @@ -474,10 +469,10 @@ uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" version = "1.0.3" [[deps.TableShowUtils]] -deps = ["DataValues", "Dates", "JSON", "Markdown", "Test"] -git-tree-sha1 = "14c54e1e96431fb87f0d2f5983f090f1b9d06457" +deps = ["DataValues", "Dates", "JSON", "Markdown", "Unicode"] +git-tree-sha1 = "2a41a3dedda21ed1184a47caab56ed9304e9a038" uuid = "5e66a065-1f0a-5976-b372-e0b8c017ca10" -version = "0.2.5" +version = "0.2.6" [[deps.TableTraits]] deps = ["IteratorInterfaceExtensions"] @@ -492,10 +487,10 @@ uuid = "382cd787-c1b6-5bf2-a167-d5b971a19bda" version = "1.0.2" [[deps.Tables]] -deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"] -git-tree-sha1 = "1544b926975372da01227b382066ab70e574a3ec" +deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"] +git-tree-sha1 = "cb76cf677714c095e535e3501ac7954732aeea2d" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "1.10.1" +version = "1.11.1" [[deps.Tar]] deps = ["ArgTools", "SHA"] @@ -521,12 +516,12 @@ version = "1.2.13+0" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.7.0+0" +version = "5.8.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" +version = "1.52.0+1" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] diff --git a/test/runtests.jl b/test/runtests.jl index 8ec77c0..0b0d024 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,6 @@ pushfirst!(LOAD_PATH, ".") -using WildBootTests using StableRNGs, StatFiles, DataFrames, CategoricalArrays, StatsModels +using WildBootTests try cd("test") catch end open("unittests.log", "w") do log # use Github Desktop to detect changes in output diff --git a/test/tests.jl b/test/tests.jl index 7b21742..42d9d98 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -1,6 +1,6 @@ pushfirst!(LOAD_PATH, pwd()) -using WildBootTests using StableRNGs, StatFiles, DataFrames, CategoricalArrays, StatsModels +using WildBootTests try cd("test") catch end open("unittests.log", "w") do log # use Github Desktop to detect changes in output diff --git a/test/unittests.log b/test/unittests.log index 762f515..485542e 100644 --- a/test/unittests.log +++ b/test/unittests.log @@ -130,7 +130,7 @@ p = 0.1040 boottest post_self=.04, weight(mammen) reps(9999) boottype(score) t(7) = 1.8479 p = 0.0903 -CI = [0.03008 0.03173; 0.0335 0.08018] +CI = [-0.1533 -0.1334; -0.03434 0.1137; 0.1242 0.1515; 0.2035 0.2524; 0.263 0.2878] boottest post_self=.04, reps(9999) jk @@ -336,7 +336,7 @@ p = 0.0080 boottest tenure, nograph bootcluster(collgrad) cluster(collgrad industry) weight(webb) reps(9999) z = 3.9420 -p = 0.2153 +p = 0.2033 CI = [-Inf Inf]