You are on page 1of 5

BOX1 (LIST OF COMMANDS)

>
>
>
>
>
>
>
>
>
>
>
>
>
>

mydata=regression_auto
attach(mydata)
#define variables
Y=cbind(mpg)
X1=cbind(weight)
X=cbind(weight1,price,foreign)
#(Y=dependent variable,X1=independentvariable)
#correlation among variables
cor(Y,X)
> cor(Y,X1)
plot(Y~X1,data=mydata)
#simpleregreession
olsreg1=ln(Y~X1)
olsreg1=lm(Y~X1)
summary(olsreg1)

BOX 2( OUTPUT/ RESULTS )


# CORRELATION RESULT :
weight1
price foreign
mpg -0.8081609 -0.4384618 0.4003376
> # CORRELATION RESULT (SINGLE VARIALBLE ):
> weight
mpg -0.8081609
Residuals:
Min
1Q Median
3Q
Max
-5.4123 -1.6073 -0.1043 0.9261 8.1072
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 38.0664601 2.6111768 14.578 2.02e-13 ***
X1
-0.0055315 0.0008229 -6.722 5.93e-07 ***
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 2.86 on 24 degrees of freedom
Multiple R-squared: 0.6531, Adjusted R-squared: 0.6387
F-statistic: 45.19 on 1 and 24 DF, p-value: 5.935e-07

DATA SET
make
AMC
AMC
AMC
Audi
Audi
BMW
Buick
Buick
Buick
Buick
Buick

mpg
22
17
22
17
23
25
20
15
18
26
20

weigh
t
2930
3350
2640
2830
2070
2650
3250
4080
3670
2230
3280

weigh
t1
2.93
3.35
2.64
2.83
2.07
2.65
3.25
4.08
3.67
2.23
3.28

Buick

16

3880

3.88

Buick

19

3400

3.4

Cadillac

14

4330

4.33

Cadillac

14

3900

3.9

Cadillac
Chevrol
et
Chevrol
et
Chevrol
et
Chevrol
et
Chevrol
et
Chevrol
et
Datsun
Datsun
Datsun
Datsun

21

4290

29

price
4099
4749
3799
9690
6295
9735
4816
7827
5788
4453
5189
1037
2

foreig
n
0
0
0
1
1
1
0
0
0
0
0

repair
s
3
3
3
5
3
4
3
4
3
3
3

lengt
h
186
173
168
189
174
177
196
222
218
170
200

207

200

221

204

4.29

4082
1138
5
1450
0
1590
6

204

2110

2.11

3299

163

16

3690

3.69

5705

212

22

3180

3.18

4504

193

22

3220

3.22

5104

200

24

2750

2.75

3667

179

19
23
35
24
21

3430
2370
2020
2280
2750

3.43
2.37
2.02
2.28
2.75

3955
6229
4589
5079
8129

0
1
1
1
1

3
4
5
4
4

197
170
165
170
184

Under the current hypothesis we can say that the


dependent variable is (Y) and the independent
variable is (X1). Running a simple regression
analysis we get the relationship between the
dependent variable and the independent variable.
The results are shown under the syntax commands
as
olsreg=lm(Y~X1). When
we hit the summary command for the above
mentioned syntax we get the result in box 2.
The interpretation of the regression analysis is as
follows ,a unit increase in the level X1 , this
basically corresponds to a 1000more pounds in car
weight. This would cause a (-5.5315) reduction in
the Y variable indicating a negative relation
between mpg and weight1. Similarly the
intercept term tells us that is the weight variable is
zero then the Y variable will be 38.0665 units .
Another important thing that one should keep in
mind is the fact that the intercept term(s) should
be statistically significant / statistically different
from zero. This can be done in three ways
1)t-statistic: the t value if lies withing [-2,2] then
the beta values are considered to be
statistically significant, whereas it will be the
opposite in the case if they are not .
2)p-values should be less than 0.05
3)confidence interval test
2.5%
97.5%
Intercept
32.67725
43.455664

X1
-3.833196

-7.229797

The above confidence interval for both the


intercept term and the slope coefficient tells us
that the values lie between interval and hence
are statistically significant .

You might also like