Skip to content

Commit

Permalink
In WRE, skip FE code if FE groups = clustering groups
Browse files Browse the repository at this point in the history
  • Loading branch information
droodman committed Dec 23, 2022
1 parent 50cb25b commit 0f70482
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "WildBootTests"
uuid = "65c2e505-86ba-4c19-93f1-95506c1443d5"
authors = ["droodman <[email protected]>"]
version = "0.8.4"
version = "0.8.5"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
18 changes: 9 additions & 9 deletions src/WRE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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✻)
Expand Down Expand Up @@ -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]))]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/unittests.log
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 0f70482

@droodman
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74576

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.5 -m "<description of version>" 0f70482b63da21adf05d0db5936b75521de3fc14
git push origin v0.8.5

Please sign in to comment.