macrosynergy.visuals.lagged_corr#

Functions used to visualize lagged correlation between two series.

plot_lagged_correlation(df, cids, xcats, lags=3, alpha=0.05, remove_zero_predictor=False, start=None, end=None, blacklist=None, figsize=(16, 9), title=None, share_x=True, share_y=True, zero=False, **kwargs)[source]#

Plots a facet grid of lagged correlation plots for two given xcats and multiple cids.

Parameters:#

dfpd.DataFrame

The input DataFrame with columns [‘real_date’, ‘cid’, ‘xcat’, ‘value’].

cidsList[str]

List of cids to plot.

xcatsList[str]

A list of two xcats to plot the lagged correlation between.

lagsUnion[int, Sequence], default=30

Number of lags for the correlation calculation. If an integer, the lags from 0 to lags are plotted. If a sequence is provided, the lags are plotted as given.

remove_zero_predictorbool, default=False

Remove zeros from the input series.

blacklistdict

cross-sections with date ranges that should be excluded from the data frame. If one cross-section has several blacklist periods append numbers to the cross-section code.

startstr

ISO-8601 formatted date string. Select data from this date onwards. If None, all dates are selected.

endstr

ISO-8601 formatted date string. Select data up to and including this date. If None, all dates are selected.

figsizeTuple[float, float], default=(16,9)

Figure size for the plot.

titleOptional[str], default=None

Title for the plot.

share_xbool, default=True

Share x-axis across all subplots.

share_ybool, default=True

Share y-axis across all subplots.

kwargsDict

Additional keyword arguments for the plot passed directly to Facetplot.lineplot.