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(33,62,39,64,45,62,46,64,45,64,45,69,49,69,50,65,54,56,59,58,58,53,56,62,48,55,50,60,52,59,53,58,55,53,43,57,42,57,38,53,41,54,41,53,39,57,34,57,27,55,15,49,14,50,31,49,41,54,43,58,46,58,42,52,45,56,45,52,40,59,35,53,36,52,38,53,39,51,32,50,24,56,21,52,12,46,29,48,36,46,31,48,28,48,30,49,38,53,27,48,40,51,40,48,44,50,47,55,45,52,42,53,38,52,46,55,37,53,41,53,40,56,33,54,34,52,36,55,36,54,38,59,42,56,35,56,25,51,24,53,22,52,27,51,17,46,30,49,30,46,34,55,37,57,36,53,33,52,33,53,33,50,37,54,40,53,35,50,37,51,43,52,42,47,33,51,39,49,40,53,37,52,44,45,42,53,43,51,40,48,30,48,30,48,31,48,18,40,24,43,22,40,26,39,28,39,23,36,17,41,12,39,9,40,19,39,21,46,18,40,18,37,15,37,24,44,18,41,19,40,30,36,33,38,35,43,36,42,47,45,46,46),dim=c(2,121),dimnames=list(c('Alg_E','Spaar'),1:121))
> y <- array(NA,dim=c(2,121),dimnames=list(c('Alg_E','Spaar'),1:121))
> 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'
> #'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
Spaar Alg_E
1 62 33
2 64 39
3 62 45
4 64 46
5 64 45
6 69 45
7 69 49
8 65 50
9 56 54
10 58 59
11 53 58
12 62 56
13 55 48
14 60 50
15 59 52
16 58 53
17 53 55
18 57 43
19 57 42
20 53 38
21 54 41
22 53 41
23 57 39
24 57 34
25 55 27
26 49 15
27 50 14
28 49 31
29 54 41
30 58 43
31 58 46
32 52 42
33 56 45
34 52 45
35 59 40
36 53 35
37 52 36
38 53 38
39 51 39
40 50 32
41 56 24
42 52 21
43 46 12
44 48 29
45 46 36
46 48 31
47 48 28
48 49 30
49 53 38
50 48 27
51 51 40
52 48 40
53 50 44
54 55 47
55 52 45
56 53 42
57 52 38
58 55 46
59 53 37
60 53 41
61 56 40
62 54 33
63 52 34
64 55 36
65 54 36
66 59 38
67 56 42
68 56 35
69 51 25
70 53 24
71 52 22
72 51 27
73 46 17
74 49 30
75 46 30
76 55 34
77 57 37
78 53 36
79 52 33
80 53 33
81 50 33
82 54 37
83 53 40
84 50 35
85 51 37
86 52 43
87 47 42
88 51 33
89 49 39
90 53 40
91 52 37
92 45 44
93 53 42
94 51 43
95 48 40
96 48 30
97 48 30
98 48 31
99 40 18
100 43 24
101 40 22
102 39 26
103 39 28
104 36 23
105 41 17
106 39 12
107 40 9
108 39 19
109 46 21
110 40 18
111 37 18
112 37 15
113 44 24
114 41 18
115 40 19
116 36 30
117 38 33
118 43 35
119 42 36
120 45 47
121 46 46
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Alg_E
36.0877 0.4265
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-12.88413 -3.12131 -0.03104 2.83622 13.71763
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 36.08766 1.63922 22.015 <2e-16 ***
Alg_E 0.42655 0.04461 9.561 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.215 on 119 degrees of freedom
Multiple R-squared: 0.4345, Adjusted R-squared: 0.4297
F-statistic: 91.42 on 1 and 119 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.01665900 0.03331799 0.983341003
[2,] 0.12535957 0.25071914 0.874640428
[3,] 0.10786436 0.21572873 0.892135637
[4,] 0.06867186 0.13734373 0.931328137
[5,] 0.43670594 0.87341187 0.563294063
[6,] 0.39732031 0.79464062 0.602679689
[7,] 0.52560730 0.94878539 0.474392696
[8,] 0.45418747 0.90837493 0.545812533
[9,] 0.56515499 0.86969002 0.434845008
[10,] 0.48708001 0.97416002 0.512919989
[11,] 0.41052433 0.82104867 0.589475666
[12,] 0.34394850 0.68789700 0.656051500
[13,] 0.39467617 0.78935234 0.605323829
[14,] 0.43507422 0.87014844 0.564925779
[15,] 0.46305854 0.92611707 0.536941463
[16,] 0.64211548 0.71576904 0.357884518
[17,] 0.68525820 0.62948360 0.314741802
[18,] 0.72886628 0.54226744 0.271133719
[19,] 0.70034507 0.59930985 0.299654926
[20,] 0.68281888 0.63436224 0.317181122
[21,] 0.68932341 0.62135318 0.310676588
[22,] 0.74838885 0.50322229 0.251611147
[23,] 0.75674837 0.48650327 0.243251633
[24,] 0.78101968 0.43796064 0.218980320
[25,] 0.75387320 0.49225361 0.246126805
[26,] 0.71835136 0.56329728 0.281648640
[27,] 0.67564542 0.64870915 0.324354577
[28,] 0.67515757 0.64968487 0.324842435
[29,] 0.63170565 0.73658871 0.368294354
[30,] 0.63893421 0.72213159 0.361065793
[31,] 0.63105318 0.73789364 0.368946821
[32,] 0.59855239 0.80289522 0.401447609
[33,] 0.57272041 0.85455919 0.427279594
[34,] 0.53880355 0.92239290 0.461196451
[35,] 0.53101825 0.93796351 0.468981753
[36,] 0.51229228 0.97541545 0.487707723
[37,] 0.56943031 0.86113939 0.430569693
[38,] 0.57233841 0.85532318 0.427661592
[39,] 0.57570039 0.84859923 0.424299613
[40,] 0.57217495 0.85565010 0.427825052
[41,] 0.65434417 0.69131165 0.345655825
[42,] 0.64602619 0.70794763 0.353973813
[43,] 0.62528040 0.74943921 0.374719604
[44,] 0.59737353 0.80525293 0.402626467
[45,] 0.55668513 0.88662973 0.443314866
[46,] 0.52832343 0.94335314 0.471676570
[47,] 0.50325036 0.99349927 0.496749637
[48,] 0.53451566 0.93096868 0.465484339
[49,] 0.54441017 0.91117966 0.455589828
[50,] 0.49782709 0.99565418 0.502172912
[51,] 0.47336814 0.94673629 0.526631857
[52,] 0.42975782 0.85951563 0.570242184
[53,] 0.38747987 0.77495973 0.612520134
[54,] 0.34194318 0.68388636 0.658056819
[55,] 0.30354703 0.60709405 0.696452975
[56,] 0.26522091 0.53044182 0.734779088
[57,] 0.24298410 0.48596819 0.757015905
[58,] 0.23039405 0.46078809 0.769605953
[59,] 0.20253101 0.40506201 0.797468993
[60,] 0.19204994 0.38409987 0.807950063
[61,] 0.17455541 0.34911082 0.825444592
[62,] 0.22517489 0.45034978 0.774825110
[63,] 0.20897064 0.41794128 0.791029359
[64,] 0.23109782 0.46219564 0.768902182
[65,] 0.23336713 0.46673426 0.766632870
[66,] 0.28812020 0.57624040 0.711879802
[67,] 0.35464343 0.70928687 0.645356567
[68,] 0.36566677 0.73133353 0.634333233
[69,] 0.37271910 0.74543820 0.627280898
[70,] 0.35253641 0.70507283 0.647463587
[71,] 0.34288836 0.68577672 0.657111638
[72,] 0.39759656 0.79519313 0.602403436
[73,] 0.50047217 0.99905567 0.499527835
[74,] 0.50833526 0.98332949 0.491664744
[75,] 0.52624891 0.94750218 0.473751090
[76,] 0.57923173 0.84153654 0.420768269
[77,] 0.57315106 0.85369789 0.426848944
[78,] 0.62839763 0.74320474 0.371602368
[79,] 0.63912612 0.72174777 0.360873883
[80,] 0.63592636 0.72814728 0.364073642
[81,] 0.64029535 0.71940931 0.359704654
[82,] 0.63281585 0.73436830 0.367184149
[83,] 0.63970187 0.72059626 0.360298132
[84,] 0.68529460 0.62941080 0.314705400
[85,] 0.66906958 0.66186084 0.330930421
[86,] 0.72723089 0.54553823 0.272769113
[87,] 0.79730828 0.40538344 0.202691721
[88,] 0.82339680 0.35320641 0.176603204
[89,] 0.88274963 0.23450075 0.117250374
[90,] 0.90926137 0.18147726 0.090738632
[91,] 0.91469177 0.17061645 0.085308226
[92,] 0.94485110 0.11029781 0.055148904
[93,] 0.97194573 0.05610854 0.028054272
[94,] 0.99020495 0.01959011 0.009795054
[95,] 0.98706159 0.02587681 0.012938406
[96,] 0.98579774 0.02840452 0.014202262
[97,] 0.98113278 0.03773445 0.018867224
[98,] 0.97912992 0.04174015 0.020870077
[99,] 0.97769729 0.04460543 0.022302714
[100,] 0.98744155 0.02511690 0.012558448
[101,] 0.98002880 0.03994240 0.019971199
[102,] 0.96670243 0.06659514 0.033297571
[103,] 0.94974536 0.10050929 0.050254645
[104,] 0.92437977 0.15124047 0.075620234
[105,] 0.97092378 0.05815245 0.029076224
[106,] 0.95183316 0.09633369 0.048166843
[107,] 0.92919934 0.14160132 0.070800658
[108,] 0.89250065 0.21499869 0.107499346
[109,] 0.89779740 0.20440521 0.102202603
[110,] 0.88352336 0.23295328 0.116476641
[111,] 0.95192590 0.09614821 0.048074104
[112,] 0.93343023 0.13313955 0.066569774
> postscript(file="/var/www/html/rcomp/tmp/1p5k91258730622.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/20iba1258730622.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/3kr151258730622.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/4kd7c1258730622.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/5x9qz1258730622.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 = 121
Frequency = 1
1 2 3 4 5 6
11.83621813 11.27692398 6.71762983 8.29108081 8.71762983 13.71762983
7 8 9 10 11 12
12.01143373 7.58488471 -3.12131139 -3.25405652 -7.82750749 2.02559056
13 14 15 16 17 18
-1.56201724 2.58488471 0.73178666 -0.69476237 -6.54786042 2.57072788
19 20 21 22 23 24
2.99727691 0.70347300 0.42382593 -0.57617407 4.27692398 6.40966910
25 26 27 28 29 30
7.39551228 6.51410057 7.94064960 -0.31068382 0.42382593 3.57072788
31 32 33 34 35 36
2.29108081 -2.00272309 0.71762983 -3.28237017 5.85037495 1.98312008
37 38 39 40 41 42
0.55657105 0.70347300 -1.72307602 0.26276715 9.67515935 6.95480643
43 44 45 46 47 48
4.79374765 -0.45758577 -5.44342895 -1.31068382 -0.03103675 0.11586520
49 50 51 52 53 54
0.70347300 0.39551228 -2.14962505 -5.14962505 -4.85582114 -1.13546822
55 56 57 58 59 60
-3.28237017 -1.00272309 -0.29652700 -0.70891919 1.13002203 -0.57617407
61 62 63 64 65 66
2.85037495 3.83621813 1.40966910 3.55657105 2.55657105 6.70347300
67 68 69 70 71 72
1.99727691 4.98312008 4.24861033 6.67515935 6.52825740 3.39551228
73 74 75 76 77 78
2.66100252 0.11586520 -2.88413480 4.40966910 5.13002203 1.55657105
79 80 81 82 83 84
1.83621813 2.83621813 -0.16378187 2.13002203 -0.14962505 -1.01687992
85 86 87 88 89 90
-0.86997797 -2.42927212 -7.00272309 0.83621813 -3.72307602 -0.14962505
91 92 93 94 95 96
0.13002203 -9.85582114 -1.00272309 -3.42927212 -5.14962505 -0.88413480
97 98 99 100 101 102
-0.88413480 -1.31068382 -3.76554650 -3.32484065 -5.47174260 -8.17793870
103 104 105 106 107 108
-9.03103675 -9.89829162 -2.33899748 -2.20625235 0.07339472 -5.19209552
109 110 111 112 113 114
0.95480643 -3.76554650 -6.76554650 -5.48589943 -2.32484065 -2.76554650
115 116 117 118 119 120
-4.19209552 -12.88413480 -12.16378187 -8.01687992 -9.44342895 -11.13546822
121
-9.70891919
> postscript(file="/var/www/html/rcomp/tmp/6dsat1258730622.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 = 121
Frequency = 1
lag(myerror, k = 1) myerror
0 11.83621813 NA
1 11.27692398 11.83621813
2 6.71762983 11.27692398
3 8.29108081 6.71762983
4 8.71762983 8.29108081
5 13.71762983 8.71762983
6 12.01143373 13.71762983
7 7.58488471 12.01143373
8 -3.12131139 7.58488471
9 -3.25405652 -3.12131139
10 -7.82750749 -3.25405652
11 2.02559056 -7.82750749
12 -1.56201724 2.02559056
13 2.58488471 -1.56201724
14 0.73178666 2.58488471
15 -0.69476237 0.73178666
16 -6.54786042 -0.69476237
17 2.57072788 -6.54786042
18 2.99727691 2.57072788
19 0.70347300 2.99727691
20 0.42382593 0.70347300
21 -0.57617407 0.42382593
22 4.27692398 -0.57617407
23 6.40966910 4.27692398
24 7.39551228 6.40966910
25 6.51410057 7.39551228
26 7.94064960 6.51410057
27 -0.31068382 7.94064960
28 0.42382593 -0.31068382
29 3.57072788 0.42382593
30 2.29108081 3.57072788
31 -2.00272309 2.29108081
32 0.71762983 -2.00272309
33 -3.28237017 0.71762983
34 5.85037495 -3.28237017
35 1.98312008 5.85037495
36 0.55657105 1.98312008
37 0.70347300 0.55657105
38 -1.72307602 0.70347300
39 0.26276715 -1.72307602
40 9.67515935 0.26276715
41 6.95480643 9.67515935
42 4.79374765 6.95480643
43 -0.45758577 4.79374765
44 -5.44342895 -0.45758577
45 -1.31068382 -5.44342895
46 -0.03103675 -1.31068382
47 0.11586520 -0.03103675
48 0.70347300 0.11586520
49 0.39551228 0.70347300
50 -2.14962505 0.39551228
51 -5.14962505 -2.14962505
52 -4.85582114 -5.14962505
53 -1.13546822 -4.85582114
54 -3.28237017 -1.13546822
55 -1.00272309 -3.28237017
56 -0.29652700 -1.00272309
57 -0.70891919 -0.29652700
58 1.13002203 -0.70891919
59 -0.57617407 1.13002203
60 2.85037495 -0.57617407
61 3.83621813 2.85037495
62 1.40966910 3.83621813
63 3.55657105 1.40966910
64 2.55657105 3.55657105
65 6.70347300 2.55657105
66 1.99727691 6.70347300
67 4.98312008 1.99727691
68 4.24861033 4.98312008
69 6.67515935 4.24861033
70 6.52825740 6.67515935
71 3.39551228 6.52825740
72 2.66100252 3.39551228
73 0.11586520 2.66100252
74 -2.88413480 0.11586520
75 4.40966910 -2.88413480
76 5.13002203 4.40966910
77 1.55657105 5.13002203
78 1.83621813 1.55657105
79 2.83621813 1.83621813
80 -0.16378187 2.83621813
81 2.13002203 -0.16378187
82 -0.14962505 2.13002203
83 -1.01687992 -0.14962505
84 -0.86997797 -1.01687992
85 -2.42927212 -0.86997797
86 -7.00272309 -2.42927212
87 0.83621813 -7.00272309
88 -3.72307602 0.83621813
89 -0.14962505 -3.72307602
90 0.13002203 -0.14962505
91 -9.85582114 0.13002203
92 -1.00272309 -9.85582114
93 -3.42927212 -1.00272309
94 -5.14962505 -3.42927212
95 -0.88413480 -5.14962505
96 -0.88413480 -0.88413480
97 -1.31068382 -0.88413480
98 -3.76554650 -1.31068382
99 -3.32484065 -3.76554650
100 -5.47174260 -3.32484065
101 -8.17793870 -5.47174260
102 -9.03103675 -8.17793870
103 -9.89829162 -9.03103675
104 -2.33899748 -9.89829162
105 -2.20625235 -2.33899748
106 0.07339472 -2.20625235
107 -5.19209552 0.07339472
108 0.95480643 -5.19209552
109 -3.76554650 0.95480643
110 -6.76554650 -3.76554650
111 -5.48589943 -6.76554650
112 -2.32484065 -5.48589943
113 -2.76554650 -2.32484065
114 -4.19209552 -2.76554650
115 -12.88413480 -4.19209552
116 -12.16378187 -12.88413480
117 -8.01687992 -12.16378187
118 -9.44342895 -8.01687992
119 -11.13546822 -9.44342895
120 -9.70891919 -11.13546822
121 NA -9.70891919
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 11.27692398 11.83621813
[2,] 6.71762983 11.27692398
[3,] 8.29108081 6.71762983
[4,] 8.71762983 8.29108081
[5,] 13.71762983 8.71762983
[6,] 12.01143373 13.71762983
[7,] 7.58488471 12.01143373
[8,] -3.12131139 7.58488471
[9,] -3.25405652 -3.12131139
[10,] -7.82750749 -3.25405652
[11,] 2.02559056 -7.82750749
[12,] -1.56201724 2.02559056
[13,] 2.58488471 -1.56201724
[14,] 0.73178666 2.58488471
[15,] -0.69476237 0.73178666
[16,] -6.54786042 -0.69476237
[17,] 2.57072788 -6.54786042
[18,] 2.99727691 2.57072788
[19,] 0.70347300 2.99727691
[20,] 0.42382593 0.70347300
[21,] -0.57617407 0.42382593
[22,] 4.27692398 -0.57617407
[23,] 6.40966910 4.27692398
[24,] 7.39551228 6.40966910
[25,] 6.51410057 7.39551228
[26,] 7.94064960 6.51410057
[27,] -0.31068382 7.94064960
[28,] 0.42382593 -0.31068382
[29,] 3.57072788 0.42382593
[30,] 2.29108081 3.57072788
[31,] -2.00272309 2.29108081
[32,] 0.71762983 -2.00272309
[33,] -3.28237017 0.71762983
[34,] 5.85037495 -3.28237017
[35,] 1.98312008 5.85037495
[36,] 0.55657105 1.98312008
[37,] 0.70347300 0.55657105
[38,] -1.72307602 0.70347300
[39,] 0.26276715 -1.72307602
[40,] 9.67515935 0.26276715
[41,] 6.95480643 9.67515935
[42,] 4.79374765 6.95480643
[43,] -0.45758577 4.79374765
[44,] -5.44342895 -0.45758577
[45,] -1.31068382 -5.44342895
[46,] -0.03103675 -1.31068382
[47,] 0.11586520 -0.03103675
[48,] 0.70347300 0.11586520
[49,] 0.39551228 0.70347300
[50,] -2.14962505 0.39551228
[51,] -5.14962505 -2.14962505
[52,] -4.85582114 -5.14962505
[53,] -1.13546822 -4.85582114
[54,] -3.28237017 -1.13546822
[55,] -1.00272309 -3.28237017
[56,] -0.29652700 -1.00272309
[57,] -0.70891919 -0.29652700
[58,] 1.13002203 -0.70891919
[59,] -0.57617407 1.13002203
[60,] 2.85037495 -0.57617407
[61,] 3.83621813 2.85037495
[62,] 1.40966910 3.83621813
[63,] 3.55657105 1.40966910
[64,] 2.55657105 3.55657105
[65,] 6.70347300 2.55657105
[66,] 1.99727691 6.70347300
[67,] 4.98312008 1.99727691
[68,] 4.24861033 4.98312008
[69,] 6.67515935 4.24861033
[70,] 6.52825740 6.67515935
[71,] 3.39551228 6.52825740
[72,] 2.66100252 3.39551228
[73,] 0.11586520 2.66100252
[74,] -2.88413480 0.11586520
[75,] 4.40966910 -2.88413480
[76,] 5.13002203 4.40966910
[77,] 1.55657105 5.13002203
[78,] 1.83621813 1.55657105
[79,] 2.83621813 1.83621813
[80,] -0.16378187 2.83621813
[81,] 2.13002203 -0.16378187
[82,] -0.14962505 2.13002203
[83,] -1.01687992 -0.14962505
[84,] -0.86997797 -1.01687992
[85,] -2.42927212 -0.86997797
[86,] -7.00272309 -2.42927212
[87,] 0.83621813 -7.00272309
[88,] -3.72307602 0.83621813
[89,] -0.14962505 -3.72307602
[90,] 0.13002203 -0.14962505
[91,] -9.85582114 0.13002203
[92,] -1.00272309 -9.85582114
[93,] -3.42927212 -1.00272309
[94,] -5.14962505 -3.42927212
[95,] -0.88413480 -5.14962505
[96,] -0.88413480 -0.88413480
[97,] -1.31068382 -0.88413480
[98,] -3.76554650 -1.31068382
[99,] -3.32484065 -3.76554650
[100,] -5.47174260 -3.32484065
[101,] -8.17793870 -5.47174260
[102,] -9.03103675 -8.17793870
[103,] -9.89829162 -9.03103675
[104,] -2.33899748 -9.89829162
[105,] -2.20625235 -2.33899748
[106,] 0.07339472 -2.20625235
[107,] -5.19209552 0.07339472
[108,] 0.95480643 -5.19209552
[109,] -3.76554650 0.95480643
[110,] -6.76554650 -3.76554650
[111,] -5.48589943 -6.76554650
[112,] -2.32484065 -5.48589943
[113,] -2.76554650 -2.32484065
[114,] -4.19209552 -2.76554650
[115,] -12.88413480 -4.19209552
[116,] -12.16378187 -12.88413480
[117,] -8.01687992 -12.16378187
[118,] -9.44342895 -8.01687992
[119,] -11.13546822 -9.44342895
[120,] -9.70891919 -11.13546822
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 11.27692398 11.83621813
2 6.71762983 11.27692398
3 8.29108081 6.71762983
4 8.71762983 8.29108081
5 13.71762983 8.71762983
6 12.01143373 13.71762983
7 7.58488471 12.01143373
8 -3.12131139 7.58488471
9 -3.25405652 -3.12131139
10 -7.82750749 -3.25405652
11 2.02559056 -7.82750749
12 -1.56201724 2.02559056
13 2.58488471 -1.56201724
14 0.73178666 2.58488471
15 -0.69476237 0.73178666
16 -6.54786042 -0.69476237
17 2.57072788 -6.54786042
18 2.99727691 2.57072788
19 0.70347300 2.99727691
20 0.42382593 0.70347300
21 -0.57617407 0.42382593
22 4.27692398 -0.57617407
23 6.40966910 4.27692398
24 7.39551228 6.40966910
25 6.51410057 7.39551228
26 7.94064960 6.51410057
27 -0.31068382 7.94064960
28 0.42382593 -0.31068382
29 3.57072788 0.42382593
30 2.29108081 3.57072788
31 -2.00272309 2.29108081
32 0.71762983 -2.00272309
33 -3.28237017 0.71762983
34 5.85037495 -3.28237017
35 1.98312008 5.85037495
36 0.55657105 1.98312008
37 0.70347300 0.55657105
38 -1.72307602 0.70347300
39 0.26276715 -1.72307602
40 9.67515935 0.26276715
41 6.95480643 9.67515935
42 4.79374765 6.95480643
43 -0.45758577 4.79374765
44 -5.44342895 -0.45758577
45 -1.31068382 -5.44342895
46 -0.03103675 -1.31068382
47 0.11586520 -0.03103675
48 0.70347300 0.11586520
49 0.39551228 0.70347300
50 -2.14962505 0.39551228
51 -5.14962505 -2.14962505
52 -4.85582114 -5.14962505
53 -1.13546822 -4.85582114
54 -3.28237017 -1.13546822
55 -1.00272309 -3.28237017
56 -0.29652700 -1.00272309
57 -0.70891919 -0.29652700
58 1.13002203 -0.70891919
59 -0.57617407 1.13002203
60 2.85037495 -0.57617407
61 3.83621813 2.85037495
62 1.40966910 3.83621813
63 3.55657105 1.40966910
64 2.55657105 3.55657105
65 6.70347300 2.55657105
66 1.99727691 6.70347300
67 4.98312008 1.99727691
68 4.24861033 4.98312008
69 6.67515935 4.24861033
70 6.52825740 6.67515935
71 3.39551228 6.52825740
72 2.66100252 3.39551228
73 0.11586520 2.66100252
74 -2.88413480 0.11586520
75 4.40966910 -2.88413480
76 5.13002203 4.40966910
77 1.55657105 5.13002203
78 1.83621813 1.55657105
79 2.83621813 1.83621813
80 -0.16378187 2.83621813
81 2.13002203 -0.16378187
82 -0.14962505 2.13002203
83 -1.01687992 -0.14962505
84 -0.86997797 -1.01687992
85 -2.42927212 -0.86997797
86 -7.00272309 -2.42927212
87 0.83621813 -7.00272309
88 -3.72307602 0.83621813
89 -0.14962505 -3.72307602
90 0.13002203 -0.14962505
91 -9.85582114 0.13002203
92 -1.00272309 -9.85582114
93 -3.42927212 -1.00272309
94 -5.14962505 -3.42927212
95 -0.88413480 -5.14962505
96 -0.88413480 -0.88413480
97 -1.31068382 -0.88413480
98 -3.76554650 -1.31068382
99 -3.32484065 -3.76554650
100 -5.47174260 -3.32484065
101 -8.17793870 -5.47174260
102 -9.03103675 -8.17793870
103 -9.89829162 -9.03103675
104 -2.33899748 -9.89829162
105 -2.20625235 -2.33899748
106 0.07339472 -2.20625235
107 -5.19209552 0.07339472
108 0.95480643 -5.19209552
109 -3.76554650 0.95480643
110 -6.76554650 -3.76554650
111 -5.48589943 -6.76554650
112 -2.32484065 -5.48589943
113 -2.76554650 -2.32484065
114 -4.19209552 -2.76554650
115 -12.88413480 -4.19209552
116 -12.16378187 -12.88413480
117 -8.01687992 -12.16378187
118 -9.44342895 -8.01687992
119 -11.13546822 -9.44342895
120 -9.70891919 -11.13546822
> 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/7dzi41258730622.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/8avv41258730622.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/915cd1258730622.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/10oyg41258730622.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/11btpr1258730622.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/125l1z1258730622.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/13qwdb1258730622.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/1444ye1258730622.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/15lkj11258730622.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/16evvj1258730622.tab")
+ }
>
> system("convert tmp/1p5k91258730622.ps tmp/1p5k91258730622.png")
> system("convert tmp/20iba1258730622.ps tmp/20iba1258730622.png")
> system("convert tmp/3kr151258730622.ps tmp/3kr151258730622.png")
> system("convert tmp/4kd7c1258730622.ps tmp/4kd7c1258730622.png")
> system("convert tmp/5x9qz1258730622.ps tmp/5x9qz1258730622.png")
> system("convert tmp/6dsat1258730622.ps tmp/6dsat1258730622.png")
> system("convert tmp/7dzi41258730622.ps tmp/7dzi41258730622.png")
> system("convert tmp/8avv41258730622.ps tmp/8avv41258730622.png")
> system("convert tmp/915cd1258730622.ps tmp/915cd1258730622.png")
> system("convert tmp/10oyg41258730622.ps tmp/10oyg41258730622.png")
>
>
> proc.time()
user system elapsed
3.162 1.638 3.602