Skip to main content

Note 30: Case Study II: Astrophysical Light Curves & Sensor Flux

Module 7: Wrangling, Case Studies & Ethics

Learning Objectives

  • Audit pre-processed space-telescope telemetry (data/lc_kepler.csv) and diagnose how aggressive detrending and sigma-clipping can erase the very physical signal under study.
  • Explain why information criteria (AIC/AICc) cannot be compared across different temporal aggregation scales and distinguish statistical significance from physical importance in large-\(N\) series.
  • Show mathematically and empirically how pre-smoothing with a rolling average injects artificial \(\text{MA}(q)\) autocorrelation into white noise.
  • Evaluate dynamic regression (ARIMA(rate ~ exposure)) against univariate ARIMA and ETS on Swift/BAT Crab Nebula X-ray telemetry (data/crab.csv) to separate astrophysical drift from instrumental exposure.

1. Tabby’s Star: When Preprocessing Erases the Signal

Tabby’s Star (KIC 8462852) became famous during NASA’s Kepler mission for irregular, asymmetric optical dimming events reaching up to 22% depth and lasting 5 to 80 days, widely attributed to transit clouds of exocomet dust fragments.

Artist impression of dust and comet fragments orbiting Tabby’s Star (KIC 8462852).

The local file data/lc_kepler.csv holds 58,502 long-cadence (~29.4-minute) flux observations indexed in Barycentric Kepler Julian Date (BKJD), defined by the NASA Kepler archive as days since 2009-01-01 12:00:00 UTC (\(\text{BJD} = \text{BKJD} + 2{,}454{,}833.0\)). Before fitting any model, always audit the empirical distribution of the archive.

lc <- read_csv("data/lc_kepler.csv", show_col_types = FALSE) |>
  mutate(datetime = as.POSIXct("2009-01-01 12:00:00", tz = "UTC") + time * 86400)

min_row <- lc |> slice_min(flux, n = 1)

tibble(
  Rows = nrow(lc),
  Start_UTC = format(min(lc$datetime), "%Y-%m-%d"),
  End_UTC = format(max(lc$datetime), "%Y-%m-%d"),
  Min_Flux = min(lc$flux),
  Max_Flux = max(lc$flux),
  SD_Flux = sd(lc$flux),
  Min_BKJD = min_row$time,
  Min_Date = format(min_row$datetime, "%Y-%m-%d")
) |> fmt_tbl(digits = 5, caption = "Empirical audit of data/lc_kepler.csv.")
Empirical audit of data/lc_kepler.csv.
Rows Start_UTC End_UTC Min_Flux Max_Flux SD_Flux Min_BKJD Min_Date
58502 2009-05-02 2013-05-02 0.9985 1.001 0.00017 794.1 2011-03-06

Look closely at Min_Flux: it is 0.99851 (a 0.15% deviation!), not 0.78. Why did the famous 22% dips vanish? This CSV was exported after applying \(3\sigma\) outlier clipping plus a 101-cadence (\(\approx 2.06\)-day) cubic Savitzky-Golay flattening filter. Any astrophysical dimming lasting 5–80 days was treated as “slow baseline drift” and divided out, while sharp dip cores were clipped as outliers! Even the deepest residual notch at BKJD 794.07 (2011-03-06, the exact date of the famous 15% D792 dip) was flattened to sub-percent micro-variability.

2. Aggregation Scales, Incomparable AICs & Huge-\(N\) Significance

Kepler operated in an Earth-trailing heliocentric orbit, so its telemetry has no 24-hour terrestrial diurnal cycle (PDQ(0, 0, 0)). Below we aggregate the full 4-year mission to regular daily means (1,462 days) and compare it against a dense 60-day hourly window (2010-05-01 to 2010-06-30, 1,440 hours).

lc_daily <- lc |>
  mutate(date = as_date(datetime)) |>
  group_by(date) |>
  summarise(flux = mean(flux, na.rm = TRUE), .groups = "drop") |>
  as_tsibble(index = date) |>
  fill_gaps() |>
  mutate(flux_imp = na_interpolation(flux, option = "linear"))

lc_hourly60 <- lc |>
  filter(datetime >= as.POSIXct("2010-05-01", tz = "UTC"),
         datetime <  as.POSIXct("2010-06-30", tz = "UTC")) |>
  mutate(hour = floor_date(datetime, "hour")) |>
  group_by(hour) |>
  summarise(flux = mean(flux, na.rm = TRUE), .groups = "drop") |>
  as_tsibble(index = hour) |>
  fill_gaps() |>
  mutate(flux_imp = na_interpolation(flux, option = "linear"))

p1 <- lc_daily |>
  autoplot(flux_imp, color = ts_pal["navy"], linewidth = 0.55) +
  labs(
    title = "Daily Mean Normalized Flux (2009–2013)",
    subtitle = "Full 4-year mission (n = 1,462 days); detrending flattened 22% dips to 0.15%",
    x = NULL,
    y = "Normalized flux"
  )

