I have a dataframe in R with two columns, each row represents a ratio in a year. There're a total of 130 rows. It looks like this:

enter image description here

When plotted out, it's like this: enter image description here

I am currently using the below code in R to model this time series:

myts <- ts(df_130$sb_ab_ratio, 
           start = min(df_130$yearID), 
           end = max(df_130$yearID),
           frequency = 20)
fit <- HoltWinters(myts)

Basically, by eyeballing the plot, I thought there's some cyclical effect every 20 years, so just use frequency as 20. I am wondering:

  • Is this the right way to do it? If not, what's the right approach?
  • Does it make more sense just to use a non linear regression model to represent? If yes, which one?


EDIT -- adding full dataset in csv format:

  • 4
    $\begingroup$ Frequency refers to the nature of the data - i.e. the frequency the data are recorded at (e.g. annual, quarterly, monthly, etc.). According to your dataframe, the data is annual, so the frequency should equal 1 - not 20. $\endgroup$ Dec 15, 2016 at 22:50
  • 1
    $\begingroup$ @George .. when u have found your answer accept the one you like to close the question. $\endgroup$
    – IrishStat
    Dec 19, 2016 at 17:49

3 Answers 3


Analyzing ratios is never a good idea unless that is all you have. It is preferential to model a Y as a function of X and upon arriving at a useful model use a predicted X to obtain a predicted Y and then convert the two predictions to a ratio.

Your series appears to significant change (reduction) in error variance thus you probably will have to use some form of weighted least squares to compensate for this inequality or there could be a change in parameters over time. Nearly impossible to decide simply based on the graph .

Simple AIC/BIC search procedures attempting to just use an ARIMA model may lead to unexpected forecasts as a result of ignoring the anomalies in the data. Your data plot suggests a number of possible deterministic effects such as pulses and either one or more level shifts or a localized time trend. My suggestion is to combine some deterministic structure and some ARIMA structure (memory) resulting in an error process free of structure. Of course all of this could change when you examine the Y responds to X.

Hope this helps. Other readers my have specific suggestions as to the freely availble tools in R which can be used to help you or at least enlighten you as to their capabilities when faced with a challenging series like this one..


Here is the plot of the acf for the enter image description here data

AUTOBOX found a structural breakpoint in parameters starting at 1948 enter image description here . The equation is here enter image description here suggesting a random walk plus three anomalies. . The Actual/Fit and Forecast is here enter image description here with residual plot here enter image description here and residual acf here enter image description here

here is a plot of the most recent 68 values enter image description here

Hope this helps .. Just because a piece of software has powerful analytics to detect structure doesn't mean that all models should be complex .. just complex enough ! In this case the most recent set of values is essentially informationless (i.e. a random walk) except for the most recent value. This model is superior to a mean model or an ARMA model in the sense that the most recent value is the best forecast.

The statistics of this model are here enter image description here

Note that a (1,0,0) model with an AR(1) parameter is approximately equal to a first difference model without drift. Here are the results of specifying an AR(1) model enter image description here with coefficient = .947

  • $\begingroup$ Thank you for the reply! This is helpful. Yes, I can only work with the ratio. Could you please suggest some R packages corresponding to the methods you recommended? $\endgroup$
    – George Liu
    Dec 16, 2016 at 1:28
  • 2
    $\begingroup$ In terms of free software (1)auto.arima might be of some help with the qualifications I made. (2) @javlacalle has done some nice things with Intervention detection. My favorite is (3) AUTOBOX which I have helped to develop integrates both ARIMA & Intervention Detection in the most general way. There is an R version available . . $\endgroup$
    – IrishStat
    Dec 16, 2016 at 2:02
  • 1
    $\begingroup$ If you post the entire series I will analyze it for you to show you what a possible model might be. $\endgroup$
    – IrishStat
    Dec 16, 2016 at 10:05
  • $\begingroup$ Thank you so much for your kind offer to help! I've added the csv format data in the post. You can copy and paste it in a blank text document and save as csv. $\endgroup$
    – George Liu
    Dec 16, 2016 at 12:39
  • $\begingroup$ for some reason I am unable to capture the data .. please send it to my email address $\endgroup$
    – IrishStat
    Dec 16, 2016 at 13:53

I actually came up with my own solution in R. Please see below:

myts <- ts(df_130$sb_ab_ratio, 
           start = min(df_130$yearID), 
           end = max(df_130$yearID),
           frequency = 1)

fit.arima <- auto.arima(df_130$sb_ab_ratio, seasonal = F)
# Do forecast
forc.arima <- forecast(fit.arima)
# predictive accuracy
acc.arima <- accuracy(forc.arima)
# Plot the forecast
  • $\begingroup$ did u plot the residuals to see if your model was adequate ? it would be be interesting and potentially informative to see this. You might also list the residuals so we can maybe suggest possible improvements. $\endgroup$
    – IrishStat
    Dec 19, 2016 at 18:24

Looking at the graph of your time serie, we see clearly a change in the trend. You could test this using the R package trend of Thorsten Pohlert and calling the function pettitt.test() on your time serie. This function tries to detect a point where the trend change direction. A positive test would justify the deletion of the data before this point. This could probably change your model. Hope this is useful.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.