diff --git a/Project.toml b/Project.toml index 8bfff06..a5fda9c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "WildBootTests" uuid = "65c2e505-86ba-4c19-93f1-95506c1443d5" authors = ["droodman "] -version = "0.9.8" +version = "0.9.9" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" diff --git a/src/WRE.jl b/src/WRE.jl index 6067294..25ab985 100644 --- a/src/WRE.jl +++ b/src/WRE.jl @@ -531,8 +531,7 @@ function Filling!(o::StrBootTest{T}, dest::AbstractMatrix{T}, i::Int64, β̈s::A t✻!(S✻UMZperpg, view(o.Repl.Zperp,S,:), o.S✻UZperpinvZperpZperpv); S✻UMZperpg .-= view(o.DGP.u⃛₁, S) .* view(o.v, view(o.ID✻, S),:) if o.NFE>0 && !o.FEboot # CT_(*,FE) (U ̈_(∥j) ) (S_FE S_FE^' )^(-1) S_FE - @tturbo for r ∈ S # S✻UMZperpg .+= view(o.invFEwtCT✻FEUv, view(o._FEID,S), :) - _r = o._FEID[S[r]] + @tturbo for (r,_r) ∈ enumerate(o._FEID[S]) # S✻UMZperpg .+= view(o.invFEwtCT✻FEUv, view(o._FEID,S), :) for c ∈ indices((S✻UMZperpg, o.invFEwtCT✻FEUv),2) S✻UMZperpg[r,c] += o.invFEwtCT✻FEUv[_r,c] end @@ -566,13 +565,11 @@ function Filling!(o::StrBootTest{T}, dest::AbstractMatrix{T}, i::Int64, β̈s::A end end - # dest[g:g,:] .+= o.PXY✻ .* (o.S✻UMZperp .- o.Z̄[g,j] .* _β̈ ) - @tturbo for c ∈ indices((dest, o.PXY✻, _β̈ , o.S✻UMZperp), 2) + @tturbo for c ∈ indices((dest, o.PXY✻, _β̈ , o.S✻UMZperp), 2) # dest[g:g,:] .+= o.PXY✻ .* (o.S✻UMZperp .- o.Z̄[g,j] .* _β̈ ) dest[g,c] += o.PXY✻[c] * (o.S✻UMZperp[c] - o.Z̄[g,j] * _β̈[c]) end else - # dest[g:g,:] .-= o.Z̄[g,j] .* o.PXY✻ .* _β̈ - @tturbo for c ∈ indices((dest, o.PXY✻, _β̈ ), 2) + @tturbo for c ∈ indices((dest, o.PXY✻, _β̈ ), 2) # dest[g:g,:] .-= o.Z̄[g,j] .* o.PXY✻ .* _β̈ dest[g,c] -= o.Z̄[g,j] * o.PXY✻[c] * _β̈[c] end end @@ -596,8 +593,7 @@ function Filling!(o::StrBootTest{T}, dest::AbstractMatrix{T}, i::Int64, β̈s::A t✻minus!(S✻UMZperpg, view(o.Z̄,S,j), _β̈ ) if o.NFE>0 && !o.FEboot # CT_(*,FE) (U ̈_(∥j) ) (S_FE S_FE^' )^(-1) S_FE - @tturbo for r ∈ S # S✻UMZperpg .+= view(o.invFEwtCT✻FEUv, view(o._FEID,S), :) - _r = o._FEID[S[r]] + @tturbo for (r,_r) ∈ enumerate(o._FEID[S]) # S✻UMZperpg .+= view(o.invFEwtCT✻FEUv, view(o._FEID,S), :) for c ∈ indices((S✻UMZperpg, o.invFEwtCT✻FEUv),2) S✻UMZperpg[r,c] += o.invFEwtCT✻FEUv[_r,c] end diff --git a/test/runtests.jl b/test/runtests.jl index 4e40117..8ec77c0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -115,7 +115,6 @@ open("unittests.log", "w") do log # use Github Desktop to detect changes in out df = DataFrame(load("nlsw88.dta"))[:,[:wage; :tenure; :ttl_exp; :collgrad; :industry]] dropmissing!(df) - desc = describe(df, :eltype) f = @formula(wage ~ 1 + tenure + ttl_exp + collgrad) f = apply_schema(f, schema(f, df)) resp, predexog = modelcols(f, df) @@ -129,7 +128,7 @@ open("unittests.log", "w") do log # use Github Desktop to detect changes in out test = wildboottest([0 1 0 0], [0]; R1=[0 0 1 0], r1=[.2], resp, predexog, clustid=[collect(1:1000); collect(1:1217)], reps=9999, rng=StableRNG(1231)) # granular but not pure robust println(log, test) - test = wildboottest([0 1 0 0], [0]; resp, predexog, clustid=[collect(1:1000); collect(1:1217)], feid=df.industry, reps=9999, rng=StableRNG(1231)) + test = wildboottest([1 0 0], [0]; resp, predexog=predexog[:,2:end], clustid=[collect(1:1000); collect(1:1217)], feid=df.industry, reps=9999, rng=StableRNG(1231)) println(log, test) df = DataFrame(load("nlsw88.dta")) diff --git a/test/tests.jl b/test/tests.jl index f3c7f21..ac635f6 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -115,7 +115,6 @@ open("unittests.log", "w") do log # use Github Desktop to detect changes in out df = DataFrame(load("nlsw88.dta"))[:,[:wage; :tenure; :ttl_exp; :collgrad; :industry]] dropmissing!(df) - desc = describe(df, :eltype) f = @formula(wage ~ 1 + tenure + ttl_exp + collgrad) f = apply_schema(f, schema(f, df)) resp, predexog = modelcols(f, df) @@ -129,7 +128,7 @@ open("unittests.log", "w") do log # use Github Desktop to detect changes in out test = wildboottest([0 1 0 0], [0]; R1=[0 0 1 0], r1=[.2], resp, predexog, clustid=[collect(1:1000); collect(1:1217)], reps=9999, rng=StableRNG(1231)) # granular but not pure robust println(log, test) - test = wildboottest([0 1 0 0], [0]; resp, predexog, clustid=[collect(1:1000); collect(1:1217)], feid=df.industry, reps=9999, rng=StableRNG(1231)) + test = wildboottest([1 0 0], [0]; resp, predexog=predexog[:,2:end], clustid=[collect(1:1000); collect(1:1217)], feid=df.industry, reps=9999, rng=StableRNG(1231)) println(log, test) df = DataFrame(load("nlsw88.dta")) diff --git a/test/unittests.log b/test/unittests.log index f44e9fd..d37e6cd 100644 --- a/test/unittests.log +++ b/test/unittests.log @@ -124,13 +124,13 @@ p = 0.0723 boottest post_self=.04, weight(mammen) reps(9999) noci t(7) = 2.0194 -p = 0.1788 +p = 0.1040 boottest post_self=.04, weight(mammen) reps(9999) boottype(score) t(7) = 1.8479 p = 0.0903 -CI = [0.0335 0.08018] +CI = [0.03008 0.03173; 0.0335 0.08018] boottest post_self=.04, reps(9999) jk @@ -201,9 +201,9 @@ t(1216) = 3.3434 p = 0.0007 CI = [0.02699 0.1033] -t(1216) = 0.7518 -p = 0.4657 -CI = [-0.02853 0.06396] +t(1216) = 0.7606 +p = 0.4655 +CI = [-0.02845 0.06413] ivregress 2sls wage ttl_exp collgrad (tenure = union), cluster(industry) @@ -336,7 +336,7 @@ p = 0.0080 boottest tenure, nograph bootcluster(collgrad) cluster(collgrad industry) weight(webb) reps(9999) z = 3.9420 -p = 0.2033 +p = 0.2153 CI = [-Inf Inf] @@ -377,7 +377,7 @@ ivreghdfe wage ttl_exp collgrad tenure (occupation = union married) [aw=hours] i boottest tenure t(11) = 2.0244 p = 0.2452 -CI = [-2.499 -0.9603; -0.1759 2.585] +CI = [-2.499 -0.9603; -0.1753 2.585] boottest tenure, jk t(11) = 0.6068 @@ -396,7 +396,7 @@ CI = [-0.4551 0.8325] boottest tenure | _b[collgrad] = 0 t(11) = -2.0001 p = 0.3544 -CI = [-0.5463 -0.0707; -0.05762 Inf] +CI = [-0.5463 Inf] t(11) = -2.0001 p = 0.3544