Maximum likelihood estimation and likelihood calculations for regressions of the form
y = X⋅β + ϵ
ϵ ∼ Normal(0, v), IID
where β
are the coefficients and v
is the variance of the error term.
The key features are
-
type stability, also for
ForwardDiff.Dual
numbers, -
fast calculations for regressions using the same
X
.
Example:
import BatchOLS # no exported symbols
N = 100
K = 3
X = randn(N, K)
rhs = BatchOLS.RHS(X)
## maximum likelihood estimation
for _ in 1:100
y = randn(N)
β, v = BatchOLS.ML_βv(y, rhs)
end
## loglikelihood calculation
β′ = randn(K)
y = randn(N)
ℓ = BatchOLS.loglikelihood(y, rhs, β′, 1.0)
The code is fairly trivial, I put it in a package to allow rigorous automated testing after optimizations, especially for type inference.