estout
  1. linearmodels_results
  • estout
  • core
  • utils
  • statsmodels_results
  • linearmodels_results

On this page

  • ynames
  • xnames
  • params
  • tstats
  • pvalues
  • covmat
  • se
  • nobs
  • r2
  • Report an issue

linearmodels_results

Functions that extract and standardize results from `linearmodels.PanelOLS.fit()’ objects.

Each function extracts a particular statistic from the results object.

These functions must be consistent across the different statistical packages supported by estout.

For example, if we write functions to extract the F-statistic from the linearmodels and statsmodels packages, these functions must have the same name in the linearmodels_results and statsmodels_results modules. They must also have the same return type.

The names of these functions will be the keys of the dictionary returned by the collect_stats function in the core module.

Exported source
import numpy as np
import pandas as pd
from linearmodels import PanelOLS

Set up an example dataset and run a few regressions to showcase the functions in this module.

np.random.seed(123)
df = pd.DataFrame(np.random.rand(9,3), 
                  columns=['y','x','z'],
                  index = pd.MultiIndex.from_product([[1,2,3],[1,2,3]], names=['firmid','time'])
                  ).assign(cons = 1)
lmres = PanelOLS(df['y'],  df[['cons','x','z']], entity_effects=True
                 ).fit(cov_type='clustered', cluster_entity=True)

source

ynames

 ynames (res)
ynames(lmres)
['y']

source

xnames

 xnames (res)
xnames(lmres)
['cons', 'x', 'z']

source

params

 params (res)
params(lmres)
cons    0.728016
x       0.643274
z      -0.774956
Name: parameter, dtype: float64
type(params(lmres))
pandas.core.series.Series

source

tstats

 tstats (res)
tstats(lmres)
cons    167.358372
x         2.262089
z        -2.909770
Name: tstat, dtype: float64

source

pvalues

 pvalues (res)
pvalues(lmres)
cons    7.646419e-09
x       8.648041e-02
z       4.368821e-02
Name: pvalue, dtype: float64

source

covmat

 covmat (res)
covmat(lmres)
cons x z
cons 0.000019 -0.000652 0.000580
x -0.000652 0.080867 -0.075700
z 0.000580 -0.075700 0.070931

source

se

 se (res)
se(lmres)
cons    0.004350
x       0.284371
z       0.266329
Name: std_error, dtype: float64

source

nobs

 nobs (res)
nobs(lmres)
9

source

r2

 r2 (res)
r2(lmres)
0.35189790336774396
  • Report an issue