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

Multivariate Data Analysis Assignment

This document contains 3 problems related to multivariate data analysis and linear regression. Problem 1 calculates the slope and intercept of a linear regression line using the least squares method. Problem 2 performs multiple linear regression on 2 variables. Problem 3 uses the total least squares method to find the best fit linear equation relating 3 variables and calculates the cost of fabricating a plant using the linear model.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Multivariate Data Analysis Assignment

This document contains 3 problems related to multivariate data analysis and linear regression. Problem 1 calculates the slope and intercept of a linear regression line using the least squares method. Problem 2 performs multiple linear regression on 2 variables. Problem 3 uses the total least squares method to find the best fit linear equation relating 3 variables and calculates the cost of fabricating a plant using the linear model.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PROBLEM 1

clc clear disp('Enter the path of excel with output as col1 and inputs as further columns'); name=input('','s'); A=xlsread(name); Z=A'; s=size(Z); X=0; Y=0; Sxy=0; Sxx=0; b=0; a=0; %syms a b J for i=1:s(1,2) X=X+Z(2,i); Y=Y+Z(1,i); %J=J+(Z(1,i)-a(b*Z(2,i)))^2; end X=X/s(1,2); Y=Y/s(1,2); for i=1:s(1,2) Sxy=Sxy+((Z(1,i)-Y)*(Z(2,i)X)); Sxx=Sxx+(Z(2,i)-X)^2; end Sxy=Sxy/s(1,2); Sxx=Sxx/s(1,2); b=Sxy/Sxx; a=Y-(b*X); fprintf('%f is beta\n',b); fprintf('%f is alpha',a); syms x y y=a+(b*x); y

MULTIVARIATE DATA ANALYSIS ASSIGNMENT

ANSWER: Beta=-0.014 Alpha=7.955 Coefficient of constant is very large compared to coefficient of x. Hence Dependency of y on x is very less saying that it is less linear relation. PROBLEM 2

clear clc disp('Enter the path of excel with output as col1 and inputs as further columns'); name=input('','s'); A=xlsread(name); len=size(A); %A=A(:,2:len(1,2)); Z=A'; s=size(Z); b=0; a=0; %syms a b J X=zeros(len(1),len(2)-1); X=A(:,2:len(1,2)); Y=A(:,1); %Y=Y/s(1,2); X Y Sxy=X'*Y; Sxx=inv(X'*X); b=Sxx*Sxy; Sxx Sxy %a=Y-(b*X); b ANSWER Beta1= 1.89 Beta2=1.30 Alpha=11.4 The highest effect on cost is due to Labour Constant is high when compared to coefficients of variables.

PROBLEM3
clear clc disp('Enter the path of excel with output as col1 and inputs as further columns'); name=input('','s'); A=xlsread(name); len=size(A); %Z=A'; X1=0; X2=0; Y=0; for i=1:len(1,1) X1=X1+A(i,2); X2=X2+A(i,3); Y=Y+A(i,1); end X1=X1/len(1); X2=X2/len(1); Y=Y/len(1); S=[0 0 0;0 0 0;0 0 0]; for i=1:len(1,1) Z=[A(i,1);A(i,2);A(i,3)]-[Y;X1;X2]; S=S+(Z*Z'); end S=S/len(1); [V D]=eig(S);

small=D(1,1); n=1; for i=1:3 if(D(i,i)<small) n=i;end end syms x1 x2 y; z=[y-Y;x1-X1;x2-X2]; vec=[V(1,n);V(2,n);V(3,n)]; ans=vec'*z; %q=[] D V ans

ANSWER y=.13x1+4.12x2+67- Equation of linear model using Total Least Square Method Cost of fabricating the plant is: 273.08 Using percentage variance to decide the number of linear variables, Cost of fabricating the plant is: 256.78

You might also like