2017-10-18 78 views
0

我想學習ARMA預測,我試圖用比特幣下載比特幣數據集來預測比特幣R有光澤的預測ARMA

我正在努力處理下面的代碼。 庫(Quandl)

library(forecast) 
    library(tseries) 
    library(shiny) 


    ui <- shinyUI(fluidPage(
     titlePanel("Simple ARMA Bitcoin Forecasting"), 
     sidebarLayout(
     sidebarPanel("Please choose the number of periods", 
        numericInput("num",h3("Numeric input"), value = 1)), 

     mainPanel(plotOutput("plot"))) 
    ) 
    ) 

    server <- shinyServer(function(input,output) { 

     output$plot <- plotOutput({ 

     bitcoin <- Quandl("BITSTAMP/USD",type = "xts") 

     bitcoin_price <- bitcoin[,3] 

     barplottest <- diff(log(bitcoin_price)) 

     fit <- auto.arima(dataInput) 

     fit %>% forecast(h="input$num") %>% autoplot() 
      }) 

    }) 

    shinyApp(ui,server) 

這是我收到的錯誤:

Warning: Error in as.ts: object 'dataInput' not found 
Stack trace (innermost first): 
    44: as.ts 
    43: auto.arima 
    42: imageOutput [#11] 
    41: plotOutput 
    40: server [#3] 
    4: <Anonymous> 
    3: do.call 
    2: print.shiny.appobj 
    1: <Promise> 
Error in as.ts(x) : object 'dataInput' not found 

回答

1

以及即時通訊不知道什麼dataInput

這裏是與highcharter包的例子:

library(shiny) 
library(Quandl) 
library(forecast) 
library(highcharter) 

bitcoin <- Quandl("BITSTAMP/USD",type = "xts") 
bitcoin_price <- bitcoin[,3] 
barplottest <- diff(log(bitcoin_price)) 
fit <- auto.arima(barplottest) 

ui <- shinyUI(fluidPage(
    titlePanel("Simple ARMA Bitcoin Forecasting"), 
    sidebarLayout(
    sidebarPanel("Please choose the number of periods", 
       numericInput("num",h3("Numeric input"), value = 1)), 

    mainPanel(highchartOutput("hcontainer",height = "500px"))) 
) 
) 

server <- shinyServer(function(input,output) { 

    output$hcontainer <- renderHighchart({ 
    hchart(forecast(fit,h=input$num)) 
    }) 
}) 

shinyApp(ui,server) 

enter image description here

+0

有沒有什麼方法可以顯示圖表下方的日期而不是觀察值的數目? –

+0

你需要確保你的數據集'barplottest'是一個時間序列對象 –