Geoscience Reference
In-Depth Information
burial depth, and temperature. In practice, the plausibility of the assumption
of linearity must i rst be examined. If this assumption is probably true then
there are several methods of multiple linear regression available, some of
which are included in the Statistics Toolbox (Mathworks 2014b).
As a i rst example we create a noise-free synthetic data set with three
variables
Var1
,
Var2
and
Var3
. We wish to i nd the inl uence of variables
Var1
and
Var2
on variable
Var3
. h e variables
Var1
and
Var2
are therefore the
predictor variables and the variable
Var3
is the response variable. h e linear
relationship between the response variable and the predictor variables is
Var3=0.2-52.0*Var1+276.0*Var2
. h e three variables
Var1
,
Var2
and
Var3
are
stored as columns 1, 2 and 3 in a single array
data
.
clear
rng(0)
data(:,1) = 0.3 + 0.03*randn(50,1);
data(:,2) = 0.2 + 0.01*randn(50,1);
data(:,3) = 0.2 ...
- 52.0*data(:,1) ...
+ 276.0*data(:,2);
We create labels for the names of the samples and the names of the variables,
as we did in Section 9.2.
for i = 1 : size(data,1)
samples(i,:) = [sprintf('%02.0f',i)];
end
variables = ['Var1';
'Var2';
'Var3'];
h en we calculate the coei cients
beta
of the multiple linear regression
model using
fitlm
.
beta = fitlm(data(:,1:2),data(:,3),...
'ResponseVar',variables(3,:),...
'PredictorVars',variables(1:2,:))
h e function
fitlm
uses a least mean-squares criterion to calculate
beta
. h e
method calculates an
F
-statistic to test the null hypothesis that all regression
coei cients are zero and there is no relationship between the response and
predictor variables. h e output of the function
fitlm
beta =
Linear regression model:
Var3 ~ 1 + Var1 + Var2