p2 <- lc_hourly60 |>
  autoplot(flux_imp, color = ts_pal["teal"], linewidth = 0.55) +
  labs(
    title = "Hourly Mean Normalized Flux (May–Jun 2010)",
    subtitle = "60-day dense window (n = 1,440 hours); AIC is incomparable across scales",
    x = "UTC Date",
    y = "Normalized flux"
  )

(p1 / p2) +
  plot_layout(guides = "collect") &
  theme(legend.position = "bottom")
Figure 1: Pre-flattened Kepler flux of KIC 8462852 across the full 4-year mission (daily means, top) and a 60-day hourly window in May–June 2010 (bottom).
fit_daily  <- lc_daily    |> model(ARIMA = ARIMA(flux_imp ~ PDQ(0, 0, 0)))
fit_hourly <- lc_hourly60 |> model(ARIMA = ARIMA(flux_imp ~ PDQ(0, 0, 0)))

bind_rows(
  glance(fit_daily)  |> mutate(Scale = "Daily (4 yr, n = 1462)",  Spec = format(fit_daily$ARIMA)),
  glance(fit_hourly) |> mutate(Scale = "Hourly (60 d, n = 1440)", Spec = format(fit_hourly$ARIMA))
) |>
  mutate(Resid_SD_ppm = sqrt(sigma2) * 1e6) |>
  select(Scale, Spec, Resid_SD_ppm, log_lik, AIC, AICc) |>
  fmt_tbl(digits = 1, caption = "ARIMA fits across two aggregation scales (AIC values are NOT comparable; SD in ppm).")
ARIMA fits across two aggregation scales (AIC values are NOT comparable; SD in ppm).
Scale Spec Resid_SD_ppm log_lik AIC AICc
Daily (4 yr, n = 1462) <ARIMA(1,0,1) w/ mean> 58.0 12187 -24367 -24367
Hourly (60 d, n = 1440) <ARIMA(3,0,2) w/ mean> 82.7 11495 -22976 -22976

Three methodological lessons follow from this comparison:

  • AIC is strictly incomparable across aggregation scales. Because \(\text{AIC} = -2\ell(\hat{\theta}; \mathbf{y}) + 2k\) evaluates the Gaussian log-likelihood on a specific data vector \(\mathbf{y}\), changing from hourly averages to daily averages alters both the observations and their noise variance \(\sigma^2 \sim 10^{-9}\). A lower AIC on daily data (-24,367 vs -22,976) never implies a “better” scientific model of the star.
  • Statistical significance is not astrophysical significance. In the daily ARIMA(1,0,1) fit, \(\hat{\phi}_1 = 0.791\) yields \(|t| = 42.4\) (\(p < 10^{-250}\)), yet the entire series standard deviation is \(0.00017\) (0.017% flux): much of that short-range autocorrelation is the residual footprint of the 2-day Savitzky-Golay filter itself.
  • Linear ARIMA cannot forecast aperiodic occultation transients. Stationary Gaussian ARIMA forms linear combinations of recent lags and reverts to the baseline mean; it has zero predictive power for sudden, asymmetric dust-cloud eclipses arriving years apart.

3. Crab Nebula X-Ray Telemetry & The Moving-Average Trap

The Crab Nebula (remnant of the 1054 CE supernova) and its central pulsar have long served as an X-ray “standard candle” for calibrating space observatories. Yet NASA’s Swift Burst Alert Telescope (BAT, 15–50 keV) revealed genuine multi-year hard X-ray drift of roughly 7% (Wilson-Hodge et al., 2011).

Hubble Space Telescope composite image of the Crab Nebula (M1, remnant of SN 1054).

Before aggregating data/crab.csv to weekly means, beware a common preprocessing mistake: applying a \(k\)-point rolling mean before fitting ARIMA. Suppose \(\varepsilon_t \stackrel{\text{iid}}{\sim} (0, \sigma^2)\) is pure white noise, and we form \(z_t = \frac{1}{3}(\varepsilon_t + \varepsilon_{t-1} + \varepsilon_{t-2})\). Because consecutive averages share overlapping innovations, \(z_t\) becomes an exact \(\text{MA}(2)\) process with theoretical autocorrelations:

\[\rho_z(1) = \frac{2}{3} \approx 0.667, \qquad \rho_z(2) = \frac{1}{3} \approx 0.333, \qquad \rho_z(h) = 0 \text{ for } h \ge 3.\]

Pre-smoothing therefore fabricates strong serial correlation that never existed in the detector data.

set.seed(493)
wn  <- rnorm(1000)
ma3 <- na.omit(as.numeric(stats::filter(wn, rep(1 / 3, 3), sides = 1)))

