diff --git a/Project.toml b/Project.toml index 445765f..1c830b5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "WildBootTests" uuid = "65c2e505-86ba-4c19-93f1-95506c1443d5" authors = ["droodman "] -version = "0.8.4" +version = "0.8.5" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" diff --git a/src/WRE.jl b/src/WRE.jl index be7a4eb..7715798 100644 --- a/src/WRE.jl +++ b/src/WRE.jl @@ -38,7 +38,7 @@ function InitWRE!(o::StrBootTest{T}) where T o.YY✻_b = zeros(o.Repl.kZ+1, o.Repl.kZ+1) o.YPXY✻_b = zeros(o.Repl.kZ+1, o.Repl.kZ+1) end - o.NFE>0 && (o.bootstrapt || !isone(o.κ) || o.liml) && (o.CT✻FEU = Vector{Matrix{T}}(undef, o.Repl.kZ+1)) + o.NFE>0 && !o.FEboot && (o.bootstrapt || !isone(o.κ) || o.liml) && (o.CT✻FEU = Vector{Matrix{T}}(undef, o.Repl.kZ+1)) end o.S✻⋂XY₂ = o.Repl.S✻⋂XY₂ - o.Repl.S✻⋂XZperp * o.Repl.invZperpZperpZperpY₂ - o.Repl.invZperpZperpZperpX' * (o.Repl.S✻⋂ZperpY₂ - o.Repl.S✻⋂ZperpZperp * o.Repl.invZperpZperpZperpY₂ ) o.S✻⋂XX = o.Repl.S✻⋂XX - o.Repl.S✻⋂XZperp * o.Repl.invZperpZperpZperpX - o.Repl.invZperpZperpZperpX' * (o.Repl.S✻⋂XZperp' - o.Repl.S✻⋂ZperpZperp * o.Repl.invZperpZperpZperpX ) @@ -75,7 +75,7 @@ function InitWRE!(o::StrBootTest{T}) where T o.S✻ZperpDGPZR₁ = @panelsum(o, o.DGP.S✻⋂ZperpZR₁ , o.info✻_✻⋂) - S✻ZperpZperp * o.DGP.invZperpZperpZperpZR₁ end - if o.NFE>0 && (o.liml || !isone(o.κ) || o.bootstrapt) + if o.NFE>0 && !o.FEboot && (o.liml || !isone(o.κ) || o.bootstrapt) CT✻⋂FEX = [crosstabFE(o, o.Repl.X₁, o.info✻⋂) crosstabFE(o, o.Repl.X₂, o.info✻⋂)] o.CT✻FEX = @panelsum(o, CT✻⋂FEX, o.info✻_✻⋂) o.CT✻FEY₂ = crosstabFE(o, o.DGP.Y₂, o.info✻) @@ -115,7 +115,7 @@ function InitWRE!(o::StrBootTest{T}) where T o.S⋂XZperpinvZperpZperp = S⋂ZperpX' * o.Repl.invZperpZperp o.Q = Array{T,3}(undef, o.N✻, o.N⋂, o.N✻) - o.NFE>0 && (o.CT⋂FEX = o.invFEwt .* @panelsum(o, CT✻⋂FEX, o.info⋂_✻⋂)) + o.NFE>0 && !o.FEboot && (o.CT⋂FEX = o.invFEwt .* @panelsum(o, CT✻⋂FEX, o.info⋂_✻⋂)) o.β̈v = isone(o.Nw) ? [Matrix{T}(undef, o.N✻, ncols(o.v))] : [Matrix{T}(undef, o.N✻, length(o.WeightGrp[1])), Matrix{T}(undef, o.N✻, length(o.WeightGrp[end]))] @@ -224,7 +224,7 @@ function PrepWRE!(o::StrBootTest{T}) where T end end - if (o.liml || o.bootstrapt || !isone(o.κ)) && o.NFE>0 + if (o.liml || o.bootstrapt || !isone(o.κ)) && o.NFE>0 && !o.FEboot CT✻FEU = o.CT✻FEY₂ - o.CT✻FEX * o.DGP.Π̂ CT✻FEURparY = CT✻FEU * o.Repl.RparY end @@ -256,7 +256,7 @@ function PrepWRE!(o::StrBootTest{T}) where T o.invZperpZperpS✻ZperpU[i+1] .= view(o.invZperpZperpS✻ZperpU₂RparY,:,:,i) end - if o.NFE>0 + if o.NFE>0 && !o.FEboot if iszero(i) o.CT✻FEU[1] = o.CT✻FEy₁ - o.CT✻FEZ * _β̈ + CT✻FEU * o.DGP.γ̈ o.DGP.restricted && @@ -319,7 +319,7 @@ function PrepWRE!(o::StrBootTest{T}) where T o.S✻UMZperp[i+1][o.crosstab✻ind] .-= view(Ü₂par,:,i) end - o.NFE>0 && + o.NFE>0 && !o.FEboot && (o.S✻UMZperp[i+1] .-= view(o.invFEwt .* o.CT✻FEU[i+1], o._FEID, :)) # CT_(*,FE) (U ̈_(parj) ) (S_FE S_FE^' )^(-1) S_FE end end @@ -342,7 +342,7 @@ function PrepWRE!(o::StrBootTest{T}) where T else o.negS✻UMZperpX[j+1][o.crosstab⋂✻ind] .-= vec(view(o.S✻⋂XU₂RparY,:,:,j)) end - o.NFE>0 && + o.NFE>0 && !o.FEboot && (o.negS✻UMZperpX[j+1] .+= o.CT⋂FEX'o.CT✻FEU[j+1]) # CT_(*,FE) (U ̈_(∥j) ) (S_FE S_FE^' )^(-1) S_FE end end @@ -416,13 +416,13 @@ function _HessianFixedkappa!(o::StrBootTest, dest::AbstractMatrix, row::Integer, dest[row,:] .= o.Repl.YY[i+1,j+1] .+ o.v'o.S✻YU[i+1,j+1] coldotminus!(o, dest, row, o.invZperpZperpS✻ZperpU[i+1] * o.v, o.S✻ZperpU[j+1] * o.v) # when is this term 0?? coldotplus!(o, dest, row, o.v, o.S✻UU[i+1, j+1], o.v) - o.NFE>0 && + o.NFE>0 && !o.FEboot && coldotminus!(o, dest, row, o.CT✻FEU[i+1] * o.v, (o.invFEwt .* o.CT✻FEU[j+1]) * o.v) else _dest = o.Repl.YY[i+1,j+1] .+ o.S✻YU[j+1,i+1]'o.v coldotminus!(o, _dest, 1, o.invZperpZperpS✻ZperpU[i+1] * o.v, o.S✻ZperpU[j+1] * o.v) coldotplus!(o, _dest, 1, o.v, o.S✻UU[i+1, j+1], o.v) - o.NFE>0 && + o.NFE>0 && !o.FEboot && coldotminus!(o, _dest, o.CT✻FEU[i+1] * o.v, (o.invFEwt .* o.CT✻FEU[j+1]) * o.v) dest[row,:] .= κ .* dest[row,:] .+ (1 - κ) .* _dest end diff --git a/src/utilities.jl b/src/utilities.jl index 6f4bc71..f5da5fb 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -95,7 +95,7 @@ coldotplus!(o::StrBootTest, dest::AbstractMatrix, row::Integer, A::AbstractMatri # nothing # end function coldotminus_turbo!(dest::AbstractVecOrMat, row::Integer, A::AbstractMatrix, B::AbstractMatrix) - @turbo for i ∈ eachindex(axes(A,2),axes(B,2)), j ∈ eachindex(axes(A,1),axes(B,1)) + @tturbo for i ∈ eachindex(axes(A,2),axes(B,2)), j ∈ eachindex(axes(A,1),axes(B,1)) dest[row,i] -= A[j,i] * B[j,i] end nothing diff --git a/test/unittests.log b/test/unittests.log index 884efeb..6f0667f 100644 --- a/test/unittests.log +++ b/test/unittests.log @@ -61,7 +61,7 @@ p = 0.7332 boottest (post_self=.05) (post=-.02) (selfemployed=-.15), reps(9999) weight(webb) F(3, 7) = 0.8534 -p = 0.7437 +p = 0.7361 regress hasinsurance selfemployed post post_self