Skip to content

Commit

Permalink
StrBoottest -> StrBootTest
Browse files Browse the repository at this point in the history
  • Loading branch information
droodman committed Dec 23, 2021
1 parent 89f7e60 commit 8216f59
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/src/OLSexamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ julia> clustid = df.firm; # extract clustering variable
julia> R = [0 1]; r = [1]; # put null that coefficient on x = 1 in Rβ̂ = r form, where β̂ is parameter vector
julia> test = wildboottest(R, r; resp=resp, predexog=predexog, clustid=clustid)
WildBootTests.BoottestResult{Float32}
WildBootTests.BootTestResult{Float32}
p = 0.492
CI = Float32[0.93461335 1.1347668]
Expand Down
4 changes: 2 additions & 2 deletions src/WildBootTests.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module WildBootTests
export BoottestResult, wildboottest, AuxWtType, PType, MAdjType, DistStatType,
export BootTestResult, wildboottest, AuxWtType, PType, MAdjType, DistStatType,
teststat, stattype, p, padj, reps, repsfeas, nbootclust, dof, dof_r, plotpoints, peak, CI, dist, statnumer, statvar, auxweights

using LinearAlgebra, Random, Distributions, SortingAlgorithms, LoopVectorization

include("StrBoottest.jl")
include("StrBootTest.jl")
include("utilities.jl")
include("estimators.jl")
include("init.jl")
Expand Down
42 changes: 21 additions & 21 deletions src/interface.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# low-level interface, meaning works with vectors and matrices, not data frames and estimation objects

"Structure to store test results"
struct BoottestResult{T}
struct BootTestResult{T}
stat::T; stattype::String
p::T; padj::T
reps::Int64; repsfeas::Int64
Expand All @@ -18,37 +18,37 @@ struct BoottestResult{T}
end

"Return test statistic"
teststat(o::BoottestResult) = o.stat
teststat(o::BootTestResult) = o.stat

"Return numerator of test statistic"
statnumer(o::BoottestResult) = o.b
statnumer(o::BootTestResult) = o.b

"Return denominator of test statistic"
statvar(o::BoottestResult) = o.V
statvar(o::BootTestResult) = o.V

"""Return type of test statistic subject: "t", "z", "F", or "χ²" """
stattype(o::BoottestResult) = o.stattype
stattype(o::BootTestResult) = o.stattype

"Return p value"
p(o::BoottestResult) = o.p
p(o::BootTestResult) = o.p

"Returnp p value after multiple-hypothesis adjustment, if any"
padj(o::BoottestResult) = o.padj
padj(o::BootTestResult) = o.padj

"Return requested number of replications"
reps(o::BoottestResult) = o.reps
reps(o::BootTestResult) = o.reps

"Return actual number of replications, subject to enumeration of Rademacher draws"
repsfeas(o::BoottestResult) = o.repsfeas
repsfeas(o::BootTestResult) = o.repsfeas

"Return number of bootstrapping clusters in test"
nbootclust(o::BoottestResult) = o.nbootclust
nbootclust(o::BootTestResult) = o.nbootclust

"Return degrees of freedom test"
dof(o::BoottestResult) = o.dof
dof(o::BootTestResult) = o.dof

"Return residual degrees of freedom test"
dof_r(o::BoottestResult) = o.dof_r
dof_r(o::BootTestResult) = o.dof_r

"""
Return data for confidence plot of test.
Expand All @@ -57,23 +57,23 @@ the confidence sampling locations and p values respectively. `X` is in turn
a 1- or 2-tuple of vectors of sampling coordinates for each
dimension of the tested hypothesis.
"""
plotpoints(o::BoottestResult) = o.plot
plotpoints(o::BootTestResult) = o.plot

"Return parameter value with peak p value in test"
peak(o::BoottestResult) = o.peak
peak(o::BootTestResult) = o.peak

"Return confidence interval matrix from test, one row per disjoint piece"
CI(o::BoottestResult) = o.CI
CI(o::BootTestResult) = o.CI