tibble(
  Lag = 1:3,
  White_Noise_ACF = acf(wn, plot = FALSE)$acf[2:4],
  MA3_Smoothed_ACF = acf(ma3, plot = FALSE)$acf[2:4],
  Theoretical_MA2 = c(2 / 3, 1 / 3, 0)
) |> fmt_tbl(digits = 3, caption = "Artificial MA(2) autocorrelation injected by a 3-point moving average on white noise.")
Artificial MA(2) autocorrelation injected by a 3-point moving average on white noise.
Lag White_Noise_ACF MA3_Smoothed_ACF Theoretical_MA2
1 -0.063 0.642 0.667
2 0.030 0.349 0.333
3 -0.002 0.002 0.000

4. Secular Flux Drift vs. Exposure Time in Swift/BAT

Auditing data/crab.csv by year reveals a high-fidelity calibration era from 2005 through 2018 (annual mean count rate drops 6.9% from 0.230 in 2008 to 0.214 in 2011), whereas 2019–2025 contains an archive outage carry-forward block (only 6 unique values in 2019) and late calibration spikes. We therefore analyze the clean 2005–2018 record, aggregating raw daily rates (DATA_FLAG == 0) directly to weekly means without rolling smoothing, and test whether weekly detector exposure (TIMEDEL_EXPO, in kiloseconds) explains flux variation using dynamic regression:

\[y_t = \beta_0 + \beta_1 \text{exposure}_t + \eta_t, \qquad \eta_t \sim \text{ARIMA}(p,d,q).\]

crab_weekly <- read_csv("data/crab.csv", show_col_types = FALSE) |>
  filter(DATA_FLAG == 0, !is.na(RATE), year(date) <= 2018) |>
  mutate(week = yearweek(date)) |>
  group_by(week) |>
  summarise(
    rate = mean(RATE),
    exposure = mean(TIMEDEL_EXPO) / 1000,
    .groups = "drop"
  ) |>
  as_tsibble(index = week) |>
  fill_gaps() |>
  mutate(
    rate = na_interpolation(rate),
    exposure = na_interpolation(exposure)
  )

crab_train <- crab_weekly |> filter(week < yearweek("2017 W01"))
crab_test  <- crab_weekly |> filter(week >= yearweek("2017 W01"))

fit_crab <- crab_train |>
  model(
    ETS = ETS(rate ~ season("N")),
    ARIMA = ARIMA(rate ~ pdq(0:2, 0:1, 0:2) + PDQ(0, 0, 0)),
    ARIMAX = ARIMA(rate ~ exposure + pdq(0:2, 0:1, 0:2) + PDQ(0, 0, 0))
  )

fc_crab <- fit_crab |> forecast(new_data = crab_test)

fabletools::accuracy(fc_crab, crab_weekly) |>
  select(.model, RMSE, MAE, MAPE) |>
  arrange(RMSE) |>
  fmt_tbl(digits = 5, caption = "Out-of-sample weekly Crab Nebula flux accuracy (2017–2018 holdout).")
Out-of-sample weekly Crab Nebula flux accuracy (2017–2018 holdout).
.model RMSE MAE MAPE
ARIMA 0.00689 0.00393 1.886
ARIMAX 0.00691 0.00395 1.897
ETS 0.00726 0.00456 2.170
fc_crab |>
  filter(.model == "ARIMA") |>
  anchor_fc(crab_train) |>
  autoplot(crab_weekly, level = c(80, 95), color = ts_pal["teal"]) +
  labs(
    title = "Crab Nebula Weekly Hard X-Ray Flux (2005–2018)",
    subtitle = "~6.9% secular drift (2008–2011); exposure covariate adds no forecast gain",
    x = "Week",
    y = bquote(bold("Swift/BAT count rate (counts " * "s"^-1 * " " * "cm"^-2 * ")"))
  )
Figure 2: Weekly Swift/BAT hard X-ray count rate of the Crab Nebula (2005–2018), showing the ~7% secular decline from 2008 to 2011 and 2017–2018 ARIMA holdout forecasts.

In ARIMAX (LM w/ ARIMA(2,1,2) errors), the exposure slope is tiny and insignificant (\(\hat{\beta}_1 = -0.000027\), \(p = 0.713\)), and univariate ARIMA(2,1,2) beats both ARIMAX and ETS on the 2-year holdout (RMSE = 0.00689, MAPE = 1.89%). This confirms that the ~7% multi-year flux variation is genuine astrophysical evolution in the nebula’s synchrotron wind rather than an artifact of spacecraft exposure time.

Practice Exercises

  1. Verifying Moving-Average Autocorrelation Bias. Simulate 2,000 standard normal white-noise observations and compare the empirical ACF at lags 1–4 of (a) the raw series and (b) a 5-point moving average against the theoretical formula \(\rho(h) = (5 - h)/5\) for \(1 \le h \le 4\).
