简体   繁体   English

R - 季节性时间序列的线性回归 model

[英]R - linear regression model of seasonal time series

I'm working with monthly averages.我正在使用每月平均值。 I have data for 24 years.我有 24 年的数据。 (so 12 * 24 = 288 rows). (所以 12 * 24 = 288 行)。 I'm trying to create linear regression model using function tslm (viz. code).我正在尝试使用 function tslm(即代码)创建线性回归 model。

library(tidyverse)
library("tseries")
library(forecast)

data <- read_csv("data.csv")

data$START_TIME <- as.Date(data$START_TIME)

data_TS <- ts(data$VALUE, frequency = 12)

fit <- tslm(data_TS ~ trend + season)

summary(fit)

Currently the output is:目前output是:

Residuals:
     Min       1Q   Median       3Q      Max 
-19.9684  -4.6493  -0.0578   3.9262  23.3977 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  70.803362   1.628675  43.473  < 2e-16 ***
trend        -0.009475   0.005170  -1.833  0.06794 .  
season2      11.006465   2.066983   5.325 2.13e-07 ***
season3      11.540922   2.067002   5.583 5.76e-08 ***
season4      13.159978   2.067034   6.367 8.31e-10 ***
season5      12.753431   2.067080   6.170 2.50e-09 ***
season6      11.666369   2.067138   5.644 4.22e-08 ***
season7      -6.322834   2.067209  -3.059  0.00245 ** 
season8     -24.284647   2.067293 -11.747  < 2e-16 ***
season9     -34.434003   2.067390 -16.656  < 2e-16 ***
season10    -35.778105   2.114752 -16.918  < 2e-16 ***
season11    -27.213367   2.089425 -13.024  < 2e-16 ***
season12    -14.267532   2.140674  -6.665 1.49e-10 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 7.16 on 269 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.8778,    Adjusted R-squared:  0.8723 
F-statistic:   161 on 12 and 269 DF,  p-value: < 2.2e-16

I want to create equation from the output, but I'm missing coefficient for season 1.我想从 output 创建方程,但我缺少第 1 季的系数。

Can anyone please explain me how to interpret values in the summary and how to create equation of linear model of my data?谁能解释我如何解释摘要中的值以及如何创建我的数据的线性 model 方程?

Thank you谢谢

The fit has an intercept.合身有一个截距。 So, the intercept is showing you the value when season1 .因此,截距向您显示了season1时的值。 Otherwise, there would be no meaning for the intercept.否则,拦截将毫无意义。 If you want it explicit, you can make your model show如果你想要它明确,你可以让你的 model 显示

fit <- tslm(data_TS ~ 0 + trend + season)

[edit more information per followup question] [根据后续问题编辑更多信息]

One way to think about this is to try to imagine manually using the model to get the estimated value of data_TS - you can see that if you had an intercept and all 12 seasons, you would be able to get a value when none of the season factors were true.考虑这一点的一种方法是尝试手动想象使用 model 来获取data_TS的估计值 - 你可以看到,如果你有一个截距和所有 12 个季节,你将能够在没有季节时得到一个值因素是真实的。 That value would be the intercept.该值将是截距。

The tslm output is like other lm outputs. tslm output 就像其他 lm 输出一样。 There are many guides to learning about them on the web. web 上有很多关于它们的学习指南。 Most assume that you understand what a linear regression model is doing from statistics text.大多数人假设您从统计文本中了解线性回归 model 正在做什么。 You might want to search for 'interpret linear model results in R'.您可能想要搜索“在 R 中解释线性 model 结果”。 Here's one result that has a bit of detail on each output item from Felipe Rego这是一个结果,其中包含来自 Felipe Rego的每个 output 项目的一些细节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM