R version 2.15.2 (2012-10-26) -- "Trick or Treat"
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(591
+ ,1.3119
+ ,0.69867
+ ,135.63
+ ,589
+ ,1.3014
+ ,0.68968
+ ,136.55
+ ,584
+ ,1.3201
+ ,0.69233
+ ,138.83
+ ,573
+ ,1.2938
+ ,0.68293
+ ,138.84
+ ,567
+ ,1.2694
+ ,0.68399
+ ,135.37
+ ,569
+ ,1.2165
+ ,0.66895
+ ,132.22
+ ,621
+ ,1.2037
+ ,0.68756
+ ,134.75
+ ,629
+ ,1.2292
+ ,0.68527
+ ,135.98
+ ,628
+ ,1.2256
+ ,0.6776
+ ,136.06
+ ,612
+ ,1.2015
+ ,0.68137
+ ,138.05
+ ,595
+ ,1.1786
+ ,0.67933
+ ,139.59
+ ,597
+ ,1.1856
+ ,0.67922
+ ,140.58
+ ,593
+ ,1.2103
+ ,0.68598
+ ,139.81
+ ,590
+ ,1.1938
+ ,0.68297
+ ,140.77
+ ,580
+ ,1.202
+ ,0.68935
+ ,140.96
+ ,574
+ ,1.2271
+ ,0.69463
+ ,143.59
+ ,573
+ ,1.277
+ ,0.6833
+ ,142.7
+ ,573
+ ,1.265
+ ,0.68666
+ ,145.11
+ ,620
+ ,1.2684
+ ,0.68782
+ ,146.7
+ ,626
+ ,1.2811
+ ,0.67669
+ ,148.53
+ ,620
+ ,1.2727
+ ,0.67511
+ ,148.99
+ ,588
+ ,1.2611
+ ,0.67254
+ ,149.65
+ ,566
+ ,1.2881
+ ,0.67397
+ ,151.11
+ ,557
+ ,1.3213
+ ,0.67286
+ ,154.82
+ ,561
+ ,1.2999
+ ,0.66341
+ ,156.56
+ ,549
+ ,1.3074
+ ,0.668
+ ,157.6
+ ,532
+ ,1.3242
+ ,0.68021
+ ,155.24
+ ,526
+ ,1.3516
+ ,0.67934
+ ,160.68
+ ,511
+ ,1.3511
+ ,0.68136
+ ,163.22
+ ,499
+ ,1.3419
+ ,0.67562
+ ,164.55
+ ,555
+ ,1.3716
+ ,0.6744
+ ,166.76
+ ,565
+ ,1.3622
+ ,0.67766
+ ,159.05
+ ,542
+ ,1.3896
+ ,0.68887
+ ,159.82
+ ,527
+ ,1.4227
+ ,0.69614
+ ,164.95
+ ,510
+ ,1.4684
+ ,0.70896
+ ,162.89
+ ,514
+ ,1.457
+ ,0.72064
+ ,163.55
+ ,517
+ ,1.4718
+ ,0.74725
+ ,158.68
+ ,508
+ ,1.4748
+ ,0.75094
+ ,157.97
+ ,493
+ ,1.5527
+ ,0.77494
+ ,156.59
+ ,490
+ ,1.575
+ ,0.79487
+ ,161.56
+ ,469
+ ,1.5557
+ ,0.79209
+ ,162.31
+ ,478
+ ,1.5553
+ ,0.79152
+ ,166.26
+ ,528
+ ,1.577
+ ,0.79308
+ ,168.45
+ ,534
+ ,1.4975
+ ,0.79279
+ ,163.63
+ ,518
+ ,1.4369
+ ,0.79924
+ ,153.2
+ ,506
+ ,1.3322
+ ,0.78668
+ ,133.52
+ ,502
+ ,1.2732
+ ,0.83063
+ ,123.28
+ ,516
+ ,1.3449
+ ,0.90448
+ ,122.51
+ ,528
+ ,1.3239
+ ,0.91819
+ ,119.73
+ ,533
+ ,1.2785
+ ,0.88691
+ ,118.3
+ ,536
+ ,1.305
+ ,0.91966
+ ,127.65
+ ,537
+ ,1.319
+ ,0.89756
+ ,130.25
+ ,524
+ ,1.365
+ ,0.88444
+ ,131.85
+ ,536
+ ,1.4016
+ ,0.8567
+ ,135.39
+ ,587
+ ,1.4088
+ ,0.86092
+ ,133.09
+ ,597
+ ,1.4268
+ ,0.86265
+ ,135.31
+ ,581
+ ,1.4562
+ ,0.89135
+ ,133.14
+ ,564
+ ,1.4816
+ ,0.91557
+ ,133.91
+ ,558
+ ,1.4914
+ ,0.89892
+ ,132.97
+ ,575
+ ,1.4614
+ ,0.89972
+ ,131.21
+ ,580
+ ,1.4272
+ ,0.88305
+ ,130.34)
+ ,dim=c(4
+ ,61)
+ ,dimnames=list(c('Werkloosheid'
+ ,'Dollar/euro'
+ ,'Pond/euro'
+ ,'Yen/euro')
+ ,1:61))
> y <- array(NA,dim=c(4,61),dimnames=list(c('Werkloosheid','Dollar/euro','Pond/euro','Yen/euro'),1:61))
> 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 = '1'
> 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
Werkloosheid Dollar/euro Pond/euro Yen/euro
1 591 1.3119 0.69867 135.63
2 589 1.3014 0.68968 136.55
3 584 1.3201 0.69233 138.83
4 573 1.2938 0.68293 138.84
5 567 1.2694 0.68399 135.37
6 569 1.2165 0.66895 132.22
7 621 1.2037 0.68756 134.75
8 629 1.2292 0.68527 135.98
9 628 1.2256 0.67760 136.06
10 612 1.2015 0.68137 138.05
11 595 1.1786 0.67933 139.59
12 597 1.1856 0.67922 140.58
13 593 1.2103 0.68598 139.81
14 590 1.1938 0.68297 140.77
15 580 1.2020 0.68935 140.96
16 574 1.2271 0.69463 143.59
17 573 1.2770 0.68330 142.70
18 573 1.2650 0.68666 145.11
19 620 1.2684 0.68782 146.70
20 626 1.2811 0.67669 148.53
21 620 1.2727 0.67511 148.99
22 588 1.2611 0.67254 149.65
23 566 1.2881 0.67397 151.11
24 557 1.3213 0.67286 154.82
25 561 1.2999 0.66341 156.56
26 549 1.3074 0.66800 157.60
27 532 1.3242 0.68021 155.24
28 526 1.3516 0.67934 160.68
29 511 1.3511 0.68136 163.22
30 499 1.3419 0.67562 164.55
31 555 1.3716 0.67440 166.76
32 565 1.3622 0.67766 159.05
33 542 1.3896 0.68887 159.82
34 527 1.4227 0.69614 164.95
35 510 1.4684 0.70896 162.89
36 514 1.4570 0.72064 163.55
37 517 1.4718 0.74725 158.68
38 508 1.4748 0.75094 157.97
39 493 1.5527 0.77494 156.59
40 490 1.5750 0.79487 161.56
41 469 1.5557 0.79209 162.31
42 478 1.5553 0.79152 166.26
43 528 1.5770 0.79308 168.45
44 534 1.4975 0.79279 163.63
45 518 1.4369 0.79924 153.20
46 506 1.3322 0.78668 133.52
47 502 1.2732 0.83063 123.28
48 516 1.3449 0.90448 122.51
49 528 1.3239 0.91819 119.73
50 533 1.2785 0.88691 118.30
51 536 1.3050 0.91966 127.65
52 537 1.3190 0.89756 130.25
53 524 1.3650 0.88444 131.85
54 536 1.4016 0.85670 135.39
55 587 1.4088 0.86092 133.09
56 597 1.4268 0.86265 135.31
57 581 1.4562 0.89135 133.14
58 564 1.4816 0.91557 133.91
59 558 1.4914 0.89892 132.97
60 575 1.4614 0.89972 131.21
61 580 1.4272 0.88305 130.34
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `Dollar/euro` `Pond/euro` `Yen/euro`
1094.639 -4.479 -306.725 -2.087
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-74.843 -18.832 -2.596 21.433 55.776
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1094.6389 84.9243 12.890 < 2e-16 ***
`Dollar/euro` -4.4791 86.4899 -0.052 0.95888
`Pond/euro` -306.7248 109.4637 -2.802 0.00693 **
`Yen/euro` -2.0873 0.6874 -3.036 0.00361 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 29.36 on 57 degrees of freedom
Multiple R-squared: 0.499, Adjusted R-squared: 0.4727
F-statistic: 18.93 on 3 and 57 DF, p-value: 1.22e-08
> 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.043344648 0.08668930 0.95665535
[2,] 0.054640917 0.10928183 0.94535908
[3,] 0.083546763 0.16709353 0.91645324
[4,] 0.082815881 0.16563176 0.91718412
[5,] 0.117019508 0.23403902 0.88298049
[6,] 0.074873663 0.14974733 0.92512634
[7,] 0.051862813 0.10372563 0.94813719
[8,] 0.033444967 0.06688993 0.96655503
[9,] 0.034455146 0.06891029 0.96554485
[10,] 0.024238469 0.04847694 0.97576153
[11,] 0.013746564 0.02749313 0.98625344
[12,] 0.007224304 0.01444861 0.99277570
[13,] 0.033884424 0.06776885 0.96611558
[14,] 0.082252188 0.16450438 0.91774781
[15,] 0.104424900 0.20884980 0.89557510
[16,] 0.101412619 0.20282524 0.89858738
[17,] 0.111810705 0.22362141 0.88818930
[18,] 0.110231167 0.22046233 0.88976883
[19,] 0.098195806 0.19639161 0.90180419
[20,] 0.090776260 0.18155252 0.90922374
[21,] 0.101999394 0.20399879 0.89800061
[22,] 0.088706039 0.17741208 0.91129396
[23,] 0.082002298 0.16400460 0.91799770
[24,] 0.085274097 0.17054819 0.91472590
[25,] 0.113217671 0.22643534 0.88678233
[26,] 0.166684880 0.33336976 0.83331512
[27,] 0.180356158 0.36071232 0.81964384
[28,] 0.192728991 0.38545798 0.80727101
[29,] 0.158609717 0.31721943 0.84139028
[30,] 0.146876491 0.29375298 0.85312351
[31,] 0.125456417 0.25091283 0.87454358
[32,] 0.098904299 0.19780860 0.90109570
[33,] 0.081326786 0.16265357 0.91867321
[34,] 0.083868310 0.16773662 0.91613169
[35,] 0.196060661 0.39212132 0.80393934
[36,] 0.415746401 0.83149280 0.58425360
[37,] 0.551660839 0.89667832 0.44833916
[38,] 0.501242265 0.99751547 0.49875773
[39,] 0.525263744 0.94947251 0.47473626
[40,] 0.677642881 0.64471424 0.32235712
[41,] 0.782268175 0.43546365 0.21773183
[42,] 0.781764420 0.43647116 0.21823558
[43,] 0.703040316 0.59391937 0.29695968
[44,] 0.662365818 0.67526836 0.33763418
[45,] 0.581721409 0.83655718 0.41827859
[46,] 0.553363942 0.89327212 0.44663606
[47,] 0.444317037 0.88863407 0.55568296
[48,] 0.964293162 0.07141368 0.03570684
> postscript(file="/var/wessaorg/rcomp/tmp/1alb71353351697.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/2f6ne1353351697.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/3uc4i1353351697.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/4xlub1353351697.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/5fn5t1353351697.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 = 61
Frequency = 1
1 2 3 4 5 6
-0.3671434 -3.2513441 -2.5957928 -16.5759348 -29.6029170 -39.0278985
7 8 9 10 11 12
23.9037047 33.8828625 30.6811397 19.8832078 5.3693092 9.4333186
13 14 15 16 17 18
6.0102170 4.0168465 -3.5929393 -2.3714914 -8.4808426 -2.4736815
19 20 21 22 23 24
48.2161042 54.6788422 49.1167354 17.6540913 -0.7389443 -2.1869377
25 26 27 28 29 30
2.4505051 -5.9372759 -24.0428683 -18.8322534 -27.9132487 -38.9389910
31 32 33 34 35 36
21.4326971 16.2976813 -1.5340088 -3.4481758 -20.6110385 -11.7019582
37 38 39 40 41 42
-10.6387138 -19.9754219 -30.1455306 -16.5588991 -36.9325907 -19.8645077
43 44 45 46 47 48
35.2822970 30.7766239 -5.2866405 -62.6855010 -74.8428374 -39.4772515
49 50 51 52 53 54
-29.1687208 -36.9512191 -4.2713302 -4.5603442 -18.0389046 -6.9945862
55 56 57 58 59 60
40.5313264 55.7763195 44.1816374 36.3314788 23.3063746 36.7437887
61
34.6615763
> postscript(file="/var/wessaorg/rcomp/tmp/6f3uj1353351697.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.3671434 NA
1 -3.2513441 -0.3671434
2 -2.5957928 -3.2513441
3 -16.5759348 -2.5957928
4 -29.6029170 -16.5759348
5 -39.0278985 -29.6029170
6 23.9037047 -39.0278985
7 33.8828625 23.9037047
8 30.6811397 33.8828625
9 19.8832078 30.6811397
10 5.3693092 19.8832078
11 9.4333186 5.3693092
12 6.0102170 9.4333186
13 4.0168465 6.0102170
14 -3.5929393 4.0168465
15 -2.3714914 -3.5929393
16 -8.4808426 -2.3714914
17 -2.4736815 -8.4808426
18 48.2161042 -2.4736815
19 54.6788422 48.2161042
20 49.1167354 54.6788422
21 17.6540913 49.1167354
22 -0.7389443 17.6540913
23 -2.1869377 -0.7389443
24 2.4505051 -2.1869377
25 -5.9372759 2.4505051
26 -24.0428683 -5.9372759
27 -18.8322534 -24.0428683
28 -27.9132487 -18.8322534
29 -38.9389910 -27.9132487
30 21.4326971 -38.9389910
31 16.2976813 21.4326971
32 -1.5340088 16.2976813
33 -3.4481758 -1.5340088
34 -20.6110385 -3.4481758
35 -11.7019582 -20.6110385
36 -10.6387138 -11.7019582
37 -19.9754219 -10.6387138
38 -30.1455306 -19.9754219
39 -16.5588991 -30.1455306
40 -36.9325907 -16.5588991
41 -19.8645077 -36.9325907
42 35.2822970 -19.8645077
43 30.7766239 35.2822970
44 -5.2866405 30.7766239
45 -62.6855010 -5.2866405
46 -74.8428374 -62.6855010
47 -39.4772515 -74.8428374
48 -29.1687208 -39.4772515
49 -36.9512191 -29.1687208
50 -4.2713302 -36.9512191
51 -4.5603442 -4.2713302
52 -18.0389046 -4.5603442
53 -6.9945862 -18.0389046
54 40.5313264 -6.9945862
55 55.7763195 40.5313264
56 44.1816374 55.7763195
57 36.3314788 44.1816374
58 23.3063746 36.3314788
59 36.7437887 23.3063746
60 34.6615763 36.7437887
61 NA 34.6615763
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3.2513441 -0.3671434
[2,] -2.5957928 -3.2513441
[3,] -16.5759348 -2.5957928
[4,] -29.6029170 -16.5759348
[5,] -39.0278985 -29.6029170
[6,] 23.9037047 -39.0278985
[7,] 33.8828625 23.9037047
[8,] 30.6811397 33.8828625
[9,] 19.8832078 30.6811397
[10,] 5.3693092 19.8832078
[11,] 9.4333186 5.3693092
[12,] 6.0102170 9.4333186
[13,] 4.0168465 6.0102170
[14,] -3.5929393 4.0168465
[15,] -2.3714914 -3.5929393
[16,] -8.4808426 -2.3714914
[17,] -2.4736815 -8.4808426
[18,] 48.2161042 -2.4736815
[19,] 54.6788422 48.2161042
[20,] 49.1167354 54.6788422
[21,] 17.6540913 49.1167354
[22,] -0.7389443 17.6540913
[23,] -2.1869377 -0.7389443
[24,] 2.4505051 -2.1869377
[25,] -5.9372759 2.4505051
[26,] -24.0428683 -5.9372759
[27,] -18.8322534 -24.0428683
[28,] -27.9132487 -18.8322534
[29,] -38.9389910 -27.9132487
[30,] 21.4326971 -38.9389910
[31,] 16.2976813 21.4326971
[32,] -1.5340088 16.2976813
[33,] -3.4481758 -1.5340088
[34,] -20.6110385 -3.4481758
[35,] -11.7019582 -20.6110385
[36,] -10.6387138 -11.7019582
[37,] -19.9754219 -10.6387138
[38,] -30.1455306 -19.9754219
[39,] -16.5588991 -30.1455306
[40,] -36.9325907 -16.5588991
[41,] -19.8645077 -36.9325907
[42,] 35.2822970 -19.8645077
[43,] 30.7766239 35.2822970
[44,] -5.2866405 30.7766239
[45,] -62.6855010 -5.2866405
[46,] -74.8428374 -62.6855010
[47,] -39.4772515 -74.8428374
[48,] -29.1687208 -39.4772515
[49,] -36.9512191 -29.1687208
[50,] -4.2713302 -36.9512191
[51,] -4.5603442 -4.2713302
[52,] -18.0389046 -4.5603442
[53,] -6.9945862 -18.0389046
[54,] 40.5313264 -6.9945862
[55,] 55.7763195 40.5313264
[56,] 44.1816374 55.7763195
[57,] 36.3314788 44.1816374
[58,] 23.3063746 36.3314788
[59,] 36.7437887 23.3063746
[60,] 34.6615763 36.7437887
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3.2513441 -0.3671434
2 -2.5957928 -3.2513441
3 -16.5759348 -2.5957928
4 -29.6029170 -16.5759348
5 -39.0278985 -29.6029170
6 23.9037047 -39.0278985
7 33.8828625 23.9037047
8 30.6811397 33.8828625
9 19.8832078 30.6811397
10 5.3693092 19.8832078
11 9.4333186 5.3693092
12 6.0102170 9.4333186
13 4.0168465 6.0102170
14 -3.5929393 4.0168465
15 -2.3714914 -3.5929393
16 -8.4808426 -2.3714914
17 -2.4736815 -8.4808426
18 48.2161042 -2.4736815
19 54.6788422 48.2161042
20 49.1167354 54.6788422
21 17.6540913 49.1167354
22 -0.7389443 17.6540913
23 -2.1869377 -0.7389443
24 2.4505051 -2.1869377
25 -5.9372759 2.4505051
26 -24.0428683 -5.9372759
27 -18.8322534 -24.0428683
28 -27.9132487 -18.8322534
29 -38.9389910 -27.9132487
30 21.4326971 -38.9389910
31 16.2976813 21.4326971
32 -1.5340088 16.2976813
33 -3.4481758 -1.5340088
34 -20.6110385 -3.4481758
35 -11.7019582 -20.6110385
36 -10.6387138 -11.7019582
37 -19.9754219 -10.6387138
38 -30.1455306 -19.9754219
39 -16.5588991 -30.1455306
40 -36.9325907 -16.5588991
41 -19.8645077 -36.9325907
42 35.2822970 -19.8645077
43 30.7766239 35.2822970
44 -5.2866405 30.7766239
45 -62.6855010 -5.2866405
46 -74.8428374 -62.6855010
47 -39.4772515 -74.8428374
48 -29.1687208 -39.4772515
49 -36.9512191 -29.1687208
50 -4.2713302 -36.9512191
51 -4.5603442 -4.2713302
52 -18.0389046 -4.5603442
53 -6.9945862 -18.0389046
54 40.5313264 -6.9945862
55 55.7763195 40.5313264
56 44.1816374 55.7763195
57 36.3314788 44.1816374
58 23.3063746 36.3314788
59 36.7437887 23.3063746
60 34.6615763 36.7437887
> 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/7ygmo1353351697.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/8taw01353351697.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/9l7e91353351697.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/10gdfk1353351697.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/11g6g81353351697.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/1206vh1353351697.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/13do601353351697.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/14vvlv1353351697.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/15m7zr1353351697.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/162fyi1353351698.tab")
+ }
>
> try(system("convert tmp/1alb71353351697.ps tmp/1alb71353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/2f6ne1353351697.ps tmp/2f6ne1353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/3uc4i1353351697.ps tmp/3uc4i1353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/4xlub1353351697.ps tmp/4xlub1353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/5fn5t1353351697.ps tmp/5fn5t1353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/6f3uj1353351697.ps tmp/6f3uj1353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ygmo1353351697.ps tmp/7ygmo1353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/8taw01353351697.ps tmp/8taw01353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/9l7e91353351697.ps tmp/9l7e91353351697.png",intern=TRUE))
character(0)
> try(system("convert tmp/10gdfk1353351697.ps tmp/10gdfk1353351697.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.081 0.857 6.944