/*
read in AIR data */
data
air ;
input
co no so2 dust wind ;
cards
;
0.63 1.1768
1.073 1.489 2.01
0.63 0.5469
0.894 1.563 1.62
0.47 0.2930
0.894 1.270 2.53
0.63 0.3857
0.858 0.879 1.37
0.31 0.1855
0.787 0.781 2.54
0.40 0.2393
0.894 1.147 1.99
0.63 0.6592
1.037 1.636 1.42
2.22 2.4658
2.110 2.393 0.96
5.11 5.0391
4.972 3.857 1.32
1.76 1.8213
3.290 5.225 1.92
0.82 0.8398
2.110 4.199 2.45
0.57 0.3369
1.431 2.051 2.94
0.54 0.3662
1.323 1.587 1.40
0.75 0.3700
1.300 2.051 1.05
0.84 0.4150
1.466 1.904 0.84
0.87 0.5518
1.288 1.855 1.23
1.84 1.6553
2.253 3.369 0.48
3.12 3.7012
3.469 5.542 0.29
3.83 4.8096
3.577 7.373 0.98
4.57 5.5566
3.577 7.642 1.38
3.17 4.7168
2.647 6.299 1.23
3.23 4.6143
2.146 5.347 0.57
3.28 5.0879
2.432 4.785 0.72
2.87 4.0186
1.967 4.468 1.07
2.12 1.9043
1.502 4.688 0.98
1.28 0.9619
1.323 4.395 2.41
1.28 1.4404
0.930 3.418 1.04
1.21 1.1865
0.858 3.052 1.43
1.17 1.1865
1.073 3.320 1.37
1.44 1.0840
1.216 3.247 1.82
2.18 2.7002
1.753 3.198 0.77
2.73 3.0420
1.896 3.564 1.09
3.23 3.5596
2.754 4.541 1.43
1.42 0.7861
2.504 4.468 2.80
1.30 1.0449
2.396 2.979 2.76
1.09 0.6689
2.182 2.368 2.70
1.14 0.6982
2.039 2.612 0.91
1.03 0.4639
1.466 3.052 2.83
1.00 0.5127
1.538 3.174 1.48
1.29 1.0010
2.289 3.613 1.52
1.51 1.3086
2.146 5.762 0.72
5.94 6.8799
4.757 8.325 0.53
6.07 7.2559
4.435 10.547 1.49
2.93 3.5400
3.577 10.986 0.86
4.43 5.8252
3.004 8.594 0.48
4.04 6.1523
3.076 6.763 0.94
4.36 5.7227
2.504 6.641 0.94
3.07 3.9844
2.039 6.494 0.76
2.35 2.4951
1.824 5.835 1.47
2.09 2.2266
2.146 4.590 1.51
1.98 1.9775
2.146 4.565 1.46
1.91 1.9336
2.146 4.297 1.23
1.86 1.8311
2.361 4.443
0.80
1.94 1.8750
2.361 6.274 0.14
2.72 2.8760
2.897 7.983 0.78
3.23 3.8916
3.684 9.692 0.77
4.16 5.0293
4.328 12.866 0.64
3.17 3.8184
4.650 14.014 0.42
3.06 3.4570
5.222 13.062 0.19
3.51 3.9990
5.615 13.354 0.84
1.91 1.6309
5.186 13.623 0.84
1.00 0.5859
3.255 9.253 2.81
0.65 0.4150
3.541 5.347 2.27
0.79 0.5762
3.112 3.027 1.51
1.55 1.5088
3.076 3.857 1.15
2.42 2.6221
3.469 6.152 1.10
4.16 4.8877
3.541 7.959 0.43
4.16 5.5469
3.255 8.887 0.77
5.33 7.2754
3.076 8.691 0.77
3.27 5.2441
2.289 7.568 0.92
3.10 4.6143
1.753 6.396 0.60
3.58 5.9717
2.218 5.640 1.04
2.79 4.6289
1.753 5.371 0.54
3.25 4.2188
1.824 5.371 0.99
1.94 2.5928
1.288 5.615 0.23
1.56 2.7002
1.216 5.176 0.55
1.92 3.7842
1.717 4.028 0.41
1.45 2.2705
1.466 3.833 0.36
1.01 2.3975
1.359 3.418 0.60
0.90 1.2207
1.180 2.612 1.59
1.14 1.4404
1.502 2.124 2.29
0.35 0.3418
2.289 1.416 3.09
0.30 0.2148
2.826 0.610
3.85
0.27 0.1416
3.505 0.464 6.24
0.30 0.1270
4.828 0.879 6.54
0.51 0.1123
4.042 1.489 5.12
0.48 0.1416
4.292 1.563 5.26
0.53 0.1611
4.077 1.367 4.53
0.64 0.2783
3.899 2.002 3.95
1.83 1.0205
3.648 3.003 1.70
0.57 0.1953
3.827 3.735 4.28
0.66 0.1563
3.612 3.467 3.93
0.69 0.3467
3.720 2.979 3.47
0.50 0.1367
4.185 3.101 2.50
0.43 0.0928
5.293 3.198 3.45
0.52 0.0635
5.901 3.296 3.48
0.49 0.0781
6.009 3.442 2.70
0.53 0.0586
7.261 3.613 3.19
0.38 0.0684
8.298 3.540 3.76
0.40 0.0781
7.869 3.369 3.73
0.36 0.0537
7.869 3.247 4.01
0.50 0.0781
6.939 3.076 4.60
0.46 0.1025
6.545 2.832 6.58
0.59 0.1563
6.188 2.124 6.26
0.54 0.1709
6.474 1.685 5.87
0.52 0.2393
6.116 1.807 4.65
0.44 0.2002
4.149 1.489 5.41
0.46 0.1563
2.933 1.294 7.86
0.46 0.1807
2.611 1.440 7.60
0.47 0.1709
2.396 1.978 6.27
0.50 0.1904
2.289 1.978 6.96
0.64 0.3076
1.967 1.782 5.96
0.69 0.2734
1.824 2.441 4.29
1.14 0.8105
2.289 2.930 3.58
0.66 0.3467
1.896 2.832 4.47
0.68 0.5273
2.074 2.368 4.72
0.47 0.2148
1.681 1.807 4.48
0.63 0.3906
1.753 1.660 3.19
0.83 0.4932
1.717 1.489 1.26
0.51 0.3174
1.824 1.685 1.65
0.47 0.2441
1.681 1.904 3.05
0.35 0.1953
1.609 1.807 2.16
0.30 0.2344
1.645 1.855 2.46
0.13 0.1025
2.074 1.758 4.38
0.13 0.0537
2.074 1.416 4.62
0.22 0.1855
2.325 1.343 3.77
0.30 0.1074
2.539 1.563 4.23
0.54 0.1465
2.826 1.587 3.96
0.54 0.1367
3.112 1.904 5.44
0.60 0.1563
3.076 1.782 6.12
0.60 0.1904
3.040 1.294 7.65
0.63 0.2002
3.076 1.611 6.14
0.57 0.1709
2.897 2.271 6.24
0.46 0.1416
2.754 3.076 6.17
0.73 0.2051
2.826 3.345 6.12
0.64 0.2148
2.754 3.540 5.20
0.85 0.2344
2.611 4.150 5.02
0.92 0.2637
2.647 4.541 4.00
0.90 0.3955
2.682 4.541 3.92
0.90 0.3516
2.682 4.199 3.45
0.93 0.3467
2.647 3.931 2.91
1.05 0.5762
2.611 3.638 1.96
0.82 0.5078
2.718 3.223 2.93
0.71 0.3809
2.432 3.418 3.33
0.82 0.3564
2.289 4.004 2.59
0.57 0.0977
2.504 4.028 3.76
0.46 0.0684
2.396 3.711 3.53
0.49 0.0684
2.396 3.638 3.53
0.43 0.0586
2.146 3.711 3.32
0.42 0.0488
2.182 3.516 3.32
0.28 0.0537
2.182 3.296 4.04
0.16 0.0488
2.289 3.345 4.14
0.23 0.0684
2.325 3.491 4.19
0.32 0.0977
2.468 3.125 4.84
0.46 0.1270
2.611 2.734 5.49
0.47 0.1758
2.539 2.661 4.72
0.43 0.1611
2.611 2.979 3.05
0.22 0.1758
2.361 3.638 2.76
0.41 0.1855
2.218 3.345 2.96
0.50 0.3516
2.003 3.296 3.04
1.35 1.4209
2.647 4.614 1.37
2.32 2.4854
2.933 6.030 1.50
1.95 1.6211
3.076 6.030 1.85
1.58 1.7725
2.611 5.396 2.45
1.20 0.8350
2.146 4.907 2.37
1.09 0.6250
2.110 4.199 2.09
1.03 0.7422
2.110 4.102 2.29
0.91 0.6836
2.253 4.272 1.58
;
/*
create scatter plots for each variable */
/*
use title statements for each plot */
title
'Scatter Plot for CO vs SO2' ;
proc
plot data=air
;
plot
co*so2 ;
run
;
title
'Scatter Plot CO vs NO' ;
proc
plot data=air
;
plot
co*so2 ;
run
;
title
'Scatter Plot CO vs DUST' ;
proc
plot data=air
;
plot
co*dust ;
run
;
title
'Scatter Plot CO vs WIND' ;
proc
plot data=air
;
plot
co*wind ;
run
;
/*
Calculate the correlations between variables using proc corr */
proc
corr data=air
;
var
co so2 no dust wind ;
run
;
/*
run a regression model - partial option */
proc
reg data=air ;
model
co = so2 no dust wind / partial ;
run
;
/*
is there evidence of interaction between SO2 and DUST? NO & DUST? */
/*
create a data set with a grouped version of DUST and compare slopes */
data
interact ;
set
air ;
if
dust<=3 then
dustcat=1 ;
else
if (dust>3
and dust<=6) then
dustcat=2 ;
else
if (dust>6
and dust<=9) then
dustcat=3 ;
else
if (dust>9
and dust<=12) then
dustcat=4 ;
else
if (dust>12)
then dustcat=5
;
run
;
/*
sort the data by dust category */
proc
sort data=interact
;
by
dustcat ;
run
;
/*
run separate regressions for each category of DUST using BY statement */
/*
if the slopes are different for each category - indicates interaction */
/*
notice the use of multiple model statements */
proc
reg data=interact ;
by
dustcat ;
model
co = so2 ;
model
co = no ;
run
;
/*
in proc reg - must create higher order terms in a data step */
data
air2 ;
set
air ;
wind2 = wind*wind ;
so2wind = so2*wind ;
nowind = no*wind ;
dustwind = dust*wind ;
so2no = so2*no ;
so2dust = so2*dust ;
nodust = no*dust ;
run;
/*
run full regression model - drop any non-significant terms */
/*
also drop wind and drop all interactions with wind */
proc
reg data=air2 ;
model
co = so2 no dust wind so2no so2dust so2wind nodust nowind dustwind wind2 ;
run
;
/*
use forward, backward, and stepwise to assess variables */
/*
first try defaults for slentry and slstay */
proc
reg data=air2 ;
model
co = so2 no dust so2no so2dust nodust / selection
= forward ;
run
;
proc
reg data=air2 ;
model
co = so2 no dust so2no so2dust nodust / selection
= backward ;
run
;
proc
reg data=air2 ;
model
co = so2 no dust so2no so2dust nodust / selection
= stepwise ;
run
;
/*
try changing slentry and slstay for stepwise */
proc
reg data=air2 ;
model
co = so2 no dust so2no so2dust nodust /
selection
= stepwise slentry = 0.01
slstay=0.01
;
run
;
/*
use VIF, INFLUENCE, and R options to check for outliers */
/*
use SS1 and SS2 to calculate the sequential and partial sums of squares */
proc
reg data=air2 ;
model
co = so2 no dust so2no so2dust nodust / vif
influence r
ss1 ss2 ;
run
;
/*
use proc glm to get the F-statistics and p-values for the full vs reduced */
/*
hypothesis tests */
proc
glm data=air2 ;
model
co = so2 no dust so2no so2dust nodust ;
run
;
quit
;