[R] Regarding fitted value

Md. Moyazzem Hossain ho@@@|nmm @end|ng |rom jun|v@edu
Tue Feb 2 17:26:45 CET 2021


Dear Partho Sarkar and Rui Barradas

Thanks a lot.

Take care.

On Tue, Feb 2, 2021 at 12:34 PM Partho Sarkar <partho.ss using gmail.com> wrote:

> My pleasure!
>
> *Best regards,*
> *Partho Sarkar*
>
> On Tue, Feb 2, 2021 at 5:55 PM Rui Barradas <ruipbarradas using sapo.pt> wrote:
>
>> Hello,
>>
>> Thanks for the links, they are very helpful.
>>
>> Rui Barradas
>>
>> Às 11:36 de 02/02/21, Partho Sarkar escreveu:
>> > In case further clarification is needed, this from Rob Hyndman, author
>> > of the Forecast package, may be helpful:
>> >
>> > "fitted produces one-step in-sample (i.e., training data) "forecasts".
>> > That is, it gives a forecast of observation t using observations up to
>> > time t-1 for each t in the data. ... So fitted(fit) gives one-step
>> > forecasts of observations 1, 2, ... It is possible to produce a
>> > "forecast" for observation 1 as a forecast is simply the expected value
>> > of that observation given the model and any preceding history."
>> >
>> >  From Hyndman's answer in this thread
>> > <a
>> > href="
>> https://stats.stackexchange.com/questions/217955/difference-between-first-one-step-ahead-forecast-and-first-forecast-from-fitted?rq=1
>> ">
>> https://stats.stackexchange.com/questions/217955/difference-between-first-one-step-ahead-forecast-and-first-forecast-from-fitted?rq=1
>> </a>
>> >
>> > See also <a
>> > href="
>> https://robjhyndman.com/hyndsight/out-of-sample-one-step-forecasts/">
>> https://robjhyndman.com/hyndsight/out-of-sample-one-step-forecasts/</a><
>> https://robjhyndman.com/hyndsight/out-of-sample-one-step-forecasts/>
>> >
>> > [A quick search on the stackexchange forum will turn up several similar
>> > questions & answers]
>> >
>> > HTH,
>> >
>> > /
>> > Best regards,
>> > /
>> > /
>> > Partho Sarkar
>> > /
>> >
>> > On Tue, Feb 2, 2021 at 12:28 PM Rui Barradas <ruipbarradas using sapo.pt
>> > <mailto:ruipbarradas using sapo.pt>> wrote:
>> >
>> >     Hello,
>> >
>> >     You get the fitted values for years 2000, ..., 2019.
>> >     Those values are the original series minus the residuals:
>> >
>> >     f <- fitted(model1)
>> >     g <- yy - resid(model1)
>> >     identical(f, g)          # returns TRUE
>> >
>> >
>> >     If you want to *forecast*, this will give you the default h = 10
>> >     forecasts.
>> >
>> >     fc <- forecast(model1)
>> >     plot(fc)
>> >
>> >
>> >     Hope this helps,
>> >
>> >     Rui Barradas
>> >
>> >     Às 23:31 de 01/02/21, Md. Moyazzem Hossain escreveu:
>> >      > Dear Rui Barradas
>> >      >
>> >      > Thank you very much for your reply.
>> >      >
>> >      > However, still now, I have a confusion whether I get the fitted
>> >     value
>> >      > for the year 2000, 2001, ..., 2020 or 2001, 2002, ..., 2021.
>> >      >
>> >      > Need any more help.
>> >      >
>> >      > Thanks in advance.
>> >      >
>> >      > Md
>> >      >
>> >      > On Thu, Jan 28, 2021 at 4:47 PM Rui Barradas
>> >     <ruipbarradas using sapo.pt <mailto:ruipbarradas using sapo.pt>
>> >      > <mailto:ruipbarradas using sapo.pt <mailto:ruipbarradas using sapo.pt>>>
>> wrote:
>> >      >
>> >      >     Hello,
>> >      >
>> >      >       From help('forecast::fitted.Arima'):
>> >      >
>> >      >     h       The number of steps to forecast ahead.
>> >      >
>> >      >
>> >      >     So you have the default h = 1 step ahead forecast for your
>> model.
>> >      >
>> >      >
>> >      >     Hope this helps,
>> >      >
>> >      >     Rui Barradas
>> >      >
>> >      >     Às 12:13 de 28/01/21, Md. Moyazzem Hossain escreveu:
>> >      >      >   Dear R-experts,
>> >      >      >
>> >      >      > I hope that all of you are doing well. I got the filled
>> value
>> >      >     from the
>> >      >      > ARIMA model.
>> >      >      >
>> >      >      > I use the following working code. But I am not clear
>> whether I
>> >      >     got the
>> >      >      > fitted value for each *corresponding time* of the original
>> >     data
>> >      >     point like
>> >      >      > 2000, 2001, 2020 or get a *one-step-ahead* fitted value.
>> >     Please
>> >      >     suggest me
>> >      >      > any reference for further reading to my understanding.
>> >      >      >
>> >      >      > ########################
>> >      >      >
>> >      >
>> >
>>  y<-c(120,340,250,430,125,324,763,458,763,905,765,456,234,345,654,654,567,876,907,456)
>> >      >      > library(forecast)
>> >      >      > library(tseries)
>> >      >      > yy=ts(y, start=c(2000,1))
>> >      >      >
>> >      >      > model1=Arima(yy,order=c(0,2,1), lambda = NULL,method='ML')
>> >      >      > model1
>> >      >      >
>> >      >      > f <- fitted( model1)
>> >      >      > plot(yy)
>> >      >      > plot(f)
>> >      >      >
>> >      >      > Thanks in advance.
>> >      >      >
>> >      >
>> >      >
>> >      >
>> >      > --
>> >      > Best Regards,
>> >      > Md. Moyazzem Hossain
>> >      > Associate Professor
>> >      > Department of Statistics
>> >      > Jahangirnagar University
>> >      > Savar, Dhaka-1342
>> >      > Bangladesh
>> >      > Website: http://www.juniv.edu/teachers/hossainmm
>> >      > Research: *Google Scholar
>> >      >
>> >     <https://scholar.google.com/citations?user=-U03XCgAAAAJ&hl=en&oi=ao
>> >*;
>> >      > *ResearchGate <
>> https://www.researchgate.net/profile/Md_Hossain107>*;
>> >      > *ORCID iD <https://orcid.org/0000-0003-3593-6936>*
>> >
>> >     ______________________________________________
>> >     R-help using r-project.org <mailto:R-help using r-project.org> mailing list --
>> >     To UNSUBSCRIBE and more, see
>> >     https://stat.ethz.ch/mailman/listinfo/r-help
>> >     PLEASE do read the posting guide
>> >     http://www.R-project.org/posting-guide.html
>> >     and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>

-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342
Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *Google Scholar
<https://scholar.google.com/citations?user=-U03XCgAAAAJ&hl=en&oi=ao>*;
*ResearchGate
<https://www.researchgate.net/profile/Md_Hossain107>*; *ORCID iD
<https://orcid.org/0000-0003-3593-6936>*

	[[alternative HTML version deleted]]



More information about the R-help mailing list