from _api_doc_utils import *InteractiveFixedEffects
Factor-model panel counterfactual helper
1 Where it fits
Group: Causal inference
InteractiveFixedEffects estimates a low-rank factor structure in a balanced panel. It is closest to a lightweight fect helper: remove additive components according to force, estimate factors, and reconstruct fitted untreated outcomes.
2 Python API
Constructor: cm.InteractiveFixedEffects
Use InteractiveFixedEffects(rank=0, force=3, ...), then fit(y). predict() reconstructs the fitted panel. summary() reports low-rank pieces, additive effects, singular values, chosen rank, and diagnostics.
print(inspect.signature(cm.InteractiveFixedEffects))(rank=0, force=3, factor_method=Ellipsis, factor_oversamples=10, factor_power_iter=1, factor_seed=None)
cls = cm.InteractiveFixedEffects
display(HTML(html_table(["Public method"], public_methods(cls))))| Public method |
|---|
fit(self, /, y) |
predict(self, /) |
summary(self, /) |
3 Minimal example
rng=np.random.default_rng(19)
y=rng.normal(size=(12,16)) + rng.normal(size=(12,1)) + rng.normal(size=(1,16))
model=cm.InteractiveFixedEffects(rank=2); model.fit(y)
print(model.summary()["rank"])
print(model.predict().shape)2
(12, 16)
4 summary() contract
The table below is generated by fitting the live class in this repository and then inspecting summary(). Shapes are shown because most values are plain NumPy arrays or scalars.
rng=np.random.default_rng(119); y=rng.normal(size=(10,12))+rng.normal(size=(10,1))+rng.normal(size=(1,12))
model=cm.InteractiveFixedEffects(rank=2); model.fit(y)
summary = model.summary()
display(HTML(html_table(["summary() key", "shape"], summary_shape_rows(summary))))| summary() key | shape |
|---|---|
fit |
(10, 12) |
residuals |
(10, 12) |
mu |
() |
alpha |
(12,) |
xi |
(10,) |
factor |
(10, 2) |
loading |
(12, 2) |
vnt |
(2, 2) |
rank |
() |
force |
() |
factor_method |
() |
factor_oversamples |
() |
factor_power_iter |
() |