plot_partial_autocorrelation¶
yohou.plotting.diagnostics.plot_partial_autocorrelation(df, *, columns=None, max_lags=None, method='yw', confidence_level=0.95, show_confidence=True, groups=None, facet_by='member', facet_n_cols=2, color_palette=None, show_legend=True, title=None, x_label=None, y_label=None, width=None, height=None, color='#059669')
¶
Plot partial autocorrelation function (PACF) for time series.
Shows correlation between the series and its lagged values after removing the effect of intermediate lags. Useful for determining appropriate AR order.
The computation is delegated to statsmodels.tsa.stattools.pacf which
supports several estimation methods and proper confidence intervals.
Requires yohou[plotting].
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame with 'time' column and numeric columns. |
required |
columns
|
str | list[str] | None
|
Column(s) to analyze. If None, uses all numeric columns except 'time'. |
None
|
max_lags
|
int | None
|
Maximum number of lags to compute. If None, uses min(len(df)//2, 40). |
None
|
method
|
str
|
PACF estimation method passed to |
"yw"
|
confidence_level
|
float
|
Confidence level for confidence bands (e.g. |
0.95
|
show_confidence
|
bool
|
Whether to show confidence bands. |
True
|
groups
|
list[str] | None
|
Panel group prefixes to plot. |
None
|
facet_by
|
Literal['group', 'member'] | None
|
Faceting axis for panel data. |
"member"
|
facet_n_cols
|
int
|
Number of columns in facet grid. |
2
|
color_palette
|
list[str] | None
|
Custom color palette (one color per column). |
None
|
show_legend
|
bool
|
Whether to show the legend. |
True
|
title
|
str | None
|
Plot title. |
None
|
x_label
|
str | None
|
X-axis label. |
None
|
y_label
|
str | None
|
Y-axis label. |
None
|
width
|
int | None
|
Plot width in pixels. |
None
|
height
|
int | None
|
Plot height in pixels. |
None
|
color
|
str
|
Bar color for single-column plots (ignored when color_palette is set). |
"#059669"
|
Returns¶
| Type | Description |
|---|---|
Figure
|
Plotly figure object. |
Examples¶
>>> # Create sample time series
>>> df = pl.DataFrame({
... "time": pl.date_range(pl.date(2020, 1, 1), pl.date(2020, 12, 31), "1d", eager=True),
... "y": [100 + i % 30 for i in range(366)],
... })
>>> # Plot PACF
>>> fig = plot_partial_autocorrelation(df, columns="y", max_lags=20)
>>> len(fig.data) > 0
True
See Also¶
plot_autocorrelation : Plot autocorrelation function.
Source Code¶
Show/Hide source
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | |
Tutorials¶
The following example notebooks use this component:
-
Seasonal Analysis
Visualization
Seasonal overlays, subseasonal structure, ACF/PACF correlation patterns, and STL decomposition for monthly, quarterly, and long-cycle datasets.