Escolar Documentos
Profissional Documentos
Cultura Documentos
OLEH :
JUMRIANTI H12116008
ROSDIANA H12116010
Untuk membuat program matlab regresi linier berganda hal pertama yang
harus dilakukan yaitu menyiapkan data bilangan random menggunakan excel
dengan rumus :
=rand()atau =randbetween(bottom;top)
Contoh data regresi linier berganda
No Y X1 X2
1 0.89 62 1
2 0.90 94 6
3 0.07 94 4
4 0.56 17 8
5 0.16 65 1
6 0.88 82 2
7 0.74 73 9
8 0.28 84 1
9 0.82 44 7
10 0.43 72 1
11 0.41 66 10
12 0.36 73 8
13 0.36 96 9
14 0.11 55 7
15 0.46 88 3
16 0.35 82 6
17 0.74 56 3
18 0.22 18 8
19 0.16 80 9
20 0.58 90 6
21 0.74 28 6
22 0.66 96 4
23 0.06 60 4
24 0.66 22 10
25 0.89 66 3
26 0.19 19 7
27 0.27 19 6
28 0.84 53 3
29 0.91 100 6
30 0.65 72 2
31 0.10 99 2
32 0.80 53 8
33 0.21 97 7
34 0.90 48 6
35 0.84 55 6
36 0.69 80 3
37 0.19 52 10
38 0.93 37 2
39 0.69 48 4
40 0.64 75 8
41 0.89 24 5
42 0.43 75 8
43 0.97 74 5
44 0.04 65 5
45 0.70 86 5
46 0.98 70 4
47 0.81 62 1
48 0.99 20 4
49 0.14 94 7
50 0.44 11 8
Ada dua penyelesaiaan yang dilakukan yaitu menggunakan aplikasi Matlab
dan secara Analitik (manual). Adapun uraiannya yaitu:
1. PROGRAM MATLAB
% Nonlinear Least Square
% Cobb-Douglas Production Function
% Non Linear Least Square Gauss-Newton Iterations
% Memerlukan file: f1, numgradf1, dan numgradS1
% Program iniakanmenaksir parameter b1, b2, dan b3
yang adapada Cobb-Douglas
Production Function
% Q = b1.(L^b2).(K^b3)
Program Utama
clear;
clc;
LKy=xlsread ('D:\Data.xlsx');
L = LKy(:,1);
K = LKy(:,2);
Q = LKy(:,3);
y = Q;
x = [L K];
T =length (x);
tic;
% Gauss-Newton Iterations
rep = 100; %The size of 'rep' depends on
the convergence criterion
b = 1.0* ones (3,1); % initial values of b,
replace this if necessary
k = length(b);
e = eye(k);
f = f1(b,x);
S = (y-f)'*(y-f);
j1 = 0;
j2 = 0;
tn = 1; %dalamiterasiGuss-Newton tidakperlumengubahtn
for i = 1:rep ;
z = numgradf1(b,x); %Numerical gradient of f1
zS = numgradS1(b,x,y);%Numerical gradient of S1
step = -0.5*inv(z'*z)*zS ;% Gauss-Newton Iterations
bnext = b + tn*step;
fnext = f1(bnext,x);
Snext = (y-fnext)'*(y-fnext) ;
if i == rep
disp('===============================================
===');
disp('Belum konvergen, iterasinya perlu di
tambah lagi.') ;
disp('Atau ubahlah initial values-nya') ;
disp('===============================================
===');
disp(' ') ;
end ;
b = bnext ;
f = f1(b,x) ;
S = (y-f)'*(y-f) ;
end ;
disp('===============================================
===');
disp('Hasil dari penggunaan iterasi Gauss-Newton
adalah:') ;
disp('===============================================
===');
[bnext' S]
t1 = toc;
Pogram Pendukung
%File f1.m
function f = f1(b,x)
%f1 Cobb-Douglas production
function %f = f1(b,x)
L = x(:,1) ;
K = x(:,2) ;
b1 = b(1,:);
b2 = b(2,:);
b3 = b(3,:);
f = b1*(D.^b2).*(R.^b3);
%file numgradf1.m
function z = numgradf1(b,x)
k = length(b);
d = 1e-7;
e = eye(k);
k = length(b);
d = 1e-6;
e = eye(k);
T = length(x);
f = f1(b,x);
s2 = (y-f)'*(y-f)/T;
LL = -0.5*(log(2*pi*s2) + (y-f)'*(y-f)/s2);
Hasil program matlab tersebut sebagai berikut:
2. SECARA ANALITIK (MANUAL)
Dari data diatas kita akan mencari nilai bo, b1, dan b2 secara manual
dengan menggunakan rumus analisis regresi linier berganda. Adapun langkah-
langkahnya yaitu:
Persamaan regresi linear berganda : Y' = b0 + b1X1 + b2X2
Menentukan nilai konstanta dan koefisien regresi
Kita membuat tabel bantu sebagai berikut:
∑ 2 = ∑ 2−
(Ʃ 1)
2
1 1
9928801
= 230917 − 50
= 230917 – 198576
= 32340,98
(Ʃ 2)2
∑2 =∑ 2
−
2 2
71824
= 1786 −
50
= 1786 – 1436,48
2 2
(Ʃ )
2
∑ =∑ −
= 19,92 − 770,5650
= 19,92 – 15,41124606
∑1 =∑1 −
Ʃ 1× Ʃ
= 4,51
= 1697,504 − 3151∗27,76
50
= 1697,504 – 1749,372
= -51,86811
Ʃ 2×Ʃ
∑2 =∑ 2 −
268∗27,76
= 140,3132 −
50
= 140,3132 – 148,7883
∑1 2=∑1 2−
Ʃ 1×Ʃ 2
= -8,475102
= 16227 − 3151∗268
50
= 16227 – 16889,36
= - 662,36
2
[(32340,98 (349,52))−(−662,36) ]
= -0,00219
2
[(Ʃ 1 ×Ʃ 2 )−(Ʃ 1 ×Ʃ 1 2)]
2=
= [(32340,98×(−8,475102)−(−51,86811 ×(−662,36)]
[(32340,98 (349,52))−(−662,36) 2]
= -0,02839
(Ʃ )−(
0= 1×Ʃ 1)−( 2×Ʃ 2)
= (27,76)−(−0,00219×3151)−(−0,02839×268)
50
= 0,845057
Jadi persamaan Regresi Linier Berganda dengan dua variabel
bebas adalah:
Y' = 0,845057 - 0,00219X1 – 0,02839 X2