R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(5.50
+ ,518
+ ,117
+ ,401
+ ,5.40
+ ,534
+ ,120
+ ,413
+ ,5.90
+ ,528
+ ,116
+ ,413
+ ,5.80
+ ,478
+ ,87
+ ,390
+ ,5.10
+ ,469
+ ,84
+ ,385
+ ,4.10
+ ,490
+ ,93
+ ,397
+ ,4.40
+ ,493
+ ,95
+ ,398
+ ,3.60
+ ,508
+ ,101
+ ,406
+ ,3.50
+ ,517
+ ,105
+ ,412
+ ,3.10
+ ,514
+ ,105
+ ,409
+ ,2.90
+ ,510
+ ,106
+ ,404
+ ,2.20
+ ,527
+ ,115
+ ,412
+ ,1.40
+ ,542
+ ,124
+ ,418
+ ,1.20
+ ,565
+ ,130
+ ,434
+ ,1.30
+ ,555
+ ,124
+ ,431
+ ,1.30
+ ,499
+ ,93
+ ,406
+ ,1.30
+ ,511
+ ,95
+ ,416
+ ,1.80
+ ,526
+ ,102
+ ,424
+ ,1.80
+ ,532
+ ,105
+ ,427
+ ,1.80
+ ,549
+ ,111
+ ,438
+ ,1.70
+ ,561
+ ,117
+ ,444
+ ,2.10
+ ,557
+ ,116
+ ,442
+ ,2.00
+ ,566
+ ,123
+ ,443
+ ,1.70
+ ,588
+ ,134
+ ,453
+ ,1.90
+ ,620
+ ,149
+ ,471
+ ,2.30
+ ,626
+ ,150
+ ,476
+ ,2.40
+ ,620
+ ,144
+ ,476
+ ,2.50
+ ,573
+ ,112
+ ,461
+ ,2.80
+ ,573
+ ,111
+ ,462
+ ,2.60
+ ,574
+ ,114
+ ,460
+ ,2.20
+ ,580
+ ,117
+ ,463
+ ,2.80
+ ,590
+ ,123
+ ,467
+ ,2.80
+ ,593
+ ,125
+ ,468
+ ,2.80
+ ,597
+ ,132
+ ,465
+ ,2.30
+ ,595
+ ,137
+ ,459
+ ,2.20
+ ,612
+ ,147
+ ,465
+ ,3.00
+ ,628
+ ,157
+ ,471
+ ,2.90
+ ,629
+ ,157
+ ,472
+ ,2.70
+ ,621
+ ,149
+ ,472
+ ,2.70
+ ,569
+ ,113
+ ,456
+ ,2.30
+ ,567
+ ,112
+ ,455
+ ,2.40
+ ,573
+ ,117
+ ,456
+ ,2.80
+ ,584
+ ,122
+ ,462
+ ,2.30
+ ,589
+ ,127
+ ,463
+ ,2.00
+ ,591
+ ,130
+ ,461
+ ,1.90
+ ,595
+ ,135
+ ,461
+ ,2.30
+ ,594
+ ,139
+ ,455
+ ,2.70
+ ,611
+ ,149
+ ,462
+ ,1.80
+ ,613
+ ,161
+ ,452
+ ,2.00
+ ,611
+ ,162
+ ,449
+ ,2.10
+ ,594
+ ,153
+ ,441
+ ,2.00
+ ,543
+ ,116
+ ,427
+ ,2.40
+ ,537
+ ,114
+ ,423
+ ,1.70
+ ,544
+ ,120
+ ,424
+ ,1.00
+ ,555
+ ,126
+ ,430
+ ,1.20
+ ,561
+ ,133
+ ,428
+ ,1.40
+ ,562
+ ,136
+ ,426
+ ,1.70
+ ,555
+ ,137
+ ,418
+ ,1.80
+ ,547
+ ,138
+ ,410
+ ,1.40
+ ,565
+ ,148
+ ,418
+ ,1.70
+ ,578
+ ,158
+ ,420
+ ,1.60
+ ,580
+ ,159
+ ,421
+ ,1.40
+ ,569
+ ,151
+ ,419
+ ,1.50
+ ,507
+ ,111
+ ,396
+ ,0.90
+ ,501
+ ,108
+ ,392
+ ,1.50
+ ,509
+ ,114
+ ,396
+ ,1.70
+ ,510
+ ,118
+ ,392
+ ,1.60
+ ,517
+ ,123
+ ,394
+ ,1.20
+ ,519
+ ,127
+ ,392)
+ ,dim=c(4
+ ,69)
+ ,dimnames=list(c('HIPC'
+ ,'Werkloosheid'
+ ,'minder25jaar'
+ ,'meer25jaar')
+ ,1:69))
> y <- array(NA,dim=c(4,69),dimnames=list(c('HIPC','Werkloosheid','minder25jaar','meer25jaar'),1:69))
> 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 = '2'
> #'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
> 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
Werkloosheid HIPC minder25jaar meer25jaar M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 518 5.5 117 401 1 0 0 0 0 0 0 0 0 0 0
2 534 5.4 120 413 0 1 0 0 0 0 0 0 0 0 0
3 528 5.9 116 413 0 0 1 0 0 0 0 0 0 0 0
4 478 5.8 87 390 0 0 0 1 0 0 0 0 0 0 0
5 469 5.1 84 385 0 0 0 0 1 0 0 0 0 0 0
6 490 4.1 93 397 0 0 0 0 0 1 0 0 0 0 0
7 493 4.4 95 398 0 0 0 0 0 0 1 0 0 0 0
8 508 3.6 101 406 0 0 0 0 0 0 0 1 0 0 0
9 517 3.5 105 412 0 0 0 0 0 0 0 0 1 0 0
10 514 3.1 105 409 0 0 0 0 0 0 0 0 0 1 0
11 510 2.9 106 404 0 0 0 0 0 0 0 0 0 0 1
12 527 2.2 115 412 0 0 0 0 0 0 0 0 0 0 0
13 542 1.4 124 418 1 0 0 0 0 0 0 0 0 0 0
14 565 1.2 130 434 0 1 0 0 0 0 0 0 0 0 0
15 555 1.3 124 431 0 0 1 0 0 0 0 0 0 0 0
16 499 1.3 93 406 0 0 0 1 0 0 0 0 0 0 0
17 511 1.3 95 416 0 0 0 0 1 0 0 0 0 0 0
18 526 1.8 102 424 0 0 0 0 0 1 0 0 0 0 0
19 532 1.8 105 427 0 0 0 0 0 0 1 0 0 0 0
20 549 1.8 111 438 0 0 0 0 0 0 0 1 0 0 0
21 561 1.7 117 444 0 0 0 0 0 0 0 0 1 0 0
22 557 2.1 116 442 0 0 0 0 0 0 0 0 0 1 0
23 566 2.0 123 443 0 0 0 0 0 0 0 0 0 0 1
24 588 1.7 134 453 0 0 0 0 0 0 0 0 0 0 0
25 620 1.9 149 471 1 0 0 0 0 0 0 0 0 0 0
26 626 2.3 150 476 0 1 0 0 0 0 0 0 0 0 0
27 620 2.4 144 476 0 0 1 0 0 0 0 0 0 0 0
28 573 2.5 112 461 0 0 0 1 0 0 0 0 0 0 0
29 573 2.8 111 462 0 0 0 0 1 0 0 0 0 0 0
30 574 2.6 114 460 0 0 0 0 0 1 0 0 0 0 0
31 580 2.2 117 463 0 0 0 0 0 0 1 0 0 0 0
32 590 2.8 123 467 0 0 0 0 0 0 0 1 0 0 0
33 593 2.8 125 468 0 0 0 0 0 0 0 0 1 0 0
34 597 2.8 132 465 0 0 0 0 0 0 0 0 0 1 0
35 595 2.3 137 459 0 0 0 0 0 0 0 0 0 0 1
36 612 2.2 147 465 0 0 0 0 0 0 0 0 0 0 0
37 628 3.0 157 471 1 0 0 0 0 0 0 0 0 0 0
38 629 2.9 157 472 0 1 0 0 0 0 0 0 0 0 0
39 621 2.7 149 472 0 0 1 0 0 0 0 0 0 0 0
40 569 2.7 113 456 0 0 0 1 0 0 0 0 0 0 0
41 567 2.3 112 455 0 0 0 0 1 0 0 0 0 0 0
42 573 2.4 117 456 0 0 0 0 0 1 0 0 0 0 0
43 584 2.8 122 462 0 0 0 0 0 0 1 0 0 0 0
44 589 2.3 127 463 0 0 0 0 0 0 0 1 0 0 0
45 591 2.0 130 461 0 0 0 0 0 0 0 0 1 0 0
46 595 1.9 135 461 0 0 0 0 0 0 0 0 0 1 0
47 594 2.3 139 455 0 0 0 0 0 0 0 0 0 0 1
48 611 2.7 149 462 0 0 0 0 0 0 0 0 0 0 0
49 613 1.8 161 452 1 0 0 0 0 0 0 0 0 0 0
50 611 2.0 162 449 0 1 0 0 0 0 0 0 0 0 0
51 594 2.1 153 441 0 0 1 0 0 0 0 0 0 0 0
52 543 2.0 116 427 0 0 0 1 0 0 0 0 0 0 0
53 537 2.4 114 423 0 0 0 0 1 0 0 0 0 0 0
54 544 1.7 120 424 0 0 0 0 0 1 0 0 0 0 0
55 555 1.0 126 430 0 0 0 0 0 0 1 0 0 0 0
56 561 1.2 133 428 0 0 0 0 0 0 0 1 0 0 0
57 562 1.4 136 426 0 0 0 0 0 0 0 0 1 0 0
58 555 1.7 137 418 0 0 0 0 0 0 0 0 0 1 0
59 547 1.8 138 410 0 0 0 0 0 0 0 0 0 0 1
60 565 1.4 148 418 0 0 0 0 0 0 0 0 0 0 0
61 578 1.7 158 420 1 0 0 0 0 0 0 0 0 0 0
62 580 1.6 159 421 0 1 0 0 0 0 0 0 0 0 0
63 569 1.4 151 419 0 0 1 0 0 0 0 0 0 0 0
64 507 1.5 111 396 0 0 0 1 0 0 0 0 0 0 0
65 501 0.9 108 392 0 0 0 0 1 0 0 0 0 0 0
66 509 1.5 114 396 0 0 0 0 0 1 0 0 0 0 0
67 510 1.7 118 392 0 0 0 0 0 0 1 0 0 0 0
68 517 1.6 123 394 0 0 0 0 0 0 0 1 0 0 0
69 519 1.2 127 392 0 0 0 0 0 0 0 0 1 0 0
t
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 51
52 52
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
61 61
62 62
63 63
64 64
65 65
66 66
67 67
68 68
69 69
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) HIPC minder25jaar meer25jaar M1
0.973216 -0.017335 0.995653 0.999675 0.006112
M2 M3 M4 M5 M6
0.355486 -0.335110 0.015405 0.011882 -0.290766
M7 M8 M9 M10 M11
-0.268543 -0.071627 -0.052006 -0.465891 -0.447517
t
-0.005325
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.92487 -0.22227 0.00381 0.19830 0.97350
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.973216 1.065650 0.913 0.365
HIPC -0.017335 0.064410 -0.269 0.789
minder25jaar 0.995653 0.019057 52.247 <2e-16 ***
meer25jaar 0.999675 0.004868 205.346 <2e-16 ***
M1 0.006112 0.323953 0.019 0.985
M2 0.355486 0.326402 1.089 0.281
M3 -0.335110 0.280026 -1.197 0.237
M4 0.015405 0.603999 0.026 0.980
M5 0.011882 0.632036 0.019 0.985
M6 -0.290766 0.553903 -0.525 0.602
M7 -0.268543 0.509189 -0.527 0.600
M8 -0.071627 0.440209 -0.163 0.871
M9 -0.052006 0.398167 -0.131 0.897
M10 -0.465891 0.367350 -1.268 0.210
M11 -0.447517 0.323998 -1.381 0.173
t -0.005325 0.010974 -0.485 0.630
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4542 on 53 degrees of freedom
Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
F-statistic: 3.601e+04 on 15 and 53 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.66883573 0.66232853 0.3311643
[2,] 0.61356267 0.77287466 0.3864373
[3,] 0.47395707 0.94791415 0.5260429
[4,] 0.49809030 0.99618061 0.5019097
[5,] 0.40980805 0.81961610 0.5901919
[6,] 0.41016225 0.82032449 0.5898378
[7,] 0.49448922 0.98897844 0.5055108
[8,] 0.54531544 0.90936912 0.4546846
[9,] 0.61548406 0.76903187 0.3845159
[10,] 0.51551183 0.96897635 0.4844882
[11,] 0.52937567 0.94124867 0.4706243
[12,] 0.52941859 0.94116282 0.4705814
[13,] 0.46341785 0.92683570 0.5365822
[14,] 0.37368610 0.74737220 0.6263139
[15,] 0.31602619 0.63205238 0.6839738
[16,] 0.25558586 0.51117172 0.7444141
[17,] 0.35956423 0.71912846 0.6404358
[18,] 0.29475662 0.58951324 0.7052434
[19,] 0.24120298 0.48240596 0.7587970
[20,] 0.18533732 0.37067464 0.8146627
[21,] 0.17878519 0.35757038 0.8212148
[22,] 0.12292982 0.24585963 0.8770702
[23,] 0.09871955 0.19743911 0.9012804
[24,] 0.07134692 0.14269384 0.9286531
[25,] 0.04818970 0.09637941 0.9518103
[26,] 0.12363610 0.24727220 0.8763639
[27,] 0.08743525 0.17487049 0.9125648
[28,] 0.26531618 0.53063237 0.7346838
[29,] 0.21661972 0.43323945 0.7833803
[30,] 0.86371423 0.27257153 0.1362858
[31,] 0.86820028 0.26359945 0.1317997
[32,] 0.74362262 0.51275475 0.2563774
> postscript(file="/var/wessaorg/rcomp/tmp/1a1zk1324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2yljv1324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3owzd1324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4ikr51324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/574pp1324308235.ps",horizontal=F,onefile=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 = 69
Frequency = 1
1 2 3 4 5 6
-0.239720274 0.431437732 -0.881362607 0.638172319 -0.379780902 -0.046119077
7 8 9 10 11 12
-0.048797856 0.774425265 -0.222265934 0.189035241 0.175240776 -0.237362308
13 14 15 16 17 18
-0.210943364 0.472822479 0.143418758 -0.344657028 -0.323864887 0.025805697
19 20 21 22 23 24
0.022923441 -0.139010165 -0.127007119 -0.705859795 0.310112012 0.913787309
25 26 27 28 29 30
-0.012475663 -0.343619240 0.327952042 -0.159487322 -0.149460955 0.167436395
31 32 33 34 35 36
0.157620003 0.003812593 -0.001464321 0.447200843 -0.554730736 0.046764503
37 38 39 40 41 42
0.105267111 -0.240191261 0.417485175 -0.089401212 -0.092159584 0.239607614
43 44 45 46 47 48
0.253328740 -0.924869666 0.068024937 -0.492762674 0.516560430 0.127048338
49 50 51 52 53 54
0.159575099 -0.177635553 0.478294355 -0.034022686 -0.028234913 0.294011137
55 56 57 58 59 60
-0.706989487 0.134666084 0.136228356 0.562386385 -0.447182482 -0.850237843
61 62 63 64 65 66
0.198297092 -0.142814157 -0.485787723 -0.010604072 0.973501241 -0.680741766
67 68 69
0.321915160 0.150975889 0.146484081
> postscript(file="/var/wessaorg/rcomp/tmp/68v881324308235.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 69
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.239720274 NA
1 0.431437732 -0.239720274
2 -0.881362607 0.431437732
3 0.638172319 -0.881362607
4 -0.379780902 0.638172319
5 -0.046119077 -0.379780902
6 -0.048797856 -0.046119077
7 0.774425265 -0.048797856
8 -0.222265934 0.774425265
9 0.189035241 -0.222265934
10 0.175240776 0.189035241
11 -0.237362308 0.175240776
12 -0.210943364 -0.237362308
13 0.472822479 -0.210943364
14 0.143418758 0.472822479
15 -0.344657028 0.143418758
16 -0.323864887 -0.344657028
17 0.025805697 -0.323864887
18 0.022923441 0.025805697
19 -0.139010165 0.022923441
20 -0.127007119 -0.139010165
21 -0.705859795 -0.127007119
22 0.310112012 -0.705859795
23 0.913787309 0.310112012
24 -0.012475663 0.913787309
25 -0.343619240 -0.012475663
26 0.327952042 -0.343619240
27 -0.159487322 0.327952042
28 -0.149460955 -0.159487322
29 0.167436395 -0.149460955
30 0.157620003 0.167436395
31 0.003812593 0.157620003
32 -0.001464321 0.003812593
33 0.447200843 -0.001464321
34 -0.554730736 0.447200843
35 0.046764503 -0.554730736
36 0.105267111 0.046764503
37 -0.240191261 0.105267111
38 0.417485175 -0.240191261
39 -0.089401212 0.417485175
40 -0.092159584 -0.089401212
41 0.239607614 -0.092159584
42 0.253328740 0.239607614
43 -0.924869666 0.253328740
44 0.068024937 -0.924869666
45 -0.492762674 0.068024937
46 0.516560430 -0.492762674
47 0.127048338 0.516560430
48 0.159575099 0.127048338
49 -0.177635553 0.159575099
50 0.478294355 -0.177635553
51 -0.034022686 0.478294355
52 -0.028234913 -0.034022686
53 0.294011137 -0.028234913
54 -0.706989487 0.294011137
55 0.134666084 -0.706989487
56 0.136228356 0.134666084
57 0.562386385 0.136228356
58 -0.447182482 0.562386385
59 -0.850237843 -0.447182482
60 0.198297092 -0.850237843
61 -0.142814157 0.198297092
62 -0.485787723 -0.142814157
63 -0.010604072 -0.485787723
64 0.973501241 -0.010604072
65 -0.680741766 0.973501241
66 0.321915160 -0.680741766
67 0.150975889 0.321915160
68 0.146484081 0.150975889
69 NA 0.146484081
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.431437732 -0.239720274
[2,] -0.881362607 0.431437732
[3,] 0.638172319 -0.881362607
[4,] -0.379780902 0.638172319
[5,] -0.046119077 -0.379780902
[6,] -0.048797856 -0.046119077
[7,] 0.774425265 -0.048797856
[8,] -0.222265934 0.774425265
[9,] 0.189035241 -0.222265934
[10,] 0.175240776 0.189035241
[11,] -0.237362308 0.175240776
[12,] -0.210943364 -0.237362308
[13,] 0.472822479 -0.210943364
[14,] 0.143418758 0.472822479
[15,] -0.344657028 0.143418758
[16,] -0.323864887 -0.344657028
[17,] 0.025805697 -0.323864887
[18,] 0.022923441 0.025805697
[19,] -0.139010165 0.022923441
[20,] -0.127007119 -0.139010165
[21,] -0.705859795 -0.127007119
[22,] 0.310112012 -0.705859795
[23,] 0.913787309 0.310112012
[24,] -0.012475663 0.913787309
[25,] -0.343619240 -0.012475663
[26,] 0.327952042 -0.343619240
[27,] -0.159487322 0.327952042
[28,] -0.149460955 -0.159487322
[29,] 0.167436395 -0.149460955
[30,] 0.157620003 0.167436395
[31,] 0.003812593 0.157620003
[32,] -0.001464321 0.003812593
[33,] 0.447200843 -0.001464321
[34,] -0.554730736 0.447200843
[35,] 0.046764503 -0.554730736
[36,] 0.105267111 0.046764503
[37,] -0.240191261 0.105267111
[38,] 0.417485175 -0.240191261
[39,] -0.089401212 0.417485175
[40,] -0.092159584 -0.089401212
[41,] 0.239607614 -0.092159584
[42,] 0.253328740 0.239607614
[43,] -0.924869666 0.253328740
[44,] 0.068024937 -0.924869666
[45,] -0.492762674 0.068024937
[46,] 0.516560430 -0.492762674
[47,] 0.127048338 0.516560430
[48,] 0.159575099 0.127048338
[49,] -0.177635553 0.159575099
[50,] 0.478294355 -0.177635553
[51,] -0.034022686 0.478294355
[52,] -0.028234913 -0.034022686
[53,] 0.294011137 -0.028234913
[54,] -0.706989487 0.294011137
[55,] 0.134666084 -0.706989487
[56,] 0.136228356 0.134666084
[57,] 0.562386385 0.136228356
[58,] -0.447182482 0.562386385
[59,] -0.850237843 -0.447182482
[60,] 0.198297092 -0.850237843
[61,] -0.142814157 0.198297092
[62,] -0.485787723 -0.142814157
[63,] -0.010604072 -0.485787723
[64,] 0.973501241 -0.010604072
[65,] -0.680741766 0.973501241
[66,] 0.321915160 -0.680741766
[67,] 0.150975889 0.321915160
[68,] 0.146484081 0.150975889
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.431437732 -0.239720274
2 -0.881362607 0.431437732
3 0.638172319 -0.881362607
4 -0.379780902 0.638172319
5 -0.046119077 -0.379780902
6 -0.048797856 -0.046119077
7 0.774425265 -0.048797856
8 -0.222265934 0.774425265
9 0.189035241 -0.222265934
10 0.175240776 0.189035241
11 -0.237362308 0.175240776
12 -0.210943364 -0.237362308
13 0.472822479 -0.210943364
14 0.143418758 0.472822479
15 -0.344657028 0.143418758
16 -0.323864887 -0.344657028
17 0.025805697 -0.323864887
18 0.022923441 0.025805697
19 -0.139010165 0.022923441
20 -0.127007119 -0.139010165
21 -0.705859795 -0.127007119
22 0.310112012 -0.705859795
23 0.913787309 0.310112012
24 -0.012475663 0.913787309
25 -0.343619240 -0.012475663
26 0.327952042 -0.343619240
27 -0.159487322 0.327952042
28 -0.149460955 -0.159487322
29 0.167436395 -0.149460955
30 0.157620003 0.167436395
31 0.003812593 0.157620003
32 -0.001464321 0.003812593
33 0.447200843 -0.001464321
34 -0.554730736 0.447200843
35 0.046764503 -0.554730736
36 0.105267111 0.046764503
37 -0.240191261 0.105267111
38 0.417485175 -0.240191261
39 -0.089401212 0.417485175
40 -0.092159584 -0.089401212
41 0.239607614 -0.092159584
42 0.253328740 0.239607614
43 -0.924869666 0.253328740
44 0.068024937 -0.924869666
45 -0.492762674 0.068024937
46 0.516560430 -0.492762674
47 0.127048338 0.516560430
48 0.159575099 0.127048338
49 -0.177635553 0.159575099
50 0.478294355 -0.177635553
51 -0.034022686 0.478294355
52 -0.028234913 -0.034022686
53 0.294011137 -0.028234913
54 -0.706989487 0.294011137
55 0.134666084 -0.706989487
56 0.136228356 0.134666084
57 0.562386385 0.136228356
58 -0.447182482 0.562386385
59 -0.850237843 -0.447182482
60 0.198297092 -0.850237843
61 -0.142814157 0.198297092
62 -0.485787723 -0.142814157
63 -0.010604072 -0.485787723
64 0.973501241 -0.010604072
65 -0.680741766 0.973501241
66 0.321915160 -0.680741766
67 0.150975889 0.321915160
68 0.146484081 0.150975889
> 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/wessaorg/rcomp/tmp/7ekmm1324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/802sb1324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/94sv31324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10eey21324308235.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11axft1324308235.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/wessaorg/rcomp/tmp/12h7yp1324308235.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/wessaorg/rcomp/tmp/13bnfj1324308235.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/wessaorg/rcomp/tmp/14josy1324308235.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/wessaorg/rcomp/tmp/158el81324308235.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/wessaorg/rcomp/tmp/16hdkl1324308235.tab")
+ }
>
> try(system("convert tmp/1a1zk1324308235.ps tmp/1a1zk1324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/2yljv1324308235.ps tmp/2yljv1324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/3owzd1324308235.ps tmp/3owzd1324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ikr51324308235.ps tmp/4ikr51324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/574pp1324308235.ps tmp/574pp1324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/68v881324308235.ps tmp/68v881324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ekmm1324308235.ps tmp/7ekmm1324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/802sb1324308235.ps tmp/802sb1324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/94sv31324308235.ps tmp/94sv31324308235.png",intern=TRUE))
character(0)
> try(system("convert tmp/10eey21324308235.ps tmp/10eey21324308235.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.271 0.608 4.043