Stats Regression panelcovariancetype - CyrilB1531/lodestar GitHub Wiki
Home āŗ Stats-Regression āŗ Panel data
PanelCovarianceType
How a panel fit estimates the covariance of its coefficients: linearmodels' panel four.
public enum PanelCovarianceType
Members ā Unadjusted assumes one variance for every error, and is the default. Robust is
White's estimator. Clustered lets errors correlate inside a cluster ā the entity, the period, the
caller's labels, or two of them at once ā and treats clusters as independent. Kernel is Driscoll
and Kraay's: the scores summed by period, then weighted across periods by
PanelOptions.Kernel, so errors may correlate across entities and along time.
Example ā the same fit under two covariances.
using Lodestar.Stats.Regression;
using Lodestar.Stats.Regression.Panel;
int[] entities = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4];
int[] periods = [2020, 2021, 2022, 2023, 2020, 2021, 2022, 2023, 2020, 2021, 2022, 2023, 2020, 2021, 2022, 2023];
double[] x = [0.5, 1.1, 1.9, 2.4, 1.2, 1.8, 2.9, 3.1, -0.3, 0.4, 0.8, 1.6, 2.0, 2.2, 3.1, 3.9];
double[] y = [2.1, 3.0, 4.2, 4.9, 4.4, 5.1, 6.8, 7.0, 0.2, 1.3, 1.7, 3.1, 6.1, 6.3, 7.9, 9.2];
var design = new PanelDesign(y, x, 1, entities, periods);
PanelSummary robust = PanelRegression.FixedEffects(
design, new PanelOptions { EntityEffects = true, CovarianceType = PanelCovarianceType.Robust });
PanelSummary clustered = PanelRegression.FixedEffects(
design, new PanelOptions { EntityEffects = true, CovarianceType = PanelCovarianceType.Clustered, ClusterEntity = true });
double robustError = robust.StandardErrors[1]; // => 0.0412274910ā¦
double clusteredError = clustered.StandardErrors[1]; // => 0.0533951997ā¦
Remarks ā the clustered covariance takes no G/(Gā1) factor, as the reference's does not;
two-way clustering is Sā + Sā ā Sāā, which need not be positive definite. Every covariance scales
by n/(n ā effects ā k) when debiased and n/(n ā effects) otherwise.
Applies to ā net10.0, netstandard2.0.
See also ā PanelOptions, KernelType.