R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(461
+ ,0
+ ,455
+ ,462
+ ,452
+ ,449
+ ,461
+ ,0
+ ,461
+ ,455
+ ,462
+ ,452
+ ,463
+ ,0
+ ,461
+ ,461
+ ,455
+ ,462
+ ,462
+ ,0
+ ,463
+ ,461
+ ,461
+ ,455
+ ,456
+ ,0
+ ,462
+ ,463
+ ,461
+ ,461
+ ,455
+ ,0
+ ,456
+ ,462
+ ,463
+ ,461
+ ,456
+ ,0
+ ,455
+ ,456
+ ,462
+ ,463
+ ,472
+ ,0
+ ,456
+ ,455
+ ,456
+ ,462
+ ,472
+ ,0
+ ,472
+ ,456
+ ,455
+ ,456
+ ,471
+ ,0
+ ,472
+ ,472
+ ,456
+ ,455
+ ,465
+ ,0
+ ,471
+ ,472
+ ,472
+ ,456
+ ,459
+ ,0
+ ,465
+ ,471
+ ,472
+ ,472
+ ,465
+ ,0
+ ,459
+ ,465
+ ,471
+ ,472
+ ,468
+ ,0
+ ,465
+ ,459
+ ,465
+ ,471
+ ,467
+ ,0
+ ,468
+ ,465
+ ,459
+ ,465
+ ,463
+ ,0
+ ,467
+ ,468
+ ,465
+ ,459
+ ,460
+ ,0
+ ,463
+ ,467
+ ,468
+ ,465
+ ,462
+ ,0
+ ,460
+ ,463
+ ,467
+ ,468
+ ,461
+ ,0
+ ,462
+ ,460
+ ,463
+ ,467
+ ,476
+ ,0
+ ,461
+ ,462
+ ,460
+ ,463
+ ,476
+ ,0
+ ,476
+ ,461
+ ,462
+ ,460
+ ,471
+ ,0
+ ,476
+ ,476
+ ,461
+ ,462
+ ,453
+ ,0
+ ,471
+ ,476
+ ,476
+ ,461
+ ,443
+ ,0
+ ,453
+ ,471
+ ,476
+ ,476
+ ,442
+ ,0
+ ,443
+ ,453
+ ,471
+ ,476
+ ,444
+ ,0
+ ,442
+ ,443
+ ,453
+ ,471
+ ,438
+ ,0
+ ,444
+ ,442
+ ,443
+ ,453
+ ,427
+ ,0
+ ,438
+ ,444
+ ,442
+ ,443
+ ,424
+ ,0
+ ,427
+ ,438
+ ,444
+ ,442
+ ,416
+ ,0
+ ,424
+ ,427
+ ,438
+ ,444
+ ,406
+ ,0
+ ,416
+ ,424
+ ,427
+ ,438
+ ,431
+ ,0
+ ,406
+ ,416
+ ,424
+ ,427
+ ,434
+ ,0
+ ,431
+ ,406
+ ,416
+ ,424
+ ,418
+ ,0
+ ,434
+ ,431
+ ,406
+ ,416
+ ,412
+ ,0
+ ,418
+ ,434
+ ,431
+ ,406
+ ,404
+ ,0
+ ,412
+ ,418
+ ,434
+ ,431
+ ,409
+ ,0
+ ,404
+ ,412
+ ,418
+ ,434
+ ,412
+ ,1
+ ,409
+ ,404
+ ,412
+ ,418
+ ,406
+ ,1
+ ,412
+ ,409
+ ,404
+ ,412
+ ,398
+ ,1
+ ,406
+ ,412
+ ,409
+ ,404
+ ,397
+ ,1
+ ,398
+ ,406
+ ,412
+ ,409
+ ,385
+ ,1
+ ,397
+ ,398
+ ,406
+ ,412
+ ,390
+ ,1
+ ,385
+ ,397
+ ,398
+ ,406
+ ,413
+ ,1
+ ,390
+ ,385
+ ,397
+ ,398
+ ,413
+ ,1
+ ,413
+ ,390
+ ,385
+ ,397
+ ,401
+ ,1
+ ,413
+ ,413
+ ,390
+ ,385
+ ,397
+ ,1
+ ,401
+ ,413
+ ,413
+ ,390
+ ,397
+ ,1
+ ,397
+ ,401
+ ,413
+ ,413
+ ,409
+ ,1
+ ,397
+ ,397
+ ,401
+ ,413
+ ,419
+ ,1
+ ,409
+ ,397
+ ,397
+ ,401
+ ,424
+ ,1
+ ,419
+ ,409
+ ,397
+ ,397
+ ,428
+ ,1
+ ,424
+ ,419
+ ,409
+ ,397
+ ,430
+ ,1
+ ,428
+ ,424
+ ,419
+ ,409
+ ,424
+ ,1
+ ,430
+ ,428
+ ,424
+ ,419
+ ,433
+ ,1
+ ,424
+ ,430
+ ,428
+ ,424
+ ,456
+ ,1
+ ,433
+ ,424
+ ,430
+ ,428
+ ,459
+ ,1
+ ,456
+ ,433
+ ,424
+ ,430)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 461 0 455 462 452 449 1 0 0 0 0 0 0 0 0 0 0 1
2 461 0 461 455 462 452 0 1 0 0 0 0 0 0 0 0 0 2
3 463 0 461 461 455 462 0 0 1 0 0 0 0 0 0 0 0 3
4 462 0 463 461 461 455 0 0 0 1 0 0 0 0 0 0 0 4
5 456 0 462 463 461 461 0 0 0 0 1 0 0 0 0 0 0 5
6 455 0 456 462 463 461 0 0 0 0 0 1 0 0 0 0 0 6
7 456 0 455 456 462 463 0 0 0 0 0 0 1 0 0 0 0 7
8 472 0 456 455 456 462 0 0 0 0 0 0 0 1 0 0 0 8
9 472 0 472 456 455 456 0 0 0 0 0 0 0 0 1 0 0 9
10 471 0 472 472 456 455 0 0 0 0 0 0 0 0 0 1 0 10
11 465 0 471 472 472 456 0 0 0 0 0 0 0 0 0 0 1 11
12 459 0 465 471 472 472 0 0 0 0 0 0 0 0 0 0 0 12
13 465 0 459 465 471 472 1 0 0 0 0 0 0 0 0 0 0 13
14 468 0 465 459 465 471 0 1 0 0 0 0 0 0 0 0 0 14
15 467 0 468 465 459 465 0 0 1 0 0 0 0 0 0 0 0 15
16 463 0 467 468 465 459 0 0 0 1 0 0 0 0 0 0 0 16
17 460 0 463 467 468 465 0 0 0 0 1 0 0 0 0 0 0 17
18 462 0 460 463 467 468 0 0 0 0 0 1 0 0 0 0 0 18
19 461 0 462 460 463 467 0 0 0 0 0 0 1 0 0 0 0 19
20 476 0 461 462 460 463 0 0 0 0 0 0 0 1 0 0 0 20
21 476 0 476 461 462 460 0 0 0 0 0 0 0 0 1 0 0 21
22 471 0 476 476 461 462 0 0 0 0 0 0 0 0 0 1 0 22
23 453 0 471 476 476 461 0 0 0 0 0 0 0 0 0 0 1 23
24 443 0 453 471 476 476 0 0 0 0 0 0 0 0 0 0 0 24
25 442 0 443 453 471 476 1 0 0 0 0 0 0 0 0 0 0 25
26 444 0 442 443 453 471 0 1 0 0 0 0 0 0 0 0 0 26
27 438 0 444 442 443 453 0 0 1 0 0 0 0 0 0 0 0 27
28 427 0 438 444 442 443 0 0 0 1 0 0 0 0 0 0 0 28
29 424 0 427 438 444 442 0 0 0 0 1 0 0 0 0 0 0 29
30 416 0 424 427 438 444 0 0 0 0 0 1 0 0 0 0 0 30
31 406 0 416 424 427 438 0 0 0 0 0 0 1 0 0 0 0 31
32 431 0 406 416 424 427 0 0 0 0 0 0 0 1 0 0 0 32
33 434 0 431 406 416 424 0 0 0 0 0 0 0 0 1 0 0 33
34 418 0 434 431 406 416 0 0 0 0 0 0 0 0 0 1 0 34
35 412 0 418 434 431 406 0 0 0 0 0 0 0 0 0 0 1 35
36 404 0 412 418 434 431 0 0 0 0 0 0 0 0 0 0 0 36
37 409 0 404 412 418 434 1 0 0 0 0 0 0 0 0 0 0 37
38 412 1 409 404 412 418 0 1 0 0 0 0 0 0 0 0 0 38
39 406 1 412 409 404 412 0 0 1 0 0 0 0 0 0 0 0 39
40 398 1 406 412 409 404 0 0 0 1 0 0 0 0 0 0 0 40
41 397 1 398 406 412 409 0 0 0 0 1 0 0 0 0 0 0 41
42 385 1 397 398 406 412 0 0 0 0 0 1 0 0 0 0 0 42
43 390 1 385 397 398 406 0 0 0 0 0 0 1 0 0 0 0 43
44 413 1 390 385 397 398 0 0 0 0 0 0 0 1 0 0 0 44
45 413 1 413 390 385 397 0 0 0 0 0 0 0 0 1 0 0 45
46 401 1 413 413 390 385 0 0 0 0 0 0 0 0 0 1 0 46
47 397 1 401 413 413 390 0 0 0 0 0 0 0 0 0 0 1 47
48 397 1 397 401 413 413 0 0 0 0 0 0 0 0 0 0 0 48
49 409 1 397 397 401 413 1 0 0 0 0 0 0 0 0 0 0 49
50 419 1 409 397 397 401 0 1 0 0 0 0 0 0 0 0 0 50
51 424 1 419 409 397 397 0 0 1 0 0 0 0 0 0 0 0 51
52 428 1 424 419 409 397 0 0 0 1 0 0 0 0 0 0 0 52
53 430 1 428 424 419 409 0 0 0 0 1 0 0 0 0 0 0 53
54 424 1 430 428 424 419 0 0 0 0 0 1 0 0 0 0 0 54
55 433 1 424 430 428 424 0 0 0 0 0 0 1 0 0 0 0 55
56 456 1 433 424 430 428 0 0 0 0 0 0 0 1 0 0 0 56
57 459 1 456 433 424 430 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
-5.3282634 2.3429505 1.0940497 -0.1034360 0.2908540 -0.2831793
M1 M2 M3 M4 M5 M6
13.4961063 9.4993273 5.3834289 -0.3164305 2.2737802 0.6348210
M7 M8 M9 M10 M11 t
7.5005164 26.0146635 5.8094784 -2.5723375 -7.7942725 0.0005948
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-7.8539 -2.3150 0.2389 3.4870 8.0098
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.3282634 24.8394648 -0.215 0.831269
X 2.3429505 3.0938379 0.757 0.453424
Y1 1.0940497 0.1522735 7.185 1.20e-08 ***
Y2 -0.1034360 0.2132358 -0.485 0.630335
Y3 0.2908540 0.2102299 1.384 0.174379
Y4 -0.2831793 0.1432580 -1.977 0.055176 .
M1 13.4961063 3.4762559 3.882 0.000389 ***
M2 9.4993273 4.0243679 2.360 0.023348 *
M3 5.3834289 4.3499208 1.238 0.223267
M4 -0.3164305 3.7680090 -0.084 0.933503
M5 2.2737802 3.4234505 0.664 0.510484
M6 0.6348210 3.4287973 0.185 0.854076
M7 7.5005164 3.4750341 2.158 0.037112 *
M8 26.0146635 3.5943724 7.238 1.01e-08 ***
M9 5.8094784 5.6404310 1.030 0.309369
M10 -2.5723375 5.4159762 -0.475 0.637469
M11 -7.7942725 4.4010377 -1.771 0.084375 .
t 0.0005948 0.0831634 0.007 0.994330
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.801 on 39 degrees of freedom
Multiple R-squared: 0.9777, Adjusted R-squared: 0.968
F-statistic: 100.5 on 17 and 39 DF, p-value: < 2.2e-16
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.01427828 0.02855655 0.98572172
[2,] 0.09017918 0.18035836 0.90982082
[3,] 0.58069887 0.83860225 0.41930113
[4,] 0.51823952 0.96352097 0.48176048
[5,] 0.40905034 0.81810069 0.59094966
[6,] 0.39172870 0.78345741 0.60827130
[7,] 0.29225806 0.58451612 0.70774194
[8,] 0.20075352 0.40150703 0.79924648
[9,] 0.34505764 0.69011528 0.65494236
[10,] 0.44489227 0.88978454 0.55510773
[11,] 0.56302185 0.87395629 0.43697815
[12,] 0.93568560 0.12862881 0.06431440
[13,] 0.93580754 0.12838492 0.06419246
[14,] 0.93808004 0.12383992 0.06191996
[15,] 0.94071175 0.11857650 0.05928825
[16,] 0.86966286 0.26067428 0.13033714
> postscript(file="/var/www/html/rcomp/tmp/14kbs1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2rt4k1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3qi1d1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4zf3o1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5xt451258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 57
Frequency = 1
1 2 3 4 5 6
-1.49213855 -6.84330635 4.76038363 3.54416999 -2.04663811 4.47088066
7 8 9 10 11 12
-0.06476311 -2.31504627 -0.92003740 7.54212593 3.48703174 0.68389535
13 14 15 16 17 18
-0.57826926 0.69494516 1.19476346 0.85418620 0.36265748 8.00981890
19 20 21 22 23 24
-1.47464211 -3.94861764 -1.68945502 4.10051812 -7.85388177 -2.22534458
25 26 27 28 29 30
-6.18912607 3.68622299 -2.67869634 -3.74920032 1.20903819 -0.69676165
31 32 33 34 35 36
-7.62064407 6.73521327 3.03149450 -4.64042903 2.29287283 -2.38575143
37 38 39 40 41 42
2.75253069 -1.67771683 -5.69962658 -4.84545980 0.23885126 -7.26156084
43 44 45 46 47 48
4.52506570 0.32426317 -0.91004218 -7.00221503 2.07397719 3.92720066
49 50 51 52 53 54
5.50700320 4.13985503 2.42317584 4.19630393 0.23609118 -4.52237707
55 56 57
4.63498359 -0.79581252 0.48804009
> postscript(file="/var/www/html/rcomp/tmp/6xvfk1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.49213855 NA
1 -6.84330635 -1.49213855
2 4.76038363 -6.84330635
3 3.54416999 4.76038363
4 -2.04663811 3.54416999
5 4.47088066 -2.04663811
6 -0.06476311 4.47088066
7 -2.31504627 -0.06476311
8 -0.92003740 -2.31504627
9 7.54212593 -0.92003740
10 3.48703174 7.54212593
11 0.68389535 3.48703174
12 -0.57826926 0.68389535
13 0.69494516 -0.57826926
14 1.19476346 0.69494516
15 0.85418620 1.19476346
16 0.36265748 0.85418620
17 8.00981890 0.36265748
18 -1.47464211 8.00981890
19 -3.94861764 -1.47464211
20 -1.68945502 -3.94861764
21 4.10051812 -1.68945502
22 -7.85388177 4.10051812
23 -2.22534458 -7.85388177
24 -6.18912607 -2.22534458
25 3.68622299 -6.18912607
26 -2.67869634 3.68622299
27 -3.74920032 -2.67869634
28 1.20903819 -3.74920032
29 -0.69676165 1.20903819
30 -7.62064407 -0.69676165
31 6.73521327 -7.62064407
32 3.03149450 6.73521327
33 -4.64042903 3.03149450
34 2.29287283 -4.64042903
35 -2.38575143 2.29287283
36 2.75253069 -2.38575143
37 -1.67771683 2.75253069
38 -5.69962658 -1.67771683
39 -4.84545980 -5.69962658
40 0.23885126 -4.84545980
41 -7.26156084 0.23885126
42 4.52506570 -7.26156084
43 0.32426317 4.52506570
44 -0.91004218 0.32426317
45 -7.00221503 -0.91004218
46 2.07397719 -7.00221503
47 3.92720066 2.07397719
48 5.50700320 3.92720066
49 4.13985503 5.50700320
50 2.42317584 4.13985503
51 4.19630393 2.42317584
52 0.23609118 4.19630393
53 -4.52237707 0.23609118
54 4.63498359 -4.52237707
55 -0.79581252 4.63498359
56 0.48804009 -0.79581252
57 NA 0.48804009
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -6.84330635 -1.49213855
[2,] 4.76038363 -6.84330635
[3,] 3.54416999 4.76038363
[4,] -2.04663811 3.54416999
[5,] 4.47088066 -2.04663811
[6,] -0.06476311 4.47088066
[7,] -2.31504627 -0.06476311
[8,] -0.92003740 -2.31504627
[9,] 7.54212593 -0.92003740
[10,] 3.48703174 7.54212593
[11,] 0.68389535 3.48703174
[12,] -0.57826926 0.68389535
[13,] 0.69494516 -0.57826926
[14,] 1.19476346 0.69494516
[15,] 0.85418620 1.19476346
[16,] 0.36265748 0.85418620
[17,] 8.00981890 0.36265748
[18,] -1.47464211 8.00981890
[19,] -3.94861764 -1.47464211
[20,] -1.68945502 -3.94861764
[21,] 4.10051812 -1.68945502
[22,] -7.85388177 4.10051812
[23,] -2.22534458 -7.85388177
[24,] -6.18912607 -2.22534458
[25,] 3.68622299 -6.18912607
[26,] -2.67869634 3.68622299
[27,] -3.74920032 -2.67869634
[28,] 1.20903819 -3.74920032
[29,] -0.69676165 1.20903819
[30,] -7.62064407 -0.69676165
[31,] 6.73521327 -7.62064407
[32,] 3.03149450 6.73521327
[33,] -4.64042903 3.03149450
[34,] 2.29287283 -4.64042903
[35,] -2.38575143 2.29287283
[36,] 2.75253069 -2.38575143
[37,] -1.67771683 2.75253069
[38,] -5.69962658 -1.67771683
[39,] -4.84545980 -5.69962658
[40,] 0.23885126 -4.84545980
[41,] -7.26156084 0.23885126
[42,] 4.52506570 -7.26156084
[43,] 0.32426317 4.52506570
[44,] -0.91004218 0.32426317
[45,] -7.00221503 -0.91004218
[46,] 2.07397719 -7.00221503
[47,] 3.92720066 2.07397719
[48,] 5.50700320 3.92720066
[49,] 4.13985503 5.50700320
[50,] 2.42317584 4.13985503
[51,] 4.19630393 2.42317584
[52,] 0.23609118 4.19630393
[53,] -4.52237707 0.23609118
[54,] 4.63498359 -4.52237707
[55,] -0.79581252 4.63498359
[56,] 0.48804009 -0.79581252
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -6.84330635 -1.49213855
2 4.76038363 -6.84330635
3 3.54416999 4.76038363
4 -2.04663811 3.54416999
5 4.47088066 -2.04663811
6 -0.06476311 4.47088066
7 -2.31504627 -0.06476311
8 -0.92003740 -2.31504627
9 7.54212593 -0.92003740
10 3.48703174 7.54212593
11 0.68389535 3.48703174
12 -0.57826926 0.68389535
13 0.69494516 -0.57826926
14 1.19476346 0.69494516
15 0.85418620 1.19476346
16 0.36265748 0.85418620
17 8.00981890 0.36265748
18 -1.47464211 8.00981890
19 -3.94861764 -1.47464211
20 -1.68945502 -3.94861764
21 4.10051812 -1.68945502
22 -7.85388177 4.10051812
23 -2.22534458 -7.85388177
24 -6.18912607 -2.22534458
25 3.68622299 -6.18912607
26 -2.67869634 3.68622299
27 -3.74920032 -2.67869634
28 1.20903819 -3.74920032
29 -0.69676165 1.20903819
30 -7.62064407 -0.69676165
31 6.73521327 -7.62064407
32 3.03149450 6.73521327
33 -4.64042903 3.03149450
34 2.29287283 -4.64042903
35 -2.38575143 2.29287283
36 2.75253069 -2.38575143
37 -1.67771683 2.75253069
38 -5.69962658 -1.67771683
39 -4.84545980 -5.69962658
40 0.23885126 -4.84545980
41 -7.26156084 0.23885126
42 4.52506570 -7.26156084
43 0.32426317 4.52506570
44 -0.91004218 0.32426317
45 -7.00221503 -0.91004218
46 2.07397719 -7.00221503
47 3.92720066 2.07397719
48 5.50700320 3.92720066
49 4.13985503 5.50700320
50 2.42317584 4.13985503
51 4.19630393 2.42317584
52 0.23609118 4.19630393
53 -4.52237707 0.23609118
54 4.63498359 -4.52237707
55 -0.79581252 4.63498359
56 0.48804009 -0.79581252
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7qzbs1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8c61l1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9btwk1258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10bi601258660680.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11a9n91258660680.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/12zaq01258660680.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/13ief41258660680.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/14tty91258660680.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/15hh1i1258660680.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/16drll1258660680.tab")
+ }
>
> system("convert tmp/14kbs1258660680.ps tmp/14kbs1258660680.png")
> system("convert tmp/2rt4k1258660680.ps tmp/2rt4k1258660680.png")
> system("convert tmp/3qi1d1258660680.ps tmp/3qi1d1258660680.png")
> system("convert tmp/4zf3o1258660680.ps tmp/4zf3o1258660680.png")
> system("convert tmp/5xt451258660680.ps tmp/5xt451258660680.png")
> system("convert tmp/6xvfk1258660680.ps tmp/6xvfk1258660680.png")
> system("convert tmp/7qzbs1258660680.ps tmp/7qzbs1258660680.png")
> system("convert tmp/8c61l1258660680.ps tmp/8c61l1258660680.png")
> system("convert tmp/9btwk1258660680.ps tmp/9btwk1258660680.png")
> system("convert tmp/10bi601258660680.ps tmp/10bi601258660680.png")
>
>
> proc.time()
user system elapsed
2.337 1.561 2.739