Skip to content

Commit

Permalink
correct dispatch for stderror with RidgePred
Browse files Browse the repository at this point in the history
  • Loading branch information
getzze committed May 12, 2023
1 parent 353c5a9 commit ce84422
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/robustlinearmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ The robust estimator object used to fit the model.
"""
Estimator(m::RobustLinearModel) = Estimator(m.resp)

StatsAPI.stderror(m::RobustLinearModel) =
StatsAPI.stderror(m::RobustLinearModel{T,R,P}) where {T,R,P<:LinPred} =
location_variance(m.resp, dof_residual(m), false) .* sqrt.(diag(vcov(m)))

StatsAPI.stderror(m::RobustLinearModel{T,R,P}) where {T,R,P<:AbstractRegularizedPred} =

Check warning on line 205 in src/robustlinearmodel.jl

View check run for this annotation

Codecov / codecov/patch

src/robustlinearmodel.jl#L205

Added line #L205 was not covered by tests
location_variance(m.resp, dof_residual(m), false) .* sqrt.(diag(vcov(m)))

StatsAPI.loglikelihood(m::RobustLinearModel) = loglikelihood(m.resp)
Expand Down Expand Up @@ -312,10 +315,10 @@ StatsAPI.predict(m::RobustLinearModel) = fitted(m)

### With RidgePred

StatsAPI.dof(m::RobustLinearModel{T,R,L}) where {T,R,L<:RidgePred} =
StatsAPI.dof(m::RobustLinearModel{T,R,P}) where {T,R,P<:RidgePred} =
tr(projectionmatrix(m.pred, workingweights(m.resp)))

function StatsAPI.stderror(m::RobustLinearModel{T,R,L}) where {T,R,L<:RidgePred}
function StatsAPI.stderror(m::RobustLinearModel{T,R,P}) where {T,R,P<:RidgePred}
wXt = (workingweights(m.resp) .* modelmatrix(m.pred))'
Σ = Hermitian(wXt * modelmatrix(m.pred))
M = vcov(m) * Σ * vcov(m)'
Expand Down

0 comments on commit ce84422

Please sign in to comment.