explore_within_persistence

source

explore_within_persistence(
    df,
    var,
    *,
    entity=None,
    time=None,
    lag=1,
    demean=True,
    alpha=None,
    title=None,
    subtitle=None,
)

Within-unit serial correlation: this period’s value against the previous one.

Parameters

Name Type Description Default
df pd.DataFrame Panel data frame. required
var str Numeric variable. required
entity str | None Panel identifiers (default to those declared via :func:expdpy.set_panel). None
time str | None Panel identifiers (default to those declared via :func:expdpy.set_panel). None
lag int Lag (in periods) for the comparison (default 1). Only consecutive observed periods exactly lag apart are paired. 1
demean bool If True (default), remove each unit’s mean first, isolating the within-unit serial correlation (the part fixed-effects models exploit). True
alpha float | None Marker opacity. Defaults to a sample-size-based value. None

Returns

Name Type Description
WithinPersistenceResult df (lagged pairs), fig, rho (within serial correlation), slope (AR fit), n_pairs and demeaned.

Examples

import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def

df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
ex.explore_within_persistence(df, var="gini_regional").fig