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(507
+ ,104.5
+ ,501
+ ,509
+ ,510
+ ,517
+ ,519
+ ,569
+ ,87.4
+ ,507
+ ,501
+ ,509
+ ,510
+ ,517
+ ,580
+ ,89.9
+ ,569
+ ,507
+ ,501
+ ,509
+ ,510
+ ,578
+ ,109.8
+ ,580
+ ,569
+ ,507
+ ,501
+ ,509
+ ,565
+ ,111.7
+ ,578
+ ,580
+ ,569
+ ,507
+ ,501
+ ,547
+ ,98.6
+ ,565
+ ,578
+ ,580
+ ,569
+ ,507
+ ,555
+ ,96.9
+ ,547
+ ,565
+ ,578
+ ,580
+ ,569
+ ,562
+ ,95.1
+ ,555
+ ,547
+ ,565
+ ,578
+ ,580
+ ,561
+ ,97
+ ,562
+ ,555
+ ,547
+ ,565
+ ,578
+ ,555
+ ,112.7
+ ,561
+ ,562
+ ,555
+ ,547
+ ,565
+ ,544
+ ,102.9
+ ,555
+ ,561
+ ,562
+ ,555
+ ,547
+ ,537
+ ,97.4
+ ,544
+ ,555
+ ,561
+ ,562
+ ,555
+ ,543
+ ,111.4
+ ,537
+ ,544
+ ,555
+ ,561
+ ,562
+ ,594
+ ,87.4
+ ,543
+ ,537
+ ,544
+ ,555
+ ,561
+ ,611
+ ,96.8
+ ,594
+ ,543
+ ,537
+ ,544
+ ,555
+ ,613
+ ,114.1
+ ,611
+ ,594
+ ,543
+ ,537
+ ,544
+ ,611
+ ,110.3
+ ,613
+ ,611
+ ,594
+ ,543
+ ,537
+ ,594
+ ,103.9
+ ,611
+ ,613
+ ,611
+ ,594
+ ,543
+ ,595
+ ,101.6
+ ,594
+ ,611
+ ,613
+ ,611
+ ,594
+ ,591
+ ,94.6
+ ,595
+ ,594
+ ,611
+ ,613
+ ,611
+ ,589
+ ,95.9
+ ,591
+ ,595
+ ,594
+ ,611
+ ,613
+ ,584
+ ,104.7
+ ,589
+ ,591
+ ,595
+ ,594
+ ,611
+ ,573
+ ,102.8
+ ,584
+ ,589
+ ,591
+ ,595
+ ,594
+ ,567
+ ,98.1
+ ,573
+ ,584
+ ,589
+ ,591
+ ,595
+ ,569
+ ,113.9
+ ,567
+ ,573
+ ,584
+ ,589
+ ,591
+ ,621
+ ,80.9
+ ,569
+ ,567
+ ,573
+ ,584
+ ,589
+ ,629
+ ,95.7
+ ,621
+ ,569
+ ,567
+ ,573
+ ,584
+ ,628
+ ,113.2
+ ,629
+ ,621
+ ,569
+ ,567
+ ,573
+ ,612
+ ,105.9
+ ,628
+ ,629
+ ,621
+ ,569
+ ,567
+ ,595
+ ,108.8
+ ,612
+ ,628
+ ,629
+ ,621
+ ,569
+ ,597
+ ,102.3
+ ,595
+ ,612
+ ,628
+ ,629
+ ,621
+ ,593
+ ,99
+ ,597
+ ,595
+ ,612
+ ,628
+ ,629
+ ,590
+ ,100.7
+ ,593
+ ,597
+ ,595
+ ,612
+ ,628
+ ,580
+ ,115.5
+ ,590
+ ,593
+ ,597
+ ,595
+ ,612
+ ,574
+ ,100.7
+ ,580
+ ,590
+ ,593
+ ,597
+ ,595
+ ,573
+ ,109.9
+ ,574
+ ,580
+ ,590
+ ,593
+ ,597
+ ,573
+ ,114.6
+ ,573
+ ,574
+ ,580
+ ,590
+ ,593
+ ,620
+ ,85.4
+ ,573
+ ,573
+ ,574
+ ,580
+ ,590
+ ,626
+ ,100.5
+ ,620
+ ,573
+ ,573
+ ,574
+ ,580
+ ,620
+ ,114.8
+ ,626
+ ,620
+ ,573
+ ,573
+ ,574
+ ,588
+ ,116.5
+ ,620
+ ,626
+ ,620
+ ,573
+ ,573
+ ,566
+ ,112.9
+ ,588
+ ,620
+ ,626
+ ,620
+ ,573
+ ,557
+ ,102
+ ,566
+ ,588
+ ,620
+ ,626
+ ,620
+ ,561
+ ,106
+ ,557
+ ,566
+ ,588
+ ,620
+ ,626
+ ,549
+ ,105.3
+ ,561
+ ,557
+ ,566
+ ,588
+ ,620
+ ,532
+ ,118.8
+ ,549
+ ,561
+ ,557
+ ,566
+ ,588
+ ,526
+ ,106.1
+ ,532
+ ,549
+ ,561
+ ,557
+ ,566
+ ,511
+ ,109.3
+ ,526
+ ,532
+ ,549
+ ,561
+ ,557
+ ,499
+ ,117.2
+ ,511
+ ,526
+ ,532
+ ,549
+ ,561
+ ,555
+ ,92.5
+ ,499
+ ,511
+ ,526
+ ,532
+ ,549
+ ,565
+ ,104.2
+ ,555
+ ,499
+ ,511
+ ,526
+ ,532
+ ,542
+ ,112.5
+ ,565
+ ,555
+ ,499
+ ,511
+ ,526
+ ,527
+ ,122.4
+ ,542
+ ,565
+ ,555
+ ,499
+ ,511
+ ,510
+ ,113.3
+ ,527
+ ,542
+ ,565
+ ,555
+ ,499
+ ,514
+ ,100
+ ,510
+ ,527
+ ,542
+ ,565
+ ,555
+ ,517
+ ,110.7
+ ,514
+ ,510
+ ,527
+ ,542
+ ,565
+ ,508
+ ,112.8
+ ,517
+ ,514
+ ,510
+ ,527
+ ,542
+ ,493
+ ,109.8
+ ,508
+ ,517
+ ,514
+ ,510
+ ,527
+ ,490
+ ,117.3
+ ,493
+ ,508
+ ,517
+ ,514
+ ,510
+ ,469
+ ,109.1
+ ,490
+ ,493
+ ,508
+ ,517
+ ,514
+ ,478
+ ,115.9
+ ,469
+ ,490
+ ,493
+ ,508
+ ,517
+ ,528
+ ,96
+ ,478
+ ,469
+ ,490
+ ,493
+ ,508
+ ,534
+ ,99.8
+ ,528
+ ,478
+ ,469
+ ,490
+ ,493
+ ,518
+ ,116.8
+ ,534
+ ,528
+ ,478
+ ,469
+ ,490
+ ,506
+ ,115.7
+ ,518
+ ,534
+ ,528
+ ,478
+ ,469
+ ,502
+ ,99.4
+ ,506
+ ,518
+ ,534
+ ,528
+ ,478
+ ,516
+ ,94.3
+ ,502
+ ,506
+ ,518
+ ,534
+ ,528)
+ ,dim=c(7
+ ,67)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Yt-1'
+ ,'Yt-2'
+ ,'Yt-3'
+ ,'Yt-4'
+ ,'Yt-5')
+ ,1:67))
> y <- array(NA,dim=c(7,67),dimnames=list(c('Y','X','Yt-1','Yt-2','Yt-3','Yt-4','Yt-5'),1:67))
> 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 = 'Do not include Seasonal 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 Yt-1 Yt-2 Yt-3 Yt-4 Yt-5 t
1 507 104.5 501 509 510 517 519 1
2 569 87.4 507 501 509 510 517 2
3 580 89.9 569 507 501 509 510 3
4 578 109.8 580 569 507 501 509 4
5 565 111.7 578 580 569 507 501 5
6 547 98.6 565 578 580 569 507 6
7 555 96.9 547 565 578 580 569 7
8 562 95.1 555 547 565 578 580 8
9 561 97.0 562 555 547 565 578 9
10 555 112.7 561 562 555 547 565 10
11 544 102.9 555 561 562 555 547 11
12 537 97.4 544 555 561 562 555 12
13 543 111.4 537 544 555 561 562 13
14 594 87.4 543 537 544 555 561 14
15 611 96.8 594 543 537 544 555 15
16 613 114.1 611 594 543 537 544 16
17 611 110.3 613 611 594 543 537 17
18 594 103.9 611 613 611 594 543 18
19 595 101.6 594 611 613 611 594 19
20 591 94.6 595 594 611 613 611 20
21 589 95.9 591 595 594 611 613 21
22 584 104.7 589 591 595 594 611 22
23 573 102.8 584 589 591 595 594 23
24 567 98.1 573 584 589 591 595 24
25 569 113.9 567 573 584 589 591 25
26 621 80.9 569 567 573 584 589 26
27 629 95.7 621 569 567 573 584 27
28 628 113.2 629 621 569 567 573 28
29 612 105.9 628 629 621 569 567 29
30 595 108.8 612 628 629 621 569 30
31 597 102.3 595 612 628 629 621 31
32 593 99.0 597 595 612 628 629 32
33 590 100.7 593 597 595 612 628 33
34 580 115.5 590 593 597 595 612 34
35 574 100.7 580 590 593 597 595 35
36 573 109.9 574 580 590 593 597 36
37 573 114.6 573 574 580 590 593 37
38 620 85.4 573 573 574 580 590 38
39 626 100.5 620 573 573 574 580 39
40 620 114.8 626 620 573 573 574 40
41 588 116.5 620 626 620 573 573 41
42 566 112.9 588 620 626 620 573 42
43 557 102.0 566 588 620 626 620 43
44 561 106.0 557 566 588 620 626 44
45 549 105.3 561 557 566 588 620 45
46 532 118.8 549 561 557 566 588 46
47 526 106.1 532 549 561 557 566 47
48 511 109.3 526 532 549 561 557 48
49 499 117.2 511 526 532 549 561 49
50 555 92.5 499 511 526 532 549 50
51 565 104.2 555 499 511 526 532 51
52 542 112.5 565 555 499 511 526 52
53 527 122.4 542 565 555 499 511 53
54 510 113.3 527 542 565 555 499 54
55 514 100.0 510 527 542 565 555 55
56 517 110.7 514 510 527 542 565 56
57 508 112.8 517 514 510 527 542 57
58 493 109.8 508 517 514 510 527 58
59 490 117.3 493 508 517 514 510 59
60 469 109.1 490 493 508 517 514 60
61 478 115.9 469 490 493 508 517 61
62 528 96.0 478 469 490 493 508 62
63 534 99.8 528 478 469 490 493 63
64 518 116.8 534 528 478 469 490 64
65 506 115.7 518 534 528 478 469 65
66 502 99.4 506 518 534 528 478 66
67 516 94.3 502 506 518 534 528 67
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X `Yt-1` `Yt-2` `Yt-3` `Yt-4`
243.30193 -1.54574 0.88924 0.03109 0.01750 -0.34704
`Yt-5` t
0.26629 -0.03040
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-21.234 -9.180 -1.955 8.434 25.810
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 243.30193 35.20399 6.911 3.82e-09 ***
X -1.54574 0.22848 -6.765 6.75e-09 ***
`Yt-1` 0.88924 0.09954 8.933 1.48e-12 ***
`Yt-2` 0.03109 0.16202 0.192 0.8485
`Yt-3` 0.01750 0.15052 0.116 0.9078
`Yt-4` -0.34704 0.14797 -2.345 0.0224 *
`Yt-5` 0.26629 0.09175 2.902 0.0052 **
t -0.03040 0.10014 -0.304 0.7625
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 12.63 on 59 degrees of freedom
Multiple R-squared: 0.9127, Adjusted R-squared: 0.9023
F-statistic: 88.08 on 7 and 59 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.5438577 0.9122845 0.4561423
[2,] 0.5551266 0.8897468 0.4448734
[3,] 0.7987174 0.4025652 0.2012826
[4,] 0.8188064 0.3623872 0.1811936
[5,] 0.7596774 0.4806452 0.2403226
[6,] 0.7638879 0.4722241 0.2361121
[7,] 0.6829544 0.6340912 0.3170456
[8,] 0.6092782 0.7814435 0.3907218
[9,] 0.5328201 0.9343599 0.4671799
[10,] 0.5308207 0.9383586 0.4691793
[11,] 0.5263717 0.9472566 0.4736283
[12,] 0.4813141 0.9626282 0.5186859
[13,] 0.5544818 0.8910364 0.4455182
[14,] 0.7655542 0.4688916 0.2344458
[15,] 0.7308207 0.5383586 0.2691793
[16,] 0.6667996 0.6664007 0.3332004
[17,] 0.6387301 0.7225399 0.3612699
[18,] 0.5809593 0.8380813 0.4190407
[19,] 0.6505135 0.6989729 0.3494865
[20,] 0.5800351 0.8399298 0.4199649
[21,] 0.5088241 0.9823519 0.4911759
[22,] 0.4772819 0.9545638 0.5227181
[23,] 0.4974506 0.9949013 0.5025494
[24,] 0.4225521 0.8451042 0.5774479
[25,] 0.5772602 0.8454796 0.4227398
[26,] 0.4998597 0.9997195 0.5001403
[27,] 0.4498030 0.8996059 0.5501970
[28,] 0.3725070 0.7450140 0.6274930
[29,] 0.3060048 0.6120096 0.6939952
[30,] 0.4200637 0.8401275 0.5799363
[31,] 0.4175194 0.8350387 0.5824806
[32,] 0.4384003 0.8768006 0.5615997
[33,] 0.3927838 0.7855677 0.6072162
[34,] 0.4906104 0.9812208 0.5093896
[35,] 0.5448749 0.9102503 0.4551251
[36,] 0.5399872 0.9200255 0.4600128
[37,] 0.5453826 0.9092349 0.4546174
[38,] 0.5600811 0.8798378 0.4399189
[39,] 0.4679556 0.9359112 0.5320444
[40,] 0.4556205 0.9112411 0.5443795
[41,] 0.3654291 0.7308582 0.6345709
[42,] 0.3518797 0.7037594 0.6481203
[43,] 0.2531921 0.5063842 0.7468079
[44,] 0.2312275 0.4624549 0.7687725
[45,] 0.1918068 0.3836135 0.8081932
[46,] 0.1325701 0.2651403 0.8674299
> postscript(file="/var/www/html/rcomp/tmp/1vqap1258723719.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/2pgcp1258723719.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/3edzw1258723719.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/45ib71258723719.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/5lb211258723719.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 = 67
Frequency = 1
1 2 3 4 5 6
-3.7842128 24.8480587 -13.9195567 0.5469999 -4.9214778 -11.7918377
7 8 9 10 11 12
-2.6363730 -8.3384333 -16.5084662 -0.4631671 -13.7674573 -18.9540399
13 14 15 16 17 18
13.1773338 20.3686104 4.2940782 16.7581952 9.6616731 0.3193948
19 20 21 22 23 24
5.2576436 -13.6907651 -11.0542263 -5.9030225 -10.3571774 -15.2741457
25 26 27 28 29 30
17.3149945 15.7337766 -2.0424130 16.1199459 -9.1111066 10.0343285
31 32 33 34 35 36
6.5785494 -5.9393745 -7.7752984 6.2501859 -8.3197380 8.7095847
37 38 39 40 41 42
17.2797807 16.6390306 4.8140997 15.4027354 -9.3462968 7.9674585
43 44 45 46 47 48
-7.6211085 8.1593220 -17.2920005 -1.8036010 -9.2489437 -9.4134660
49 50 51 52 53 54
-0.5787389 25.8098192 7.2082807 -16.9628736 2.3620325 7.8344974
55 56 57 58 59 60
-4.1495644 2.0095072 -5.2895244 -18.9617499 9.1427310 -21.2344819
61 62 63 64 65 66
13.4145082 22.5778577 -6.9389653 -10.1672203 -1.9552610 -5.1018483
67
-5.9770801
> postscript(file="/var/www/html/rcomp/tmp/6wss61258723719.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 = 67
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.7842128 NA
1 24.8480587 -3.7842128
2 -13.9195567 24.8480587
3 0.5469999 -13.9195567
4 -4.9214778 0.5469999
5 -11.7918377 -4.9214778
6 -2.6363730 -11.7918377
7 -8.3384333 -2.6363730
8 -16.5084662 -8.3384333
9 -0.4631671 -16.5084662
10 -13.7674573 -0.4631671
11 -18.9540399 -13.7674573
12 13.1773338 -18.9540399
13 20.3686104 13.1773338
14 4.2940782 20.3686104
15 16.7581952 4.2940782
16 9.6616731 16.7581952
17 0.3193948 9.6616731
18 5.2576436 0.3193948
19 -13.6907651 5.2576436
20 -11.0542263 -13.6907651
21 -5.9030225 -11.0542263
22 -10.3571774 -5.9030225
23 -15.2741457 -10.3571774
24 17.3149945 -15.2741457
25 15.7337766 17.3149945
26 -2.0424130 15.7337766
27 16.1199459 -2.0424130
28 -9.1111066 16.1199459
29 10.0343285 -9.1111066
30 6.5785494 10.0343285
31 -5.9393745 6.5785494
32 -7.7752984 -5.9393745
33 6.2501859 -7.7752984
34 -8.3197380 6.2501859
35 8.7095847 -8.3197380
36 17.2797807 8.7095847
37 16.6390306 17.2797807
38 4.8140997 16.6390306
39 15.4027354 4.8140997
40 -9.3462968 15.4027354
41 7.9674585 -9.3462968
42 -7.6211085 7.9674585
43 8.1593220 -7.6211085
44 -17.2920005 8.1593220
45 -1.8036010 -17.2920005
46 -9.2489437 -1.8036010
47 -9.4134660 -9.2489437
48 -0.5787389 -9.4134660
49 25.8098192 -0.5787389
50 7.2082807 25.8098192
51 -16.9628736 7.2082807
52 2.3620325 -16.9628736
53 7.8344974 2.3620325
54 -4.1495644 7.8344974
55 2.0095072 -4.1495644
56 -5.2895244 2.0095072
57 -18.9617499 -5.2895244
58 9.1427310 -18.9617499
59 -21.2344819 9.1427310
60 13.4145082 -21.2344819
61 22.5778577 13.4145082
62 -6.9389653 22.5778577
63 -10.1672203 -6.9389653
64 -1.9552610 -10.1672203
65 -5.1018483 -1.9552610
66 -5.9770801 -5.1018483
67 NA -5.9770801
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 24.8480587 -3.7842128
[2,] -13.9195567 24.8480587
[3,] 0.5469999 -13.9195567
[4,] -4.9214778 0.5469999
[5,] -11.7918377 -4.9214778
[6,] -2.6363730 -11.7918377
[7,] -8.3384333 -2.6363730
[8,] -16.5084662 -8.3384333
[9,] -0.4631671 -16.5084662
[10,] -13.7674573 -0.4631671
[11,] -18.9540399 -13.7674573
[12,] 13.1773338 -18.9540399
[13,] 20.3686104 13.1773338
[14,] 4.2940782 20.3686104
[15,] 16.7581952 4.2940782
[16,] 9.6616731 16.7581952
[17,] 0.3193948 9.6616731
[18,] 5.2576436 0.3193948
[19,] -13.6907651 5.2576436
[20,] -11.0542263 -13.6907651
[21,] -5.9030225 -11.0542263
[22,] -10.3571774 -5.9030225
[23,] -15.2741457 -10.3571774
[24,] 17.3149945 -15.2741457
[25,] 15.7337766 17.3149945
[26,] -2.0424130 15.7337766
[27,] 16.1199459 -2.0424130
[28,] -9.1111066 16.1199459
[29,] 10.0343285 -9.1111066
[30,] 6.5785494 10.0343285
[31,] -5.9393745 6.5785494
[32,] -7.7752984 -5.9393745
[33,] 6.2501859 -7.7752984
[34,] -8.3197380 6.2501859
[35,] 8.7095847 -8.3197380
[36,] 17.2797807 8.7095847
[37,] 16.6390306 17.2797807
[38,] 4.8140997 16.6390306
[39,] 15.4027354 4.8140997
[40,] -9.3462968 15.4027354
[41,] 7.9674585 -9.3462968
[42,] -7.6211085 7.9674585
[43,] 8.1593220 -7.6211085
[44,] -17.2920005 8.1593220
[45,] -1.8036010 -17.2920005
[46,] -9.2489437 -1.8036010
[47,] -9.4134660 -9.2489437
[48,] -0.5787389 -9.4134660
[49,] 25.8098192 -0.5787389
[50,] 7.2082807 25.8098192
[51,] -16.9628736 7.2082807
[52,] 2.3620325 -16.9628736
[53,] 7.8344974 2.3620325
[54,] -4.1495644 7.8344974
[55,] 2.0095072 -4.1495644
[56,] -5.2895244 2.0095072
[57,] -18.9617499 -5.2895244
[58,] 9.1427310 -18.9617499
[59,] -21.2344819 9.1427310
[60,] 13.4145082 -21.2344819
[61,] 22.5778577 13.4145082
[62,] -6.9389653 22.5778577
[63,] -10.1672203 -6.9389653
[64,] -1.9552610 -10.1672203
[65,] -5.1018483 -1.9552610
[66,] -5.9770801 -5.1018483
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 24.8480587 -3.7842128
2 -13.9195567 24.8480587
3 0.5469999 -13.9195567
4 -4.9214778 0.5469999
5 -11.7918377 -4.9214778
6 -2.6363730 -11.7918377
7 -8.3384333 -2.6363730
8 -16.5084662 -8.3384333
9 -0.4631671 -16.5084662
10 -13.7674573 -0.4631671
11 -18.9540399 -13.7674573
12 13.1773338 -18.9540399
13 20.3686104 13.1773338
14 4.2940782 20.3686104
15 16.7581952 4.2940782
16 9.6616731 16.7581952
17 0.3193948 9.6616731
18 5.2576436 0.3193948
19 -13.6907651 5.2576436
20 -11.0542263 -13.6907651
21 -5.9030225 -11.0542263
22 -10.3571774 -5.9030225
23 -15.2741457 -10.3571774
24 17.3149945 -15.2741457
25 15.7337766 17.3149945
26 -2.0424130 15.7337766
27 16.1199459 -2.0424130
28 -9.1111066 16.1199459
29 10.0343285 -9.1111066
30 6.5785494 10.0343285
31 -5.9393745 6.5785494
32 -7.7752984 -5.9393745
33 6.2501859 -7.7752984
34 -8.3197380 6.2501859
35 8.7095847 -8.3197380
36 17.2797807 8.7095847
37 16.6390306 17.2797807
38 4.8140997 16.6390306
39 15.4027354 4.8140997
40 -9.3462968 15.4027354
41 7.9674585 -9.3462968
42 -7.6211085 7.9674585
43 8.1593220 -7.6211085
44 -17.2920005 8.1593220
45 -1.8036010 -17.2920005
46 -9.2489437 -1.8036010
47 -9.4134660 -9.2489437
48 -0.5787389 -9.4134660
49 25.8098192 -0.5787389
50 7.2082807 25.8098192
51 -16.9628736 7.2082807
52 2.3620325 -16.9628736
53 7.8344974 2.3620325
54 -4.1495644 7.8344974
55 2.0095072 -4.1495644
56 -5.2895244 2.0095072
57 -18.9617499 -5.2895244
58 9.1427310 -18.9617499
59 -21.2344819 9.1427310
60 13.4145082 -21.2344819
61 22.5778577 13.4145082
62 -6.9389653 22.5778577
63 -10.1672203 -6.9389653
64 -1.9552610 -10.1672203
65 -5.1018483 -1.9552610
66 -5.9770801 -5.1018483
> 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/7wnaw1258723719.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/81dwt1258723719.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/9737a1258723719.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/10c6gr1258723719.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/11cp421258723719.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/12h0pi1258723719.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/137nqz1258723719.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/14cqqc1258723719.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/154nyn1258723719.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/16wuvd1258723719.tab")
+ }
>
> system("convert tmp/1vqap1258723719.ps tmp/1vqap1258723719.png")
> system("convert tmp/2pgcp1258723719.ps tmp/2pgcp1258723719.png")
> system("convert tmp/3edzw1258723719.ps tmp/3edzw1258723719.png")
> system("convert tmp/45ib71258723719.ps tmp/45ib71258723719.png")
> system("convert tmp/5lb211258723719.ps tmp/5lb211258723719.png")
> system("convert tmp/6wss61258723719.ps tmp/6wss61258723719.png")
> system("convert tmp/7wnaw1258723719.ps tmp/7wnaw1258723719.png")
> system("convert tmp/81dwt1258723719.ps tmp/81dwt1258723719.png")
> system("convert tmp/9737a1258723719.ps tmp/9737a1258723719.png")
> system("convert tmp/10c6gr1258723719.ps tmp/10c6gr1258723719.png")
>
>
> proc.time()
user system elapsed
2.527 1.562 2.952