R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(19,0,23,0,22,0,23,0,25,0,25,0,23,0,22,0,21,0,16,0,21,0,21,0,26,0,23,0,22,0,22,0,22,0,12,0,20,0,18,0,23,0,25,0,28,0,28,0,29,0,31,0,33,0,32,0,33,0,35,0,33,0,36,0,30,0,34,0,34,0,35,0,33,0,28,0,27,0,23,0,23,0,24,0,24,0,20,0,16,1,6,1,2,1,12,1,19,1,21,1,22,1,20,1,21,1,20,1,19,1,17,1,17,1,17,1,16,1,12,1,11,1,7,1,2,1,9,1,11,1,10,1,7,1,9,1,15,1,5,1,14,1,14,1,17,1,19,1,17,1,16,1,14,1,20,1,16,1,18,1,18,1,14,1,13,1,14,1,14,1,17,1,18,1,15,1,9,1,9,1,9,1,10,1,6,1,12,1,11,1,15,1,19,1,18,1,15,1,16,1,14,1,18,1,18,1,18,1,18,1,22,1,21,1,12,1,19,1,21,1,19,1,22,1,22,1,21,1,19,1,18,1,18,1,19,1,12,1,16,1),dim=c(2,120),dimnames=list(c('Vertrouwen','Aanslag'),1:120))
> y <- array(NA,dim=c(2,120),dimnames=list(c('Vertrouwen','Aanslag'),1:120))
> 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'
> #'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
Vertrouwen Aanslag
1 19 0
2 23 0
3 22 0
4 23 0
5 25 0
6 25 0
7 23 0
8 22 0
9 21 0
10 16 0
11 21 0
12 21 0
13 26 0
14 23 0
15 22 0
16 22 0
17 22 0
18 12 0
19 20 0
20 18 0
21 23 0
22 25 0
23 28 0
24 28 0
25 29 0
26 31 0
27 33 0
28 32 0
29 33 0
30 35 0
31 33 0
32 36 0
33 30 0
34 34 0
35 34 0
36 35 0
37 33 0
38 28 0
39 27 0
40 23 0
41 23 0
42 24 0
43 24 0
44 20 0
45 16 1
46 6 1
47 2 1
48 12 1
49 19 1
50 21 1
51 22 1
52 20 1
53 21 1
54 20 1
55 19 1
56 17 1
57 17 1
58 17 1
59 16 1
60 12 1
61 11 1
62 7 1
63 2 1
64 9 1
65 11 1
66 10 1
67 7 1
68 9 1
69 15 1
70 5 1
71 14 1
72 14 1
73 17 1
74 19 1
75 17 1
76 16 1
77 14 1
78 20 1
79 16 1
80 18 1
81 18 1
82 14 1
83 13 1
84 14 1
85 14 1
86 17 1
87 18 1
88 15 1
89 9 1
90 9 1
91 9 1
92 10 1
93 6 1
94 12 1
95 11 1
96 15 1
97 19 1
98 18 1
99 15 1
100 16 1
101 14 1
102 18 1
103 18 1
104 18 1
105 18 1
106 22 1
107 21 1
108 12 1
109 19 1
110 21 1
111 19 1
112 22 1
113 22 1
114 21 1
115 19 1
116 18 1
117 18 1
118 19 1
119 12 1
120 16 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Aanslag
25.61 -10.52
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.6136 -3.6136 0.1471 3.9079 10.3864
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 25.6136 0.7788 32.89 <2e-16 ***
Aanslag -10.5215 0.9786 -10.75 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.166 on 118 degrees of freedom
Multiple R-squared: 0.4949, Adjusted R-squared: 0.4906
F-statistic: 115.6 on 1 and 118 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.128516348 0.257032696 0.8714836522
[2,] 0.076917007 0.153834015 0.9230829925
[3,] 0.030499325 0.060998650 0.9695006749
[4,] 0.012025962 0.024051925 0.9879740376
[5,] 0.005821216 0.011642432 0.9941787840
[6,] 0.039586575 0.079173149 0.9604134254
[7,] 0.021149976 0.042299953 0.9788500237
[8,] 0.010931625 0.021863250 0.9890683750
[9,] 0.012716821 0.025433642 0.9872831792
[10,] 0.006649036 0.013298072 0.9933509639
[11,] 0.003302321 0.006604641 0.9966976794
[12,] 0.001601520 0.003203039 0.9983984804
[13,] 0.000761253 0.001522506 0.9992387469
[14,] 0.040900313 0.081800626 0.9590996872
[15,] 0.031662288 0.063324577 0.9683377117
[16,] 0.035187826 0.070375652 0.9648121739
[17,] 0.026491702 0.052983403 0.9735082984
[18,] 0.024796678 0.049593355 0.9752033224
[19,] 0.042200075 0.084400150 0.9577999248
[20,] 0.059715653 0.119431307 0.9402843465
[21,] 0.090242459 0.180484918 0.9097575408
[22,] 0.166825889 0.333651778 0.8331741109
[23,] 0.323116547 0.646233093 0.6768834535
[24,] 0.428069621 0.856139242 0.5719303790
[25,] 0.551002135 0.897995731 0.4489978654
[26,] 0.717430356 0.565139289 0.2825696444
[27,] 0.776809876 0.446380247 0.2231901237
[28,] 0.883232493 0.233535015 0.1167675073
[29,] 0.873733661 0.252532679 0.1262663394
[30,] 0.909688886 0.180622227 0.0903111136
[31,] 0.936545651 0.126908699 0.0634543494
[32,] 0.964603394 0.070793212 0.0353966058
[33,] 0.974364106 0.051271789 0.0256358943
[34,] 0.968356948 0.063286103 0.0316430516
[35,] 0.960091156 0.079817688 0.0399088438
[36,] 0.949226837 0.101546325 0.0507731627
[37,] 0.936051481 0.127897038 0.0639485188
[38,] 0.919217078 0.161565844 0.0807829221
[39,] 0.901223102 0.197553796 0.0987768979
[40,] 0.892506880 0.214986241 0.1074931203
[41,] 0.865645456 0.268709088 0.1343545439
[42,] 0.900726338 0.198547324 0.0992736619
[43,] 0.956334866 0.087330268 0.0436651342
[44,] 0.949013957 0.101972086 0.0509860432
[45,] 0.958246151 0.083507699 0.0417538494
[46,] 0.969572550 0.060854900 0.0304274499
[47,] 0.978757004 0.042485992 0.0212429960
[48,] 0.978693229 0.042613542 0.0213067712
[49,] 0.980560568 0.038878865 0.0194394323
[50,] 0.979455928 0.041088144 0.0205440720
[51,] 0.975908924 0.048182152 0.0240910762
[52,] 0.968377556 0.063244889 0.0316224443
[53,] 0.959021320 0.081957360 0.0409786799
[54,] 0.947568792 0.104862416 0.0524312078
[55,] 0.932371534 0.135256932 0.0676284658
[56,] 0.922222960 0.155554081 0.0777770403
[57,] 0.916250368 0.167499264 0.0837496318
[58,] 0.943232148 0.113535705 0.0567678525
[59,] 0.990087798 0.019824404 0.0099122018
[60,] 0.991599724 0.016800553 0.0084002764
[61,] 0.990521210 0.018957580 0.0094787902
[62,] 0.990710041 0.018579918 0.0092899590
[63,] 0.995219814 0.009560372 0.0047801859
[64,] 0.996342672 0.007314656 0.0036573278
[65,] 0.994636672 0.010726656 0.0053633278
[66,] 0.998948772 0.002102456 0.0010512280
[67,] 0.998453729 0.003092543 0.0015462715
[68,] 0.997756826 0.004486349 0.0022431744
[69,] 0.996777357 0.006445286 0.0032226431
[70,] 0.996183659 0.007632682 0.0038163409
[71,] 0.994552038 0.010895924 0.0054479618
[72,] 0.992033179 0.015933642 0.0079668210
[73,] 0.988948647 0.022102705 0.0110513527
[74,] 0.988506921 0.022986157 0.0114930787
[75,] 0.983568095 0.032863810 0.0164319052
[76,] 0.978744838 0.042510324 0.0212551618
[77,] 0.972695178 0.054609643 0.0273048217
[78,] 0.963502892 0.072994215 0.0364971076
[79,] 0.954622164 0.090755672 0.0453778360
[80,] 0.940988587 0.118022827 0.0590114134
[81,] 0.924361543 0.151276914 0.0756384571
[82,] 0.902527247 0.194945506 0.0974727531
[83,] 0.880581551 0.238836897 0.1194184487
[84,] 0.848384790 0.303230421 0.1516152104
[85,] 0.881337335 0.237325330 0.1186626652
[86,] 0.914359079 0.171281842 0.0856409210
[87,] 0.945172012 0.109655977 0.0548279883
[88,] 0.962117134 0.075765732 0.0378828658
[89,] 0.996428092 0.007143816 0.0035719080
[90,] 0.997597441 0.004805118 0.0024025592
[91,] 0.999205522 0.001588956 0.0007944781
[92,] 0.998969832 0.002060336 0.0010301679
[93,] 0.998248072 0.003503857 0.0017519284
[94,] 0.996891225 0.006217549 0.0031087746
[95,] 0.996063552 0.007872896 0.0039364480
[96,] 0.994134958 0.011730083 0.0058650417
[97,] 0.994902860 0.010194280 0.0050971401
[98,] 0.991056859 0.017886283 0.0089431414
[99,] 0.984681042 0.030637916 0.0153189581
[100,] 0.974421804 0.051156392 0.0255781959
[101,] 0.958436267 0.083127465 0.0415637326
[102,] 0.953753668 0.092492664 0.0462463319
[103,] 0.939424228 0.121151544 0.0605757720
[104,] 0.975169200 0.049661600 0.0248308001
[105,] 0.954399300 0.091201400 0.0456006999
[106,] 0.933892999 0.132214002 0.0661070010
[107,] 0.885470424 0.229059151 0.1145295757
[108,] 0.871901567 0.256196866 0.1280984328
[109,] 0.873738921 0.252522158 0.1262610789
[110,] 0.859808900 0.280382200 0.1401910999
[111,] 0.768724694 0.462550613 0.2312753064
> postscript(file="/var/www/html/freestat/rcomp/tmp/1tcm41229608456.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/freestat/rcomp/tmp/2i1fy1229608456.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/freestat/rcomp/tmp/32u4g1229608456.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/freestat/rcomp/tmp/4feab1229608456.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/freestat/rcomp/tmp/5jwe11229608456.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 = 120
Frequency = 1
1 2 3 4 5 6
-6.61363636 -2.61363636 -3.61363636 -2.61363636 -0.61363636 -0.61363636
7 8 9 10 11 12
-2.61363636 -3.61363636 -4.61363636 -9.61363636 -4.61363636 -4.61363636
13 14 15 16 17 18
0.38636364 -2.61363636 -3.61363636 -3.61363636 -3.61363636 -13.61363636
19 20 21 22 23 24
-5.61363636 -7.61363636 -2.61363636 -0.61363636 2.38636364 2.38636364
25 26 27 28 29 30
3.38636364 5.38636364 7.38636364 6.38636364 7.38636364 9.38636364
31 32 33 34 35 36
7.38636364 10.38636364 4.38636364 8.38636364 8.38636364 9.38636364
37 38 39 40 41 42
7.38636364 2.38636364 1.38636364 -2.61363636 -2.61363636 -1.61363636
43 44 45 46 47 48
-1.61363636 -5.61363636 0.90789474 -9.09210526 -13.09210526 -3.09210526
49 50 51 52 53 54
3.90789474 5.90789474 6.90789474 4.90789474 5.90789474 4.90789474
55 56 57 58 59 60
3.90789474 1.90789474 1.90789474 1.90789474 0.90789474 -3.09210526
61 62 63 64 65 66
-4.09210526 -8.09210526 -13.09210526 -6.09210526 -4.09210526 -5.09210526
67 68 69 70 71 72
-8.09210526 -6.09210526 -0.09210526 -10.09210526 -1.09210526 -1.09210526
73 74 75 76 77 78
1.90789474 3.90789474 1.90789474 0.90789474 -1.09210526 4.90789474
79 80 81 82 83 84
0.90789474 2.90789474 2.90789474 -1.09210526 -2.09210526 -1.09210526
85 86 87 88 89 90
-1.09210526 1.90789474 2.90789474 -0.09210526 -6.09210526 -6.09210526
91 92 93 94 95 96
-6.09210526 -5.09210526 -9.09210526 -3.09210526 -4.09210526 -0.09210526
97 98 99 100 101 102
3.90789474 2.90789474 -0.09210526 0.90789474 -1.09210526 2.90789474
103 104 105 106 107 108
2.90789474 2.90789474 2.90789474 6.90789474 5.90789474 -3.09210526
109 110 111 112 113 114
3.90789474 5.90789474 3.90789474 6.90789474 6.90789474 5.90789474
115 116 117 118 119 120
3.90789474 2.90789474 2.90789474 3.90789474 -3.09210526 0.90789474
> postscript(file="/var/www/html/freestat/rcomp/tmp/6iyzx1229608456.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 = 120
Frequency = 1
lag(myerror, k = 1) myerror
0 -6.61363636 NA
1 -2.61363636 -6.61363636
2 -3.61363636 -2.61363636
3 -2.61363636 -3.61363636
4 -0.61363636 -2.61363636
5 -0.61363636 -0.61363636
6 -2.61363636 -0.61363636
7 -3.61363636 -2.61363636
8 -4.61363636 -3.61363636
9 -9.61363636 -4.61363636
10 -4.61363636 -9.61363636
11 -4.61363636 -4.61363636
12 0.38636364 -4.61363636
13 -2.61363636 0.38636364
14 -3.61363636 -2.61363636
15 -3.61363636 -3.61363636
16 -3.61363636 -3.61363636
17 -13.61363636 -3.61363636
18 -5.61363636 -13.61363636
19 -7.61363636 -5.61363636
20 -2.61363636 -7.61363636
21 -0.61363636 -2.61363636
22 2.38636364 -0.61363636
23 2.38636364 2.38636364
24 3.38636364 2.38636364
25 5.38636364 3.38636364
26 7.38636364 5.38636364
27 6.38636364 7.38636364
28 7.38636364 6.38636364
29 9.38636364 7.38636364
30 7.38636364 9.38636364
31 10.38636364 7.38636364
32 4.38636364 10.38636364
33 8.38636364 4.38636364
34 8.38636364 8.38636364
35 9.38636364 8.38636364
36 7.38636364 9.38636364
37 2.38636364 7.38636364
38 1.38636364 2.38636364
39 -2.61363636 1.38636364
40 -2.61363636 -2.61363636
41 -1.61363636 -2.61363636
42 -1.61363636 -1.61363636
43 -5.61363636 -1.61363636
44 0.90789474 -5.61363636
45 -9.09210526 0.90789474
46 -13.09210526 -9.09210526
47 -3.09210526 -13.09210526
48 3.90789474 -3.09210526
49 5.90789474 3.90789474
50 6.90789474 5.90789474
51 4.90789474 6.90789474
52 5.90789474 4.90789474
53 4.90789474 5.90789474
54 3.90789474 4.90789474
55 1.90789474 3.90789474
56 1.90789474 1.90789474
57 1.90789474 1.90789474
58 0.90789474 1.90789474
59 -3.09210526 0.90789474
60 -4.09210526 -3.09210526
61 -8.09210526 -4.09210526
62 -13.09210526 -8.09210526
63 -6.09210526 -13.09210526
64 -4.09210526 -6.09210526
65 -5.09210526 -4.09210526
66 -8.09210526 -5.09210526
67 -6.09210526 -8.09210526
68 -0.09210526 -6.09210526
69 -10.09210526 -0.09210526
70 -1.09210526 -10.09210526
71 -1.09210526 -1.09210526
72 1.90789474 -1.09210526
73 3.90789474 1.90789474
74 1.90789474 3.90789474
75 0.90789474 1.90789474
76 -1.09210526 0.90789474
77 4.90789474 -1.09210526
78 0.90789474 4.90789474
79 2.90789474 0.90789474
80 2.90789474 2.90789474
81 -1.09210526 2.90789474
82 -2.09210526 -1.09210526
83 -1.09210526 -2.09210526
84 -1.09210526 -1.09210526
85 1.90789474 -1.09210526
86 2.90789474 1.90789474
87 -0.09210526 2.90789474
88 -6.09210526 -0.09210526
89 -6.09210526 -6.09210526
90 -6.09210526 -6.09210526
91 -5.09210526 -6.09210526
92 -9.09210526 -5.09210526
93 -3.09210526 -9.09210526
94 -4.09210526 -3.09210526
95 -0.09210526 -4.09210526
96 3.90789474 -0.09210526
97 2.90789474 3.90789474
98 -0.09210526 2.90789474
99 0.90789474 -0.09210526
100 -1.09210526 0.90789474
101 2.90789474 -1.09210526
102 2.90789474 2.90789474
103 2.90789474 2.90789474
104 2.90789474 2.90789474
105 6.90789474 2.90789474
106 5.90789474 6.90789474
107 -3.09210526 5.90789474
108 3.90789474 -3.09210526
109 5.90789474 3.90789474
110 3.90789474 5.90789474
111 6.90789474 3.90789474
112 6.90789474 6.90789474
113 5.90789474 6.90789474
114 3.90789474 5.90789474
115 2.90789474 3.90789474
116 2.90789474 2.90789474
117 3.90789474 2.90789474
118 -3.09210526 3.90789474
119 0.90789474 -3.09210526
120 NA 0.90789474
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.61363636 -6.61363636
[2,] -3.61363636 -2.61363636
[3,] -2.61363636 -3.61363636
[4,] -0.61363636 -2.61363636
[5,] -0.61363636 -0.61363636
[6,] -2.61363636 -0.61363636
[7,] -3.61363636 -2.61363636
[8,] -4.61363636 -3.61363636
[9,] -9.61363636 -4.61363636
[10,] -4.61363636 -9.61363636
[11,] -4.61363636 -4.61363636
[12,] 0.38636364 -4.61363636
[13,] -2.61363636 0.38636364
[14,] -3.61363636 -2.61363636
[15,] -3.61363636 -3.61363636
[16,] -3.61363636 -3.61363636
[17,] -13.61363636 -3.61363636
[18,] -5.61363636 -13.61363636
[19,] -7.61363636 -5.61363636
[20,] -2.61363636 -7.61363636
[21,] -0.61363636 -2.61363636
[22,] 2.38636364 -0.61363636
[23,] 2.38636364 2.38636364
[24,] 3.38636364 2.38636364
[25,] 5.38636364 3.38636364
[26,] 7.38636364 5.38636364
[27,] 6.38636364 7.38636364
[28,] 7.38636364 6.38636364
[29,] 9.38636364 7.38636364
[30,] 7.38636364 9.38636364
[31,] 10.38636364 7.38636364
[32,] 4.38636364 10.38636364
[33,] 8.38636364 4.38636364
[34,] 8.38636364 8.38636364
[35,] 9.38636364 8.38636364
[36,] 7.38636364 9.38636364
[37,] 2.38636364 7.38636364
[38,] 1.38636364 2.38636364
[39,] -2.61363636 1.38636364
[40,] -2.61363636 -2.61363636
[41,] -1.61363636 -2.61363636
[42,] -1.61363636 -1.61363636
[43,] -5.61363636 -1.61363636
[44,] 0.90789474 -5.61363636
[45,] -9.09210526 0.90789474
[46,] -13.09210526 -9.09210526
[47,] -3.09210526 -13.09210526
[48,] 3.90789474 -3.09210526
[49,] 5.90789474 3.90789474
[50,] 6.90789474 5.90789474
[51,] 4.90789474 6.90789474
[52,] 5.90789474 4.90789474
[53,] 4.90789474 5.90789474
[54,] 3.90789474 4.90789474
[55,] 1.90789474 3.90789474
[56,] 1.90789474 1.90789474
[57,] 1.90789474 1.90789474
[58,] 0.90789474 1.90789474
[59,] -3.09210526 0.90789474
[60,] -4.09210526 -3.09210526
[61,] -8.09210526 -4.09210526
[62,] -13.09210526 -8.09210526
[63,] -6.09210526 -13.09210526
[64,] -4.09210526 -6.09210526
[65,] -5.09210526 -4.09210526
[66,] -8.09210526 -5.09210526
[67,] -6.09210526 -8.09210526
[68,] -0.09210526 -6.09210526
[69,] -10.09210526 -0.09210526
[70,] -1.09210526 -10.09210526
[71,] -1.09210526 -1.09210526
[72,] 1.90789474 -1.09210526
[73,] 3.90789474 1.90789474
[74,] 1.90789474 3.90789474
[75,] 0.90789474 1.90789474
[76,] -1.09210526 0.90789474
[77,] 4.90789474 -1.09210526
[78,] 0.90789474 4.90789474
[79,] 2.90789474 0.90789474
[80,] 2.90789474 2.90789474
[81,] -1.09210526 2.90789474
[82,] -2.09210526 -1.09210526
[83,] -1.09210526 -2.09210526
[84,] -1.09210526 -1.09210526
[85,] 1.90789474 -1.09210526
[86,] 2.90789474 1.90789474
[87,] -0.09210526 2.90789474
[88,] -6.09210526 -0.09210526
[89,] -6.09210526 -6.09210526
[90,] -6.09210526 -6.09210526
[91,] -5.09210526 -6.09210526
[92,] -9.09210526 -5.09210526
[93,] -3.09210526 -9.09210526
[94,] -4.09210526 -3.09210526
[95,] -0.09210526 -4.09210526
[96,] 3.90789474 -0.09210526
[97,] 2.90789474 3.90789474
[98,] -0.09210526 2.90789474
[99,] 0.90789474 -0.09210526
[100,] -1.09210526 0.90789474
[101,] 2.90789474 -1.09210526
[102,] 2.90789474 2.90789474
[103,] 2.90789474 2.90789474
[104,] 2.90789474 2.90789474
[105,] 6.90789474 2.90789474
[106,] 5.90789474 6.90789474
[107,] -3.09210526 5.90789474
[108,] 3.90789474 -3.09210526
[109,] 5.90789474 3.90789474
[110,] 3.90789474 5.90789474
[111,] 6.90789474 3.90789474
[112,] 6.90789474 6.90789474
[113,] 5.90789474 6.90789474
[114,] 3.90789474 5.90789474
[115,] 2.90789474 3.90789474
[116,] 2.90789474 2.90789474
[117,] 3.90789474 2.90789474
[118,] -3.09210526 3.90789474
[119,] 0.90789474 -3.09210526
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.61363636 -6.61363636
2 -3.61363636 -2.61363636
3 -2.61363636 -3.61363636
4 -0.61363636 -2.61363636
5 -0.61363636 -0.61363636
6 -2.61363636 -0.61363636
7 -3.61363636 -2.61363636
8 -4.61363636 -3.61363636
9 -9.61363636 -4.61363636
10 -4.61363636 -9.61363636
11 -4.61363636 -4.61363636
12 0.38636364 -4.61363636
13 -2.61363636 0.38636364
14 -3.61363636 -2.61363636
15 -3.61363636 -3.61363636
16 -3.61363636 -3.61363636
17 -13.61363636 -3.61363636
18 -5.61363636 -13.61363636
19 -7.61363636 -5.61363636
20 -2.61363636 -7.61363636
21 -0.61363636 -2.61363636
22 2.38636364 -0.61363636
23 2.38636364 2.38636364
24 3.38636364 2.38636364
25 5.38636364 3.38636364
26 7.38636364 5.38636364
27 6.38636364 7.38636364
28 7.38636364 6.38636364
29 9.38636364 7.38636364
30 7.38636364 9.38636364
31 10.38636364 7.38636364
32 4.38636364 10.38636364
33 8.38636364 4.38636364
34 8.38636364 8.38636364
35 9.38636364 8.38636364
36 7.38636364 9.38636364
37 2.38636364 7.38636364
38 1.38636364 2.38636364
39 -2.61363636 1.38636364
40 -2.61363636 -2.61363636
41 -1.61363636 -2.61363636
42 -1.61363636 -1.61363636
43 -5.61363636 -1.61363636
44 0.90789474 -5.61363636
45 -9.09210526 0.90789474
46 -13.09210526 -9.09210526
47 -3.09210526 -13.09210526
48 3.90789474 -3.09210526
49 5.90789474 3.90789474
50 6.90789474 5.90789474
51 4.90789474 6.90789474
52 5.90789474 4.90789474
53 4.90789474 5.90789474
54 3.90789474 4.90789474
55 1.90789474 3.90789474
56 1.90789474 1.90789474
57 1.90789474 1.90789474
58 0.90789474 1.90789474
59 -3.09210526 0.90789474
60 -4.09210526 -3.09210526
61 -8.09210526 -4.09210526
62 -13.09210526 -8.09210526
63 -6.09210526 -13.09210526
64 -4.09210526 -6.09210526
65 -5.09210526 -4.09210526
66 -8.09210526 -5.09210526
67 -6.09210526 -8.09210526
68 -0.09210526 -6.09210526
69 -10.09210526 -0.09210526
70 -1.09210526 -10.09210526
71 -1.09210526 -1.09210526
72 1.90789474 -1.09210526
73 3.90789474 1.90789474
74 1.90789474 3.90789474
75 0.90789474 1.90789474
76 -1.09210526 0.90789474
77 4.90789474 -1.09210526
78 0.90789474 4.90789474
79 2.90789474 0.90789474
80 2.90789474 2.90789474
81 -1.09210526 2.90789474
82 -2.09210526 -1.09210526
83 -1.09210526 -2.09210526
84 -1.09210526 -1.09210526
85 1.90789474 -1.09210526
86 2.90789474 1.90789474
87 -0.09210526 2.90789474
88 -6.09210526 -0.09210526
89 -6.09210526 -6.09210526
90 -6.09210526 -6.09210526
91 -5.09210526 -6.09210526
92 -9.09210526 -5.09210526
93 -3.09210526 -9.09210526
94 -4.09210526 -3.09210526
95 -0.09210526 -4.09210526
96 3.90789474 -0.09210526
97 2.90789474 3.90789474
98 -0.09210526 2.90789474
99 0.90789474 -0.09210526
100 -1.09210526 0.90789474
101 2.90789474 -1.09210526
102 2.90789474 2.90789474
103 2.90789474 2.90789474
104 2.90789474 2.90789474
105 6.90789474 2.90789474
106 5.90789474 6.90789474
107 -3.09210526 5.90789474
108 3.90789474 -3.09210526
109 5.90789474 3.90789474
110 3.90789474 5.90789474
111 6.90789474 3.90789474
112 6.90789474 6.90789474
113 5.90789474 6.90789474
114 3.90789474 5.90789474
115 2.90789474 3.90789474
116 2.90789474 2.90789474
117 3.90789474 2.90789474
118 -3.09210526 3.90789474
119 0.90789474 -3.09210526
> 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/freestat/rcomp/tmp/7m0eo1229608456.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/freestat/rcomp/tmp/8icda1229608456.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/freestat/rcomp/tmp/92j491229608456.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/freestat/rcomp/tmp/10tqzg1229608456.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/116im11229608456.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/freestat/rcomp/tmp/12kfuc1229608456.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/freestat/rcomp/tmp/137dk51229608456.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/freestat/rcomp/tmp/14hoiy1229608456.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/freestat/rcomp/tmp/155vze1229608456.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/freestat/rcomp/tmp/16miym1229608456.tab")
+ }
>
> system("convert tmp/1tcm41229608456.ps tmp/1tcm41229608456.png")
> system("convert tmp/2i1fy1229608456.ps tmp/2i1fy1229608456.png")
> system("convert tmp/32u4g1229608456.ps tmp/32u4g1229608456.png")
> system("convert tmp/4feab1229608456.ps tmp/4feab1229608456.png")
> system("convert tmp/5jwe11229608456.ps tmp/5jwe11229608456.png")
> system("convert tmp/6iyzx1229608456.ps tmp/6iyzx1229608456.png")
> system("convert tmp/7m0eo1229608456.ps tmp/7m0eo1229608456.png")
> system("convert tmp/8icda1229608456.ps tmp/8icda1229608456.png")
> system("convert tmp/92j491229608456.ps tmp/92j491229608456.png")
> system("convert tmp/10tqzg1229608456.ps tmp/10tqzg1229608456.png")
>
>
> proc.time()
user system elapsed
4.671 2.642 5.762