0% found this document useful (0 votes)
303 views

Matlab Code - Sales Forecasting For Bhushan Steel Ltd.

The document details the implementation of various forecasting models including regression analysis, time series analysis, and a combination of both. Sales data for multiple companies is analyzed using these techniques and the results are saved to an excel file. The code also applies corrections to the time series model by taking the log of the sales data before performing the analysis.

Uploaded by

Omkar Hande
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
303 views

Matlab Code - Sales Forecasting For Bhushan Steel Ltd.

The document details the implementation of various forecasting models including regression analysis, time series analysis, and a combination of both. Sales data for multiple companies is analyzed using these techniques and the results are saved to an excel file. The code also applies corrections to the time series model by taking the log of the sales data before performing the analysis.

Uploaded by

Omkar Hande
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

%% SALES FORECASTING MODEL % Following code is am implementation of forecasting models discussed in % section 4.

3 % % Written by Omkar Sayaji Hande %% INITIALIZATION % Data is read from excel sheets and stored in form of arrays. The sizes of % each array are stored in separate variables. Other matrices which will be % used in future are intialized as well. B=ones(39,7); E=ones(40,8); bsl=xlsread('bsl.xlsx'); ash=xlsread('ashley.xlsx'); mnm=xlsread('MnM.xlsx'); voltas=xlsread('voltas.xlsx'); metal=xlsread('metal.xlsx'); maruti=xlsread('maruti.xlsx'); eicher=xlsread('eicher.xlsx'); tata=xlsread('tata.xlsx'); [bsl_m bsl_n]=size(bsl); [ash_m ash_n]=size(ash); [mnm_m mnm_n]=size(mnm); [voltas_m voltas_n]=size(voltas); [metal_m metal_n]=size(metal); [maruti_m maruti_n]=size(maruti); [eicher_m eicher_n]=size(eicher); [tata_m tata_n]=size(tata); initial_m=[bsl_m ash_m mnm_m voltas_m metal_m maruti_m eicher_m]; %% REGRESSION ANALYSIS MODEL % The regression model discussed in 4.3.2 is implemented in this section. % The results obtained are written to an excel file as output. C=bsl(1:39); B(:,1)=1; B(:,2)=ash(2:40); B(:,3)=mnm(2:40); B(:,4)=voltas(2:40); B(:,5)=metal(2:40); B(:,6)=maruti(2:40); B(:,7)=eicher(2:40); B(:,8)=tata(2:40); theta_bsl_2=(inv((transpose(B))*B))*((transpose(B))*C); xlswrite('forecast.xlsx',C,'Reg', 'A1'); xlswrite('forecast.xlsx',B,'Reg', 'B1'); xlswrite('forecast.xlsx',B*theta_bsl_2,'Reg','J1'); %% TIME SERIES AND REGRESSION ANALYSIS MODEL % The time series and regression model discussed in section 4.3.3 is % implemented in this section. The output is written into an excel file. D=bsl(1:40); E(:,1)=1; E(:,2)=ash(1:40);

E(:,3)=mnm(1:40); E(:,4)=voltas(1:40); E(:,5)=metal(1:40); E(:,6)=maruti(1:40); E(:,7)=eicher(1:40); E(:,8)=tata(1:40); theta_bsl_3=(inv((transpose(E))*E))*((transpose(E))*D); xlswrite('forecast.xlsx',D,'TS&Reg', 'A1'); xlswrite('forecast.xlsx',E,'TS&Reg', 'B1'); xlswrite('forecast.xlsx',E*theta_bsl_3,'TS&Reg','J1'); %% TIME SERIES ANALYSIS ON BHUSHAN STEEL'S SALES % Time series analysis discussed in section 4.3.1 is implemented here. The % results are stored in an excel file. j=2; clear A; bsl_m=bsl_m - 3; for i=1:bsl_m temp=j; A(i,2)=bsl(j,1); j=j+1; A(i,3)=bsl(j,1); j=j+1; A(i,4)=bsl(j,1); j=temp+1; end A(:,1)=1; bsl=bsl(1:bsl_m); theta_bsl=(inv((transpose(A))*A))*((transpose(A))*bsl); xlswrite('forecast.xlsx',bsl,'TS', 'A1'); xlswrite('forecast.xlsx',A,'TS', 'B1'); xlswrite('forecast.xlsx',A*theta_bsl,'TS','F1'); f_bsl=[1 bsl(1) A(1,2) A(1,3)]*theta_bsl; %% TIME SERIES ANALYSIS ON SALES OF ASHOK LEYLAND % Time series analysis on sales of ashok leyland is performed here. This is % required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; ash_m=ash_m - 3; for i=1:ash_m temp=j; A(i,2)=ash(j,1); j=j+1; A(i,3)=ash(j,1); j=j+1; A(i,4)=ash(j,1); j=temp+1; end A(:,1)=1; ash=ash(1:ash_m); theta_ash=(inv((transpose(A))*A))*((transpose(A))*ash);

