Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:在预测时间序列上使用geom_平滑_R_Ggplot2_Time Series_Smoothing - Fatal编程技术网

R:在预测时间序列上使用geom_平滑

R:在预测时间序列上使用geom_平滑,r,ggplot2,time-series,smoothing,R,Ggplot2,Time Series,Smoothing,我对我正在进行的时间序列预测有问题。我被要求在图层trend中添加一条线,该线应给出线性演变。更清楚地说:我必须在这个表中复制geom_平滑组件。这里是一个最小的可复制示例: require(forecast) require(ggplot2) require(dplyr) nottem.stl = stl(nottem, s.window="periodic") autoplot(nottem.stl) dmn <- list(month.abb, unique(floor(time

我对我正在进行的时间序列预测有问题。我被要求在图层
trend
中添加一条线,该线应给出线性演变。更清楚地说:我必须在这个表中复制
geom_平滑
组件。这里是一个最小的可复制示例:

require(forecast)
require(ggplot2)
require(dplyr)

nottem.stl = stl(nottem, s.window="periodic")
autoplot(nottem.stl)

dmn <- list(month.abb, unique(floor(time(nottem))))
nottem.df <- as.data.frame(t(matrix(nottem, 12, dimnames = dmn)))
nottem.df$mean <- rowMeans(nottem.df, na.rm = TRUE)
nottem.df <- tibble::rownames_to_column(nottem.df)
nottem.df$rowname <- as.numeric(nottem.df$rowname)

ggplot(data=nottem.df, aes(x=rowname, y=mean))+
  geom_line()+
  geom_smooth(method = 'lm', color="blue")
require(预测)
需要(ggplot2)
需要(dplyr)
nottem.stl=stl(nottem,s.window=“定期”)
自动绘图(非项目stl)

dmn自动绘图(nottem.stl)+geom_smooth()?感谢您的想法。它在某种程度上起作用,因为它在网格
趋势
,但不幸的是,它也高于其他网格(
数据
季节性
,…)。我怎么能避免呢?我想你可以一次画一个序列,只对趋势序列应用
geom_smooth
,然后使用网格将它们缝合在一起
autoplot(nottem.stl$time.series[,“trend”],facets=TRUE)+geom_smooth(method=“lm”)
应该为您提供一个窗格。如果您将其作为答案提交,并添加“使用网格”的代码,因为我不确定您的意思,我会接受它:)很高兴提供帮助,这个问题对于网站来说有点太具体了(至少对我来说是这样)。简而言之,grid是一个处理图形的软件包。在这里可以找到一个示例,说明如何使用它并排绘制任何数量的ggplot图形:autoplot(nottem.stl)+geom_smooth()?谢谢你的想法。它在某种程度上是有效的,因为它在网格
趋势
,但不幸的是,它也高于其他网格(
数据
季节性
,…)。我怎么能避免呢?我想你总是可以一次绘制一个序列,只对趋势序列应用
geom_smooth
,然后使用网格将它们缝合在一起。
autoplot(nottem.stl$time.series[,“trend”],facets=TRUE)+geom_smooth(method=“lm”)
应该给你一个窗格。如果你将其作为答案提交,并添加“使用网格”的代码,因为我不确定你的意思,我会接受它:)很高兴能提供帮助,这个问题对于网站来说有点太具体了(至少对我的口味而言)。简而言之,grid是一个处理图形的包。可在此处找到如何将其用于并排绘制任意数量的ggplot图的示例: