Sunteți pe pagina 1din 6

> data=read.csv("ANREG.

csv",header=T,sep=",")

> data

Y X

1 3.01 10

2 3.15 12

3 2.90 9

4 3.10 10

5 2.70 8

6 3.25 11

7 3.60 15

8 3.70 17

9 3.65 16

10 3.15 10

11 3.06 11

12 3.20 13

13 2.95 10

14 3.15 11

15 32.75 9

16 3.30 12

17 3.65 16

18 3.75 18

19 3.70 17

20 3.20 11

> attach(data)

> residual1=resid(data)
> residual1

NULL

> model1=lm(Y~X,data=data)

> model1

Call:

lm(formula = Y ~ X, data = data)

Coefficients:

(Intercept) X

10.2480 -0.4473

> summary(model1)

Call:

lm(formula = Y ~ X, data = data)

Residuals:

Min 1Q Median 3Q Max

-3.9695 -2.6373 -1.9039 0.5591 26.5279

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 10.2480 6.2531 1.639 0.119

X -0.4473 0.4939 -0.906 0.377

Residual standard error: 6.63 on 18 degrees of freedom


Multiple R-squared: 0.04359, Adjusted R-squared: -0.009549

F-statistic: 0.8203 on 1 and 18 DF, p-value: 0.3771

> library(stats)

> step(model1)

Start: AIC=77.56

Y~X

Df Sum of Sq RSS AIC

-X 1 36.056 827.26 76.448

<none> 791.20 77.556

Step: AIC=76.45

Y~1

Call:

lm(formula = Y ~ 1, data = data)

Coefficients:

(Intercept)

4.746

> residual1=resid(model1)

> residual1

1 2 3 4 5 6

-2.76482242 -1.73019423 -3.32213651 -2.67482242 -3.96945061 -2.07750832


7 8 9 10 11 12

0.06174806 1.05637625 0.55906215 -2.62482242 -2.26750832 -1.23288013

13 14 15 16 17 18

-2.82482242 -2.17750832 26.52786349 -1.58019423 0.55906215 1.55369034

19 20

1.05637625 -2.12750832

> library(stats)

> shapiro.test(residual1)

Shapiro-Wilk normality test

data: residual1

W = 0.46089, p-value = 1.435e-07

> library(lmtest)

> bptest(model1,studentize=F,data=data)

Breusch-Pagan test

data: model1

BP = 11.02, df = 1, p-value = 0.0009015

> #autokorelasi

> library(lmtest)

> dwtest(model1)

Durbin-Watson test
data: model1

DW = 2.0973, p-value = 0.5314

alternative hypothesis: true autocorrelation is greater than 0


Variables Entered/Removeda

Model Variables Variables Method


Entered Removed

1 D1, X1b . Enter

a. Dependent Variable: Y
b. All requested variables entered.

Model Summary

Model R R Square Adjusted R Std. Error of the


Square Estimate

1 .382a .146 .045 6.44820

a. Predictors: (Constant), D1, X1

ANOVAa

Model Sum of Squares df Mean Square F Sig.

Regression 120.408 2 60.204 1.448 .263b

1 Residual 706.848 17 41.579

Total 827.256 19

a. Dependent Variable: Y
b. Predictors: (Constant), D1, X1

Coefficientsa
Model Unstandardized Coefficients Standardized t Sig.
Coefficients

B Std. Error Beta

(Constant) 14.387 6.740 2.134 .048

1 X1 -.595 .491 -.278 -1.211 .243

D1 -4.223 2.965 -.327 -1.424 .172

a. Dependent Variable: Y

S-ar putea să vă placă și