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(501
+ ,98.1
+ ,509
+ ,510
+ ,517
+ ,519
+ ,507
+ ,104.5
+ ,501
+ ,509
+ ,510
+ ,517
+ ,569
+ ,87.4
+ ,507
+ ,501
+ ,509
+ ,510
+ ,580
+ ,89.9
+ ,569
+ ,507
+ ,501
+ ,509
+ ,578
+ ,109.8
+ ,580
+ ,569
+ ,507
+ ,501
+ ,565
+ ,111.7
+ ,578
+ ,580
+ ,569
+ ,507
+ ,547
+ ,98.6
+ ,565
+ ,578
+ ,580
+ ,569
+ ,555
+ ,96.9
+ ,547
+ ,565
+ ,578
+ ,580
+ ,562
+ ,95.1
+ ,555
+ ,547
+ ,565
+ ,578
+ ,561
+ ,97
+ ,562
+ ,555
+ ,547
+ ,565
+ ,555
+ ,112.7
+ ,561
+ ,562
+ ,555
+ ,547
+ ,544
+ ,102.9
+ ,555
+ ,561
+ ,562
+ ,555
+ ,537
+ ,97.4
+ ,544
+ ,555
+ ,561
+ ,562
+ ,543
+ ,111.4
+ ,537
+ ,544
+ ,555
+ ,561
+ ,594
+ ,87.4
+ ,543
+ ,537
+ ,544
+ ,555
+ ,611
+ ,96.8
+ ,594
+ ,543
+ ,537
+ ,544
+ ,613
+ ,114.1
+ ,611
+ ,594
+ ,543
+ ,537
+ ,611
+ ,110.3
+ ,613
+ ,611
+ ,594
+ ,543
+ ,594
+ ,103.9
+ ,611
+ ,613
+ ,611
+ ,594
+ ,595
+ ,101.6
+ ,594
+ ,611
+ ,613
+ ,611
+ ,591
+ ,94.6
+ ,595
+ ,594
+ ,611
+ ,613
+ ,589
+ ,95.9
+ ,591
+ ,595
+ ,594
+ ,611
+ ,584
+ ,104.7
+ ,589
+ ,591
+ ,595
+ ,594
+ ,573
+ ,102.8
+ ,584
+ ,589
+ ,591
+ ,595
+ ,567
+ ,98.1
+ ,573
+ ,584
+ ,589
+ ,591
+ ,569
+ ,113.9
+ ,567
+ ,573
+ ,584
+ ,589
+ ,621
+ ,80.9
+ ,569
+ ,567
+ ,573
+ ,584
+ ,629
+ ,95.7
+ ,621
+ ,569
+ ,567
+ ,573
+ ,628
+ ,113.2
+ ,629
+ ,621
+ ,569
+ ,567
+ ,612
+ ,105.9
+ ,628
+ ,629
+ ,621
+ ,569
+ ,595
+ ,108.8
+ ,612
+ ,628
+ ,629
+ ,621
+ ,597
+ ,102.3
+ ,595
+ ,612
+ ,628
+ ,629
+ ,593
+ ,99
+ ,597
+ ,595
+ ,612
+ ,628
+ ,590
+ ,100.7
+ ,593
+ ,597
+ ,595
+ ,612
+ ,580
+ ,115.5
+ ,590
+ ,593
+ ,597
+ ,595
+ ,574
+ ,100.7
+ ,580
+ ,590
+ ,593
+ ,597
+ ,573
+ ,109.9
+ ,574
+ ,580
+ ,590
+ ,593
+ ,573
+ ,114.6
+ ,573
+ ,574
+ ,580
+ ,590
+ ,620
+ ,85.4
+ ,573
+ ,573
+ ,574
+ ,580
+ ,626
+ ,100.5
+ ,620
+ ,573
+ ,573
+ ,574
+ ,620
+ ,114.8
+ ,626
+ ,620
+ ,573
+ ,573
+ ,588
+ ,116.5
+ ,620
+ ,626
+ ,620
+ ,573
+ ,566
+ ,112.9
+ ,588
+ ,620
+ ,626
+ ,620
+ ,557
+ ,102
+ ,566
+ ,588
+ ,620
+ ,626
+ ,561
+ ,106
+ ,557
+ ,566
+ ,588
+ ,620
+ ,549
+ ,105.3
+ ,561
+ ,557
+ ,566
+ ,588
+ ,532
+ ,118.8
+ ,549
+ ,561
+ ,557
+ ,566
+ ,526
+ ,106.1
+ ,532
+ ,549
+ ,561
+ ,557
+ ,511
+ ,109.3
+ ,526
+ ,532
+ ,549
+ ,561
+ ,499
+ ,117.2
+ ,511
+ ,526
+ ,532
+ ,549
+ ,555
+ ,92.5
+ ,499
+ ,511
+ ,526
+ ,532
+ ,565
+ ,104.2
+ ,555
+ ,499
+ ,511
+ ,526
+ ,542
+ ,112.5
+ ,565
+ ,555
+ ,499
+ ,511
+ ,527
+ ,122.4
+ ,542
+ ,565
+ ,555
+ ,499
+ ,510
+ ,113.3
+ ,527
+ ,542
+ ,565
+ ,555
+ ,514
+ ,100
+ ,510
+ ,527
+ ,542
+ ,565
+ ,517
+ ,110.7
+ ,514
+ ,510
+ ,527
+ ,542
+ ,508
+ ,112.8
+ ,517
+ ,514
+ ,510
+ ,527
+ ,493
+ ,109.8
+ ,508
+ ,517
+ ,514
+ ,510
+ ,490
+ ,117.3
+ ,493
+ ,508
+ ,517
+ ,514
+ ,469
+ ,109.1
+ ,490
+ ,493
+ ,508
+ ,517
+ ,478
+ ,115.9
+ ,469
+ ,490
+ ,493
+ ,508
+ ,528
+ ,96
+ ,478
+ ,469
+ ,490
+ ,493
+ ,534
+ ,99.8
+ ,528
+ ,478
+ ,469
+ ,490
+ ,518
+ ,116.8
+ ,534
+ ,528
+ ,478
+ ,469
+ ,506
+ ,115.7
+ ,518
+ ,534
+ ,528
+ ,478
+ ,502
+ ,99.4
+ ,506
+ ,518
+ ,534
+ ,528
+ ,516
+ ,94.3
+ ,502
+ ,506
+ ,518
+ ,534)
+ ,dim=c(6
+ ,68)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:68))
> y <- array(NA,dim=c(6,68),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),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 = 'No Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 501 98.1 509 510 517 519 1 0 0 0 0 0 0 0 0 0 0
2 507 104.5 501 509 510 517 0 1 0 0 0 0 0 0 0 0 0
3 569 87.4 507 501 509 510 0 0 1 0 0 0 0 0 0 0 0
4 580 89.9 569 507 501 509 0 0 0 1 0 0 0 0 0 0 0
5 578 109.8 580 569 507 501 0 0 0 0 1 0 0 0 0 0 0
6 565 111.7 578 580 569 507 0 0 0 0 0 1 0 0 0 0 0
7 547 98.6 565 578 580 569 0 0 0 0 0 0 1 0 0 0 0
8 555 96.9 547 565 578 580 0 0 0 0 0 0 0 1 0 0 0
9 562 95.1 555 547 565 578 0 0 0 0 0 0 0 0 1 0 0
10 561 97.0 562 555 547 565 0 0 0 0 0 0 0 0 0 1 0
11 555 112.7 561 562 555 547 0 0 0 0 0 0 0 0 0 0 1
12 544 102.9 555 561 562 555 0 0 0 0 0 0 0 0 0 0 0
13 537 97.4 544 555 561 562 1 0 0 0 0 0 0 0 0 0 0
14 543 111.4 537 544 555 561 0 1 0 0 0 0 0 0 0 0 0
15 594 87.4 543 537 544 555 0 0 1 0 0 0 0 0 0 0 0
16 611 96.8 594 543 537 544 0 0 0 1 0 0 0 0 0 0 0
17 613 114.1 611 594 543 537 0 0 0 0 1 0 0 0 0 0 0
18 611 110.3 613 611 594 543 0 0 0 0 0 1 0 0 0 0 0
19 594 103.9 611 613 611 594 0 0 0 0 0 0 1 0 0 0 0
20 595 101.6 594 611 613 611 0 0 0 0 0 0 0 1 0 0 0
21 591 94.6 595 594 611 613 0 0 0 0 0 0 0 0 1 0 0
22 589 95.9 591 595 594 611 0 0 0 0 0 0 0 0 0 1 0
23 584 104.7 589 591 595 594 0 0 0 0 0 0 0 0 0 0 1
24 573 102.8 584 589 591 595 0 0 0 0 0 0 0 0 0 0 0
25 567 98.1 573 584 589 591 1 0 0 0 0 0 0 0 0 0 0
26 569 113.9 567 573 584 589 0 1 0 0 0 0 0 0 0 0 0
27 621 80.9 569 567 573 584 0 0 1 0 0 0 0 0 0 0 0
28 629 95.7 621 569 567 573 0 0 0 1 0 0 0 0 0 0 0
29 628 113.2 629 621 569 567 0 0 0 0 1 0 0 0 0 0 0
30 612 105.9 628 629 621 569 0 0 0 0 0 1 0 0 0 0 0
31 595 108.8 612 628 629 621 0 0 0 0 0 0 1 0 0 0 0
32 597 102.3 595 612 628 629 0 0 0 0 0 0 0 1 0 0 0
33 593 99.0 597 595 612 628 0 0 0 0 0 0 0 0 1 0 0
34 590 100.7 593 597 595 612 0 0 0 0 0 0 0 0 0 1 0
35 580 115.5 590 593 597 595 0 0 0 0 0 0 0 0 0 0 1
36 574 100.7 580 590 593 597 0 0 0 0 0 0 0 0 0 0 0
37 573 109.9 574 580 590 593 1 0 0 0 0 0 0 0 0 0 0
38 573 114.6 573 574 580 590 0 1 0 0 0 0 0 0 0 0 0
39 620 85.4 573 573 574 580 0 0 1 0 0 0 0 0 0 0 0
40 626 100.5 620 573 573 574 0 0 0 1 0 0 0 0 0 0 0
41 620 114.8 626 620 573 573 0 0 0 0 1 0 0 0 0 0 0
42 588 116.5 620 626 620 573 0 0 0 0 0 1 0 0 0 0 0
43 566 112.9 588 620 626 620 0 0 0 0 0 0 1 0 0 0 0
44 557 102.0 566 588 620 626 0 0 0 0 0 0 0 1 0 0 0
45 561 106.0 557 566 588 620 0 0 0 0 0 0 0 0 1 0 0
46 549 105.3 561 557 566 588 0 0 0 0 0 0 0 0 0 1 0
47 532 118.8 549 561 557 566 0 0 0 0 0 0 0 0 0 0 1
48 526 106.1 532 549 561 557 0 0 0 0 0 0 0 0 0 0 0
49 511 109.3 526 532 549 561 1 0 0 0 0 0 0 0 0 0 0
50 499 117.2 511 526 532 549 0 1 0 0 0 0 0 0 0 0 0
51 555 92.5 499 511 526 532 0 0 1 0 0 0 0 0 0 0 0
52 565 104.2 555 499 511 526 0 0 0 1 0 0 0 0 0 0 0
53 542 112.5 565 555 499 511 0 0 0 0 1 0 0 0 0 0 0
54 527 122.4 542 565 555 499 0 0 0 0 0 1 0 0 0 0 0
55 510 113.3 527 542 565 555 0 0 0 0 0 0 1 0 0 0 0
56 514 100.0 510 527 542 565 0 0 0 0 0 0 0 1 0 0 0
57 517 110.7 514 510 527 542 0 0 0 0 0 0 0 0 1 0 0
58 508 112.8 517 514 510 527 0 0 0 0 0 0 0 0 0 1 0
59 493 109.8 508 517 514 510 0 0 0 0 0 0 0 0 0 0 1
60 490 117.3 493 508 517 514 0 0 0 0 0 0 0 0 0 0 0
61 469 109.1 490 493 508 517 1 0 0 0 0 0 0 0 0 0 0
62 478 115.9 469 490 493 508 0 1 0 0 0 0 0 0 0 0 0
63 528 96.0 478 469 490 493 0 0 1 0 0 0 0 0 0 0 0
64 534 99.8 528 478 469 490 0 0 0 1 0 0 0 0 0 0 0
65 518 116.8 534 528 478 469 0 0 0 0 1 0 0 0 0 0 0
66 506 115.7 518 534 528 478 0 0 0 0 0 1 0 0 0 0 0
67 502 99.4 506 518 534 528 0 0 0 0 0 0 1 0 0 0 0
68 516 94.3 502 506 518 534 0 0 0 0 0 0 0 1 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
47.81280 -0.32412 1.04159 -0.01157 0.12074 -0.18704
M1 M2 M3 M4 M5 M6
-2.37853 12.75717 54.64038 12.20172 -1.85566 -14.74455
M7 M8 M9 M10 M11
-8.75987 11.47557 10.62730 3.67932 -1.60303
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-14.243 -2.798 0.462 2.846 12.099
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 47.81280 26.16587 1.827 0.07351 .
X -0.32412 0.18869 -1.718 0.09191 .
Y1 1.04159 0.14515 7.176 2.87e-09 ***
Y2 -0.01157 0.20495 -0.056 0.95519
Y3 0.12074 0.21113 0.572 0.56991
Y4 -0.18704 0.14271 -1.311 0.19584
M1 -2.37853 4.19139 -0.567 0.57288
M2 12.75717 4.41505 2.889 0.00565 **
M3 54.64038 5.50254 9.930 1.64e-13 ***
M4 12.20172 9.89614 1.233 0.22324
M5 -1.85566 10.66125 -0.174 0.86251
M6 -14.74455 8.80015 -1.675 0.09996 .
M7 -8.75987 4.22956 -2.071 0.04343 *
M8 11.47557 4.79665 2.392 0.02046 *
M9 10.62730 5.58233 1.904 0.06259 .
M10 3.67932 5.43817 0.677 0.50173
M11 -1.60303 4.65011 -0.345 0.73172
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.546 on 51 degrees of freedom
Multiple R-squared: 0.9803, Adjusted R-squared: 0.9742
F-statistic: 158.9 on 16 and 51 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.626946599 0.746106803 0.3730534
[2,] 0.512338341 0.975323318 0.4876617
[3,] 0.366202291 0.732404582 0.6337977
[4,] 0.255878374 0.511756749 0.7441216
[5,] 0.171581022 0.343162043 0.8284190
[6,] 0.114031506 0.228063012 0.8859685
[7,] 0.075306909 0.150613818 0.9246931
[8,] 0.042039657 0.084079314 0.9579603
[9,] 0.026524101 0.053048201 0.9734759
[10,] 0.022447504 0.044895008 0.9775525
[11,] 0.017426682 0.034853363 0.9825733
[12,] 0.009575633 0.019151266 0.9904244
[13,] 0.004799697 0.009599395 0.9952003
[14,] 0.005810502 0.011621003 0.9941895
[15,] 0.002984428 0.005968856 0.9970156
[16,] 0.002578844 0.005157688 0.9974212
[17,] 0.001686936 0.003373872 0.9983131
[18,] 0.006250806 0.012501613 0.9937492
[19,] 0.005921289 0.011842578 0.9940787
[20,] 0.003724761 0.007449523 0.9962752
[21,] 0.002153020 0.004306040 0.9978470
[22,] 0.069414850 0.138829700 0.9305852
[23,] 0.261916919 0.523833839 0.7380831
[24,] 0.183680295 0.367360589 0.8163197
[25,] 0.233693174 0.467386348 0.7663068
[26,] 0.167186001 0.334372002 0.8328140
[27,] 0.119576516 0.239153031 0.8804235
[28,] 0.158649688 0.317299376 0.8413503
[29,] 0.171277410 0.342554819 0.8287226
> postscript(file="/var/www/html/rcomp/tmp/14tff1258626530.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/2nxaw1258626530.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/3uclp1258626530.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/4d1we1258626530.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/5wsup1258626530.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
-2.25591929 -0.52494440 6.51865238 -2.96287066 2.58370915 -1.06496945
7 8 9 10 11 12
-5.50950839 2.60126689 2.52064199 1.62769695 2.78861291 -6.10167678
13 14 15 16 17 18
0.31233831 3.41561710 -1.37116609 6.85009847 9.36413951 12.09921577
19 20 21 22 23 24
-3.36690340 -2.72560488 -8.76894425 2.45690522 4.32792713 -3.03608779
25 26 27 28 29 30
2.71205402 1.04936953 -1.28951804 -1.52662489 8.10818175 -2.13946488
31 32 33 34 35 36
1.23009219 0.02689171 -4.72950144 3.01894839 2.75555171 1.59380494
37 38 39 40 41 42
11.70215199 -0.29171420 -5.79682981 -2.42037603 4.37927462 -13.53681655
43 44 45 46 47 48
-1.36014548 -9.73704552 8.26901053 -4.60947437 -2.43433334 1.24813442
49 50 51 52 53 54
-2.08620570 -11.29875366 4.68247659 3.13411677 -14.24287251 1.92099398
55 56 57 58 59 60
0.61157821 2.24638756 2.70879316 -2.49407619 -7.43775841 6.29582522
61 62 63 64 65 66
-10.38441933 7.65042564 -2.74361504 -3.07434366 -10.19243252 2.72104113
67 68
8.39488686 7.58810423
> postscript(file="/var/www/html/rcomp/tmp/61bsr1258626530.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 -2.25591929 NA
1 -0.52494440 -2.25591929
2 6.51865238 -0.52494440
3 -2.96287066 6.51865238
4 2.58370915 -2.96287066
5 -1.06496945 2.58370915
6 -5.50950839 -1.06496945
7 2.60126689 -5.50950839
8 2.52064199 2.60126689
9 1.62769695 2.52064199
10 2.78861291 1.62769695
11 -6.10167678 2.78861291
12 0.31233831 -6.10167678
13 3.41561710 0.31233831
14 -1.37116609 3.41561710
15 6.85009847 -1.37116609
16 9.36413951 6.85009847
17 12.09921577 9.36413951
18 -3.36690340 12.09921577
19 -2.72560488 -3.36690340
20 -8.76894425 -2.72560488
21 2.45690522 -8.76894425
22 4.32792713 2.45690522
23 -3.03608779 4.32792713
24 2.71205402 -3.03608779
25 1.04936953 2.71205402
26 -1.28951804 1.04936953
27 -1.52662489 -1.28951804
28 8.10818175 -1.52662489
29 -2.13946488 8.10818175
30 1.23009219 -2.13946488
31 0.02689171 1.23009219
32 -4.72950144 0.02689171
33 3.01894839 -4.72950144
34 2.75555171 3.01894839
35 1.59380494 2.75555171
36 11.70215199 1.59380494
37 -0.29171420 11.70215199
38 -5.79682981 -0.29171420
39 -2.42037603 -5.79682981
40 4.37927462 -2.42037603
41 -13.53681655 4.37927462
42 -1.36014548 -13.53681655
43 -9.73704552 -1.36014548
44 8.26901053 -9.73704552
45 -4.60947437 8.26901053
46 -2.43433334 -4.60947437
47 1.24813442 -2.43433334
48 -2.08620570 1.24813442
49 -11.29875366 -2.08620570
50 4.68247659 -11.29875366
51 3.13411677 4.68247659
52 -14.24287251 3.13411677
53 1.92099398 -14.24287251
54 0.61157821 1.92099398
55 2.24638756 0.61157821
56 2.70879316 2.24638756
57 -2.49407619 2.70879316
58 -7.43775841 -2.49407619
59 6.29582522 -7.43775841
60 -10.38441933 6.29582522
61 7.65042564 -10.38441933
62 -2.74361504 7.65042564
63 -3.07434366 -2.74361504
64 -10.19243252 -3.07434366
65 2.72104113 -10.19243252
66 8.39488686 2.72104113
67 7.58810423 8.39488686
68 NA 7.58810423
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.52494440 -2.25591929
[2,] 6.51865238 -0.52494440
[3,] -2.96287066 6.51865238
[4,] 2.58370915 -2.96287066
[5,] -1.06496945 2.58370915
[6,] -5.50950839 -1.06496945
[7,] 2.60126689 -5.50950839
[8,] 2.52064199 2.60126689
[9,] 1.62769695 2.52064199
[10,] 2.78861291 1.62769695
[11,] -6.10167678 2.78861291
[12,] 0.31233831 -6.10167678
[13,] 3.41561710 0.31233831
[14,] -1.37116609 3.41561710
[15,] 6.85009847 -1.37116609
[16,] 9.36413951 6.85009847
[17,] 12.09921577 9.36413951
[18,] -3.36690340 12.09921577
[19,] -2.72560488 -3.36690340
[20,] -8.76894425 -2.72560488
[21,] 2.45690522 -8.76894425
[22,] 4.32792713 2.45690522
[23,] -3.03608779 4.32792713
[24,] 2.71205402 -3.03608779
[25,] 1.04936953 2.71205402
[26,] -1.28951804 1.04936953
[27,] -1.52662489 -1.28951804
[28,] 8.10818175 -1.52662489
[29,] -2.13946488 8.10818175
[30,] 1.23009219 -2.13946488
[31,] 0.02689171 1.23009219
[32,] -4.72950144 0.02689171
[33,] 3.01894839 -4.72950144
[34,] 2.75555171 3.01894839
[35,] 1.59380494 2.75555171
[36,] 11.70215199 1.59380494
[37,] -0.29171420 11.70215199
[38,] -5.79682981 -0.29171420
[39,] -2.42037603 -5.79682981
[40,] 4.37927462 -2.42037603
[41,] -13.53681655 4.37927462
[42,] -1.36014548 -13.53681655
[43,] -9.73704552 -1.36014548
[44,] 8.26901053 -9.73704552
[45,] -4.60947437 8.26901053
[46,] -2.43433334 -4.60947437
[47,] 1.24813442 -2.43433334
[48,] -2.08620570 1.24813442
[49,] -11.29875366 -2.08620570
[50,] 4.68247659 -11.29875366
[51,] 3.13411677 4.68247659
[52,] -14.24287251 3.13411677
[53,] 1.92099398 -14.24287251
[54,] 0.61157821 1.92099398
[55,] 2.24638756 0.61157821
[56,] 2.70879316 2.24638756
[57,] -2.49407619 2.70879316
[58,] -7.43775841 -2.49407619
[59,] 6.29582522 -7.43775841
[60,] -10.38441933 6.29582522
[61,] 7.65042564 -10.38441933
[62,] -2.74361504 7.65042564
[63,] -3.07434366 -2.74361504
[64,] -10.19243252 -3.07434366
[65,] 2.72104113 -10.19243252
[66,] 8.39488686 2.72104113
[67,] 7.58810423 8.39488686
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.52494440 -2.25591929
2 6.51865238 -0.52494440
3 -2.96287066 6.51865238
4 2.58370915 -2.96287066
5 -1.06496945 2.58370915
6 -5.50950839 -1.06496945
7 2.60126689 -5.50950839
8 2.52064199 2.60126689
9 1.62769695 2.52064199
10 2.78861291 1.62769695
11 -6.10167678 2.78861291
12 0.31233831 -6.10167678
13 3.41561710 0.31233831
14 -1.37116609 3.41561710
15 6.85009847 -1.37116609
16 9.36413951 6.85009847
17 12.09921577 9.36413951
18 -3.36690340 12.09921577
19 -2.72560488 -3.36690340
20 -8.76894425 -2.72560488
21 2.45690522 -8.76894425
22 4.32792713 2.45690522
23 -3.03608779 4.32792713
24 2.71205402 -3.03608779
25 1.04936953 2.71205402
26 -1.28951804 1.04936953
27 -1.52662489 -1.28951804
28 8.10818175 -1.52662489
29 -2.13946488 8.10818175
30 1.23009219 -2.13946488
31 0.02689171 1.23009219
32 -4.72950144 0.02689171
33 3.01894839 -4.72950144
34 2.75555171 3.01894839
35 1.59380494 2.75555171
36 11.70215199 1.59380494
37 -0.29171420 11.70215199
38 -5.79682981 -0.29171420
39 -2.42037603 -5.79682981
40 4.37927462 -2.42037603
41 -13.53681655 4.37927462
42 -1.36014548 -13.53681655
43 -9.73704552 -1.36014548
44 8.26901053 -9.73704552
45 -4.60947437 8.26901053
46 -2.43433334 -4.60947437
47 1.24813442 -2.43433334
48 -2.08620570 1.24813442
49 -11.29875366 -2.08620570
50 4.68247659 -11.29875366
51 3.13411677 4.68247659
52 -14.24287251 3.13411677
53 1.92099398 -14.24287251
54 0.61157821 1.92099398
55 2.24638756 0.61157821
56 2.70879316 2.24638756
57 -2.49407619 2.70879316
58 -7.43775841 -2.49407619
59 6.29582522 -7.43775841
60 -10.38441933 6.29582522
61 7.65042564 -10.38441933
62 -2.74361504 7.65042564
63 -3.07434366 -2.74361504
64 -10.19243252 -3.07434366
65 2.72104113 -10.19243252
66 8.39488686 2.72104113
67 7.58810423 8.39488686
> 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/7uimc1258626530.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/82q551258626530.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/9xgek1258626530.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/10dmiz1258626530.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/11o9au1258626530.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/12dm8t1258626530.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/13xvyg1258626530.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/14bjqe1258626530.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/15kbp31258626530.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/165t711258626530.tab")
+ }
>
> system("convert tmp/14tff1258626530.ps tmp/14tff1258626530.png")
> system("convert tmp/2nxaw1258626530.ps tmp/2nxaw1258626530.png")
> system("convert tmp/3uclp1258626530.ps tmp/3uclp1258626530.png")
> system("convert tmp/4d1we1258626530.ps tmp/4d1we1258626530.png")
> system("convert tmp/5wsup1258626530.ps tmp/5wsup1258626530.png")
> system("convert tmp/61bsr1258626530.ps tmp/61bsr1258626530.png")
> system("convert tmp/7uimc1258626530.ps tmp/7uimc1258626530.png")
> system("convert tmp/82q551258626530.ps tmp/82q551258626530.png")
> system("convert tmp/9xgek1258626530.ps tmp/9xgek1258626530.png")
> system("convert tmp/10dmiz1258626530.ps tmp/10dmiz1258626530.png")
>
>
> proc.time()
user system elapsed
2.512 1.561 3.393