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(431
+ ,436
+ ,443
+ ,448
+ ,460
+ ,467
+ ,484
+ ,431
+ ,436
+ ,443
+ ,448
+ ,460
+ ,510
+ ,484
+ ,431
+ ,436
+ ,443
+ ,448
+ ,513
+ ,510
+ ,484
+ ,431
+ ,436
+ ,443
+ ,503
+ ,513
+ ,510
+ ,484
+ ,431
+ ,436
+ ,471
+ ,503
+ ,513
+ ,510
+ ,484
+ ,431
+ ,471
+ ,471
+ ,503
+ ,513
+ ,510
+ ,484
+ ,476
+ ,471
+ ,471
+ ,503
+ ,513
+ ,510
+ ,475
+ ,476
+ ,471
+ ,471
+ ,503
+ ,513
+ ,470
+ ,475
+ ,476
+ ,471
+ ,471
+ ,503
+ ,461
+ ,470
+ ,475
+ ,476
+ ,471
+ ,471
+ ,455
+ ,461
+ ,470
+ ,475
+ ,476
+ ,471
+ ,456
+ ,455
+ ,461
+ ,470
+ ,475
+ ,476
+ ,517
+ ,456
+ ,455
+ ,461
+ ,470
+ ,475
+ ,525
+ ,517
+ ,456
+ ,455
+ ,461
+ ,470
+ ,523
+ ,525
+ ,517
+ ,456
+ ,455
+ ,461
+ ,519
+ ,523
+ ,525
+ ,517
+ ,456
+ ,455
+ ,509
+ ,519
+ ,523
+ ,525
+ ,517
+ ,456
+ ,512
+ ,509
+ ,519
+ ,523
+ ,525
+ ,517
+ ,519
+ ,512
+ ,509
+ ,519
+ ,523
+ ,525
+ ,517
+ ,519
+ ,512
+ ,509
+ ,519
+ ,523
+ ,510
+ ,517
+ ,519
+ ,512
+ ,509
+ ,519
+ ,509
+ ,510
+ ,517
+ ,519
+ ,512
+ ,509
+ ,501
+ ,509
+ ,510
+ ,517
+ ,519
+ ,512
+ ,507
+ ,501
+ ,509
+ ,510
+ ,517
+ ,519
+ ,569
+ ,507
+ ,501
+ ,509
+ ,510
+ ,517
+ ,580
+ ,569
+ ,507
+ ,501
+ ,509
+ ,510
+ ,578
+ ,580
+ ,569
+ ,507
+ ,501
+ ,509
+ ,565
+ ,578
+ ,580
+ ,569
+ ,507
+ ,501
+ ,547
+ ,565
+ ,578
+ ,580
+ ,569
+ ,507
+ ,555
+ ,547
+ ,565
+ ,578
+ ,580
+ ,569
+ ,562
+ ,555
+ ,547
+ ,565
+ ,578
+ ,580
+ ,561
+ ,562
+ ,555
+ ,547
+ ,565
+ ,578
+ ,555
+ ,561
+ ,562
+ ,555
+ ,547
+ ,565
+ ,544
+ ,555
+ ,561
+ ,562
+ ,555
+ ,547
+ ,537
+ ,544
+ ,555
+ ,561
+ ,562
+ ,555
+ ,543
+ ,537
+ ,544
+ ,555
+ ,561
+ ,562
+ ,594
+ ,543
+ ,537
+ ,544
+ ,555
+ ,561
+ ,611
+ ,594
+ ,543
+ ,537
+ ,544
+ ,555
+ ,613
+ ,611
+ ,594
+ ,543
+ ,537
+ ,544
+ ,611
+ ,613
+ ,611
+ ,594
+ ,543
+ ,537
+ ,594
+ ,611
+ ,613
+ ,611
+ ,594
+ ,543
+ ,595
+ ,594
+ ,611
+ ,613
+ ,611
+ ,594
+ ,591
+ ,595
+ ,594
+ ,611
+ ,613
+ ,611
+ ,589
+ ,591
+ ,595
+ ,594
+ ,611
+ ,613
+ ,584
+ ,589
+ ,591
+ ,595
+ ,594
+ ,611
+ ,573
+ ,584
+ ,589
+ ,591
+ ,595
+ ,594
+ ,567
+ ,573
+ ,584
+ ,589
+ ,591
+ ,595
+ ,569
+ ,567
+ ,573
+ ,584
+ ,589
+ ,591
+ ,621
+ ,569
+ ,567
+ ,573
+ ,584
+ ,589
+ ,629
+ ,621
+ ,569
+ ,567
+ ,573
+ ,584
+ ,628
+ ,629
+ ,621
+ ,569
+ ,567
+ ,573
+ ,612
+ ,628
+ ,629
+ ,621
+ ,569
+ ,567
+ ,595
+ ,612
+ ,628
+ ,629
+ ,621
+ ,569
+ ,597
+ ,595
+ ,612
+ ,628
+ ,629
+ ,621
+ ,593
+ ,597
+ ,595
+ ,612
+ ,628
+ ,629
+ ,590
+ ,593
+ ,597
+ ,595
+ ,612
+ ,628
+ ,580
+ ,590
+ ,593
+ ,597
+ ,595
+ ,612
+ ,574
+ ,580
+ ,590
+ ,593
+ ,597
+ ,595
+ ,573
+ ,574
+ ,580
+ ,590
+ ,593
+ ,597
+ ,573
+ ,573
+ ,574
+ ,580
+ ,590
+ ,593
+ ,620
+ ,573
+ ,573
+ ,574
+ ,580
+ ,590
+ ,626
+ ,620
+ ,573
+ ,573
+ ,574
+ ,580
+ ,620
+ ,626
+ ,620
+ ,573
+ ,573
+ ,574
+ ,588
+ ,620
+ ,626
+ ,620
+ ,573
+ ,573
+ ,566
+ ,588
+ ,620
+ ,626
+ ,620
+ ,573
+ ,557
+ ,566
+ ,588
+ ,620
+ ,626
+ ,620)
+ ,dim=c(6
+ ,67)
+ ,dimnames=list(c('Y'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)'
+ ,'Y(t-5)
')
+ ,1:67))
> y <- array(NA,dim=c(6,67),dimnames=list(c('Y','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)','Y(t-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 = '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 Y(t-1) Y(t-2) Y(t-3) Y(t-4) Y(t-5)\r M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 431 436 443 448 460 467 1 0 0 0 0 0 0 0 0 0 0
2 484 431 436 443 448 460 0 1 0 0 0 0 0 0 0 0 0
3 510 484 431 436 443 448 0 0 1 0 0 0 0 0 0 0 0
4 513 510 484 431 436 443 0 0 0 1 0 0 0 0 0 0 0
5 503 513 510 484 431 436 0 0 0 0 1 0 0 0 0 0 0
6 471 503 513 510 484 431 0 0 0 0 0 1 0 0 0 0 0
7 471 471 503 513 510 484 0 0 0 0 0 0 1 0 0 0 0
8 476 471 471 503 513 510 0 0 0 0 0 0 0 1 0 0 0
9 475 476 471 471 503 513 0 0 0 0 0 0 0 0 1 0 0
10 470 475 476 471 471 503 0 0 0 0 0 0 0 0 0 1 0
11 461 470 475 476 471 471 0 0 0 0 0 0 0 0 0 0 1
12 455 461 470 475 476 471 0 0 0 0 0 0 0 0 0 0 0
13 456 455 461 470 475 476 1 0 0 0 0 0 0 0 0 0 0
14 517 456 455 461 470 475 0 1 0 0 0 0 0 0 0 0 0
15 525 517 456 455 461 470 0 0 1 0 0 0 0 0 0 0 0
16 523 525 517 456 455 461 0 0 0 1 0 0 0 0 0 0 0
17 519 523 525 517 456 455 0 0 0 0 1 0 0 0 0 0 0
18 509 519 523 525 517 456 0 0 0 0 0 1 0 0 0 0 0
19 512 509 519 523 525 517 0 0 0 0 0 0 1 0 0 0 0
20 519 512 509 519 523 525 0 0 0 0 0 0 0 1 0 0 0
21 517 519 512 509 519 523 0 0 0 0 0 0 0 0 1 0 0
22 510 517 519 512 509 519 0 0 0 0 0 0 0 0 0 1 0
23 509 510 517 519 512 509 0 0 0 0 0 0 0 0 0 0 1
24 501 509 510 517 519 512 0 0 0 0 0 0 0 0 0 0 0
25 507 501 509 510 517 519 1 0 0 0 0 0 0 0 0 0 0
26 569 507 501 509 510 517 0 1 0 0 0 0 0 0 0 0 0
27 580 569 507 501 509 510 0 0 1 0 0 0 0 0 0 0 0
28 578 580 569 507 501 509 0 0 0 1 0 0 0 0 0 0 0
29 565 578 580 569 507 501 0 0 0 0 1 0 0 0 0 0 0
30 547 565 578 580 569 507 0 0 0 0 0 1 0 0 0 0 0
31 555 547 565 578 580 569 0 0 0 0 0 0 1 0 0 0 0
32 562 555 547 565 578 580 0 0 0 0 0 0 0 1 0 0 0
33 561 562 555 547 565 578 0 0 0 0 0 0 0 0 1 0 0
34 555 561 562 555 547 565 0 0 0 0 0 0 0 0 0 1 0
35 544 555 561 562 555 547 0 0 0 0 0 0 0 0 0 0 1
36 537 544 555 561 562 555 0 0 0 0 0 0 0 0 0 0 0
37 543 537 544 555 561 562 1 0 0 0 0 0 0 0 0 0 0
38 594 543 537 544 555 561 0 1 0 0 0 0 0 0 0 0 0
39 611 594 543 537 544 555 0 0 1 0 0 0 0 0 0 0 0
40 613 611 594 543 537 544 0 0 0 1 0 0 0 0 0 0 0
41 611 613 611 594 543 537 0 0 0 0 1 0 0 0 0 0 0
42 594 611 613 611 594 543 0 0 0 0 0 1 0 0 0 0 0
43 595 594 611 613 611 594 0 0 0 0 0 0 1 0 0 0 0
44 591 595 594 611 613 611 0 0 0 0 0 0 0 1 0 0 0
45 589 591 595 594 611 613 0 0 0 0 0 0 0 0 1 0 0
46 584 589 591 595 594 611 0 0 0 0 0 0 0 0 0 1 0
47 573 584 589 591 595 594 0 0 0 0 0 0 0 0 0 0 1
48 567 573 584 589 591 595 0 0 0 0 0 0 0 0 0 0 0
49 569 567 573 584 589 591 1 0 0 0 0 0 0 0 0 0 0
50 621 569 567 573 584 589 0 1 0 0 0 0 0 0 0 0 0
51 629 621 569 567 573 584 0 0 1 0 0 0 0 0 0 0 0
52 628 629 621 569 567 573 0 0 0 1 0 0 0 0 0 0 0
53 612 628 629 621 569 567 0 0 0 0 1 0 0 0 0 0 0
54 595 612 628 629 621 569 0 0 0 0 0 1 0 0 0 0 0
55 597 595 612 628 629 621 0 0 0 0 0 0 1 0 0 0 0
56 593 597 595 612 628 629 0 0 0 0 0 0 0 1 0 0 0
57 590 593 597 595 612 628 0 0 0 0 0 0 0 0 1 0 0
58 580 590 593 597 595 612 0 0 0 0 0 0 0 0 0 1 0
59 574 580 590 593 597 595 0 0 0 0 0 0 0 0 0 0 1
60 573 574 580 590 593 597 0 0 0 0 0 0 0 0 0 0 0
61 573 573 574 580 590 593 1 0 0 0 0 0 0 0 0 0 0
62 620 573 573 574 580 590 0 1 0 0 0 0 0 0 0 0 0
63 626 620 573 573 574 580 0 0 1 0 0 0 0 0 0 0 0
64 620 626 620 573 573 574 0 0 0 1 0 0 0 0 0 0 0
65 588 620 626 620 573 573 0 0 0 0 1 0 0 0 0 0 0
66 566 588 620 626 620 573 0 0 0 0 0 1 0 0 0 0 0
67 557 566 588 620 626 620 0 0 0 0 0 0 1 0 0 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
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)` `Y(t-5)\r`
-45.73691 1.13418 -0.16359 -0.01006 0.11604 0.01993
M1 M2 M3 M4 M5 M6
6.59174 59.26444 11.83497 6.52606 -2.29913 -13.11896
M7 M8 M9 M10 M11 t
5.31205 2.18713 -0.46216 -1.93906 -1.94342 -0.33254
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-14.8127 -2.3153 -0.2318 2.9740 10.5110
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -45.73691 27.93241 -1.637 0.1080
`Y(t-1)` 1.13418 0.14336 7.912 2.61e-10 ***
`Y(t-2)` -0.16359 0.21982 -0.744 0.4603
`Y(t-3)` -0.01006 0.24040 -0.042 0.9668
`Y(t-4)` 0.11604 0.24556 0.473 0.6386
`Y(t-5)\r` 0.01993 0.16766 0.119 0.9058
M1 6.59174 3.52776 1.869 0.0677 .
M2 59.26444 3.92464 15.101 < 2e-16 ***
M3 11.83497 9.57672 1.236 0.2224
M4 6.52606 9.75868 0.669 0.5068
M5 -2.29913 9.76151 -0.236 0.8148
M6 -13.11896 8.98232 -1.461 0.1505
M7 5.31205 4.34379 1.223 0.2272
M8 2.18713 4.80296 0.455 0.6509
M9 -0.46216 5.12435 -0.090 0.9285
M10 -1.93906 5.11703 -0.379 0.7064
M11 -1.94342 3.58936 -0.541 0.5907
t -0.33254 0.16201 -2.053 0.0455 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.52 on 49 degrees of freedom
Multiple R-squared: 0.9912, Adjusted R-squared: 0.9882
F-statistic: 325.3 on 17 and 49 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.9662243 0.06755133 0.03377567
[2,] 0.9398798 0.12024039 0.06012019
[3,] 0.9438431 0.11231375 0.05615687
[4,] 0.9190037 0.16199259 0.08099630
[5,] 0.8888419 0.22231624 0.11115812
[6,] 0.8767211 0.24655781 0.12327891
[7,] 0.8804492 0.23910167 0.11955083
[8,] 0.8516602 0.29667967 0.14833984
[9,] 0.8340696 0.33186085 0.16593043
[10,] 0.7689758 0.46204843 0.23102422
[11,] 0.7060158 0.58796837 0.29398418
[12,] 0.6581314 0.68373721 0.34186860
[13,] 0.5923147 0.81537060 0.40768530
[14,] 0.5127891 0.97442181 0.48721090
[15,] 0.4715188 0.94303750 0.52848125
[16,] 0.4681524 0.93630473 0.53184764
[17,] 0.3683818 0.73676358 0.63161821
[18,] 0.4426179 0.88523585 0.55738208
[19,] 0.3391095 0.67821901 0.66089050
[20,] 0.2561130 0.51222590 0.74388705
[21,] 0.6665579 0.66688426 0.33344213
[22,] 0.5555310 0.88893808 0.44446904
[23,] 0.4425977 0.88519545 0.55740228
[24,] 0.3825376 0.76507519 0.61746241
[25,] 0.2569778 0.51395559 0.74302220
[26,] 0.1604510 0.32090203 0.83954898
> postscript(file="/var/www/html/rcomp/tmp/1ax591260712065.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/2n17s1260712065.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/3wcrb1260712065.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/4ft8a1260712065.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/592w71260712065.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
-9.73793323 -3.07056103 10.51096774 -0.80440923 0.45683989 -14.34728048
7 8 9 10 11 12
-1.83124293 0.42441325 -2.48584882 0.18837801 -2.27924064 -1.09070319
13 14 15 16 17 18
-1.05102483 6.00273329 -6.17296269 -0.74034975 8.61147954 6.95537730
19 20 21 22 23 24
0.37997143 5.83138756 -0.23180172 -0.73856331 6.13203956 -4.38198443
25 26 27 28 29 30
4.29082373 6.67897368 -3.72153905 -1.40498082 -1.09266978 -0.72668729
31 32 33 34 35 36
4.93099540 3.25248911 -0.02883777 0.48823933 -4.03248858 -2.13073089
37 38 39 40 41 42
3.66602684 -5.01877782 4.20723326 2.00252974 9.62909177 0.51024144
43 44 45 46 47 48
-0.60353498 -5.65233292 0.05107051 0.49714535 -4.63961888 -0.16833682
49 50 51 52 53 54
0.83960869 -2.24099360 -3.81339388 1.19684641 -2.79205745 3.35003473
55 56 57 58 59 60
1.94028915 -3.85595700 2.69541780 -0.43519938 4.81930854 7.77175534
61 62 63 64 65 66
1.99249881 -2.35137453 -1.01030539 -0.24963635 -14.81268396 4.25831431
67
-4.81647807
> postscript(file="/var/www/html/rcomp/tmp/6pqav1260712065.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 -9.73793323 NA
1 -3.07056103 -9.73793323
2 10.51096774 -3.07056103
3 -0.80440923 10.51096774
4 0.45683989 -0.80440923
5 -14.34728048 0.45683989
6 -1.83124293 -14.34728048
7 0.42441325 -1.83124293
8 -2.48584882 0.42441325
9 0.18837801 -2.48584882
10 -2.27924064 0.18837801
11 -1.09070319 -2.27924064
12 -1.05102483 -1.09070319
13 6.00273329 -1.05102483
14 -6.17296269 6.00273329
15 -0.74034975 -6.17296269
16 8.61147954 -0.74034975
17 6.95537730 8.61147954
18 0.37997143 6.95537730
19 5.83138756 0.37997143
20 -0.23180172 5.83138756
21 -0.73856331 -0.23180172
22 6.13203956 -0.73856331
23 -4.38198443 6.13203956
24 4.29082373 -4.38198443
25 6.67897368 4.29082373
26 -3.72153905 6.67897368
27 -1.40498082 -3.72153905
28 -1.09266978 -1.40498082
29 -0.72668729 -1.09266978
30 4.93099540 -0.72668729
31 3.25248911 4.93099540
32 -0.02883777 3.25248911
33 0.48823933 -0.02883777
34 -4.03248858 0.48823933
35 -2.13073089 -4.03248858
36 3.66602684 -2.13073089
37 -5.01877782 3.66602684
38 4.20723326 -5.01877782
39 2.00252974 4.20723326
40 9.62909177 2.00252974
41 0.51024144 9.62909177
42 -0.60353498 0.51024144
43 -5.65233292 -0.60353498
44 0.05107051 -5.65233292
45 0.49714535 0.05107051
46 -4.63961888 0.49714535
47 -0.16833682 -4.63961888
48 0.83960869 -0.16833682
49 -2.24099360 0.83960869
50 -3.81339388 -2.24099360
51 1.19684641 -3.81339388
52 -2.79205745 1.19684641
53 3.35003473 -2.79205745
54 1.94028915 3.35003473
55 -3.85595700 1.94028915
56 2.69541780 -3.85595700
57 -0.43519938 2.69541780
58 4.81930854 -0.43519938
59 7.77175534 4.81930854
60 1.99249881 7.77175534
61 -2.35137453 1.99249881
62 -1.01030539 -2.35137453
63 -0.24963635 -1.01030539
64 -14.81268396 -0.24963635
65 4.25831431 -14.81268396
66 -4.81647807 4.25831431
67 NA -4.81647807
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3.07056103 -9.73793323
[2,] 10.51096774 -3.07056103
[3,] -0.80440923 10.51096774
[4,] 0.45683989 -0.80440923
[5,] -14.34728048 0.45683989
[6,] -1.83124293 -14.34728048
[7,] 0.42441325 -1.83124293
[8,] -2.48584882 0.42441325
[9,] 0.18837801 -2.48584882
[10,] -2.27924064 0.18837801
[11,] -1.09070319 -2.27924064
[12,] -1.05102483 -1.09070319
[13,] 6.00273329 -1.05102483
[14,] -6.17296269 6.00273329
[15,] -0.74034975 -6.17296269
[16,] 8.61147954 -0.74034975
[17,] 6.95537730 8.61147954
[18,] 0.37997143 6.95537730
[19,] 5.83138756 0.37997143
[20,] -0.23180172 5.83138756
[21,] -0.73856331 -0.23180172
[22,] 6.13203956 -0.73856331
[23,] -4.38198443 6.13203956
[24,] 4.29082373 -4.38198443
[25,] 6.67897368 4.29082373
[26,] -3.72153905 6.67897368
[27,] -1.40498082 -3.72153905
[28,] -1.09266978 -1.40498082
[29,] -0.72668729 -1.09266978
[30,] 4.93099540 -0.72668729
[31,] 3.25248911 4.93099540
[32,] -0.02883777 3.25248911
[33,] 0.48823933 -0.02883777
[34,] -4.03248858 0.48823933
[35,] -2.13073089 -4.03248858
[36,] 3.66602684 -2.13073089
[37,] -5.01877782 3.66602684
[38,] 4.20723326 -5.01877782
[39,] 2.00252974 4.20723326
[40,] 9.62909177 2.00252974
[41,] 0.51024144 9.62909177
[42,] -0.60353498 0.51024144
[43,] -5.65233292 -0.60353498
[44,] 0.05107051 -5.65233292
[45,] 0.49714535 0.05107051
[46,] -4.63961888 0.49714535
[47,] -0.16833682 -4.63961888
[48,] 0.83960869 -0.16833682
[49,] -2.24099360 0.83960869
[50,] -3.81339388 -2.24099360
[51,] 1.19684641 -3.81339388
[52,] -2.79205745 1.19684641
[53,] 3.35003473 -2.79205745
[54,] 1.94028915 3.35003473
[55,] -3.85595700 1.94028915
[56,] 2.69541780 -3.85595700
[57,] -0.43519938 2.69541780
[58,] 4.81930854 -0.43519938
[59,] 7.77175534 4.81930854
[60,] 1.99249881 7.77175534
[61,] -2.35137453 1.99249881
[62,] -1.01030539 -2.35137453
[63,] -0.24963635 -1.01030539
[64,] -14.81268396 -0.24963635
[65,] 4.25831431 -14.81268396
[66,] -4.81647807 4.25831431
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3.07056103 -9.73793323
2 10.51096774 -3.07056103
3 -0.80440923 10.51096774
4 0.45683989 -0.80440923
5 -14.34728048 0.45683989
6 -1.83124293 -14.34728048
7 0.42441325 -1.83124293
8 -2.48584882 0.42441325
9 0.18837801 -2.48584882
10 -2.27924064 0.18837801
11 -1.09070319 -2.27924064
12 -1.05102483 -1.09070319
13 6.00273329 -1.05102483
14 -6.17296269 6.00273329
15 -0.74034975 -6.17296269
16 8.61147954 -0.74034975
17 6.95537730 8.61147954
18 0.37997143 6.95537730
19 5.83138756 0.37997143
20 -0.23180172 5.83138756
21 -0.73856331 -0.23180172
22 6.13203956 -0.73856331
23 -4.38198443 6.13203956
24 4.29082373 -4.38198443
25 6.67897368 4.29082373
26 -3.72153905 6.67897368
27 -1.40498082 -3.72153905
28 -1.09266978 -1.40498082
29 -0.72668729 -1.09266978
30 4.93099540 -0.72668729
31 3.25248911 4.93099540
32 -0.02883777 3.25248911
33 0.48823933 -0.02883777
34 -4.03248858 0.48823933
35 -2.13073089 -4.03248858
36 3.66602684 -2.13073089
37 -5.01877782 3.66602684
38 4.20723326 -5.01877782
39 2.00252974 4.20723326
40 9.62909177 2.00252974
41 0.51024144 9.62909177
42 -0.60353498 0.51024144
43 -5.65233292 -0.60353498
44 0.05107051 -5.65233292
45 0.49714535 0.05107051
46 -4.63961888 0.49714535
47 -0.16833682 -4.63961888
48 0.83960869 -0.16833682
49 -2.24099360 0.83960869
50 -3.81339388 -2.24099360
51 1.19684641 -3.81339388
52 -2.79205745 1.19684641
53 3.35003473 -2.79205745
54 1.94028915 3.35003473
55 -3.85595700 1.94028915
56 2.69541780 -3.85595700
57 -0.43519938 2.69541780
58 4.81930854 -0.43519938
59 7.77175534 4.81930854
60 1.99249881 7.77175534
61 -2.35137453 1.99249881
62 -1.01030539 -2.35137453
63 -0.24963635 -1.01030539
64 -14.81268396 -0.24963635
65 4.25831431 -14.81268396
66 -4.81647807 4.25831431
> 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/7apqb1260712065.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/8mf1l1260712065.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/9hc8l1260712065.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/109yeu1260712065.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/11x1lm1260712065.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/128qtq1260712065.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/13n50f1260712065.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/14h09b1260712065.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/15jvdn1260712065.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/161fn01260712065.tab")
+ }
>
> try(system("convert tmp/1ax591260712065.ps tmp/1ax591260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/2n17s1260712065.ps tmp/2n17s1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/3wcrb1260712065.ps tmp/3wcrb1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ft8a1260712065.ps tmp/4ft8a1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/592w71260712065.ps tmp/592w71260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/6pqav1260712065.ps tmp/6pqav1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/7apqb1260712065.ps tmp/7apqb1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/8mf1l1260712065.ps tmp/8mf1l1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/9hc8l1260712065.ps tmp/9hc8l1260712065.png",intern=TRUE))
character(0)
> try(system("convert tmp/109yeu1260712065.ps tmp/109yeu1260712065.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.473 1.564 3.131