给定的代码未生成图形,而是显示此错误“未找到对象“ ts.monthly”

时间:2019-05-02 10:08:27

标签: r

  

na.StructTS错误:未找到对象'ts.monthly'

它与使用R软件包的shiny中的股票市场预测代码有关。

output$auto.arima <- renderPlot({



library('quantmod')
library('ggplot2')
library('forecast')
library('tseries')
library('zoo')
decompose(na.StructTS(ts.monthly))


data <- eventReactive(input$click, {
  (input$StockCode) 
})
Stock <- as.character(data())
print(Stock)

Stock_df<-as.data.frame(getSymbols(Symbols = Stock, 
                                   src = "yahoo", from = "2016-01-01", env = NULL))
Stock_df$Open = Stock_df[,1]
Stock_df$High = Stock_df[,2]
Stock_df$Low = Stock_df[,3]
Stock_df$Close = Stock_df[,4]
Stock_df$Volume = Stock_df[,5]
Stock_df$Adj = Stock_df[,6]
Stock_df <- Stock_df[,c(7,8,9,10,11,12)] 





Stock_df$v7_MA = ma(Stock_df$Close, order=7)
Stock_df$v30_MA <- ma(Stock_df$Close, order=30)


rental_ma <- ts(na.omit(Stock_df$v7_MA), frequency=30)
decomp_rental <- stl(rental_ma, s.window="periodic")

adj_rental <- seasadj(decomp_rental)




fit <- auto.arima(Stock_df$Close,ic="bic")
fit.forecast <- forecast(fit)
plot(fit.forecast,  main= Stock)
fit.forecast

  })

代码未显示非季节性以及季节性组件的输出图-

0 个答案:

没有答案