R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(580
+ ,0
+ ,590
+ ,593
+ ,597
+ ,595
+ ,574
+ ,0
+ ,580
+ ,590
+ ,593
+ ,597
+ ,573
+ ,0
+ ,574
+ ,580
+ ,590
+ ,593
+ ,573
+ ,0
+ ,573
+ ,574
+ ,580
+ ,590
+ ,620
+ ,0
+ ,573
+ ,573
+ ,574
+ ,580
+ ,626
+ ,0
+ ,620
+ ,573
+ ,573
+ ,574
+ ,620
+ ,0
+ ,626
+ ,620
+ ,573
+ ,573
+ ,588
+ ,0
+ ,620
+ ,626
+ ,620
+ ,573
+ ,566
+ ,0
+ ,588
+ ,620
+ ,626
+ ,620
+ ,557
+ ,0
+ ,566
+ ,588
+ ,620
+ ,626
+ ,561
+ ,0
+ ,557
+ ,566
+ ,588
+ ,620
+ ,549
+ ,0
+ ,561
+ ,557
+ ,566
+ ,588
+ ,532
+ ,0
+ ,549
+ ,561
+ ,557
+ ,566
+ ,526
+ ,0
+ ,532
+ ,549
+ ,561
+ ,557
+ ,511
+ ,0
+ ,526
+ ,532
+ ,549
+ ,561
+ ,499
+ ,0
+ ,511
+ ,526
+ ,532
+ ,549
+ ,555
+ ,0
+ ,499
+ ,511
+ ,526
+ ,532
+ ,565
+ ,0
+ ,555
+ ,499
+ ,511
+ ,526
+ ,542
+ ,0
+ ,565
+ ,555
+ ,499
+ ,511
+ ,527
+ ,0
+ ,542
+ ,565
+ ,555
+ ,499
+ ,510
+ ,0
+ ,527
+ ,542
+ ,565
+ ,555
+ ,514
+ ,0
+ ,510
+ ,527
+ ,542
+ ,565
+ ,517
+ ,0
+ ,514
+ ,510
+ ,527
+ ,542
+ ,508
+ ,0
+ ,517
+ ,514
+ ,510
+ ,527
+ ,493
+ ,0
+ ,508
+ ,517
+ ,514
+ ,510
+ ,490
+ ,0
+ ,493
+ ,508
+ ,517
+ ,514
+ ,469
+ ,0
+ ,490
+ ,493
+ ,508
+ ,517
+ ,478
+ ,0
+ ,469
+ ,490
+ ,493
+ ,508
+ ,528
+ ,0
+ ,478
+ ,469
+ ,490
+ ,493
+ ,534
+ ,0
+ ,528
+ ,478
+ ,469
+ ,490
+ ,518
+ ,0
+ ,534
+ ,528
+ ,478
+ ,469
+ ,506
+ ,0
+ ,518
+ ,534
+ ,528
+ ,478
+ ,502
+ ,1
+ ,506
+ ,518
+ ,534
+ ,528
+ ,516
+ ,1
+ ,502
+ ,506
+ ,518
+ ,534
+ ,528
+ ,1
+ ,516
+ ,502
+ ,506
+ ,518
+ ,533
+ ,1
+ ,528
+ ,516
+ ,502
+ ,506
+ ,536
+ ,1
+ ,533
+ ,528
+ ,516
+ ,502
+ ,537
+ ,1
+ ,536
+ ,533
+ ,528
+ ,516
+ ,524
+ ,1
+ ,537
+ ,536
+ ,533
+ ,528
+ ,536
+ ,1
+ ,524
+ ,537
+ ,536
+ ,533
+ ,587
+ ,1
+ ,536
+ ,524
+ ,537
+ ,536
+ ,597
+ ,1
+ ,587
+ ,536
+ ,524
+ ,537
+ ,581
+ ,1
+ ,597
+ ,587
+ ,536
+ ,524
+ ,564
+ ,1
+ ,581
+ ,597
+ ,587
+ ,536
+ ,558
+ ,1
+ ,564
+ ,581
+ ,597
+ ,587
+ ,575
+ ,1
+ ,558
+ ,564
+ ,581
+ ,597
+ ,580
+ ,1
+ ,575
+ ,558
+ ,564
+ ,581
+ ,575
+ ,1
+ ,580
+ ,575
+ ,558
+ ,564
+ ,563
+ ,1
+ ,575
+ ,580
+ ,575
+ ,558
+ ,552
+ ,1
+ ,563
+ ,575
+ ,580
+ ,575
+ ,537
+ ,1
+ ,552
+ ,563
+ ,575
+ ,580
+ ,545
+ ,1
+ ,537
+ ,552
+ ,563
+ ,575
+ ,601
+ ,1
+ ,545
+ ,537
+ ,552
+ ,563
+ ,604
+ ,1
+ ,601
+ ,545
+ ,537
+ ,552
+ ,586
+ ,1
+ ,604
+ ,601
+ ,545
+ ,537
+ ,564
+ ,1
+ ,586
+ ,604
+ ,601
+ ,545
+ ,549
+ ,1
+ ,564
+ ,586
+ ,604
+ ,601)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('werkloosheid'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('werkloosheid','X','Y1','Y2','Y3','Y4'),1:57))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par20 = ''
> par19 = ''
> par18 = ''
> par17 = ''
> par16 = ''
> par15 = ''
> par14 = ''
> par13 = ''
> par12 = ''
> par11 = ''
> par10 = ''
> par9 = ''
> par8 = ''
> par7 = ''
> par6 = ''
> par5 = ''
> par4 = ''
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> ylab = ''
> xlab = ''
> main = ''
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
werkloosheid X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 580 0 590 593 597 595 1 0 0 0 0 0 0 0 0 0 0 1
2 574 0 580 590 593 597 0 1 0 0 0 0 0 0 0 0 0 2
3 573 0 574 580 590 593 0 0 1 0 0 0 0 0 0 0 0 3
4 573 0 573 574 580 590 0 0 0 1 0 0 0 0 0 0 0 4
5 620 0 573 573 574 580 0 0 0 0 1 0 0 0 0 0 0 5
6 626 0 620 573 573 574 0 0 0 0 0 1 0 0 0 0 0 6
7 620 0 626 620 573 573 0 0 0 0 0 0 1 0 0 0 0 7
8 588 0 620 626 620 573 0 0 0 0 0 0 0 1 0 0 0 8
9 566 0 588 620 626 620 0 0 0 0 0 0 0 0 1 0 0 9
10 557 0 566 588 620 626 0 0 0 0 0 0 0 0 0 1 0 10
11 561 0 557 566 588 620 0 0 0 0 0 0 0 0 0 0 1 11
12 549 0 561 557 566 588 0 0 0 0 0 0 0 0 0 0 0 12
13 532 0 549 561 557 566 1 0 0 0 0 0 0 0 0 0 0 13
14 526 0 532 549 561 557 0 1 0 0 0 0 0 0 0 0 0 14
15 511 0 526 532 549 561 0 0 1 0 0 0 0 0 0 0 0 15
16 499 0 511 526 532 549 0 0 0 1 0 0 0 0 0 0 0 16
17 555 0 499 511 526 532 0 0 0 0 1 0 0 0 0 0 0 17
18 565 0 555 499 511 526 0 0 0 0 0 1 0 0 0 0 0 18
19 542 0 565 555 499 511 0 0 0 0 0 0 1 0 0 0 0 19
20 527 0 542 565 555 499 0 0 0 0 0 0 0 1 0 0 0 20
21 510 0 527 542 565 555 0 0 0 0 0 0 0 0 1 0 0 21
22 514 0 510 527 542 565 0 0 0 0 0 0 0 0 0 1 0 22
23 517 0 514 510 527 542 0 0 0 0 0 0 0 0 0 0 1 23
24 508 0 517 514 510 527 0 0 0 0 0 0 0 0 0 0 0 24
25 493 0 508 517 514 510 1 0 0 0 0 0 0 0 0 0 0 25
26 490 0 493 508 517 514 0 1 0 0 0 0 0 0 0 0 0 26
27 469 0 490 493 508 517 0 0 1 0 0 0 0 0 0 0 0 27
28 478 0 469 490 493 508 0 0 0 1 0 0 0 0 0 0 0 28
29 528 0 478 469 490 493 0 0 0 0 1 0 0 0 0 0 0 29
30 534 0 528 478 469 490 0 0 0 0 0 1 0 0 0 0 0 30
31 518 0 534 528 478 469 0 0 0 0 0 0 1 0 0 0 0 31
32 506 0 518 534 528 478 0 0 0 0 0 0 0 1 0 0 0 32
33 502 1 506 518 534 528 0 0 0 0 0 0 0 0 1 0 0 33
34 516 1 502 506 518 534 0 0 0 0 0 0 0 0 0 1 0 34
35 528 1 516 502 506 518 0 0 0 0 0 0 0 0 0 0 1 35
36 533 1 528 516 502 506 0 0 0 0 0 0 0 0 0 0 0 36
37 536 1 533 528 516 502 1 0 0 0 0 0 0 0 0 0 0 37
38 537 1 536 533 528 516 0 1 0 0 0 0 0 0 0 0 0 38
39 524 1 537 536 533 528 0 0 1 0 0 0 0 0 0 0 0 39
40 536 1 524 537 536 533 0 0 0 1 0 0 0 0 0 0 0 40
41 587 1 536 524 537 536 0 0 0 0 1 0 0 0 0 0 0 41
42 597 1 587 536 524 537 0 0 0 0 0 1 0 0 0 0 0 42
43 581 1 597 587 536 524 0 0 0 0 0 0 1 0 0 0 0 43
44 564 1 581 597 587 536 0 0 0 0 0 0 0 1 0 0 0 44
45 558 1 564 581 597 587 0 0 0 0 0 0 0 0 1 0 0 45
46 575 1 558 564 581 597 0 0 0 0 0 0 0 0 0 1 0 46
47 580 1 575 558 564 581 0 0 0 0 0 0 0 0 0 0 1 47
48 575 1 580 575 558 564 0 0 0 0 0 0 0 0 0 0 0 48
49 563 1 575 580 575 558 1 0 0 0 0 0 0 0 0 0 0 49
50 552 1 563 575 580 575 0 1 0 0 0 0 0 0 0 0 0 50
51 537 1 552 563 575 580 0 0 1 0 0 0 0 0 0 0 0 51
52 545 1 537 552 563 575 0 0 0 1 0 0 0 0 0 0 0 52
53 601 1 545 537 552 563 0 0 0 0 1 0 0 0 0 0 0 53
54 604 1 601 545 537 552 0 0 0 0 0 1 0 0 0 0 0 54
55 586 1 604 601 545 537 0 0 0 0 0 0 1 0 0 0 0 55
56 564 1 586 604 601 545 0 0 0 0 0 0 0 1 0 0 0 56
57 549 1 564 586 604 601 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
54.68887 15.46720 0.86718 0.01824 0.09016 -0.07925
M1 M2 M3 M4 M5 M6
-6.32635 -1.98379 -9.38552 6.24483 55.50250 18.44939
M7 M8 M9 M10 M11 t
-5.37931 -15.49761 -10.28966 9.22863 10.64635 -0.32660
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.886 -2.560 -0.281 2.383 14.139
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 54.68887 19.80139 2.762 0.00872 **
X 15.46720 5.11726 3.023 0.00441 **
Y1 0.86718 0.16356 5.302 4.81e-06 ***
Y2 0.01824 0.21021 0.087 0.93132
Y3 0.09016 0.20935 0.431 0.66909
Y4 -0.07925 0.14488 -0.547 0.58750
M1 -6.32635 5.17270 -1.223 0.22866
M2 -1.98379 5.65065 -0.351 0.72742
M3 -9.38552 5.22151 -1.797 0.08001 .
M4 6.24483 5.40775 1.155 0.25520
M5 55.50250 5.17684 10.721 3.43e-13 ***
M6 18.44939 8.62436 2.139 0.03873 *
M7 -5.37931 8.72921 -0.616 0.54132
M8 -15.49761 10.86999 -1.426 0.16190
M9 -10.28966 7.22770 -1.424 0.16250
M10 9.22863 6.58594 1.401 0.16904
M11 10.64635 5.25900 2.024 0.04982 *
t -0.32660 0.13114 -2.490 0.01712 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.123 on 39 degrees of freedom
Multiple R-squared: 0.9801, Adjusted R-squared: 0.9714
F-statistic: 113 on 17 and 39 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.9584374 0.083125191 0.041562596
[2,] 0.9951336 0.009732797 0.004866398
[3,] 0.9894391 0.021121822 0.010560911
[4,] 0.9793880 0.041224002 0.020612001
[5,] 0.9776003 0.044799310 0.022399655
[6,] 0.9761109 0.047778245 0.023889122
[7,] 0.9763636 0.047272703 0.023636351
[8,] 0.9840582 0.031883572 0.015941786
[9,] 0.9716751 0.056649827 0.028324913
[10,] 0.9543197 0.091360628 0.045680314
[11,] 0.9231514 0.153697109 0.076848555
[12,] 0.9018115 0.196376939 0.098188469
[13,] 0.8387500 0.322499932 0.161249966
[14,] 0.9207956 0.158408800 0.079204400
[15,] 0.8432594 0.313481109 0.156740555
[16,] 0.7061217 0.587756691 0.293878345
> postscript(file="/var/www/rcomp/tmp/1usic1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/rcomp/tmp/2usic1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/rcomp/tmp/3usic1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/rcomp/tmp/4510f1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/rcomp/tmp/5510f1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 57
Frequency = 1
1 2 3 4 5
2.842349350 2.072049913 14.139303278 0.475961764 -1.688430960
6 7 8 9 10
0.548343306 12.564236120 -8.134583329 -3.972871100 -11.486567506
11 12 13 14 15
2.037669505 -2.846532190 -3.792409519 0.078679366 -0.281004510
16 17 18 19 20
-13.885931602 3.056413967 2.969569145 -5.674994520 3.532938830
21 22 23 24 25
-1.384841612 1.305226466 -0.415015714 -0.772631393 -3.077620433
26 27 28 29 30
3.124802991 -6.222622361 6.378277128 -0.892780194 0.619228419
31 32 33 34 35
0.184000663 8.599786732 -1.629261420 -1.215378768 -2.560230743
36 37 38 39 40
2.160857697 5.679864652 -0.001215589 -5.694561901 2.382596805
41 42 43 44 45
-5.570022900 -1.384163240 -4.942831324 -1.452393830 5.840295945
46 47 48 49 50
11.396719807 0.937576952 1.458305886 -1.652184049 -5.274316682
51 52 53 54 55
-1.941114506 4.649095905 5.094820087 -2.752977630 -2.130410939
56 57
-2.545748403 1.146678188
> postscript(file="/var/www/rcomp/tmp/6510f1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 2.842349350 NA
1 2.072049913 2.842349350
2 14.139303278 2.072049913
3 0.475961764 14.139303278
4 -1.688430960 0.475961764
5 0.548343306 -1.688430960
6 12.564236120 0.548343306
7 -8.134583329 12.564236120
8 -3.972871100 -8.134583329
9 -11.486567506 -3.972871100
10 2.037669505 -11.486567506
11 -2.846532190 2.037669505
12 -3.792409519 -2.846532190
13 0.078679366 -3.792409519
14 -0.281004510 0.078679366
15 -13.885931602 -0.281004510
16 3.056413967 -13.885931602
17 2.969569145 3.056413967
18 -5.674994520 2.969569145
19 3.532938830 -5.674994520
20 -1.384841612 3.532938830
21 1.305226466 -1.384841612
22 -0.415015714 1.305226466
23 -0.772631393 -0.415015714
24 -3.077620433 -0.772631393
25 3.124802991 -3.077620433
26 -6.222622361 3.124802991
27 6.378277128 -6.222622361
28 -0.892780194 6.378277128
29 0.619228419 -0.892780194
30 0.184000663 0.619228419
31 8.599786732 0.184000663
32 -1.629261420 8.599786732
33 -1.215378768 -1.629261420
34 -2.560230743 -1.215378768
35 2.160857697 -2.560230743
36 5.679864652 2.160857697
37 -0.001215589 5.679864652
38 -5.694561901 -0.001215589
39 2.382596805 -5.694561901
40 -5.570022900 2.382596805
41 -1.384163240 -5.570022900
42 -4.942831324 -1.384163240
43 -1.452393830 -4.942831324
44 5.840295945 -1.452393830
45 11.396719807 5.840295945
46 0.937576952 11.396719807
47 1.458305886 0.937576952
48 -1.652184049 1.458305886
49 -5.274316682 -1.652184049
50 -1.941114506 -5.274316682
51 4.649095905 -1.941114506
52 5.094820087 4.649095905
53 -2.752977630 5.094820087
54 -2.130410939 -2.752977630
55 -2.545748403 -2.130410939
56 1.146678188 -2.545748403
57 NA 1.146678188
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 2.072049913 2.842349350
[2,] 14.139303278 2.072049913
[3,] 0.475961764 14.139303278
[4,] -1.688430960 0.475961764
[5,] 0.548343306 -1.688430960
[6,] 12.564236120 0.548343306
[7,] -8.134583329 12.564236120
[8,] -3.972871100 -8.134583329
[9,] -11.486567506 -3.972871100
[10,] 2.037669505 -11.486567506
[11,] -2.846532190 2.037669505
[12,] -3.792409519 -2.846532190
[13,] 0.078679366 -3.792409519
[14,] -0.281004510 0.078679366
[15,] -13.885931602 -0.281004510
[16,] 3.056413967 -13.885931602
[17,] 2.969569145 3.056413967
[18,] -5.674994520 2.969569145
[19,] 3.532938830 -5.674994520
[20,] -1.384841612 3.532938830
[21,] 1.305226466 -1.384841612
[22,] -0.415015714 1.305226466
[23,] -0.772631393 -0.415015714
[24,] -3.077620433 -0.772631393
[25,] 3.124802991 -3.077620433
[26,] -6.222622361 3.124802991
[27,] 6.378277128 -6.222622361
[28,] -0.892780194 6.378277128
[29,] 0.619228419 -0.892780194
[30,] 0.184000663 0.619228419
[31,] 8.599786732 0.184000663
[32,] -1.629261420 8.599786732
[33,] -1.215378768 -1.629261420
[34,] -2.560230743 -1.215378768
[35,] 2.160857697 -2.560230743
[36,] 5.679864652 2.160857697
[37,] -0.001215589 5.679864652
[38,] -5.694561901 -0.001215589
[39,] 2.382596805 -5.694561901
[40,] -5.570022900 2.382596805
[41,] -1.384163240 -5.570022900
[42,] -4.942831324 -1.384163240
[43,] -1.452393830 -4.942831324
[44,] 5.840295945 -1.452393830
[45,] 11.396719807 5.840295945
[46,] 0.937576952 11.396719807
[47,] 1.458305886 0.937576952
[48,] -1.652184049 1.458305886
[49,] -5.274316682 -1.652184049
[50,] -1.941114506 -5.274316682
[51,] 4.649095905 -1.941114506
[52,] 5.094820087 4.649095905
[53,] -2.752977630 5.094820087
[54,] -2.130410939 -2.752977630
[55,] -2.545748403 -2.130410939
[56,] 1.146678188 -2.545748403
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 2.072049913 2.842349350
2 14.139303278 2.072049913
3 0.475961764 14.139303278
4 -1.688430960 0.475961764
5 0.548343306 -1.688430960
6 12.564236120 0.548343306
7 -8.134583329 12.564236120
8 -3.972871100 -8.134583329
9 -11.486567506 -3.972871100
10 2.037669505 -11.486567506
11 -2.846532190 2.037669505
12 -3.792409519 -2.846532190
13 0.078679366 -3.792409519
14 -0.281004510 0.078679366
15 -13.885931602 -0.281004510
16 3.056413967 -13.885931602
17 2.969569145 3.056413967
18 -5.674994520 2.969569145
19 3.532938830 -5.674994520
20 -1.384841612 3.532938830
21 1.305226466 -1.384841612
22 -0.415015714 1.305226466
23 -0.772631393 -0.415015714
24 -3.077620433 -0.772631393
25 3.124802991 -3.077620433
26 -6.222622361 3.124802991
27 6.378277128 -6.222622361
28 -0.892780194 6.378277128
29 0.619228419 -0.892780194
30 0.184000663 0.619228419
31 8.599786732 0.184000663
32 -1.629261420 8.599786732
33 -1.215378768 -1.629261420
34 -2.560230743 -1.215378768
35 2.160857697 -2.560230743
36 5.679864652 2.160857697
37 -0.001215589 5.679864652
38 -5.694561901 -0.001215589
39 2.382596805 -5.694561901
40 -5.570022900 2.382596805
41 -1.384163240 -5.570022900
42 -4.942831324 -1.384163240
43 -1.452393830 -4.942831324
44 5.840295945 -1.452393830
45 11.396719807 5.840295945
46 0.937576952 11.396719807
47 1.458305886 0.937576952
48 -1.652184049 1.458305886
49 -5.274316682 -1.652184049
50 -1.941114506 -5.274316682
51 4.649095905 -1.941114506
52 5.094820087 4.649095905
53 -2.752977630 5.094820087
54 -2.130410939 -2.752977630
55 -2.545748403 -2.130410939
56 1.146678188 -2.545748403
> 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/rcomp/tmp/7ysz01293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/rcomp/tmp/89kg31293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/rcomp/tmp/99kg31293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/rcomp/tmp/101byo1293210368.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/115twc1293210368.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/rcomp/tmp/12xkdf1293210368.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/rcomp/tmp/13rphf1293210368.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/rcomp/tmp/148mrx1293210368.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/rcomp/tmp/150dqz1293210368.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/rcomp/tmp/16f5or1293210368.tab")
+ }
>
> try(system("convert tmp/1usic1293210368.ps tmp/1usic1293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/2usic1293210368.ps tmp/2usic1293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/3usic1293210368.ps tmp/3usic1293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/4510f1293210368.ps tmp/4510f1293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/5510f1293210368.ps tmp/5510f1293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/6510f1293210368.ps tmp/6510f1293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ysz01293210368.ps tmp/7ysz01293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/89kg31293210368.ps tmp/89kg31293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/99kg31293210368.ps tmp/99kg31293210368.png",intern=TRUE))
character(0)
> try(system("convert tmp/101byo1293210368.ps tmp/101byo1293210368.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.960 0.840 3.818