-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab9.m
More file actions
47 lines (30 loc) · 894 Bytes
/
lab9.m
File metadata and controls
47 lines (30 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
rainfall=rain(:,1);
runoff=rain(:,2);
figure
scatter(rainfall,runoff)
xlabel('rainfall')
ylabel('runoff')
% fit simple linear regression model
% Y = b0 + b1 * x + epsilon
%% fit the simple linear regression model
rainmod = fitlm(rainfall, runoff)
%% Equation of the fitted line is
% yhat = -327.12 + 0.91946 x
pvalue=2*tcdf(-10.298,29)
% we conclude that rainfall amount has a significant influence on the
% runoff
rainmod.RMSE
%% v)
coefCI(rainmod)
% 95% ci for the slope coefficient betal...
% 98% ci
coefCI(rainmod, 0.02)
%% find sample correlation coefficient
r = sqrt(rainmod.Rsquared.Ordinary)
%% Assumptions
subplot(1,2,1)
plotResiduals(rainmod,'fitted')
subplot(1,2,2)
plotResiduals(rainmod,'probability')
%% 99% ci for mean of y when x = 30
[ypred, yci] = predict(rainmod, 1100, 'alpha', 0.01, 'Prediction', 'observation')