R 中回归输出中排除的虚拟变量系数(无错误)(时间序列图未更改)

发布于 2025-01-11 13:02:11 字数 928 浏览 1 评论 0原文

刚开始在这里发帖,但对这些宝贵的资源还不是很熟悉。环顾四周,没有看到任何对我的情况有帮助的东西。 运行拟合的 LogLinear 回归模型(成功),当我尝试使用“虚拟”变量进行调整时,我没有收到任何错误。我也没有收到趋势调整回归模型中虚拟变量系数的输出。

感谢您抽出时间。

数据=图书馆(fpp3)的纪念品 代码如下:

library(fpp3)
# Data
tsdat <- souvenirs

# Model
fit_tsdat_dummy <- tsdat %>%
  mutate(DummyDec = month(Month) == 12) %>%
  model(TSLM(log(Sales) ~ trend() + season()))

report(fit_tsdat_dummy) # Coefficients expected here

# Produces the same plot as non-adjusted time-series plot 
# Validates no coefficients above, but why?)
augment(fit_tsdat_dummy) %>%
  ggplot(aes(x = Month)) +
  geom_line(aes(y = Sales, colour = "Data")) +
  geom_line(aes(y = .fitted, colour = "Fitted")) +
  labs(x = "Month", 
       y = "Sales",
       title = "Monthly Sales")

在此处输入图像描述

New to posting here, but not to the invaluable resources. Looked around and did not see anything that helped in my situation.
Running a fitted LogLinear regression model (successful) and when I attempted to adjust using "dummy" variables, I received no error. I also did not receive outputs for the dummyvars coefficients in my trend adjusted regression model.

Thank you for your time.

Data = souvenirs of library(fpp3)
code looks like :

library(fpp3)
# Data
tsdat <- souvenirs

# Model
fit_tsdat_dummy <- tsdat %>%
  mutate(DummyDec = month(Month) == 12) %>%
  model(TSLM(log(Sales) ~ trend() + season()))

report(fit_tsdat_dummy) # Coefficients expected here

# Produces the same plot as non-adjusted time-series plot 
# Validates no coefficients above, but why?)
augment(fit_tsdat_dummy) %>%
  ggplot(aes(x = Month)) +
  geom_line(aes(y = Sales, colour = "Data")) +
  geom_line(aes(y = .fitted, colour = "Fitted")) +
  labs(x = "Month", 
       y = "Sales",
       title = "Monthly Sales")

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2025-01-18 13:02:11

两个问题:

1.没有在模型公式中调用虚拟变量。

2. 存在共线性,因此相应的“重复”虚拟变量为 NaN。

谢谢。

NTS:附加列 - 标志检查属性。

TWO ISSUES:

1. Did not call the Dummy variable in the model formula.

2. Collinearity was present, therefore NaN for the respective "duplicate" dummy.

Thank you.

NTS: Additional columns - flag check attribute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文