Solution

A \(k\)-point simple moving average of white noise shares \(k - h\) overlapping innovations at lag \(h < k\), yielding \(\rho(h) = (k - h)/k\):

set.seed(2025)
e <- rnorm(2000)
ma5 <- na.omit(as.numeric(stats::filter(e, rep(1 / 5, 5), sides = 1)))

tibble(
  Lag = 1:4,
  Raw_WN = acf(e, plot = FALSE)$acf[2:5],
  MA5_Empirical = acf(ma5, plot = FALSE)$acf[2:5],
  MA5_Theoretical = (5 - 1:4) / 5
) |> fmt_tbl(digits = 3, caption = "Empirical vs. theoretical autocorrelation induced by a 5-point moving average.")
Empirical vs. theoretical autocorrelation induced by a 5-point moving average.
Lag Raw_WN MA5_Empirical MA5_Theoretical
1 0.011 0.776 0.8
2 -0.022 0.534 0.6
3 -0.029 0.296 0.4
4 -0.055 0.075 0.2
  1. Daily vs. Weekly Crab Nebula Diagnostics. Fit a parsimonious ARIMA(RATE ~ pdq(0:2, 0:1, 0:2) + PDQ(0, 0, 0)) to the 2005–2018 daily Crab Nebula series (after fill_gaps() and linear interpolation) and compare its residual standard deviation (\(\sqrt{\sigma^2}\)) and lag-20 Ljung-Box test against the weekly ARIMA model from Section 4.
Solution

Aggregate averaging reduces daily photon-counting noise substantially, while both series should be audited with exact dof = p + q:

crab_daily <- read_csv("data/crab.csv", show_col_types = FALSE) |>
  filter(DATA_FLAG == 0, !is.na(RATE), year(date) <= 2018) |>
  as_tsibble(index = date) |>
  fill_gaps() |>
  mutate(RATE = na_interpolation(RATE))

fit_d <- crab_daily |> model(ARIMA = ARIMA(RATE ~ pdq(0:2, 0:1, 0:2) + PDQ(0, 0, 0)))
dof_d <- sum(grepl("^(ar|ma)[0-9]+$", tidy(fit_d)$term))
dof_w <- sum(grepl("^(ar|ma)[0-9]+$", tidy(fit_crab |> select(ARIMA))$term))

bind_rows(
  fit_d |> augment() |> features(.innov, ljung_box, lag = 20, dof = dof_d) |>
    mutate(Scale = "Daily", Resid_SD = sqrt(glance(fit_d)$sigma2), .before = 1),
  fit_crab |> select(ARIMA) |> augment() |> features(.innov, ljung_box, lag = 20, dof = dof_w) |>
    mutate(Scale = "Weekly", Resid_SD = sqrt(glance(fit_crab |> select(ARIMA))$sigma2), .before = 1)
) |> select(Scale, Resid_SD, lb_stat, lb_pvalue) |>
  fmt_tbl(digits = 5, caption = "Daily vs. weekly Crab Nebula ARIMA residual diagnostics.")
Daily vs. weekly Crab Nebula ARIMA residual diagnostics.
Scale Resid_SD lb_stat lb_pvalue
Daily 0.00355 975.35 0.0000
Weekly 0.00527 15.08 0.5187

Daily ARIMA(2,1,1) shows a deceptively small innovation SD (0.00355) yet fails the Ljung-Box test dramatically (\(Q^* = 975.4\), \(p < 0.0001\)) with a sharp negative residual spike at lag 3 (-0.39). Because differencing a 3-point moving average produces \(\Delta z_t = (\varepsilon_t - \varepsilon_{t-3})/3\) (theoretical lag-3 ACF of \(-0.5\)), that diagnostic uncovers a 3-day rolling average baked into the archived daily file upstream! Aggregating directly into non-overlapping weekly bins breaks the 3-day overlap and restores clean white-noise innovations (\(Q^* = 15.08\), \(p = 0.519\)).

Key Takeaways

  • Always inspect empirical min/max ranges before modeling archived data: over-aggressive sigma-clipping and short-window Savitzky-Golay detrending erased Tabby’s Star’s real 22% dips down to 0.15% micro-variability.
  • Never compare AIC or AICc across different aggregation frequencies (hourly vs. daily) or different sample windows; likelihoods live on incompatible data spaces.
  • Never pre-smooth a series with a rolling average before fitting ARIMA: a \(k\)-point moving average injects artificial \(\text{MA}(k-1)\) autocorrelation into white noise.
  • Dynamic regression (ARIMA(y ~ x)) provides a formal out-of-sample test separating instrumental artifacts (such as spacecraft exposure) from real astrophysical drift.
Back to top