# 时间加权回归

时间加权回归（Temporally weighted regression，TWR）是一种局部回归方法，它按观测点在时间上的距离为其赋权，使靠近估计点的时间段对拟合系数的贡献大于相距较远的时间段。它针对的是时间非平稳性，即响应变量与其解释变量之间的关系在研究时段内发生变化的情形，此时单一的全局普通最小二乘（OLS）估计会将不同机制的时期混为一谈、取一个平均。在已发表的文献中，TWR很少单独出现：它主要作为地理与时间加权回归（GTWR）的时间特例被记录，其中空间加权被关闭，只保留时间维度。

| 关键事实 | 详情 |
|---|---|
| 估计内容 | 在每个时间点上通过加权最小二乘法估计局部系数 \( \beta_{k}(t_{i}) \)，权重仅基于时间间隔<sup>[1](https://doi.org/10.3390/e19020053)</sup> |
| 与GTWR的关系 | TWR与GWR是GTWR局部加权方案的特例<sup>[2](https://doi.org/10.1080/13658810802672469)</sup> |
| 卡尔加里基准 | 相较全局OLS，TWR、GWR和GTWR分别将绝对误差降低3.5%、31.5%和46.4%；拟合优度分别为0.7794、0.8897和0.9282<sup>[2](https://doi.org/10.1080/13658810802672469)</sup> |
| 常用核函数 | 高斯核，\( W_{ij} = \exp(-(d_{ij}^{ST})^{2}/h^{2}) \)，作用于时空距离<sup>[1](https://doi.org/10.3390/e19020053)</sup> |
| 带宽选择 | 交叉验证或AIC/AICc，先空间带宽，后时间带宽<sup>[3](https://doi.org/10.1111/gean.12071)</sup><sup> • </sup><sup>[4](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)</sup> |
| 诊断指标 | AICc与有效残差自由度 \( n - 2\,\mathrm{trace}(S) + \mathrm{trace}(S' \cdot S) \)，有效参数数量为 \( 2\,\mathrm{trace}(S) - \mathrm{trace}(S' \cdot S) \)<sup>[4](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)</sup> |
| 典型领域 | 房价、降雨、形变监测、空气污染、房产评估<sup>[3](https://doi.org/10.1111/gean.12071)</sup><sup> • </sup><sup>[5](https://scik.org/index.php/jmcs/article/download/7427/3515)</sup><sup> • </sup><sup>[6](https://onlinelibrary.wiley.com/doi/10.1155/2019/4352396)</sup> |

## 工作原理

模型将时空位置 \( (u_{i},v_{i},t_{i}) \) 处的响应变量写为

\[ y_{i} = \beta_{0}(u_{i},v_{i},t_{i}) + \sum_{k=1}^{p} \beta_{k}(u_{i},v_{i},t_{i})\, x_{ik} + \varepsilon_{i} \]

其中每个系数都允许随空间和时间变化。<sup>[1](https://doi.org/10.3390/e19020053)</sup><sup> • </sup><sup>[7](https://www.sciencedirect.com/science/article/abs/pii/S2211675322000501)</sup> 在每个回归点上，系数通过加权最小二乘法估计，

\[ \hat{\beta}_{i} = (X' \cdot W(u_{i},v_{i},t_{i}) \cdot X)^{-1} X' \cdot W(u_{i},v_{i},t_{i})\, y \]

其中权重矩阵由回归点与每个观测点之间的距离构建。<sup>[1](https://doi.org/10.3390/e19020053)</sup> 在纯TWR中，权重仅取决于 \( |t_{i} - t_{j}| \)；在GTWR中，它们同时结合空间间隔与时间间隔。黄波、吴波和迈克尔·巴里的表述将空间核函数与时间核函数线性组合，并把过去、当前和未来的数据点都作为邻居；而A·斯图尔特·福瑟林汉姆、里卡多·克雷斯波和姚静的版本则分离空间带宽与时间带宽，只把过去和当前的点视为时空邻居。<sup>[7](https://www.sciencedirect.com/science/article/abs/pii/S2211675322000501)</sup>

一种常用的时空距离是

\[ (d_{ij}^{ST})^{2} = \phi_{S}\left[(u_{i}-u_{j})^{2} + (v_{i}-v_{j})^{2}\right] + \phi_{T}(t_{i}-t_{j})^{2} \]

将其代入高斯核 \( W_{ij} = \exp(-(d_{ij}^{ST})^{2}/h^{2}) \)，该核被称为最常用的权重函数。<sup>[1](https://doi.org/10.3390/e19020053)</sup> 由于空间与时间以不同的尺度度量，尺度因子 \( \mu_{S} \) 和 \( \mu_{T} \) 仅通过其比值 \( \tau = \mu_{T}/\mu_{S} \) 进入权重，因此将 \( \mu_{S} \) 设为1，剩下三个调节参数（邻居数量、\( \mu_{T} \) 和一个核参数）需要调优。<sup>[8](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0205063)</sup>

## 操作流程

实践者首先按时间（GTWR中还要按位置）对数据排序，然后选择核函数（高斯核或双平方核）以及固定带宽或自适应带宽。<sup>[4](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)</sup> GWmodel R包的`gtwr()`函数将时空距离计算为

\[ \lambda \cdot s_{ij} + (1-\lambda) \cdot t_{ij} + 2\sqrt{\lambda(1-\lambda)\, s_{ij} \cdot t_{ij}} \cos(\xi) \]

默认取 \( \lambda = 0.05 \)。<sup>[4](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)</sup> 随后通过最小化拟合优度准则、交叉验证（CV）或赤池信息准则来选择带宽；在A·斯图尔特·福瑟林汉姆等人的标定中，先找到最优空间带宽，再以最小化CV得分的时间带宽确定最终的空间带宽。<sup>[3](https://doi.org/10.1111/gean.12071)</sup><sup> • </sup><sup>[4](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)</sup> STWR以CV为默认准则，同时报告校正AIC（AICc）。<sup>[9](https://doi.org/10.5194/gmd-13-6149-2020)</sup> 拟合完成后，诊断指标包括AICc、调整\( R^{2} \)以及有效残差自由度 \( n - 2\,\mathrm{trace}(S) + \mathrm{trace}(S' S) \)，它相对于样本量的补量 \( 2\,\mathrm{trace}(S) - \mathrm{trace}(S' S) \) 量化了局部平滑器实际消耗的独立参数数量。<sup>[4](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)</sup>

## 起源

其空间前身——地理加权回归（GWR）——由克里斯·布伦斯登、A·斯图尔特·福瑟林汉姆和马丁·E·查尔顿于1996年在《地理分析》上发表。<sup>[10](https://doi.org/10.1111/j.1538-4632.1996.tb00936.x)</sup> 早期的时空扩展来自里卡多·克雷斯波、A·斯图尔特·福瑟林汉姆和马丁·E·查尔顿于2007年的工作，他们在19年伦敦房价数据集上标定了局部特征价格模型，其时空带宽考虑了随时间变化的局部空间效应。<sup>[9](https://doi.org/10.5194/gmd-13-6149-2020)</sup> 此后GTWR出现了两条谱系：黄波、吴波和迈克尔·巴里于2010年在《国际地理信息科学杂志》上提出GTWR，将时间效应纳入GWR<sup>[2](https://doi.org/10.1080/13658810802672469)</sup>；A·斯图尔特·福瑟林汉姆、里卡多·克雷斯波和姚静于2015年在《地理分析》上独立开发了一个版本，分离了空间带宽与时间带宽。<sup>[3](https://doi.org/10.1111/gean.12071)</sup> A·斯图尔特·福瑟林汉姆及其同事还提醒，仅用单一度量来整合空间距离与时间距离可能产生误导，因为位置与时间通常以不同尺度度量。<sup>[9](https://doi.org/10.5194/gmd-13-6149-2020)</sup> 没有已发表的论文记载TWR曾作为独立方法被提出；TWR是作为GTWR的特例被记录的，卡尔加里基准是其主要的定量亮相。<sup>[2](https://doi.org/10.1080/13658810802672469)</sup>

## 变体

**混合GTWR。** 刘等人于2017年在《熵》上提出混合GTWR（MGTWR），在GTWR中加入全局平稳变量，并通过两阶段最小二乘法进行标定。<sup>[1](https://doi.org/10.3390/e19020053)</sup> 该缩写在文献中有歧义：它也指多尺度GTWR，即吴超、任福、胡炜和杜清运于2018年在《国际地理信息系统杂志》上对多尺度GWR的扩展<sup>[11](https://doi.org/10.1080/13658816.2018.1545158)</sup>，尽管有一篇综述将该扩展追溯到2019年。<sup>[7](https://www.sciencedirect.com/science/article/abs/pii/S2211675322000501)</sup>

**单向时间加权。** 张等人于2021年提出UGTWR及其多尺度版本MUGTWR，仅对过去观测赋权，应用于北京房价。<sup>[12](https://doi.org/10.1080/13658816.2021.1912348)</sup>

**自回归形式。** 吴波、李荣荣和黄波于2014年开发了地理与时间加权自回归模型（GTWAR），将GTWR与空间滞后因变量在两阶段最小二乘法下结合，在2004至2008年深圳房价上进行了检验。<sup>[13](https://doi.org/10.1080/13658816.2013.878463)</sup>

**STWR。** 时空加权回归（STWR v1.0）由阙翔、马小刚、马超和陈启宇于2020年在《地球科学模型开发》上发表，它将时间距离重新定义为值随时间变化的速率而非时间间隔，因此变化越快、间隔越短，权重越大；它用加权平均 \( w_{ST} = (1-\lambda) k_{S} + \lambda k_{T} \) 取代GTWR的乘法核，因为乘积永远不会超过其较小的因子，可能低估复合权重。<sup>[9](https://doi.org/10.5194/gmd-13-6149-2020)</sup>

**神经网络形式。** GTNNWR及其时空邻近神经网络（STPNN）学习时空距离，而非假设一个简单的线性加权函数。<sup>[14](https://doi.org/10.1080/13658816.2020.1775836)</sup><sup> • </sup><sup>[15](https://doi.org/10.5194/gmd-17-8455-2024)</sup>

## 应用

主要应用是特征价格房价建模：卡尔加里（2002至2004年）<sup>[2](https://doi.org/10.1080/13658810802672469)</sup>、伦敦（1980至1998年）<sup>[3](https://doi.org/10.1111/gean.12071)</sup>、深圳（2004至2008年）<sup>[13](https://doi.org/10.1080/13658816.2013.878463)</sup>和北京。<sup>[12](https://doi.org/10.1080/13658816.2021.1912348)</sup> 在水文学中，采用指数核与固定带宽的GTWR对西爪哇35个站点的月降雨量（1983至2012年）进行建模，表现优于逐步变量选择模型，且指数核优于高斯核和双平方核。<sup>[5](https://scik.org/index.php/jmcs/article/download/7427/3515)</sup> 在形变监测中，GTWR给出的均方根误差小于TWR，拟合\( R^{2} \)大于TWR。<sup>[6](https://onlinelibrary.wiley.com/doi/10.1155/2019/4352396)</sup> 将时间地理加权回归（TGWR）应用于康涅狄格州50个市镇和马萨诸塞州145个市镇的住宅销售，表现优于带固定效应的OLS，并产生了累退性更低的评估值。<sup>[16](https://www.business.uconn.edu/wp-content/uploads/sites/969/2016/01/Cohen_Coughlin_Zabel_TGWR_2-25-19_final.pdf)</sup> 综述还列出了空气污染、环境建模和城市地理等应用。<sup>[15](https://doi.org/10.5194/gmd-17-8455-2024)</sup>

## 局限与替代方案

**边界效应。** 由于时空域是三维的，其边界远大于一维区间的边界，导致边缘畸变严重；2025年的一种非迭代MGTWR估计量将局部线性拟合与两步加权最小二乘法结合，校正了边界效应，并将计算效率相较回代拟合提高了三分之二。<sup>[17](https://www.mdpi.com/2227-7390/13/9/1446)</sup>

**计算。** 传统多尺度GWR仅适用于小数据集；约5000个观测以上的中等规模数据集需要难以承受的运行时间，而增加一个时间维度会进一步加剧负担。<sup>[17](https://www.mdpi.com/2227-7390/13/9/1446)</sup>

**带宽与共线性。** 结果可能对核函数和带宽的选择高度敏感。<sup>[16](https://www.business.uconn.edu/wp-content/uploads/sites/969/2016/01/Cohen_Coughlin_Zabel_TGWR_2-25-19_final.pdf)</sup> 仅依赖AICc可能产生严重的局部多重共线性，这是GWR类模型的已知问题，促使人们引入显式的局部共线性控制。<sup>[18](https://arxiv.org/html/2603.22990)</sup> 对于MGTWR，早期的带宽选择算法无法保证最优结果，也没有给出有效参数数量的公式；2025年的一篇标定论文提供了最优时间带宽与空间带宽以及ENP公式。<sup>[19](https://www.tandfonline.com/doi/full/10.1080/13658816.2024.2440600)</sup>

**替代方案。** 在时变参数文献中，滚动窗口方法是矩形核加权的一个特例，而状态空间模型以灵活的运动规律表示时变参数，并有大量软件支持。<sup>[20](https://link.springer.com/article/10.1007/s00180-023-01452-3)</sup> GTWR先验的、相对简单的时空距离假设（例如线性加权函数）正是神经网络变体所要放松的。<sup>[15](https://doi.org/10.5194/gmd-17-8455-2024)</sup> 没有已发表的直接对比基准将TWR或GTWR与用于时变系数的样条或随机效应面板模型进行比较，TWR在流行病学或能源建模中的使用在已发表文献中也没有记录。

## References

1. [Jiping Liu and colleagues (2017). A Mixed Geographically and Temporally Weighted Regression: Exploring Spatial-Temporal Variations from Global and Local Perspectives. Entropy.](https://doi.org/10.3390/e19020053)
2. [Bo Huang, Bo Wu, Michael Barry (2010). Geographically and temporally weighted regression for modeling spatio-temporal variation in house prices. International Journal of Geographical Information Systems.](https://doi.org/10.1080/13658810802672469)
3. [A. Stewart Fotheringham, Ricardo Crespo, Jing Yao (2015). Geographical and Temporal Weighted Regression (GTWR). Geographical Analysis.](https://doi.org/10.1111/gean.12071)
4. [GWmodel R package, gtwr.R source code](https://github.com/cran/GWmodel/blob/master/R/gtwr.R)
5. [Geographically and Temporally Weighted Regression for monthly rainfall estimation in West Java](https://scik.org/index.php/jmcs/article/download/7427/3515)
6. [A Spatiotemporal Deformation Modelling Method Based on Geographically and Temporally Weighted Regression](https://onlinelibrary.wiley.com/doi/10.1155/2019/4352396)
7. [Introducing bootstrap test technique to identify spatial heterogeneity in geographically and temporally weighted regression models](https://www.sciencedirect.com/science/article/abs/pii/S2211675322000501)
8. [Kernel-based geographically and temporally weighted autoregressive model for house price estimation](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0205063)
9. [Xiang Que and colleagues (2020). A spatiotemporal weighted regression model (STWR v1.0) for analyzing local nonstationarity in space and time. Geoscientific model development.](https://doi.org/10.5194/gmd-13-6149-2020)
10. [Chris Brunsdon, A. Stewart Fotheringham, Martin E. Charlton (1996). Geographically Weighted Regression: A Method for Exploring Spatial Nonstationarity. Geographical Analysis.](https://doi.org/10.1111/j.1538-4632.1996.tb00936.x)
11. [Chao Wu and colleagues (2018). Multiscale geographically and temporally weighted regression: exploring the spatiotemporal determinants of housing prices. International Journal of Geographical Information Systems.](https://doi.org/10.1080/13658816.2018.1545158)
12. [Zhi Zhang and colleagues (2021). Multiscale geographically and temporally weighted regression with a unilateral temporal weighting scheme and its application in the analysis of spatiotemporal characteristics of house prices in Beijing. International Journal of Geographical Information Systems.](https://doi.org/10.1080/13658816.2021.1912348)
13. [Bo Wu, Rongrong Li, Bo Huang (2014). A geographically and temporally weighted autoregressive model with application to housing prices. International Journal of Geographical Information Systems.](https://doi.org/10.1080/13658816.2013.878463)
14. [Sensen Wu and colleagues (2020). Geographically and temporally neural network weighted regression for modeling spatiotemporal non-stationary relationships. International Journal of Geographical Information Systems.](https://doi.org/10.1080/13658816.2020.1775836)
15. [Ziyu Yin and colleagues (2024). GNNWR: an open-source package of spatiotemporal intelligent regression methods for modeling spatial and temporal nonstationarity. Geoscientific model development.](https://doi.org/10.5194/gmd-17-8455-2024)
16. [Time-Geographically Weighted Regressions and Residential Property Value Assessment](https://www.business.uconn.edu/wp-content/uploads/sites/969/2016/01/Cohen_Coughlin_Zabel_TGWR_2-25-19_final.pdf)
17. [Non-Iterative Estimation of Multiscale Geographically and Temporally Weighted Regression Model](https://www.mdpi.com/2227-7390/13/9/1446)
18. [A Top-Down Scale Approach for Multiscale Geographically and Temporally Weighted Regression](https://arxiv.org/html/2603.22990)
19. [On the calibration of multiscale geographically and temporally weighted regression models (IJGIS 2025, Vol 39 No 6)](https://www.tandfonline.com/doi/full/10.1080/13658816.2024.2440600)
20. [Linear models with time-varying parameters: a comparison of different approaches](https://link.springer.com/article/10.1007/s00180-023-01452-3)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Regression analysis › Time series regression

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/temporally-weighted-regression

English original: https://www.edgepedia.org/temporally-weighted-regression
