|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from collections.abc import Sequence |
| 4 | +from dataclasses import dataclass |
| 5 | +from typing import Any, TypeAlias |
| 6 | + |
| 7 | +ArrayLike: TypeAlias = Any |
| 8 | +MatrixLike: TypeAlias = Any |
| 9 | +ModelLike: TypeAlias = Any |
| 10 | +DataFrameLike: TypeAlias = Any |
| 11 | + |
| 12 | + |
| 13 | +@dataclass(slots=True) |
| 14 | +class CoordinateData: |
| 15 | + """Normalized coordinates for spatial distance calculations. |
| 16 | +
|
| 17 | + This record holds the observation-aligned coordinate matrix together with |
| 18 | + the information needed to interpret those coordinates correctly. In this |
| 19 | + package, locations can come in either as longitude/latitude pairs or as |
| 20 | + ordinary Euclidean coordinates. `CoordinateData` gives the rest of the |
| 21 | + code one consistent representation of that information. |
| 22 | +
|
| 23 | + Attributes: |
| 24 | + coords: Numeric coordinate matrix aligned to the model observations. |
| 25 | + latlong: Whether the coordinates should be treated as longitude and |
| 26 | + latitude rather than Euclidean coordinates. |
| 27 | + """ |
| 28 | + |
| 29 | + coords: MatrixLike |
| 30 | + latlong: bool |
| 31 | + |
| 32 | + |
| 33 | +@dataclass(slots=True) |
| 34 | +class ConditionalProjectionSetup: |
| 35 | + """Regressor information for the conditional SCPC adjustment. |
| 36 | +
|
| 37 | + This record contains the regression-side objects needed to build the |
| 38 | + conditional projection basis. In higher-level terms, it represents the |
| 39 | + covariate space that spatial directions must be made orthogonal to before |
| 40 | + conditional SCPC inference can be computed. |
| 41 | +
|
| 42 | + Attributes: |
| 43 | + model_mat: Regression design matrix aligned to the active observations. |
| 44 | + include_intercept: Whether the conditional projection should include an |
| 45 | + explicit intercept column. |
| 46 | + fixef_id: Optional fixed-effect identifiers used for demeaning. |
| 47 | + """ |
| 48 | + |
| 49 | + model_mat: MatrixLike |
| 50 | + include_intercept: bool |
| 51 | + fixef_id: ArrayLike | None |
| 52 | + |
| 53 | + |
| 54 | +@dataclass(slots=True) |
| 55 | +class SpatialSetup: |
| 56 | + """Spatial reference objects derived from the distance matrix. |
| 57 | +
|
| 58 | + This record gathers the main outputs of the spatial setup stage: the final |
| 59 | + projection basis, the critical value attached to that basis, the omega |
| 60 | + grid used for size control, and the kernel scales behind those objects. |
| 61 | + It exists so the main inference routine can pass around one coherent |
| 62 | + description of the spatial environment. |
| 63 | +
|
| 64 | + Attributes: |
| 65 | + wfin: Final spatial projection matrix. |
| 66 | + cvfin: Critical value attached to the final projection. |
| 67 | + omsfin: Omega matrices over the spatial correlation grid. |
| 68 | + c0: Kernel scale matching the target average correlation bound. |
| 69 | + cmax: Largest kernel scale used in the spatial grid search. |
| 70 | + """ |
| 71 | + |
| 72 | + wfin: MatrixLike |
| 73 | + cvfin: float |
| 74 | + omsfin: list[MatrixLike] |
| 75 | + c0: float |
| 76 | + cmax: float |
| 77 | + |
| 78 | + |
| 79 | +@dataclass(slots=True) |
| 80 | +class SCPCResult: |
| 81 | + """SCPC estimates, intervals, and projection metadata. |
| 82 | +
|
| 83 | + This is the main user-facing result type returned by `scpc()`. It keeps |
| 84 | + together the estimated coefficient table, any stored critical values, and |
| 85 | + the spatial projection information that explains how the inference was |
| 86 | + constructed. |
| 87 | +
|
| 88 | + Attributes: |
| 89 | + scpcstats: Main result table with estimates, standard errors, test |
| 90 | + statistics, p-values, and confidence interval endpoints. |
| 91 | + scpccvs: Optional table of stored critical values at supported levels. |
| 92 | + w: Final spatial projection matrix used for inference. |
| 93 | + avc: Average pairwise correlation bound supplied by the user. |
| 94 | + c0: Kernel scale implied by `avc`. |
| 95 | + cv: Unconditional 5 percent critical value. |
| 96 | + q: Number of non-constant spatial principal components retained. |
| 97 | + call: Optional textual representation of the original call. |
| 98 | + """ |
| 99 | + |
| 100 | + scpcstats: MatrixLike |
| 101 | + scpccvs: MatrixLike | None |
| 102 | + w: MatrixLike |
| 103 | + avc: float |
| 104 | + c0: float |
| 105 | + cv: float |
| 106 | + q: int |
| 107 | + call: str | None = None |
| 108 | + |
| 109 | + def __repr__(self) -> str: |
| 110 | + """Return a developer-oriented representation of the result. |
| 111 | +
|
| 112 | + This method provides a compact object representation for interactive |
| 113 | + work and debugging, where a short structural summary is more useful |
| 114 | + than the full printed results table. |
| 115 | +
|
| 116 | + Returns: |
| 117 | + A representation string. |
| 118 | + """ |
| 119 | + pass |
| 120 | + |
| 121 | + def __str__(self) -> str: |
| 122 | + """Return a user-facing summary string. |
| 123 | +
|
| 124 | + This method fills the role of `print.scpc`. It is the quick, readable |
| 125 | + view of the SCPC result that a user sees when they inspect the object |
| 126 | + at the console. |
| 127 | +
|
| 128 | + Returns: |
| 129 | + A formatted summary string. |
| 130 | + """ |
| 131 | + pass |
| 132 | + |
| 133 | + def summary(self) -> str: |
| 134 | + """Return an extended formatted summary. |
| 135 | +
|
| 136 | + This method fills the role of `summary.scpc`. It exists for the case |
| 137 | + where the user wants the fuller inference table, confidence intervals, |
| 138 | + and any stored critical values in one readable summary. |
| 139 | +
|
| 140 | + Returns: |
| 141 | + A formatted summary string. |
| 142 | + """ |
| 143 | + pass |
| 144 | + |
| 145 | + def coef(self) -> Any: |
| 146 | + """Return the coefficient estimates. |
| 147 | +
|
| 148 | + This method fills the role of `coef.scpc`. It gives users the compact |
| 149 | + coefficient vector without making them manually pull it out of the full |
| 150 | + result table. |
| 151 | +
|
| 152 | + Returns: |
| 153 | + The coefficient estimates. |
| 154 | + """ |
| 155 | + pass |
| 156 | + |
| 157 | + def confint( |
| 158 | + self, |
| 159 | + parm: Sequence[str] | Sequence[int] | None = None, |
| 160 | + level: float = 0.95, |
| 161 | + ) -> Any: |
| 162 | + """Return confidence intervals for selected coefficients. |
| 163 | +
|
| 164 | + This method fills the role of `confint.scpc`. It is the focused access |
| 165 | + path for interval extraction when a user wants selected coefficients or |
| 166 | + a supported confidence level without reading the full summary output. |
| 167 | +
|
| 168 | + Args: |
| 169 | + parm: Coefficient names or positions to include. |
| 170 | + level: Confidence level to request. |
| 171 | +
|
| 172 | + Returns: |
| 173 | + Confidence intervals for the selected coefficients. |
| 174 | +
|
| 175 | + Raises: |
| 176 | + ValueError: Raised later for unknown coefficients or unsupported |
| 177 | + confidence levels. |
| 178 | + """ |
| 179 | + pass |
0 commit comments