File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -1275,15 +1275,26 @@ def analyze_persistence(
12751275
12761276 Examples
12771277 --------
1278+ >>> import causalpy as cp
1279+ >>> import pandas as pd
1280+ >>> df = (
1281+ ... cp.load_data("its")
1282+ ... .assign(date=lambda x: pd.to_datetime(x["date"]))
1283+ ... .set_index("date")
1284+ ... )
12781285 >>> result = cp.InterruptedTimeSeries(
12791286 ... df,
1280- ... treatment_time=pd.Timestamp("2024-01-01"),
1281- ... treatment_end_time=pd.Timestamp("2024-04-01"),
1282- ... formula="y ~ 1 + t",
1287+ ... treatment_time=pd.Timestamp("2017-01-01"),
1288+ ... treatment_end_time=pd.Timestamp("2017-06-01"),
1289+ ... formula="y ~ 1 + t + C(month)",
1290+ ... model=cp.pymc_models.LinearRegression(
1291+ ... sample_kwargs={"random_seed": 42, "progressbar": False}
1292+ ... ),
12831293 ... )
1284- >>> persistence = result.analyze_persistence()
1285- >>> # Results are automatically printed
1286- >>> print(f"Persistence ratio: {persistence['persistence_ratio']:.2f}")
1294+ >>> persistence = result.analyze_persistence() # doctest: +SKIP
1295+ ... # Note: Results are automatically printed to console
1296+ >>> persistence["persistence_ratio"] # doctest: +SKIP
1297+ -1.224
12871298 """
12881299 if self .treatment_end_time is None :
12891300 raise ValueError (
You can’t perform that action at this time.
0 commit comments