How to Perform Naive Forecasting in R
In this article, we are going to learn how to perform naive forecasting in the R programming language.
A naïve forecast is one where the value predicted for a certain period is the same as seen in the preceding period. This is a method of estimation that uses the last period’s actuals as the forecast for a current period without making any adjustments or attempting to identify the causes. It is solely used to compare forecasts made using more advanced (better) approaches.
The step-wise procedure to perform naive forecasting:
Step 1: In this step, we are simply providing the data in the form of a vector containing 20 integers and storing it in a variable; this is the actual data, which will further be used to perform naive forecasting.
 50 74 64 91 52 63 41 21 34 59 14 85 71 35 24 60 85 39 10 65
Step 2: In this step, we simply put the actual data into the formula to create naive forecasts for each corresponding data.
The syntax for the forecast formula:
x <- c(NA,data[-length(data)])
here, data is the actual data which is used to forecast and NA is used for the first forecasted value.
 NA 50 74 64 91 52 63 41 21 34 59 14 85 71 35 24 60 85 39 10
Step 3:In this step, we are measuring the accuracy of the generated forecasts in step 2; here, we will calculate the accuracy using mean absolute percentage error(MAPE) and mean absolute error(MAE).
Mean absolute percentage error(MAPE):
The average or mean of forecasts’ absolute percentage error is the mean absolute percentage error (MAPE). Actual or observed value less predicted value is the definition of error. To calculate MAPE, percentage errors are added without regard to sign.
Mean absolute error(MAE):
This determines the average error size in a batch of predictions without taking direction into account. It represents the weighted average of the individual deviations between the actual observation and the forecast over the test sample.
 "MAPE"  81.84397  "MAE"  29.42105
Step 4:In this step, we will visualize the Forecasts using the plot() and lines() function; here, we will create a simple line plot to visualize the differences between the actual sales and the naive forecasts during each period.