r - ggplot2 texashousing 数据平滑短期噪声
问题描述
我正在研究 Hadley Wickham 的 ggplot2 优雅图形数据分析第 11 章练习 11.3.1:
在这里,Wickham 试图删除数据中的每月趋势 - tidyverse 中的 txhousing:
deseas <- function(x, month) {
resid(lm(x ~ factor(month), na.action = na.exclude))
}
txhousing <- txhousing %>%
group_by(city) %>%
mutate(rel_sales = deseas(log(sales), month))
ggplot(txhousing, aes(date, rel_sales)) +
geom_line(aes(group = city), alpha = 1/5) +
geom_line(stat = "summary", fun.y = "mean", colour = "red")
但问题是:最终的图显示了整体趋势中有很多短期噪音。您如何进一步平滑这一点以专注于长期变化?由于我对时间序列不太熟悉,因此不知道如何平滑短期变化......有没有人可以帮助我?
谢谢!
解决方案
推荐阅读
- local - 如何在运行时从本地存储导入 SFB 文件?
- android - 如何更改 Stripe 中 Ephemeral Key Provider 的 apiVersion?
- node.js - 如何使用 mongoose 查找和合并多集合
- c# - 转换PictureBox图片源地址
- c# - 有没有办法指定一个文本块样式,它采用给定的字体颜色/画笔并降低其饱和度
- c# - 针对 4.7.2 的 Asp.net 网站项目无法使用 MSBuild 解析 .netstandard 2.0 参考
- reactjs - Redux 更改为仅反映一个道具
- python - 与 Raspberry Pi 的任何 GPIO 进行串行通信
- bash - Cygwin:使用参数、输出重定向和复杂的 Windows 路径调用批处理文件
- javascript - 将“lat”和“lng”添加到现有数组