Documente Academic
Documente Profesional
Documente Cultură
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:
Coefficients:
(Intercept) X
10.2480 -0.4473
> summary(model1)
Call:
Residuals:
Coefficients:
> library(stats)
> step(model1)
Start: AIC=77.56
Y~X
Step: AIC=76.45
Y~1
Call:
Coefficients:
(Intercept)
4.746
> residual1=resid(model1)
> residual1
1 2 3 4 5 6
13 14 15 16 17 18
19 20
1.05637625 -2.12750832
> library(stats)
> shapiro.test(residual1)
data: residual1
> library(lmtest)
> bptest(model1,studentize=F,data=data)
Breusch-Pagan test
data: model1
> #autokorelasi
> library(lmtest)
> dwtest(model1)
Durbin-Watson test
data: model1
a. Dependent Variable: Y
b. All requested variables entered.
Model Summary
ANOVAa
Total 827.256 19
a. Dependent Variable: Y
b. Predictors: (Constant), D1, X1
Coefficientsa
Model Unstandardized Coefficients Standardized t Sig.
Coefficients
a. Dependent Variable: Y