Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:55:09+00:00 2026-06-17T05:55:09+00:00

I have the following R code library(forecast) value <- c(1.2, 1.7, 1.6, 1.2, 1.6,

  • 0

I have the following R code

library(forecast)
value <- c(1.2, 1.7, 1.6, 1.2, 1.6, 1.3, 1.5, 1.9, 5.4, 4.2, 5.5, 6, 5.6, 
6.2, 6.8, 7.1, 7.1, 5.8, 0, 5.2, 4.6, 3.6, 3, 3.8, 3.1, 3.4, 
2, 3.1, 3.2, 1.6, 0.6, 3.3, 4.9, 6.5, 5.3, 3.5, 5.3, 7.2, 7.4, 
7.3, 7.2, 4, 6.1, 4.3, 4, 2.4, 0.4, 2.4)

sensor<-ts(value,frequency=24)
fit <- auto.arima(sensor)
LH.pred<-predict(fit,n.ahead=24)
plot(sensor,ylim=c(0,10),xlim=c(0,5),type="o", lwd="1")
lines(LH.pred$pred,col="red",type="o",lwd="1")
grid()

The resulting graph is
prediction

But I am not satisfied with the prediction. Is there any way to make the prediction look similar to the value trends preceding it (see graph)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:55:10+00:00Added an answer on June 17, 2026 at 5:55 am

    As you defined the frequency as 24, I assume that you are working with 24 hours (daily) per cycle and thus have approximately 2 cycles in your historical dataset. Generally speaking this is limited sample data to initiate a time series forecast. I would recommend to get a little more data and then you can do the forecasting model again. The more data you have the better it will capture the seasonality and thus forecast future values. With limited available automatic algorithms like auto.arima often default to something similar to moving averages. Your data set deserves something better than moving averages as there is some seasonality in the cycle. There are a number of forecasting algorithms that could help you to get the forward curve shaped better; things like Holt-Winters or other exponential smoothing methods might help. However, auto.arima is a pretty good bet as well (I would first try to see what I can do with this one).

    Getting more data and going through the same routine will improve your chart. Personally, I prefer the use of forecast over predict; the data seems to come out a bit nicer as well as the chart as it shows your confidence intervals. In the code, I have also expanded the data set a bit by copying the two periods so we got four periods. See the result below:

    library(forecast)
    value <- c(1.2,1.7,1.6, 1.2, 1.6, 1.3, 1.5, 1.9, 5.4, 4.2, 5.5, 6.0, 5.6, 6.2, 6.8, 7.1, 7.1, 5.8, 0.0, 5.2, 4.6, 3.6, 3.0, 3.8, 3.1, 3.4, 2.0, 3.1, 3.2, 1.6, 0.6, 3.3, 4.9, 6.5, 5.3, 3.5, 5.3, 7.2, 7.4, 7.3, 7.2, 4.0, 6.1, 4.3, 4.0, 2.4, 0.4, 2.4, 1.2,1.7,1.6, 1.2, 1.6, 1.3, 1.5, 1.9, 5.4, 4.2, 5.5, 6.0, 5.6, 6.2, 6.8, 7.1, 7.1, 5.8, 0.0, 5.2, 4.6, 3.6, 3.0, 3.8, 3.1, 3.4, 2.0, 3.1, 3.2, 1.6, 0.6, 3.3, 4.9, 6.5, 5.3, 3.5, 5.3, 7.2, 7.4, 7.3, 7.2, 4.0, 6.1, 4.3, 4.0, 2.4, 0.4, 2.4)
    sensor <- ts(value,frequency=24) # consider adding a start so you get nicer labelling on your chart. 
    fit <- auto.arima(sensor)
    fcast <- forecast(fit)
    plot(fcast)
    grid()
    fcast
             Point Forecast     Lo 80    Hi 80      Lo 95    Hi 95
    3.000000       2.867879 0.8348814 4.900877 -0.2413226 5.977081
    3.041667       3.179447 0.7369338 5.621961 -0.5560547 6.914950
    3.083333       3.386926 0.7833486 5.990503 -0.5949021 7.368754
    3.125000       3.525089 0.8531946 6.196984 -0.5612211 7.611400
    3.166667       3.617095 0.9154577 6.318732 -0.5147025 7.748892
    

    graph with four periods

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In physics library written in C# I have the following code: (in ContactManager.cs) public
I am using Codeigniter message library. In my controller I have the following code
I have the following code ///Get BitmapData from library in SWC var ClassReference:Class =
I have the following code, which uses a Unicode string class from a library
I have the following code: tr = document.createElement(tr); root.appendChild(tr); td = document.createElement(td); td.appendChild(document.createTextNode(some value));
This is more of a beginner's question. Say I have the following code: library(multicore)
I have the following code in a c++/CLI library to catch unmanaged exceptions and
I have the following code in a class library: public class Manager { private
I have the following code to try to get the MarkerClusterer library to work
I have the following code: // ---- third party library code ---- struct Point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.