"Return bootstrap distribution of statistic or statistic numerator in bootstrap test"
dist(o::BoottestResult) = o.dist
dist(o::BootTestResult) = o.dist

"Return auxilliary weight matrix for wild bootstrap"
auxweights(o::BoottestResult) = o.auxweights
auxweights(o::BootTestResult) = o.auxweights

using Printf
function Base.show(io::IO, o::BoottestResult{T}) where T
print(io, "WildBootTests.BoottestResult{$T}\n\n")
function Base.show(io::IO, o::BootTestResult{T}) where T
print(io, "WildBootTests.BootTestResult{$T}\n\n")
Printf.@printf(io, "%s = %5.3f\n", stattype(o)*repeat(' ',2-length(stattype(o))), teststat(o))
Printf.@printf(io, "p = %5.3f\n", p(o))
isdefined(o, :CI) && !isnothing(o.CI) && length(o.CI)>0 && print(io, "CI = $(CI(o))\n")
Expand Down Expand Up @@ -144,7 +144,7 @@ function __wildboottest(

padj = getp(M) # trigger central (re)computation

BoottestResult{T}(getstat(M),
BootTestResult{T}(getstat(M),
isone(nrows(R)) ? (small ? "t" : "z") : (small ? "F" : "χ²"),
M.p, padj, M.B, M.BFeas, M.N✻, M.dof, M.dof_r, plot, peak, CI,
getdist(M, diststat),
Expand Down Expand Up @@ -298,7 +298,7 @@ _wildboottest(R::Union{UniformScaling{Bool},AbstractVecOrMat}, r::Union{Number,A

"""
wildboottest([T::DataType=Float32,] R::AbstractMatrix, r::AbstractVector;
resp, <optional keyword arguments>) -> WildBootTests.BoottestResult
resp, <optional keyword arguments>) -> WildBootTests.BootTestResult
Function to perform wild-bootstrap-based hypothesis test
Expand Down
12 changes: 6 additions & 6 deletions src/precompile_WildBootTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,22 +470,22 @@ function _precompile_()
Base.precompile(Tuple{typeof(matmulplus_nonturbo!),Vector{Float64},Matrix{Float64},Vector{Float64}}) # time: 0.0039732
Base.precompile(Tuple{var"#303#threadsfor_fun#4"{Vector{Float32}, SubArray{Float32, 1, Matrix{Float32}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}, SubArray{Float32, 1, Matrix{Float32}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}, Vector{UnitRange{Int64}}, CartesianIndices{0, Tuple{}}, CartesianIndices{0, Tuple{}}, Base.OneTo{Int64}}}) # time: 0.0038176
Base.precompile(Tuple{var"#257#threadsfor_fun#3"{Vector{Float32}, Vector{Float32}, Vector{UnitRange{Int64}}, CartesianIndices{0, Tuple{}}, CartesianIndices{0, Tuple{}}, Base.OneTo{Int64}}}) # time: 0.0037039
Base.precompile(Tuple{Type{BoottestResult{Float64}},Float64,String,Float64,Float64,Int64,Int64,Int64,Int64,Float64,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float64}}, Vector{Float64}}},NamedTuple{(:X, :p), Tuple{Vector{Float64}, Float64}},Matrix{Float64},Matrix{Float64},Vector{Float64},Matrix{Float64},Nothing,StrBootTest{Float64}}) # time: 0.0036245
Base.precompile(Tuple{Type{BootTestResult{Float64}},Float64,String,Float64,Float64,Int64,Int64,Int64,Int64,Float64,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float64}}, Vector{Float64}}},NamedTuple{(:X, :p), Tuple{Vector{Float64}, Float64}},Matrix{Float64},Matrix{Float64},Vector{Float64},Matrix{Float64},Nothing,StrBootTest{Float64}}) # time: 0.0036245
Base.precompile(Tuple{var"#303#threadsfor_fun#4"{Matrix{Float32}, Matrix{Float32}, SubArray{Float32, 1, Matrix{Float32}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}, Vector{UnitRange{Int64}}, Base.OneTo{Int64}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, Base.OneTo{Int64}}}) # time: 0.0035412
Base.precompile(Tuple{var"#303#threadsfor_fun#4"{Matrix{Float64}, Matrix{Float64}, SubArray{Float64, 1, Vector{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true}, Vector{UnitRange{Int64}}, Base.OneTo{Int64}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, Base.OneTo{Int64}}}) # time: 0.0034894
Base.precompile(Tuple{var"#303#threadsfor_fun#4"{Matrix{Float64}, Matrix{Float64}, SubArray{Float64, 1, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}, Vector{UnitRange{Int64}}, Base.OneTo{Int64}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, Base.OneTo{Int64}}}) # time: 0.0034398
Base.precompile(Tuple{var"#303#threadsfor_fun#4"{SubArray{Float32, 2, Matrix{Float32}, Tuple{Base.Slice{Base.OneTo{Int64}}, UnitRange{Int64}}, true}, Vector{Float32}, SubArray{Float32, 1, Vector{Float32}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true}, Vector{UnitRange{Int64}}, CartesianIndices{0, Tuple{}}, CartesianIndices{0, Tuple{}}, Base.OneTo{Int64}}}) # time: 0.0033734
Base.precompile(Tuple{var"#257#threadsfor_fun#3"{Matrix{Float32}, Matrix{Float32}, Vector{UnitRange{Int64}}, Base.OneTo{Int64}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, Base.OneTo{Int64}}}) # time: 0.0032131
Base.precompile(Tuple{Type{BoottestResult{Float64}},Float64,String,Float64,Float64,Int64,Int64,Int64,Int64,Float64,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float64}, Vector{Float64}}, Vector{Float64}}},NamedTuple{(:X, :p), Tuple{Vector{Float64}, Float64}},Matrix{Float64},Matrix{Float64},Vector{Float64},Matrix{Float64},Nothing,StrBootTest{Float64}}) # time: 0.0031914
Base.precompile(Tuple{Type{BootTestResult{Float64}},Float64,String,Float64,Float64,Int64,Int64,Int64,Int64,Float64,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float64}, Vector{Float64}}, Vector{Float64}}},NamedTuple{(:X, :p), Tuple{Vector{Float64}, Float64}},Matrix{Float64},Matrix{Float64},Vector{Float64},Matrix{Float64},Nothing,StrBootTest{Float64}}) # time: 0.0031914
Base.precompile(Tuple{var"#257#threadsfor_fun#3"{Matrix{Float64}, Matrix{Float64}, Vector{UnitRange{Int64}}, Base.OneTo{Int64}, CartesianIndices{1, Tuple{Base.OneTo{Int64}}}, Base.OneTo{Int64}}}) # time: 0.0030588
Base.precompile(Tuple{Type{BoottestResult{Float32}},Float32,String,Float32,Float32,Int64,Int64,Int64,Int64,Float32,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float32}}, Vector{Float32}}},NamedTuple{(:X, :p), Tuple{Vector{Float32}, Float32}},Matrix{Float32},Matrix{Float32},Vector{Float32},Matrix{Float32},Nothing,StrBootTest{Float32}}) # time: 0.0029822
Base.precompile(Tuple{Type{BoottestResult{Float32}},Float32,String,Float32,Float32,Int64,Int64,Int64,Int64,Float32,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float32}, Vector{Float32}}, Vector{Float32}}},NamedTuple{(:X, :p), Tuple{Vector{Float32}, Float32}},Matrix{Float32},Matrix{Float32},Vector{Float32},Matrix{Float32},Nothing,StrBootTest{Float32}}) # time: 0.0029424
Base.precompile(Tuple{Type{BootTestResult{Float32}},Float32,String,Float32,Float32,Int64,Int64,Int64,Int64,Float32,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float32}}, Vector{Float32}}},NamedTuple{(:X, :p), Tuple{Vector{Float32}, Float32}},Matrix{Float32},Matrix{Float32},Vector{Float32},Matrix{Float32},Nothing,StrBootTest{Float32}}) # time: 0.0029822
Base.precompile(Tuple{Type{BootTestResult{Float32}},Float32,String,Float32,Float32,Int64,Int64,Int64,Int64,Float32,NamedTuple{(:X, :p), Tuple{Tuple{Vector{Float32}, Vector{Float32}}, Vector{Float32}}},NamedTuple{(:X, :p), Tuple{Vector{Float32}, Float32}},Matrix{Float32},Matrix{Float32},Vector{Float32},Matrix{Float32},Nothing,StrBootTest{Float32}}) # time: 0.0029424
Base.precompile(Tuple{var"#103#threadsfor_fun#1"{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, Base.OneTo{Int64}}}) # time: 0.0029084
Base.precompile(Tuple{var"#103#threadsfor_fun#1"{Matrix{Float32}, Matrix{Float32}, Matrix{Float32}, Base.OneTo{Int64}}}) # time: 0.0026717
Base.precompile(Tuple{typeof(matconvert),DataType,Vector{Int8}}) # time: 0.0024415
Base.precompile(Tuple{var"#257#threadsfor_fun#3"{Vector{Float64}, Vector{Float64}, Vector{UnitRange{Int64}}, CartesianIndices{0, Tuple{}}, CartesianIndices{0, Tuple{}}, Base.OneTo{Int64}}}) # time: 0.0024048
Base.precompile(Tuple{Type{BoottestResult{Float64}},Float64,String,Float64,Float64,Int64,Int64,Int64,Int64,Float64,Nothing,Nothing,Nothing,Matrix{Float64},Vector{Float64},Matrix{Float64},Nothing,StrBootTest{Float64}}) # time: 0.0015056
Base.precompile(Tuple{Type{BoottestResult{Float32}},Float32,String,Float32,Float32,Int64,Int64,Int64,Int64,Float32,Nothing,Nothing,Nothing,Matrix{Float32},Vector{Float32},Matrix{Float32},Nothing,StrBootTest{Float32}}) # time: 0.0014248
Base.precompile(Tuple{Type{BootTestResult{Float64}},Float64,String,Float64,Float64,Int64,Int64,Int64,Int64,Float64,Nothing,Nothing,Nothing,Matrix{Float64},Vector{Float64},Matrix{Float64},Nothing,StrBootTest{Float64}}) # time: 0.0015056
Base.precompile(Tuple{Type{BootTestResult{Float32}},Float32,String,Float32,Float32,Int64,Int64,Int64,Int64,Float32,Nothing,Nothing,Nothing,Matrix{Float32},Vector{Float32},Matrix{Float32},Nothing,StrBootTest{Float32}}) # time: 0.0014248
Base.precompile(Tuple{Core.kwftype(typeof(wildboottest)),NamedTuple{(:turbo, :resp, :predexog, :clustid, :nbootclustvar, :nerrclustvar, :reps), Tuple{Bool, Vector{Float32}, Matrix{Float32}, Matrix{Int64}, Int64, Int64, Int64}},typeof(wildboottest),Type,Matrix{Float64},Vector{Int64}}) # time: 0.0011542
Base.precompile(Tuple{Core.kwftype(typeof(wildboottest)),NamedTuple{(:turbo, :resp, :predexog, :predendog, :inst, :LIML, :clustid, :small, :reps), Tuple{Bool, Vector{Float32}, Matrix{Float32}, Vector{Float64}, Matrix{Float64}, Bool, Vector{Int32}, Bool, Int64}},typeof(wildboottest),Type,Matrix{Int64},Vector{Int64}}) # time: 0.0011381
Base.precompile(Tuple{Core.kwftype(typeof(wildboottest)),NamedTuple{(:turbo, :resp, :predexog, :predendog, :inst, :clustid, :small, :reps, :auxwttype, :bootstrapc, :ptype), Tuple{Bool, Vector{Float32}, Matrix{Float32}, Vector{Float64}, Vector{Float64}, Vector{Int32}, Bool, Int64, AuxWtType, Bool, PType}},typeof(wildboottest),Type,Matrix{Int64},Vector{Float64}}) # time: 0.0010797
Expand Down

0 comments on commit 8216f59

Please sign in to comment.