R Programming Tutorial for Forecasting a Linear Trend

To load data set from the package “fma”, use the commands:

{`  >data (package=fma)
  This instantly loads the pre existing data sets in the package.

  To load the data set regarding tourist travels in Australia over a period of time, use the command:
  >data (austa)

  To print the data:
  >austa
  `}
  

For help on how to load Data in R see this tutorial.

Forecasting Linear Trend using R image 1

To fit the time series regression, use the following command in R program:

{`> fit <- tslm (austa~trend)

     To forecast the values for the next 5 years under 80% and 95 % levels of confidence, use the following R program command:
  > fcast <- forecast (fit, h=5, level=c(80,95))

  Now, plot this forecast using R by the command:
  > plot (fcast)
  This will display the forecasts from linear regression model.`}
  

See more on learn R for time series analysis tutorial

Forecasting Linear Trend using R image 2

To fit the forecast line, use the command:

{`> lines (fitted (fit))`}
Forecasting Linear Trend using R image 3

To get summary of the regression model in R, use the command:

{`>summary (fit)`}
Forecasting Linear Trend using R image 4

This will generate the regression model summary of the time series model which contains values of intercept and trend coefficient along with their standard errors and confidence intervals as well as overall F statistics and p value for our time series model.

Looking for help with statistical analysis with R programming?

Assignmenthelp.net offers R programming help for everyone who wants to learn R. R programming language is a widely-used software for statistical analysis, data analytics as well as for data science projects. Our online data science tutors are statistical software tutors are available 24x7 online to help you with your R programming projects using R studio, R and its libraries and can provide homework assignment hep with R language for statistical and graphical techniques, linear and nonlinear modelling in R, classical statistical tests in R, time-series analysis using R, classification, clustering, and other data mining help with R. So, order now and get help with R programming for data science and R programming for data analysis.

Learn R programming for Statistical Analysis