Forget about Excel. It is hopeless for any serious work. (If you need convincing, see Bruce McCullough’s articles on Excel.) Any research student in the quantitative sciences should be using a matrix language for computation. I recommend students use R. It is free, has a big user base, and has zillions of add-on packages.

Recommended books about R

If you see nothing below, try turning off your ad-blocker.

See also “Econometrics and R”.

R news

To keep up with everything R, subscribe to R-bloggers.

Blog posts about R

In reverse time order

  • Daniel


    I have mete­o­ro­log­i­cal data, a serie of the 24 data for day. I need a serie time graphic, with the days in x axis.
    But in one day with 24 obser­va­tions, understand?

    I try sev­eral form (library “date” “BootPR” …) but with­out sucess.

    The dis­po­si­tion of the data is:
    The day is: dd/mm/yyyy
    Day Hr Obs
    01/01/2010 00 25,5
    01/01/2010 01 26
    01/01/2010 02 27
    05/01/2010 00 20
    05/01/2010 23 19

    Have how you help me?
    I’m brazil­ian and sorry my english

    • Please direct R questions to stats.stackexchange.com.

    • castet01

      Well, it looks like problem very similar to a stock exchange intraday time-series display class problem.

      Should I therefore suggest you to investigate stock-related packs.

  • castet01

    How to load a bmp pic ?

    I’ve got a geo map in bmp.
    I’d like to load it in R, for display, to be able to click and record geo locations.
    What’s the recipy ?

    As an example, I am searching to perform in R, what I do with this in matlab, I do loadbmp, image, …, ginput:

    % — load %{{{
    sBmp=input( sprintf( ‘>– enter bmp [%s]: ‘, mapBmp));
    if isempty(sBmp), sBmp=mapBmp;end
    sBmp=[ sBmp ‘.bmp’];
    [tab tabM]=loadbmp( sBmp);

    % – plot %{{{
    figure(4); clg
    colormap(tabM);image( vMap([1 2]),vMap([3 4]), tab); axis(‘xy’);
    set( 4, ‘Position’, [590 52 751 652]);

    ( … )

    [x y]=ginput



  • Please send R questions to stats.stackexchange.com. I do not have time to answer questions here.

  • language jobs

    Well, this is encouraging. Good news for me because I haven’t yet mastered Excel and I have to admit to getting slightly peeved with some of the faults on it – which is probably why I gave up on it in the first place.

  • I recently wrote some basic R tutorials myself on: R statistics. I would really appriciate it if you could post some reference to it somewhere.

    I do find the tutorials very useful for High School and University students.

  • caba3233

    I have a daily series with double seasonality (weekly and monthly) and could be used function tbats or bats for predictin … I don t understand .how to give the parameters??fit <- tbats(serie1,seasonal.periods=c(7,35)) ? ..

    • 7 is correct for weekly patterns. But months are of unequal lengths so it is not possible to handle with Fourier like terms. It is rare to see daily data with a monthly pattern. It is much more common to have an annual pattern where the seasonality is 365.25,

  • Pingback: Forecasting Continued: Using Simulation to Create Prediction Intervals Around Holt-Winters | Analytics Made Skeezy()

  • Andrew

    Dear Rob,
    Is there a section devoted to updating the forecast using predict() with estimated parameters? Regards

    • I don’t know what this means. predict() is not my function. How is the forecast meant to be updated?

      • Andrew

        Dear Rob,

        By update I mean this: a time series has 100 values, I predict value 101… 105. The data is dynamic so I can check if prediction 101 is close to the real value when I observe it…. colse or not once the observed value 101 is available I’d like to recalculate the prediction of values 102… 105.
        I know it’s not your fuction; predict(x,n.ahead=5) uses the results of your fuction… I just imagined you might have some section in your blog covering this topic. If not, thanks anyway!

  • Forecaster

    Dear Prof Hyndman, Thank you very much for the forecast package in R. This has been very helpful in my job. I had a question of Thetaf forecast. I tried using AirPassenger example with thetaf, it just provided a trend line and did not provide seasonal forecast. Does thetaf detect and forecast seasonality ?

    Appreciate your response.

    • The Theta method does not handle seasonality.

      • forecasted

        Thank you Prof Hyndman. On a related note, theta method was one of the best methods and had the lowest MAPE in M3 competition. If this method does not handle seasonality, does this mean that the M3 competition did not have any season time series data ?

        I doing some additional research, looks like there is also a variant of theta method called Theta AI (based on neural network) which I believe handles seasonality, I was not sure. Any insight would be greatly appreciated. I also don’t seem to find this method in any commercial software packages.

  • Kelvin Lam

    Hi Prof. Hyndman,

    Thank you for the good work. I have a question regarding setting annual seasonality to 365.25. Sometimes I get an error message when using tbats() as follows:

    Error in optim(par = param.vector$vect, fn = calcLikelihoodTBATS, method = “Nelder-Mead”, : function cannot be evaluated at initial parameters

    However, when I switch it to 365.25001 things work just fine. Any insight will be greatly appreciated! Thanks again.

  • dialpemo


    I would like to know how can I extract the deseasonalized data from the tbats function.
    Kind regards,

  • Pingback: Quora()

  • sanaz

    Hi Prof. Hyndman,

    Thank you for the good work. I have a question regarding 10-fold cross
    validation .
    I want to get the best neighborhood to K-NN Method using
    no packages.

  • sanaz

    I need a code for cross-validation

  • ShivOnkar

    Dear Sir,

    I am new to Time series and have
    basic knowledge only. I am facing following problem. In following dataset “Response”
    is derived from “InputA/B” for 16 hours ( 8 am – 23 pm) everyday.

    To train I tried
    Msts_ Response <- msts(Response, seasonal.periods =c(?,?) ) # do not kow what to put in “?”

    Once above is done then use
    Fit <- tslm(Msts_ Response ~ InputA + InputB, data = train)

    Could you help in filling “?” and is the approach OK for tslm

  • Pingback: ujjwalkarn/R-Tutorials | GITROOM()

  • Pingback: R Tutorials for Data Science, NLP & Machine Learning | 神刀安全网()

  • Jake Yu

    Mr. Hyndman,

    I just found your blog. I am a 3rd year undergrad at Rutgers University studying Statistics. I’ve been thinking that I want to orient my career toward load forecasting. I have zero experience in R. What is the best intro course or book I should take?

  • Colin


    I was curious what the bin sizes are when using BoxCox.lambda function with the Guerrero method? It doesn’t look like they can be customized and I couldn’t find a default size in the package documentation.

    Thank you,

    • For seasonal data, it is the frequency of the seasonality. For non-seasonal data, it is 2.