% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{diagnose_gwpr}
\alias{diagnose_gwpr}
\title{Run diagnostic tests on a fitted GWPR model}
\usage{
diagnose_gwpr(
  object,
  diagnostics = c("moran", "f_test", "hausman", "lm_test"),
  spatial_weights = NULL,
  panel_index = NULL,
  ...
)
}
\arguments{
\item{object}{A `gwpr_fit` object returned by `fit_gwpr()` or similar.}

\item{diagnostics}{Character vector naming the tests to run.  Any subset of
`c("moran", "f_test", "hausman", "lm_test")`.  Default is all four.}

\item{spatial_weights}{Required when `"moran"` is in `diagnostics`.
A row-standardised n x n spatial weights matrix.}

\item{panel_index}{Required when `"moran"` is in `diagnostics`.
A data.frame with columns `id` and `time` identifying each element of
`object$residuals`.}

\item{...}{Additional arguments passed to individual diagnostic functions.}
}
\value{
A `gwpr_diagnostics` object (list with class `"gwpr_diagnostics"`)
  whose `diagnostics` slot contains the result of each requested test.
}
\description{
Top-level interface that dispatches to individual diagnostic sub-functions.
Returns a `gwpr_diagnostics` object containing all requested test results.
}
\details{
Tests that are not applicable to the fitted model (e.g., Hausman test on a
pooling model) return a list with `status = "not_applicable"` and an
explanatory `message`, rather than an error.
}
\examples{
\donttest{
library(sf)
pts <- sf::st_as_sf(
  data.frame(id = 1:4, X = c(0,1,0,1), Y = c(0,0,1,1)),
  coords = c("X", "Y"), crs = NA_integer_
)
dat <- data.frame(
  id   = rep(1:4, each = 5),
  time = rep(1:5, 4),
  y    = rnorm(20),
  x1   = rnorm(20)
)
fit <- fit_gwpr(y ~ x1, data = dat, spatial = pts, id = "id",
                time = "time", bandwidth = 2, workers = 1)
diag_result <- diagnose_gwpr(fit, diagnostics = c("f_test", "hausman"))
print(diag_result)
}

}
