-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from nilshg/master
Compat with Vcov 0.8 and newer FixedEffectModels versions
- Loading branch information
Showing
7 changed files
with
39 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "GLFixedEffectModels" | ||
uuid = "bafb0ae5-e5f5-5100-81b6-6a55d777c812" | ||
authors = ["Johannes Boehm <[email protected]>"] | ||
version = "0.5.2" | ||
version = "0.5.3" | ||
|
||
[deps] | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
|
@@ -24,13 +24,13 @@ Vcov = "ec2bfdc2-55df-4fc9-b9ae-4958c2cf2486" | |
DataFrames = "1" | ||
Distributions = "0.25" | ||
FillArrays = "1" | ||
FixedEffectModels = "1.7" | ||
FixedEffects = "2.1" | ||
FixedEffectModels = "1.7,1.8,1.9,1.10,1.11" | ||
FixedEffects = "2.1,2.2,2.3" | ||
GLM = "^1.3.6" | ||
LoopVectorization = "0.12" | ||
Reexport = "1" | ||
StatsAPI = "1" | ||
StatsBase = "0.33, 0.34" | ||
StatsModels = "0.6, 0.7" | ||
Vcov = "0.7" | ||
julia = "1" | ||
Vcov = "0.7, 0.8" | ||
julia = ">= 1.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
struct VcovDataGLM{T, N} <: RegressionModel | ||
struct VcovDataGLM{T, Tu, N} <: RegressionModel | ||
modelmatrix::Matrix{Float64} # X | ||
crossmodelmatrix::T # X'X in the simplest case. Can be Matrix but preferably Factorization | ||
invcrossmodelmatrix::Tu | ||
residuals::Array{Float64, N} # vector or matrix of residuals (matrix in the case of IV, residuals of Xendo on (Z, Xexo)) | ||
dof_residual::Int | ||
end | ||
StatsAPI.modelmatrix(x::VcovDataGLM) = x.modelmatrix | ||
StatsAPI.crossmodelmatrix(x::VcovDataGLM) = x.crossmodelmatrix | ||
invcrossmodelmatrix(x::VcovDataGLM) = x.invcrossmodelmatrix | ||
StatsAPI.residuals(x::VcovDataGLM) = x.residuals | ||
StatsAPI.dof_residual(x::VcovDataGLM) = x.dof_residual | ||
|
||
# with clusters, the standard StatsBase.vcov works | ||
|
||
function StatsAPI.vcov(x::VcovDataGLM, ::Vcov.RobustCovariance) | ||
A = inv(crossmodelmatrix(x)) | ||
A = invcrossmodelmatrix(x) | ||
C = modelmatrix(x) .* residuals(x) | ||
B = C' * C | ||
return Symmetric(A * B * A) | ||
end | ||
|
||
function StatsAPI.vcov(x::VcovDataGLM, ::Vcov.SimpleCovariance) | ||
return Symmetric(inv(crossmodelmatrix(x))) | ||
return Symmetric(invcrossmodelmatrix(x)) | ||
end | ||
|
||
function StatsAPI.vcov(x::VcovDataGLM, v::Vcov.ClusterCovariance) | ||
xtx = invcrossmodelmatrix(x) | ||
Vcov.pinvertible(Symmetric(xtx * Vcov.S_hat(x, v) * xtx)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters