Skip to content

Autodiff across FE result #188

@cpfiffer

Description

@cpfiffer

Someone noted to me that FixedEffectModels.jl is tricky to use AD on because there are so many explicit Float64 type constraints -- does anyone have a good sense of how much effort it would take to remove/parameterize/reduce the explicit type constraints here?

As an example, the FixedEffectModel struct has a lot of Float64 explicit types that could be parametric instead.

struct FixedEffectModel <: RegressionModel
coef::Vector{Float64} # Vector of coefficients
vcov::Matrix{Float64} # Covariance matrix
vcov_type::CovarianceEstimator
nclusters::Union{NamedTuple, Nothing}
esample::BitVector # Is the row of the original dataframe part of the estimation sample?
residuals::Union{AbstractVector, Nothing}
fe::DataFrame
fekeys::Vector{Symbol}
coefnames::Vector # Name of coefficients
yname::Union{String, Symbol} # Name of dependent variable
formula::FormulaTerm # Original formula
formula_predict::FormulaTerm
contrasts::Dict
nobs::Int64 # Number of observations
dof_residual::Int64 # nobs - degrees of freedoms
rss::Float64 # Sum of squared residuals
tss::Float64 # Total sum of squares
r2::Float64 # R squared
adjr2::Float64 # R squared adjusted
F::Float64 # F statistics
p::Float64 # p value for the F statistics
# for FE
iterations::Union{Int, Nothing} # Number of iterations
converged::Union{Bool, Nothing} # Has the demeaning algorithm converged?
r2_within::Union{Float64, Nothing} # within r2 (with fixed effect
# for IV
F_kp::Union{Float64, Nothing} # First Stage F statistics KP
p_kp::Union{Float64, Nothing} # First Stage p value KP
end

Is there an appetite for this? I think it'd be lovely to be able to AD through high-dimensional fixed effect estimates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions