regtools.linmodels package¶
Subpackages¶
Submodules¶
regtools.linmodels.reg module¶
-
regtools.linmodels.reg.
linear_reg
(df, yvar, xvars, entity_var, time_var, robust=True, cluster=False, cons=True, fe=None, interaction_tuples=None, num_lags=0, lag_variables='xvars', lag_period_var='Date', lag_id_var='TICKER', lag_fill_method='ffill', lag_fill_limit=None, reg_type='fama macbeth', **fit_kwargs)[source]¶ Runs a regression from the linearmodels library, standardizing the output to that of statsmodels
- Parameters
df¶ (
DataFrame
) –xvars¶ (
Sequence
[str
]) – column names of x variables for regressionentity_var¶ (
str
) – column name of variable representing entities in the datatime_var¶ (
str
) – column name of variable representing time in the datarobust¶ (
bool
) – set to True to use heterskedasticity-robust standard errorscluster¶ (
Union
[bool
,str
,Sequence
[str
]]) – set to a column name to calculate standard errors within clusters given by unique values of given column name. set to multiple column names for multiway clustering following Cameron, Gelbach, and Miller (2011). NOTE: will get exponentially slower as more cluster variables are addedcons¶ (
bool
) – set to False to not include a constant in the regressionfe¶ (
Union
[str
,Sequence
[str
],None
]) – If a str or list of strs is passed, uses these categorical variables to construct dummies for fixed effects.interaction_tuples¶ (
Union
[Tuple
[str
,str
],Sequence
[Tuple
[str
,str
]],None
]) – tuple or list of tuples of column names to interact and include as xvarsnum_lags¶ (
int
) – Number of periods to lag variables. Setting to other than 0 will activate lagslag_variables¶ (
Union
[str
,Sequence
[str
]]) – ‘all’, ‘xvars’, or list of strs of names of columns to lag for regressions.lag_period_var¶ (
str
) – only used if lag_variables is not None. name of column which contains period variable for lagginglag_id_var¶ (
str
) – only used if lag_variables is not None. name of column which contains identifier variable for lagginglag_fill_method¶ (
Optional
[str
]) – ‘ffill’ or ‘bfill’ for which method to use to fill in missing rows when creating lag variables. Set to None to not fill and have missing instead. See pandas.DataFrame.fillna for more detailslag_fill_limit¶ (
Optional
[int
]) – maximum number of periods to fill with lag_fill_methodfit_kwargs¶ –
- Returns
statsmodels regression result.