f_ash=[1 ash(1) A(1,2) A(1,3)]*theta_ash; %% TIME SERIES ANALYSIS ON SALES OF MAHINDRA & MAHINDRA % Time series analysis on sales of Mahindra and Mahindra is performed here. % This is required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; mnm_m=mnm_m - 3; for i=1:mnm_m temp=j; A(i,2)=mnm(j,1); j=j+1; A(i,3)=mnm(j,1); j=j+1; A(i,4)=mnm(j,1); j=temp+1; end A(:,1)=1; mnm=mnm(1:mnm_m); theta_mnm=(inv((transpose(A))*A))*((transpose(A))*mnm); f_mnm=[1 mnm(1) A(1,2) A(1,3)]*theta_mnm; %% TIME SERIES ANALYSIS ON SALES OF VOLTAS % Time series analysis on sales of voltas is performed here. This is % required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; voltas_m=voltas_m - 3; for i=1:voltas_m temp=j; A(i,2)=voltas(j,1); j=j+1; A(i,3)=voltas(j,1); j=j+1; A(i,4)=voltas(j,1); j=temp+1; end A(:,1)=1; voltas=voltas(1:voltas_m); theta_voltas=(inv((transpose(A))*A))*((transpose(A))*voltas); f_voltas=[1 voltas(1) A(1,2) A(1,3)]*theta_voltas; %% TIME SERIES ANALYSIS ON INTERNATIONAL METAL INDEX % Time series analysis on international metal index is performed here. This % is required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; metal_m=metal_m - 3; for i=1:metal_m temp=j; A(i,2)=metal(j,1); j=j+1;

A(i,3)=metal(j,1); j=j+1; A(i,4)=metal(j,1); j=temp+1; end A(:,1)=1; metal=metal(1:metal_m); theta_metal=(inv((transpose(A))*A))*((transpose(A))*metal); f_metal=[1 metal(1) A(1,2) A(1,3)]*theta_metal; %% TIME SERIES ANALYSIS ON SALES OF MARUTI SUZUKI % Time series analysis on sales of maruti suzuki is performed here. This is % required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; maruti_m=maruti_m - 3; for i=1:maruti_m temp=j; A(i,2)=maruti(j,1); j=j+1; A(i,3)=maruti(j,1); j=j+1; A(i,4)=maruti(j,1); j=temp+1; end A(:,1)=1; maruti=maruti(1:maruti_m); theta_maruti=(inv((transpose(A))*A))*((transpose(A))*maruti); f_maruti=[1 maruti(1) A(1,2) A(1,3)]*theta_maruti; %% TIME SERIES ANALYSIS ON SALES OF EICHER % Time series analysis on sales of eicher is performed here. This is % required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; eicher_m=eicher_m - 3; for i=1:eicher_m temp=j; A(i,2)=eicher(j,1); j=j+1; A(i,3)=eicher(j,1); j=j+1; A(i,4)=eicher(j,1); j=temp+1; end A(:,1)=1; eicher=eicher(1:eicher_m); theta_eicher=(inv((transpose(A))*A))*((transpose(A))*eicher); f_eicher=[1 eicher(1) A(1,2) A(1,3)]*theta_eicher; %% TIME SERIES ANALYSIS ON SALES OF TATA MOTORS % Time series analysis on sales of tata motors is performed here. This is

% required for forecasting method discussed in section 4.3.3. clear A j temp; j=2; tata_m=tata_m - 3; for i=1:tata_m temp=j; A(i,2)=tata(j,1); j=j+1; A(i,3)=tata(j,1); j=j+1; A(i,4)=tata(j,1); j=temp+1; end A(:,1)=1; tata=tata(1:tata_m); theta_tata=(inv((transpose(A))*A))*((transpose(A))*tata); %% DISPLAY OF FINAL OUTPUT f_tata=[1 tata(1) A(1,2) A(1,3)]*theta_tata; f_sales=[1 ash(1,1) mnm(1,1) voltas(1,1) metal(1,1) maruti(1,1) eicher(1,1) tata (1,1)]*theta_bsl_2; f_sales_2=[1 f_ash f_mnm f_voltas f_metal f_maruti f_eicher f_tata]*theta_bsl_3; clc fprintf('\n\nSales prediction by Regression Analysis %d\n\n', f_sales); fprintf('\n\nSales prediction by Time Series and Regression Analysis %d\n\n', f_ sales_2); fprintf('\n\nSales prediction by Time Series Analysis %d\n\n', f_bsl); %% CORRECTION IN TIME SERIES MODEL OF 4.3.1 % Due to appearence of a time series like pattern amongst the errors of thw % forecasted sales, we take a log transformation and rework the data by % following the same process again. clear; j=2; bsl=xlsread('bsl.xlsx'); [bsl_m bsl_n]=size(bsl); bsl_m=bsl_m - 3; bsl=log(bsl); for i=1:bsl_m temp=j; A(i,2)=bsl(j,1); j=j+1; A(i,3)=bsl(j,1); j=j+1; A(i,4)=bsl(j,1);

j=temp+1; end A(:,1)=1; bsl=bsl(1:bsl_m); theta_bsl=(inv((transpose(A))*A))*((transpose(A))*bsl); xlswrite('forecast.xlsx',bsl,'TS_Log', 'A1'); xlswrite('forecast.xlsx',A,'TS_Log', 'B1'); xlswrite('forecast.xlsx',A*theta_bsl,'TS_Log','F1'); f_bsl_2=[1 bsl(1) A(1,2) A(1,3)]*theta_bsl; fprintf('\n\nSales prediction by Time Series Analysis after taking log %d\n\n', exp(f_bsl_2)); %% WRITTEN BY OMKAR SAYAJI HANDE

You might also like