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(101.9
+ ,436
+ ,443
+ ,448
+ ,460
+ ,467
+ ,106.2
+ ,431
+ ,436
+ ,443
+ ,448
+ ,460
+ ,81
+ ,484
+ ,431
+ ,436
+ ,443
+ ,448
+ ,94.7
+ ,510
+ ,484
+ ,431
+ ,436
+ ,443
+ ,101
+ ,513
+ ,510
+ ,484
+ ,431
+ ,436
+ ,109.4
+ ,503
+ ,513
+ ,510
+ ,484
+ ,431
+ ,102.3
+ ,471
+ ,503
+ ,513
+ ,510
+ ,484
+ ,90.7
+ ,471
+ ,471
+ ,503
+ ,513
+ ,510
+ ,96.2
+ ,476
+ ,471
+ ,471
+ ,503
+ ,513
+ ,96.1
+ ,475
+ ,476
+ ,471
+ ,471
+ ,503
+ ,106
+ ,470
+ ,475
+ ,476
+ ,471
+ ,471
+ ,103.1
+ ,461
+ ,470
+ ,475
+ ,476
+ ,471
+ ,102
+ ,455
+ ,461
+ ,470
+ ,475
+ ,476
+ ,104.7
+ ,456
+ ,455
+ ,461
+ ,470
+ ,475
+ ,86
+ ,517
+ ,456
+ ,455
+ ,461
+ ,470
+ ,92.1
+ ,525
+ ,517
+ ,456
+ ,455
+ ,461
+ ,106.9
+ ,523
+ ,525
+ ,517
+ ,456
+ ,455
+ ,112.6
+ ,519
+ ,523
+ ,525
+ ,517
+ ,456
+ ,101.7
+ ,509
+ ,519
+ ,523
+ ,525
+ ,517
+ ,92
+ ,512
+ ,509
+ ,519
+ ,523
+ ,525
+ ,97.4
+ ,519
+ ,512
+ ,509
+ ,519
+ ,523
+ ,97
+ ,517
+ ,519
+ ,512
+ ,509
+ ,519
+ ,105.4
+ ,510
+ ,517
+ ,519
+ ,512
+ ,509
+ ,102.7
+ ,509
+ ,510
+ ,517
+ ,519
+ ,512
+ ,98.1
+ ,501
+ ,509
+ ,510
+ ,517
+ ,519
+ ,104.5
+ ,507
+ ,501
+ ,509
+ ,510
+ ,517
+ ,87.4
+ ,569
+ ,507
+ ,501
+ ,509
+ ,510
+ ,89.9
+ ,580
+ ,569
+ ,507
+ ,501
+ ,509
+ ,109.8
+ ,578
+ ,580
+ ,569
+ ,507
+ ,501
+ ,111.7
+ ,565
+ ,578
+ ,580
+ ,569
+ ,507
+ ,98.6
+ ,547
+ ,565
+ ,578
+ ,580
+ ,569
+ ,96.9
+ ,555
+ ,547
+ ,565
+ ,578
+ ,580
+ ,95.1
+ ,562
+ ,555
+ ,547
+ ,565
+ ,578
+ ,97
+ ,561
+ ,562
+ ,555
+ ,547
+ ,565
+ ,112.7
+ ,555
+ ,561
+ ,562
+ ,555
+ ,547
+ ,102.9
+ ,544
+ ,555
+ ,561
+ ,562
+ ,555
+ ,97.4
+ ,537
+ ,544
+ ,555
+ ,561
+ ,562
+ ,111.4
+ ,543
+ ,537
+ ,544
+ ,555
+ ,561
+ ,87.4
+ ,594
+ ,543
+ ,537
+ ,544
+ ,555
+ ,96.8
+ ,611
+ ,594
+ ,543
+ ,537
+ ,544
+ ,114.1
+ ,613
+ ,611
+ ,594
+ ,543
+ ,537
+ ,110.3
+ ,611
+ ,613
+ ,611
+ ,594
+ ,543
+ ,103.9
+ ,594
+ ,611
+ ,613
+ ,611
+ ,594
+ ,101.6
+ ,595
+ ,594
+ ,611
+ ,613
+ ,611
+ ,94.6
+ ,591
+ ,595
+ ,594
+ ,611
+ ,613
+ ,95.9
+ ,589
+ ,591
+ ,595
+ ,594
+ ,611
+ ,104.7
+ ,584
+ ,589
+ ,591
+ ,595
+ ,594
+ ,102.8
+ ,573
+ ,584
+ ,589
+ ,591
+ ,595
+ ,98.1
+ ,567
+ ,573
+ ,584
+ ,589
+ ,591
+ ,113.9
+ ,569
+ ,567
+ ,573
+ ,584
+ ,589
+ ,80.9
+ ,621
+ ,569
+ ,567
+ ,573
+ ,584
+ ,95.7
+ ,629
+ ,621
+ ,569
+ ,567
+ ,573
+ ,113.2
+ ,628
+ ,629
+ ,621
+ ,569
+ ,567
+ ,105.9
+ ,612
+ ,628
+ ,629
+ ,621
+ ,569
+ ,108.8
+ ,595
+ ,612
+ ,628
+ ,629
+ ,621
+ ,102.3
+ ,597
+ ,595
+ ,612
+ ,628
+ ,629
+ ,99
+ ,593
+ ,597
+ ,595
+ ,612
+ ,628
+ ,100.7
+ ,590
+ ,593
+ ,597
+ ,595
+ ,612
+ ,115.5
+ ,580
+ ,590
+ ,593
+ ,597
+ ,595
+ ,100.7
+ ,574
+ ,580
+ ,590
+ ,593
+ ,597
+ ,109.9
+ ,573
+ ,574
+ ,580
+ ,590
+ ,593
+ ,114.6
+ ,573
+ ,573
+ ,574
+ ,580
+ ,590
+ ,85.4
+ ,620
+ ,573
+ ,573
+ ,574
+ ,580
+ ,100.5
+ ,626
+ ,620
+ ,573
+ ,573
+ ,574
+ ,114.8
+ ,620
+ ,626
+ ,620
+ ,573
+ ,573
+ ,116.5
+ ,588
+ ,620
+ ,626
+ ,620
+ ,573
+ ,112.9
+ ,566
+ ,588
+ ,620
+ ,626
+ ,620
+ ,102
+ ,557
+ ,566
+ ,588
+ ,620
+ ,626)
+ ,dim=c(6
+ ,68)
+ ,dimnames=list(c('X'
+ ,'Y'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)')
+ ,1:68))
> y <- array(NA,dim=c(6,68),dimnames=list(c('X','Y','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)'),1:68))
> 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
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 Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 436 101.9 443 448 460 467 1 0 0 0 0 0 0 0 0 0 0 1
2 431 106.2 436 443 448 460 0 1 0 0 0 0 0 0 0 0 0 2
3 484 81.0 431 436 443 448 0 0 1 0 0 0 0 0 0 0 0 3
4 510 94.7 484 431 436 443 0 0 0 1 0 0 0 0 0 0 0 4
5 513 101.0 510 484 431 436 0 0 0 0 1 0 0 0 0 0 0 5
6 503 109.4 513 510 484 431 0 0 0 0 0 1 0 0 0 0 0 6
7 471 102.3 503 513 510 484 0 0 0 0 0 0 1 0 0 0 0 7
8 471 90.7 471 503 513 510 0 0 0 0 0 0 0 1 0 0 0 8
9 476 96.2 471 471 503 513 0 0 0 0 0 0 0 0 1 0 0 9
10 475 96.1 476 471 471 503 0 0 0 0 0 0 0 0 0 1 0 10
11 470 106.0 475 476 471 471 0 0 0 0 0 0 0 0 0 0 1 11
12 461 103.1 470 475 476 471 0 0 0 0 0 0 0 0 0 0 0 12
13 455 102.0 461 470 475 476 1 0 0 0 0 0 0 0 0 0 0 13
14 456 104.7 455 461 470 475 0 1 0 0 0 0 0 0 0 0 0 14
15 517 86.0 456 455 461 470 0 0 1 0 0 0 0 0 0 0 0 15
16 525 92.1 517 456 455 461 0 0 0 1 0 0 0 0 0 0 0 16
17 523 106.9 525 517 456 455 0 0 0 0 1 0 0 0 0 0 0 17
18 519 112.6 523 525 517 456 0 0 0 0 0 1 0 0 0 0 0 18
19 509 101.7 519 523 525 517 0 0 0 0 0 0 1 0 0 0 0 19
20 512 92.0 509 519 523 525 0 0 0 0 0 0 0 1 0 0 0 20
21 519 97.4 512 509 519 523 0 0 0 0 0 0 0 0 1 0 0 21
22 517 97.0 519 512 509 519 0 0 0 0 0 0 0 0 0 1 0 22
23 510 105.4 517 519 512 509 0 0 0 0 0 0 0 0 0 0 1 23
24 509 102.7 510 517 519 512 0 0 0 0 0 0 0 0 0 0 0 24
25 501 98.1 509 510 517 519 1 0 0 0 0 0 0 0 0 0 0 25
26 507 104.5 501 509 510 517 0 1 0 0 0 0 0 0 0 0 0 26
27 569 87.4 507 501 509 510 0 0 1 0 0 0 0 0 0 0 0 27
28 580 89.9 569 507 501 509 0 0 0 1 0 0 0 0 0 0 0 28
29 578 109.8 580 569 507 501 0 0 0 0 1 0 0 0 0 0 0 29
30 565 111.7 578 580 569 507 0 0 0 0 0 1 0 0 0 0 0 30
31 547 98.6 565 578 580 569 0 0 0 0 0 0 1 0 0 0 0 31
32 555 96.9 547 565 578 580 0 0 0 0 0 0 0 1 0 0 0 32
33 562 95.1 555 547 565 578 0 0 0 0 0 0 0 0 1 0 0 33
34 561 97.0 562 555 547 565 0 0 0 0 0 0 0 0 0 1 0 34
35 555 112.7 561 562 555 547 0 0 0 0 0 0 0 0 0 0 1 35
36 544 102.9 555 561 562 555 0 0 0 0 0 0 0 0 0 0 0 36
37 537 97.4 544 555 561 562 1 0 0 0 0 0 0 0 0 0 0 37
38 543 111.4 537 544 555 561 0 1 0 0 0 0 0 0 0 0 0 38
39 594 87.4 543 537 544 555 0 0 1 0 0 0 0 0 0 0 0 39
40 611 96.8 594 543 537 544 0 0 0 1 0 0 0 0 0 0 0 40
41 613 114.1 611 594 543 537 0 0 0 0 1 0 0 0 0 0 0 41
42 611 110.3 613 611 594 543 0 0 0 0 0 1 0 0 0 0 0 42
43 594 103.9 611 613 611 594 0 0 0 0 0 0 1 0 0 0 0 43
44 595 101.6 594 611 613 611 0 0 0 0 0 0 0 1 0 0 0 44
45 591 94.6 595 594 611 613 0 0 0 0 0 0 0 0 1 0 0 45
46 589 95.9 591 595 594 611 0 0 0 0 0 0 0 0 0 1 0 46
47 584 104.7 589 591 595 594 0 0 0 0 0 0 0 0 0 0 1 47
48 573 102.8 584 589 591 595 0 0 0 0 0 0 0 0 0 0 0 48
49 567 98.1 573 584 589 591 1 0 0 0 0 0 0 0 0 0 0 49
50 569 113.9 567 573 584 589 0 1 0 0 0 0 0 0 0 0 0 50
51 621 80.9 569 567 573 584 0 0 1 0 0 0 0 0 0 0 0 51
52 629 95.7 621 569 567 573 0 0 0 1 0 0 0 0 0 0 0 52
53 628 113.2 629 621 569 567 0 0 0 0 1 0 0 0 0 0 0 53
54 612 105.9 628 629 621 569 0 0 0 0 0 1 0 0 0 0 0 54
55 595 108.8 612 628 629 621 0 0 0 0 0 0 1 0 0 0 0 55
56 597 102.3 595 612 628 629 0 0 0 0 0 0 0 1 0 0 0 56
57 593 99.0 597 595 612 628 0 0 0 0 0 0 0 0 1 0 0 57
58 590 100.7 593 597 595 612 0 0 0 0 0 0 0 0 0 1 0 58
59 580 115.5 590 593 597 595 0 0 0 0 0 0 0 0 0 0 1 59
60 574 100.7 580 590 593 597 0 0 0 0 0 0 0 0 0 0 0 60
61 573 109.9 574 580 590 593 1 0 0 0 0 0 0 0 0 0 0 61
62 573 114.6 573 574 580 590 0 1 0 0 0 0 0 0 0 0 0 62
63 620 85.4 573 573 574 580 0 0 1 0 0 0 0 0 0 0 0 63
64 626 100.5 620 573 573 574 0 0 0 1 0 0 0 0 0 0 0 64
65 620 114.8 626 620 573 573 0 0 0 0 1 0 0 0 0 0 0 65
66 588 116.5 620 626 620 573 0 0 0 0 0 1 0 0 0 0 0 66
67 566 112.9 588 620 626 620 0 0 0 0 0 0 1 0 0 0 0 67
68 557 102.0 566 588 620 626 0 0 0 0 0 0 0 1 0 0 0 68
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)`
-92.3661 0.3626 1.1470 -0.1107 -0.1038 0.1839
M1 M2 M3 M4 M5 M6
1.4332 6.2253 67.9439 15.8730 2.5670 -2.3717
M7 M8 M9 M10 M11 t
-13.0528 9.0946 6.3060 2.0873 -2.2235 -0.4107
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-15.3015 -2.3176 -0.1695 2.4085 10.1202
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -92.3661 40.9304 -2.257 0.02843 *
X 0.3626 0.2404 1.508 0.13773
`Y(t-1)` 1.1470 0.1399 8.198 8.22e-11 ***
`Y(t-2)` -0.1107 0.2145 -0.516 0.60817
`Y(t-3)` -0.1038 0.2363 -0.439 0.66235
`Y(t-4)` 0.1839 0.1696 1.084 0.28347
M1 1.4332 3.4301 0.418 0.67786
M2 6.2253 4.0444 1.539 0.13005
M3 67.9439 5.7056 11.908 3.28e-16 ***
M4 15.8730 9.3954 1.689 0.09736 .
M5 2.5670 9.3545 0.274 0.78490
M6 -2.3717 8.7732 -0.270 0.78801
M7 -13.0528 3.9198 -3.330 0.00164 **
M8 9.0946 4.4691 2.035 0.04717 *
M9 6.3060 4.9766 1.267 0.21098
M10 2.0873 4.9600 0.421 0.67569
M11 -2.2235 3.8882 -0.572 0.56998
t -0.4107 0.1623 -2.530 0.01458 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.397 on 50 degrees of freedom
Multiple R-squared: 0.992, Adjusted R-squared: 0.9893
F-statistic: 366.5 on 17 and 50 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.9589225 0.08215503 0.04107752
[2,] 0.9622814 0.07543728 0.03771864
[3,] 0.9280020 0.14399609 0.07199804
[4,] 0.9007061 0.19858772 0.09929386
[5,] 0.8702988 0.25940249 0.12970125
[6,] 0.8263293 0.34734150 0.17367075
[7,] 0.8079947 0.38401054 0.19200527
[8,] 0.7981641 0.40367178 0.20183589
[9,] 0.7719140 0.45617190 0.22808595
[10,] 0.7575012 0.48499762 0.24249881
[11,] 0.6969126 0.60617481 0.30308740
[12,] 0.6151818 0.76963633 0.38481816
[13,] 0.5642875 0.87142494 0.43571247
[14,] 0.4937319 0.98746379 0.50626811
[15,] 0.4093360 0.81867198 0.59066401
[16,] 0.3707188 0.74143764 0.62928118
[17,] 0.3959467 0.79189335 0.60405333
[18,] 0.3000499 0.60009983 0.69995009
[19,] 0.3797601 0.75952022 0.62023989
[20,] 0.2828764 0.56575271 0.71712365
[21,] 0.2135179 0.42703589 0.78648206
[22,] 0.6843467 0.63130666 0.31565333
[23,] 0.5797385 0.84052304 0.42026152
[24,] 0.4950931 0.99018628 0.50490686
[25,] 0.4206033 0.84120659 0.57939670
[26,] 0.2845373 0.56907452 0.71546274
[27,] 0.1656597 0.33131932 0.83434034
> postscript(file="/var/www/html/rcomp/tmp/1hyar1260803053.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/28bu21260803053.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/3c8hf1260803053.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/4hxgk1260803053.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/5i7hn1260803053.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 = 68
Frequency = 1
1 2 3 4 5 6
-6.2955761 -9.7188797 -2.2402061 10.1202148 1.3623020 -0.4767464
7 8 9 10 11 12
-14.0553850 -0.4570521 0.6169832 -2.9356250 0.7808104 -2.8367790
13 14 15 16 17 18
-0.7136671 0.4769149 5.1244072 -5.4320982 -0.3015854 8.3089965
19 20 21 22 23 24
7.3330346 1.4626884 5.1086579 -0.1167054 -0.2222915 5.9269393
25 26 27 28 29 30
-2.5499095 5.4544972 5.7636378 -2.7599738 -1.9224438 -1.4175776
31 32 33 34 35 36
0.8550780 4.7123583 3.4145430 -0.2670469 -1.1766077 -4.4085652
37 38 39 40 41 42
0.1257350 3.0404974 -6.2596103 3.2747634 0.7718575 9.2775445
43 44 45 46 47 48
0.5916160 -2.9514904 -4.8173730 0.6423219 2.2541465 -4.9549660
49 50 51 52 53 54
2.3189443 -0.2783464 -0.7998965 -3.7095594 0.5497826 -0.3907053
55 56 57 58 59 60
2.1591370 0.9335619 -4.3228111 2.6770554 -1.6360578 6.2733710
61 62 63 64 65 66
7.1144734 1.0253165 -1.5883320 -1.4933467 -0.4599130 -15.3015117
67 68
3.1165194 -3.7000661
> postscript(file="/var/www/html/rcomp/tmp/6bdi21260803053.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 = 68
Frequency = 1
lag(myerror, k = 1) myerror
0 -6.2955761 NA
1 -9.7188797 -6.2955761
2 -2.2402061 -9.7188797
3 10.1202148 -2.2402061
4 1.3623020 10.1202148
5 -0.4767464 1.3623020
6 -14.0553850 -0.4767464
7 -0.4570521 -14.0553850
8 0.6169832 -0.4570521
9 -2.9356250 0.6169832
10 0.7808104 -2.9356250
11 -2.8367790 0.7808104
12 -0.7136671 -2.8367790
13 0.4769149 -0.7136671
14 5.1244072 0.4769149
15 -5.4320982 5.1244072
16 -0.3015854 -5.4320982
17 8.3089965 -0.3015854
18 7.3330346 8.3089965
19 1.4626884 7.3330346
20 5.1086579 1.4626884
21 -0.1167054 5.1086579
22 -0.2222915 -0.1167054
23 5.9269393 -0.2222915
24 -2.5499095 5.9269393
25 5.4544972 -2.5499095
26 5.7636378 5.4544972
27 -2.7599738 5.7636378
28 -1.9224438 -2.7599738
29 -1.4175776 -1.9224438
30 0.8550780 -1.4175776
31 4.7123583 0.8550780
32 3.4145430 4.7123583
33 -0.2670469 3.4145430
34 -1.1766077 -0.2670469
35 -4.4085652 -1.1766077
36 0.1257350 -4.4085652
37 3.0404974 0.1257350
38 -6.2596103 3.0404974
39 3.2747634 -6.2596103
40 0.7718575 3.2747634
41 9.2775445 0.7718575
42 0.5916160 9.2775445
43 -2.9514904 0.5916160
44 -4.8173730 -2.9514904
45 0.6423219 -4.8173730
46 2.2541465 0.6423219
47 -4.9549660 2.2541465
48 2.3189443 -4.9549660
49 -0.2783464 2.3189443
50 -0.7998965 -0.2783464
51 -3.7095594 -0.7998965
52 0.5497826 -3.7095594
53 -0.3907053 0.5497826
54 2.1591370 -0.3907053
55 0.9335619 2.1591370
56 -4.3228111 0.9335619
57 2.6770554 -4.3228111
58 -1.6360578 2.6770554
59 6.2733710 -1.6360578
60 7.1144734 6.2733710
61 1.0253165 7.1144734
62 -1.5883320 1.0253165
63 -1.4933467 -1.5883320
64 -0.4599130 -1.4933467
65 -15.3015117 -0.4599130
66 3.1165194 -15.3015117
67 -3.7000661 3.1165194
68 NA -3.7000661
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -9.7188797 -6.2955761
[2,] -2.2402061 -9.7188797
[3,] 10.1202148 -2.2402061
[4,] 1.3623020 10.1202148
[5,] -0.4767464 1.3623020
[6,] -14.0553850 -0.4767464
[7,] -0.4570521 -14.0553850
[8,] 0.6169832 -0.4570521
[9,] -2.9356250 0.6169832
[10,] 0.7808104 -2.9356250
[11,] -2.8367790 0.7808104
[12,] -0.7136671 -2.8367790
[13,] 0.4769149 -0.7136671
[14,] 5.1244072 0.4769149
[15,] -5.4320982 5.1244072
[16,] -0.3015854 -5.4320982
[17,] 8.3089965 -0.3015854
[18,] 7.3330346 8.3089965
[19,] 1.4626884 7.3330346
[20,] 5.1086579 1.4626884
[21,] -0.1167054 5.1086579
[22,] -0.2222915 -0.1167054
[23,] 5.9269393 -0.2222915
[24,] -2.5499095 5.9269393
[25,] 5.4544972 -2.5499095
[26,] 5.7636378 5.4544972
[27,] -2.7599738 5.7636378
[28,] -1.9224438 -2.7599738
[29,] -1.4175776 -1.9224438
[30,] 0.8550780 -1.4175776
[31,] 4.7123583 0.8550780
[32,] 3.4145430 4.7123583
[33,] -0.2670469 3.4145430
[34,] -1.1766077 -0.2670469
[35,] -4.4085652 -1.1766077
[36,] 0.1257350 -4.4085652
[37,] 3.0404974 0.1257350
[38,] -6.2596103 3.0404974
[39,] 3.2747634 -6.2596103
[40,] 0.7718575 3.2747634
[41,] 9.2775445 0.7718575
[42,] 0.5916160 9.2775445
[43,] -2.9514904 0.5916160
[44,] -4.8173730 -2.9514904
[45,] 0.6423219 -4.8173730
[46,] 2.2541465 0.6423219
[47,] -4.9549660 2.2541465
[48,] 2.3189443 -4.9549660
[49,] -0.2783464 2.3189443
[50,] -0.7998965 -0.2783464
[51,] -3.7095594 -0.7998965
[52,] 0.5497826 -3.7095594
[53,] -0.3907053 0.5497826
[54,] 2.1591370 -0.3907053
[55,] 0.9335619 2.1591370
[56,] -4.3228111 0.9335619
[57,] 2.6770554 -4.3228111
[58,] -1.6360578 2.6770554
[59,] 6.2733710 -1.6360578
[60,] 7.1144734 6.2733710
[61,] 1.0253165 7.1144734
[62,] -1.5883320 1.0253165
[63,] -1.4933467 -1.5883320
[64,] -0.4599130 -1.4933467
[65,] -15.3015117 -0.4599130
[66,] 3.1165194 -15.3015117
[67,] -3.7000661 3.1165194
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -9.7188797 -6.2955761
2 -2.2402061 -9.7188797
3 10.1202148 -2.2402061
4 1.3623020 10.1202148
5 -0.4767464 1.3623020
6 -14.0553850 -0.4767464
7 -0.4570521 -14.0553850
8 0.6169832 -0.4570521
9 -2.9356250 0.6169832
10 0.7808104 -2.9356250
11 -2.8367790 0.7808104
12 -0.7136671 -2.8367790
13 0.4769149 -0.7136671
14 5.1244072 0.4769149
15 -5.4320982 5.1244072
16 -0.3015854 -5.4320982
17 8.3089965 -0.3015854
18 7.3330346 8.3089965
19 1.4626884 7.3330346
20 5.1086579 1.4626884
21 -0.1167054 5.1086579
22 -0.2222915 -0.1167054
23 5.9269393 -0.2222915
24 -2.5499095 5.9269393
25 5.4544972 -2.5499095
26 5.7636378 5.4544972
27 -2.7599738 5.7636378
28 -1.9224438 -2.7599738
29 -1.4175776 -1.9224438
30 0.8550780 -1.4175776
31 4.7123583 0.8550780
32 3.4145430 4.7123583
33 -0.2670469 3.4145430
34 -1.1766077 -0.2670469
35 -4.4085652 -1.1766077
36 0.1257350 -4.4085652
37 3.0404974 0.1257350
38 -6.2596103 3.0404974
39 3.2747634 -6.2596103
40 0.7718575 3.2747634
41 9.2775445 0.7718575
42 0.5916160 9.2775445
43 -2.9514904 0.5916160
44 -4.8173730 -2.9514904
45 0.6423219 -4.8173730
46 2.2541465 0.6423219
47 -4.9549660 2.2541465
48 2.3189443 -4.9549660
49 -0.2783464 2.3189443
50 -0.7998965 -0.2783464
51 -3.7095594 -0.7998965
52 0.5497826 -3.7095594
53 -0.3907053 0.5497826
54 2.1591370 -0.3907053
55 0.9335619 2.1591370
56 -4.3228111 0.9335619
57 2.6770554 -4.3228111
58 -1.6360578 2.6770554
59 6.2733710 -1.6360578
60 7.1144734 6.2733710
61 1.0253165 7.1144734
62 -1.5883320 1.0253165
63 -1.4933467 -1.5883320
64 -0.4599130 -1.4933467
65 -15.3015117 -0.4599130
66 3.1165194 -15.3015117
67 -3.7000661 3.1165194
> 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/7976y1260803053.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/8ak411260803053.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/9gxdm1260803053.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/10al4d1260803053.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/11ihgl1260803053.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/12wcgx1260803053.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/13r44g1260803053.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/143n6a1260803053.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/155nnd1260803053.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/16ajmc1260803053.tab")
+ }
>
> try(system("convert tmp/1hyar1260803053.ps tmp/1hyar1260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/28bu21260803053.ps tmp/28bu21260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/3c8hf1260803053.ps tmp/3c8hf1260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/4hxgk1260803053.ps tmp/4hxgk1260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/5i7hn1260803053.ps tmp/5i7hn1260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/6bdi21260803053.ps tmp/6bdi21260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/7976y1260803053.ps tmp/7976y1260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/8ak411260803053.ps tmp/8ak411260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/9gxdm1260803053.ps tmp/9gxdm1260803053.png",intern=TRUE))
character(0)
> try(system("convert tmp/10al4d1260803053.ps tmp/10al4d1260803053.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.465 1.638 3.760