全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2672 1
2017-08-22
> souvenir <- scan("http://robjhyndman.com/tsdldata/data/fancy.dat")
Read 84 items
> souvenirtimeseries <- ts(souvenir, frequency=12, start=c(1987,1))
> logsouvenirtimeseries <- log(souvenirtimeseries)
> plot.ts(logsouvenirtimeseries)
> souvenirtimeseriesforecasts <- HoltWinters(logsouvenirtimeseries)
> plot(souvenirtimeseriesforecasts)
> library("forecast")
> souvenirtimeseriesforecasts2 <- forecast(souvenirtimeseriesforecasts, h=48)
>  plot(souvenirtimeseriesforecasts2)
> plotForecastErrors <- function(forecasterrors)
+ {
+ # make a red histogram of the forecast errors:
+ mysd <- sd(forecasterrors)
+ hist(forecasterrors, col="red", freq=FALSE)
+ # freq=FALSE ensures the area under the histogram = 1
+ # generate normally distributed data with mean 0 and standard deviation mysd
+ mynorm <- rnorm(10000, mean=0, sd=mysd)
+ myhist <- hist(mynorm, plot=FALSE)
+ # plot the normal curve as a blue line on top of the histogram of forecast errors:
+ points(myhist$mids, myhist$density, type="l", col="blue", lwd=2)
+ }
> source("plotForecastErrors.R")
Error in file(filename, "r", encoding = encoding) : 无法打开链结
此外: Warning message:
In file(filename, "r", encoding = encoding) :
  无法打开文件'plotForecastErrors.R': No such file or directory
>  plotForecastErrors(souvenirtimeseriesforecasts2$residuals)
Error in hist.default(mynorm, plot = FALSE) : invalid number of 'breaks
此外: Warning message:
In rnorm(10000, mean = 0, sd = mysd) : 产生了NA
[E0N}5{})1ZV_8D@])1@RYY.png 这个图片是我做出来的结果
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-5-7 08:24:49
你好,你的问题解决了吗?我也出现了同样的情况
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群