R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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(31/12/1961
+ ,9190
+ ,2514
+ ,2550
+ ,1512
+ ,1591
+ ,472
+ ,551
+ ,31/12/1962
+ ,9251
+ ,2537
+ ,2572
+ ,1517
+ ,1595
+ ,476
+ ,554
+ ,31/12/1963
+ ,9328
+ ,2564
+ ,2597
+ ,1525
+ ,1602
+ ,483
+ ,558
+ ,31/12/1964
+ ,9428
+ ,2595
+ ,2623
+ ,1540
+ ,1613
+ ,493
+ ,565
+ ,31/12/1965
+ ,9499
+ ,2617
+ ,2647
+ ,1547
+ ,1622
+ ,498
+ ,568
+ ,31/12/1966
+ ,9556
+ ,2638
+ ,2670
+ ,1547
+ ,1627
+ ,502
+ ,572
+ ,31/12/1967
+ ,9606
+ ,2657
+ ,2690
+ ,1547
+ ,1632
+ ,504
+ ,575
+ ,31/12/1968
+ ,9632
+ ,2668
+ ,2705
+ ,1547
+ ,1634
+ ,503
+ ,574
+ ,31/12/1969
+ ,9660
+ ,2683
+ ,2721
+ ,1546
+ ,1637
+ ,501
+ ,572
+ ,31/12/1970
+ ,9651
+ ,2687
+ ,2729
+ ,1533
+ ,1627
+ ,502
+ ,573
+ ,31/12/1971
+ ,9695
+ ,2705
+ ,2747
+ ,1538
+ ,1632
+ ,502
+ ,572
+ ,31/12/1972
+ ,9727
+ ,2717
+ ,2761
+ ,1543
+ ,1637
+ ,500
+ ,569
+ ,31/12/1973
+ ,9757
+ ,2728
+ ,2773
+ ,1549
+ ,1643
+ ,498
+ ,566
+ ,31/12/1974
+ ,9788
+ ,2741
+ ,2786
+ ,1556
+ ,1650
+ ,495
+ ,560
+ ,31/12/1975
+ ,9813
+ ,2752
+ ,2796
+ ,1559
+ ,1654
+ ,494
+ ,557
+ ,31/12/1976
+ ,9823
+ ,2759
+ ,2807
+ ,1559
+ ,1656
+ ,490
+ ,552
+ ,31/12/1977
+ ,9837
+ ,2767
+ ,2817
+ ,1563
+ ,1661
+ ,484
+ ,545
+ ,31/12/1978
+ ,9842
+ ,2774
+ ,2827
+ ,1563
+ ,1662
+ ,477
+ ,539
+ ,31/12/1979
+ ,9855
+ ,2781
+ ,2838
+ ,1564
+ ,1664
+ ,474
+ ,535
+ ,31/12/1980
+ ,9863
+ ,2788
+ ,2847
+ ,1564
+ ,1665
+ ,469
+ ,531
+ ,31/12/1981
+ ,9855
+ ,2789
+ ,2853
+ ,1557
+ ,1661
+ ,466
+ ,528
+ ,31/12/1982
+ ,9858
+ ,2795
+ ,2860
+ ,1554
+ ,1659
+ ,464
+ ,526
+ ,31/12/1983
+ ,9853
+ ,2798
+ ,2864
+ ,1552
+ ,1656
+ ,460
+ ,523
+ ,31/12/1984
+ ,9858
+ ,2801
+ ,2869
+ ,1552
+ ,1656
+ ,458
+ ,521
+ ,31/12/1985
+ ,9859
+ ,2803
+ ,2873
+ ,1551
+ ,1655
+ ,457
+ ,519
+ ,31/12/1986
+ ,9865
+ ,2808
+ ,2877
+ ,1552
+ ,1654
+ ,456
+ ,517
+ ,31/12/1987
+ ,9876
+ ,2813
+ ,2883
+ ,1554
+ ,1656
+ ,455
+ ,515
+ ,31/12/1988
+ ,9928
+ ,2826
+ ,2896
+ ,1567
+ ,1668
+ ,456
+ ,514
+ ,31/12/1989
+ ,9948
+ ,2835
+ ,2905
+ ,1572
+ ,1672
+ ,453
+ ,511
+ ,31/12/1990
+ ,9987
+ ,2849
+ ,2919
+ ,1579
+ ,1680
+ ,453
+ ,508
+ ,31/12/1991
+ ,10022
+ ,2862
+ ,2933
+ ,1588
+ ,1688
+ ,449
+ ,502
+ ,31/12/1992
+ ,10068
+ ,2877
+ ,2948
+ ,1597
+ ,1696
+ ,449
+ ,501
+ ,31/12/1993
+ ,10101
+ ,2888
+ ,2959
+ ,1603
+ ,1702
+ ,449
+ ,500
+ ,31/12/1994
+ ,10131
+ ,2897
+ ,2969
+ ,1607
+ ,1706
+ ,452
+ ,500
+ ,31/12/1995
+ ,10143
+ ,2902
+ ,2978
+ ,1607
+ ,1708
+ ,450
+ ,498
+ ,31/12/1996
+ ,10170
+ ,2911
+ ,2988
+ ,1609
+ ,1711
+ ,452
+ ,499
+ ,31/12/1997
+ ,10192
+ ,2917
+ ,2996
+ ,1612
+ ,1714
+ ,454
+ ,499
+ ,31/12/1998
+ ,10214
+ ,2924
+ ,3003
+ ,1615
+ ,1717
+ ,455
+ ,500
+ ,31/12/1999
+ ,10239
+ ,2930
+ ,3011
+ ,1619
+ ,1721
+ ,458
+ ,501
+ ,31/12/2000
+ ,10263
+ ,2935
+ ,3018
+ ,1622
+ ,1724
+ ,461
+ ,503
+ ,31/12/2001
+ ,10310
+ ,2945
+ ,3028
+ ,1628
+ ,1730
+ ,469
+ ,510
+ ,31/12/2002
+ ,10355
+ ,2957
+ ,3038
+ ,1634
+ ,1735
+ ,477
+ ,515
+ ,31/12/2003
+ ,10396
+ ,2967
+ ,3049
+ ,1640
+ ,1740
+ ,480
+ ,520
+ ,31/12/2004
+ ,10446
+ ,2980
+ ,3063
+ ,1648
+ ,1748
+ ,484
+ ,523
+ ,31/12/2005
+ ,10511
+ ,2997
+ ,3081
+ ,1657
+ ,1757
+ ,490
+ ,529
+ ,31/12/2006
+ ,10585
+ ,3017
+ ,3100
+ ,1668
+ ,1768
+ ,497
+ ,534
+ ,31/12/2007
+ ,10667
+ ,3040
+ ,3122
+ ,1678
+ ,1778
+ ,506
+ ,543
+ ,31/12/2008
+ ,10753
+ ,3064
+ ,3145
+ ,1687
+ ,1789
+ ,516
+ ,553
+ ,31/12/2009
+ ,10840
+ ,3085
+ ,3167
+ ,1700
+ ,1798
+ ,527
+ ,563
+ ,31/12/2010
+ ,10951
+ ,3113
+ ,3193
+ ,1714
+ ,1811
+ ,542
+ ,577)
+ ,dim=c(8
+ ,50)
+ ,dimnames=list(c('jaar'
+ ,'totaal'
+ ,'vlaams_man'
+ ,'vlaams_vrouw'
+ ,'waals_man'
+ ,'waals_vrouw'
+ ,'brussel_man'
+ ,'brussel_vrouw')
+ ,1:50))
> y <- array(NA,dim=c(8,50),dimnames=list(c('jaar','totaal','vlaams_man','vlaams_vrouw','waals_man','waals_vrouw','brussel_man','brussel_vrouw'),1:50))
> 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 = 'Do not include Seasonal Dummies'
> par1 = '2'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
totaal jaar vlaams_man vlaams_vrouw waals_man waals_vrouw brussel_man
1 9190 0.001317355 2514 2550 1512 1591 472
2 9251 0.001316684 2537 2572 1517 1595 476
3 9328 0.001316013 2564 2597 1525 1602 483
4 9428 0.001315343 2595 2623 1540 1613 493
5 9499 0.001314673 2617 2647 1547 1622 498
6 9556 0.001314005 2638 2670 1547 1627 502
7 9606 0.001313337 2657 2690 1547 1632 504
8 9632 0.001312669 2668 2705 1547 1634 503
9 9660 0.001312003 2683 2721 1546 1637 501
10 9651 0.001311337 2687 2729 1533 1627 502
11 9695 0.001310671 2705 2747 1538 1632 502
12 9727 0.001310007 2717 2761 1543 1637 500
13 9757 0.001309343 2728 2773 1549 1643 498
14 9788 0.001308680 2741 2786 1556 1650 495
15 9813 0.001308017 2752 2796 1559 1654 494
16 9823 0.001307355 2759 2807 1559 1656 490
17 9837 0.001306694 2767 2817 1563 1661 484
18 9842 0.001306033 2774 2827 1563 1662 477
19 9855 0.001305373 2781 2838 1564 1664 474
20 9863 0.001304714 2788 2847 1564 1665 469
21 9855 0.001304055 2789 2853 1557 1661 466
22 9858 0.001303397 2795 2860 1554 1659 464
23 9853 0.001302740 2798 2864 1552 1656 460
24 9858 0.001302083 2801 2869 1552 1656 458
25 9859 0.001301427 2803 2873 1551 1655 457
26 9865 0.001300772 2808 2877 1552 1654 456
27 9876 0.001300117 2813 2883 1554 1656 455
28 9928 0.001299463 2826 2896 1567 1668 456
29 9948 0.001298810 2835 2905 1572 1672 453
30 9987 0.001298157 2849 2919 1579 1680 453
31 10022 0.001297505 2862 2933 1588 1688 449
32 10068 0.001296854 2877 2948 1597 1696 449
33 10101 0.001296203 2888 2959 1603 1702 449
34 10131 0.001295553 2897 2969 1607 1706 452
35 10143 0.001294904 2902 2978 1607 1708 450
36 10170 0.001294255 2911 2988 1609 1711 452
37 10192 0.001293607 2917 2996 1612 1714 454
38 10214 0.001292960 2924 3003 1615 1717 455
39 10239 0.001292313 2930 3011 1619 1721 458
40 10263 0.001291667 2935 3018 1622 1724 461
41 10310 0.001291021 2945 3028 1628 1730 469
42 10355 0.001290376 2957 3038 1634 1735 477
43 10396 0.001289732 2967 3049 1640 1740 480
44 10446 0.001289088 2980 3063 1648 1748 484
45 10511 0.001288446 2997 3081 1657 1757 490
46 10585 0.001287803 3017 3100 1668 1768 497
47 10667 0.001287162 3040 3122 1678 1778 506
48 10753 0.001286521 3064 3145 1687 1789 516
49 10840 0.001285880 3085 3167 1700 1798 527
50 10951 0.001285240 3113 3193 1714 1811 542
brussel_vrouw
1 551
2 554
3 558
4 565
5 568
6 572
7 575
8 574
9 572
10 573
11 572
12 569
13 566
14 560
15 557
16 552
17 545
18 539
19 535
20 531
21 528
22 526
23 523
24 521
25 519
26 517
27 515
28 514
29 511
30 508
31 502
32 501
33 500
34 500
35 498
36 499
37 499
38 500
39 501
40 503
41 510
42 515
43 520
44 523
45 529
46 534
47 543
48 553
49 563
50 577
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) jaar vlaams_man vlaams_vrouw waals_man
-1.830e+02 1.215e+05 9.492e-01 1.062e+00 1.041e+00
waals_vrouw brussel_man brussel_vrouw
9.515e-01 9.440e-01 1.064e+00
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.1971 -0.2700 0.1089 0.2044 1.2028
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.830e+02 4.100e+02 -0.446 0.658
jaar 1.215e+05 2.972e+05 0.409 0.685
vlaams_man 9.493e-01 7.317e-02 12.974 2.76e-16 ***
vlaams_vrouw 1.062e+00 8.285e-02 12.816 4.18e-16 ***
waals_man 1.041e+00 6.180e-02 16.836 < 2e-16 ***
waals_vrouw 9.515e-01 7.484e-02 12.714 5.46e-16 ***
brussel_man 9.440e-01 6.683e-02 14.125 < 2e-16 ***
brussel_vrouw 1.064e+00 6.125e-02 17.363 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.6264 on 42 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 2.775e+06 on 7 and 42 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.1793308 0.3586616 0.82066918
[2,] 0.2820260 0.5640520 0.71797400
[3,] 0.1774933 0.3549865 0.82250674
[4,] 0.1776158 0.3552315 0.82238424
[5,] 0.2285475 0.4570950 0.77145248
[6,] 0.2365000 0.4730000 0.76349998
[7,] 0.2107915 0.4215831 0.78920845
[8,] 0.2373314 0.4746628 0.76266861
[9,] 0.2805239 0.5610478 0.71947609
[10,] 0.4123080 0.8246160 0.58769202
[11,] 0.5422112 0.9155777 0.45778884
[12,] 0.5795837 0.8408326 0.42041628
[13,] 0.6208324 0.7583352 0.37916762
[14,] 0.5361671 0.9276657 0.46383287
[15,] 0.5648804 0.8702392 0.43511961
[16,] 0.6116302 0.7767396 0.38836978
[17,] 0.8015768 0.3968464 0.19842320
[18,] 0.9034788 0.1930423 0.09652115
[19,] 0.9267543 0.1464914 0.07324569
[20,] 0.9443176 0.1113647 0.05568237
[21,] 0.9127080 0.1745840 0.08729200
[22,] 0.8593093 0.2813815 0.14069075
[23,] 0.7938838 0.4122324 0.20611619
[24,] 0.7313836 0.5372328 0.26861642
[25,] 0.7592443 0.4815115 0.24075574
[26,] 0.7047129 0.5905741 0.29528707
[27,] 0.6490720 0.7018560 0.35092799
[28,] 0.5454596 0.9090809 0.45454044
[29,] 0.9207827 0.1584345 0.07921726
> postscript(file="/var/wessaorg/rcomp/tmp/1d5ol1351875113.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/wessaorg/rcomp/tmp/2dqiv1351875113.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/wessaorg/rcomp/tmp/31m6b1351875113.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/wessaorg/rcomp/tmp/41efl1351875113.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/wessaorg/rcomp/tmp/5i6ou1351875113.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 = 50
Frequency = 1
1 2 3 4 5 6
0.193212520 0.107024047 -0.833277627 -0.744668627 0.212005318 0.149806490
7 8 9 10 11 12
1.123000817 0.939699656 -0.005929979 -0.182301281 -1.197139873 -0.254273200
13 14 15 16 17 18
-0.230625773 -0.024852904 1.202800323 0.149161593 0.206480188 0.061532860
19 20 21 22 23 24
-1.040397233 -1.138733940 0.733368286 -0.275267163 -0.388298613 0.549722049
25 26 27 28 29 30
0.546723699 0.614848121 -0.335726530 0.774727055 -0.231461817 -1.012093085
31 32 33 34 35 36
0.041968602 0.042051338 0.110859828 0.228376290 0.116789807 0.147199021
37 38 39 40 41 42
0.171880791 0.189560394 -0.785450682 0.179030976 0.198103455 -0.602899499
43 44 45 46 47 48
0.152777582 0.122668303 -0.022330401 1.058496136 -0.043980800 -1.076079745
49 50
-0.401844898 0.503758124
> postscript(file="/var/wessaorg/rcomp/tmp/6yr881351875113.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 = 50
Frequency = 1
lag(myerror, k = 1) myerror
0 0.193212520 NA
1 0.107024047 0.193212520
2 -0.833277627 0.107024047
3 -0.744668627 -0.833277627
4 0.212005318 -0.744668627
5 0.149806490 0.212005318
6 1.123000817 0.149806490
7 0.939699656 1.123000817
8 -0.005929979 0.939699656
9 -0.182301281 -0.005929979
10 -1.197139873 -0.182301281
11 -0.254273200 -1.197139873
12 -0.230625773 -0.254273200
13 -0.024852904 -0.230625773
14 1.202800323 -0.024852904
15 0.149161593 1.202800323
16 0.206480188 0.149161593
17 0.061532860 0.206480188
18 -1.040397233 0.061532860
19 -1.138733940 -1.040397233
20 0.733368286 -1.138733940
21 -0.275267163 0.733368286
22 -0.388298613 -0.275267163
23 0.549722049 -0.388298613
24 0.546723699 0.549722049
25 0.614848121 0.546723699
26 -0.335726530 0.614848121
27 0.774727055 -0.335726530
28 -0.231461817 0.774727055
29 -1.012093085 -0.231461817
30 0.041968602 -1.012093085
31 0.042051338 0.041968602
32 0.110859828 0.042051338
33 0.228376290 0.110859828
34 0.116789807 0.228376290
35 0.147199021 0.116789807
36 0.171880791 0.147199021
37 0.189560394 0.171880791
38 -0.785450682 0.189560394
39 0.179030976 -0.785450682
40 0.198103455 0.179030976
41 -0.602899499 0.198103455
42 0.152777582 -0.602899499
43 0.122668303 0.152777582
44 -0.022330401 0.122668303
45 1.058496136 -0.022330401
46 -0.043980800 1.058496136
47 -1.076079745 -0.043980800
48 -0.401844898 -1.076079745
49 0.503758124 -0.401844898
50 NA 0.503758124
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.107024047 0.193212520
[2,] -0.833277627 0.107024047
[3,] -0.744668627 -0.833277627
[4,] 0.212005318 -0.744668627
[5,] 0.149806490 0.212005318
[6,] 1.123000817 0.149806490
[7,] 0.939699656 1.123000817
[8,] -0.005929979 0.939699656
[9,] -0.182301281 -0.005929979
[10,] -1.197139873 -0.182301281
[11,] -0.254273200 -1.197139873
[12,] -0.230625773 -0.254273200
[13,] -0.024852904 -0.230625773
[14,] 1.202800323 -0.024852904
[15,] 0.149161593 1.202800323
[16,] 0.206480188 0.149161593
[17,] 0.061532860 0.206480188
[18,] -1.040397233 0.061532860
[19,] -1.138733940 -1.040397233
[20,] 0.733368286 -1.138733940
[21,] -0.275267163 0.733368286
[22,] -0.388298613 -0.275267163
[23,] 0.549722049 -0.388298613
[24,] 0.546723699 0.549722049
[25,] 0.614848121 0.546723699
[26,] -0.335726530 0.614848121
[27,] 0.774727055 -0.335726530
[28,] -0.231461817 0.774727055
[29,] -1.012093085 -0.231461817
[30,] 0.041968602 -1.012093085
[31,] 0.042051338 0.041968602
[32,] 0.110859828 0.042051338
[33,] 0.228376290 0.110859828
[34,] 0.116789807 0.228376290
[35,] 0.147199021 0.116789807
[36,] 0.171880791 0.147199021
[37,] 0.189560394 0.171880791
[38,] -0.785450682 0.189560394
[39,] 0.179030976 -0.785450682
[40,] 0.198103455 0.179030976
[41,] -0.602899499 0.198103455
[42,] 0.152777582 -0.602899499
[43,] 0.122668303 0.152777582
[44,] -0.022330401 0.122668303
[45,] 1.058496136 -0.022330401
[46,] -0.043980800 1.058496136
[47,] -1.076079745 -0.043980800
[48,] -0.401844898 -1.076079745
[49,] 0.503758124 -0.401844898
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.107024047 0.193212520
2 -0.833277627 0.107024047
3 -0.744668627 -0.833277627
4 0.212005318 -0.744668627
5 0.149806490 0.212005318
6 1.123000817 0.149806490
7 0.939699656 1.123000817
8 -0.005929979 0.939699656
9 -0.182301281 -0.005929979
10 -1.197139873 -0.182301281
11 -0.254273200 -1.197139873
12 -0.230625773 -0.254273200
13 -0.024852904 -0.230625773
14 1.202800323 -0.024852904
15 0.149161593 1.202800323
16 0.206480188 0.149161593
17 0.061532860 0.206480188
18 -1.040397233 0.061532860
19 -1.138733940 -1.040397233
20 0.733368286 -1.138733940
21 -0.275267163 0.733368286
22 -0.388298613 -0.275267163
23 0.549722049 -0.388298613
24 0.546723699 0.549722049
25 0.614848121 0.546723699
26 -0.335726530 0.614848121
27 0.774727055 -0.335726530
28 -0.231461817 0.774727055
29 -1.012093085 -0.231461817
30 0.041968602 -1.012093085
31 0.042051338 0.041968602
32 0.110859828 0.042051338
33 0.228376290 0.110859828
34 0.116789807 0.228376290
35 0.147199021 0.116789807
36 0.171880791 0.147199021
37 0.189560394 0.171880791
38 -0.785450682 0.189560394
39 0.179030976 -0.785450682
40 0.198103455 0.179030976
41 -0.602899499 0.198103455
42 0.152777582 -0.602899499
43 0.122668303 0.152777582
44 -0.022330401 0.122668303
45 1.058496136 -0.022330401
46 -0.043980800 1.058496136
47 -1.076079745 -0.043980800
48 -0.401844898 -1.076079745
49 0.503758124 -0.401844898
> 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/wessaorg/rcomp/tmp/78jao1351875113.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/wessaorg/rcomp/tmp/8i5ub1351875113.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/wessaorg/rcomp/tmp/9uceo1351875113.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/wessaorg/rcomp/tmp/10higz1351875113.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11zd0c1351875113.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/wessaorg/rcomp/tmp/12o9tf1351875113.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/wessaorg/rcomp/tmp/13wpzu1351875113.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/wessaorg/rcomp/tmp/1441xc1351875114.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/wessaorg/rcomp/tmp/15z94z1351875114.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/wessaorg/rcomp/tmp/16bgnx1351875114.tab")
+ }
>
> try(system("convert tmp/1d5ol1351875113.ps tmp/1d5ol1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/2dqiv1351875113.ps tmp/2dqiv1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/31m6b1351875113.ps tmp/31m6b1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/41efl1351875113.ps tmp/41efl1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/5i6ou1351875113.ps tmp/5i6ou1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/6yr881351875113.ps tmp/6yr881351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/78jao1351875113.ps tmp/78jao1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/8i5ub1351875113.ps tmp/8i5ub1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/9uceo1351875113.ps tmp/9uceo1351875113.png",intern=TRUE))
character(0)
> try(system("convert tmp/10higz1351875113.ps tmp/10higz1351875113.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
7.875 1.465 9.344