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(103.48
+ ,101.94
+ ,108.42
+ ,106.34
+ ,100.17
+ ,103.93
+ ,102.62
+ ,108.62
+ ,106.35
+ ,102.01
+ ,103.89
+ ,102.71
+ ,109.43
+ ,106.61
+ ,100.30
+ ,104.40
+ ,103.39
+ ,110.25
+ ,108.03
+ ,99.94
+ ,104.79
+ ,104.51
+ ,110.59
+ ,108.50
+ ,100.16
+ ,104.77
+ ,104.09
+ ,110.71
+ ,108.49
+ ,100.18
+ ,105.13
+ ,104.29
+ ,111.33
+ ,109.09
+ ,99.98
+ ,105.26
+ ,104.57
+ ,111.45
+ ,109.21
+ ,100.04
+ ,104.96
+ ,105.39
+ ,110.93
+ ,107.20
+ ,100.05
+ ,104.75
+ ,105.15
+ ,110.58
+ ,106.15
+ ,100.11
+ ,105.01
+ ,106.13
+ ,110.75
+ ,106.25
+ ,100.11
+ ,105.15
+ ,105.46
+ ,111.26
+ ,106.52
+ ,101.03
+ ,105.20
+ ,106.47
+ ,111.08
+ ,105.16
+ ,100.84
+ ,105.77
+ ,106.62
+ ,111.92
+ ,105.68
+ ,102.68
+ ,105.78
+ ,106.52
+ ,111.02
+ ,107.01
+ ,101.27
+ ,106.26
+ ,108.04
+ ,111.21
+ ,107.90
+ ,100.28
+ ,106.13
+ ,107.15
+ ,110.71
+ ,108.12
+ ,100.82
+ ,106.12
+ ,107.32
+ ,110.43
+ ,108.43
+ ,100.87
+ ,106.57
+ ,107.76
+ ,110.73
+ ,109.02
+ ,101.23
+ ,106.44
+ ,107.26
+ ,111.07
+ ,108.39
+ ,101.09
+ ,106.54
+ ,107.89
+ ,111.55
+ ,108.65
+ ,101.22
+ ,107.10
+ ,109.08
+ ,112.47
+ ,109.55
+ ,101.33
+ ,108.10
+ ,110.40
+ ,114.97
+ ,111.69
+ ,101.30
+ ,108.40
+ ,111.03
+ ,115.65
+ ,110.76
+ ,102.39
+ ,108.84
+ ,112.05
+ ,117.44
+ ,110.78
+ ,101.69
+ ,109.62
+ ,112.28
+ ,120.13
+ ,110.76
+ ,103.75
+ ,110.42
+ ,112.80
+ ,122.87
+ ,112.38
+ ,102.99
+ ,110.67
+ ,114.17
+ ,123.67
+ ,112.86
+ ,100.80
+ ,111.66
+ ,114.92
+ ,125.68
+ ,114.74
+ ,102.21
+ ,112.28
+ ,114.65
+ ,127.68
+ ,116.21
+ ,102.45
+ ,112.87
+ ,115.49
+ ,128.41
+ ,116.86
+ ,102.49
+ ,112.18
+ ,114.67
+ ,127.03
+ ,114.51
+ ,102.40
+ ,112.36
+ ,114.71
+ ,128.57
+ ,114.11
+ ,102.99
+ ,112.16
+ ,115.15
+ ,127.54
+ ,112.12
+ ,103.19
+ ,111.49
+ ,115.03
+ ,126.27
+ ,108.90
+ ,103.35
+ ,111.25
+ ,115.07
+ ,125.69
+ ,106.62
+ ,104.44
+ ,111.36
+ ,116.46
+ ,125.80
+ ,105.95
+ ,103.42
+ ,111.74
+ ,116.37
+ ,124.36
+ ,107.03
+ ,105.81
+ ,111.10
+ ,116.20
+ ,121.18
+ ,107.10
+ ,104.25
+ ,111.33
+ ,116.50
+ ,121.08
+ ,108.00
+ ,103.78
+ ,111.25
+ ,116.38
+ ,119.98
+ ,108.24
+ ,104.53
+ ,111.04
+ ,115.44
+ ,117.58
+ ,109.72
+ ,105.01
+ ,110.97
+ ,114.96
+ ,117.29
+ ,109.53
+ ,104.83
+ ,111.31
+ ,114.48
+ ,119.02
+ ,110.64
+ ,104.55
+ ,111.02
+ ,114.30
+ ,117.76
+ ,110.03
+ ,105.16
+ ,111.07
+ ,114.66
+ ,118.06
+ ,109.38
+ ,105.06
+ ,111.36
+ ,114.97
+ ,118.76
+ ,110.62
+ ,105.20
+ ,111.54
+ ,114.79
+ ,119.04
+ ,110.57
+ ,105.87
+ ,112.05
+ ,116.16
+ ,120.34
+ ,111.52
+ ,105.41
+ ,112.52
+ ,116.52
+ ,120.74
+ ,111.47
+ ,107.89
+ ,112.94
+ ,117.14
+ ,122.26
+ ,112.97
+ ,106.06
+ ,113.33
+ ,117.27
+ ,123.41
+ ,114.24
+ ,105.50
+ ,113.78
+ ,117.58
+ ,124.12
+ ,114.97
+ ,106.71
+ ,113.77
+ ,117.21
+ ,124.29
+ ,114.82
+ ,106.34
+ ,113.82
+ ,117.08
+ ,124.02
+ ,114.61
+ ,106.11
+ ,113.89
+ ,117.06
+ ,124.35
+ ,114.68
+ ,106.15
+ ,114.25
+ ,117.55
+ ,125.56
+ ,114.90
+ ,106.61
+ ,114.41
+ ,117.61
+ ,125.99
+ ,115.05
+ ,106.63
+ ,114.55
+ ,117.74
+ ,126.35
+ ,115.67
+ ,106.27
+ ,115.00
+ ,117.87
+ ,127.53
+ ,117.17
+ ,105.59
+ ,115.66
+ ,118.59
+ ,128.42
+ ,118.17
+ ,107.09
+ ,116.33
+ ,119.09
+ ,130.11
+ ,118.61
+ ,108.53
+ ,116.91
+ ,118.93
+ ,132.15
+ ,120.38
+ ,108.01
+ ,117.20
+ ,119.62
+ ,132.91
+ ,121.27
+ ,106.52
+ ,117.59
+ ,120.09
+ ,133.84
+ ,121.55
+ ,107.27
+ ,117.95
+ ,120.38
+ ,135.52
+ ,121.08
+ ,107.58
+ ,118.09
+ ,120.49
+ ,135.29
+ ,121.01
+ ,107.36
+ ,117.99
+ ,120.02
+ ,135.13
+ ,121.15
+ ,107.23
+ ,118.31
+ ,120.17
+ ,136.43
+ ,121.84
+ ,107.54
+ ,118.49
+ ,120.58
+ ,136.29
+ ,121.83
+ ,107.64
+ ,118.96
+ ,121.54
+ ,137.32
+ ,121.86
+ ,108.23
+ ,119.01
+ ,121.52
+ ,137.30
+ ,121.56
+ ,108.42
+ ,119.88
+ ,121.81
+ ,138.38
+ ,122.81
+ ,109.33
+ ,120.59
+ ,122.85
+ ,139.39
+ ,123.24
+ ,111.30
+ ,120.85
+ ,122.97
+ ,140.03
+ ,124.52
+ ,110.52
+ ,120.93
+ ,122.96
+ ,140.05
+ ,125.03
+ ,109.86
+ ,120.89
+ ,123.40
+ ,139.47
+ ,123.56
+ ,110.94
+ ,120.61
+ ,123.23
+ ,138.31
+ ,122.58
+ ,111.35
+ ,120.83
+ ,123.24
+ ,138.50
+ ,122.95
+ ,111.01
+ ,121.36
+ ,123.72
+ ,139.31
+ ,124.73
+ ,110.84
+ ,121.57
+ ,123.99
+ ,139.66
+ ,125.75
+ ,110.79
+ ,121.79
+ ,125.10
+ ,139.63
+ ,125.16
+ ,110.87)
+ ,dim=c(5
+ ,82)
+ ,dimnames=list(c('Algemeen_indexcijfer'
+ ,'Voedingsmiddelen_en_dranken'
+ ,'Huisv_wat_elektr_gas_ed'
+ ,'Vervoer'
+ ,'Recreatie_en_cultuur')
+ ,1:82))
> y <- array(NA,dim=c(5,82),dimnames=list(c('Algemeen_indexcijfer','Voedingsmiddelen_en_dranken','Huisv_wat_elektr_gas_ed','Vervoer','Recreatie_en_cultuur'),1:82))
> 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
Algemeen_indexcijfer Voedingsmiddelen_en_dranken Huisv_wat_elektr_gas_ed
1 103.48 101.94 108.42
2 103.93 102.62 108.62
3 103.89 102.71 109.43
4 104.40 103.39 110.25
5 104.79 104.51 110.59
6 104.77 104.09 110.71
7 105.13 104.29 111.33
8 105.26 104.57 111.45
9 104.96 105.39 110.93
10 104.75 105.15 110.58
11 105.01 106.13 110.75
12 105.15 105.46 111.26
13 105.20 106.47 111.08
14 105.77 106.62 111.92
15 105.78 106.52 111.02
16 106.26 108.04 111.21
17 106.13 107.15 110.71
18 106.12 107.32 110.43
19 106.57 107.76 110.73
20 106.44 107.26 111.07
21 106.54 107.89 111.55
22 107.10 109.08 112.47
23 108.10 110.40 114.97
24 108.40 111.03 115.65
25 108.84 112.05 117.44
26 109.62 112.28 120.13
27 110.42 112.80 122.87
28 110.67 114.17 123.67
29 111.66 114.92 125.68
30 112.28 114.65 127.68
31 112.87 115.49 128.41
32 112.18 114.67 127.03
33 112.36 114.71 128.57
34 112.16 115.15 127.54
35 111.49 115.03 126.27
36 111.25 115.07 125.69
37 111.36 116.46 125.80
38 111.74 116.37 124.36
39 111.10 116.20 121.18
40 111.33 116.50 121.08
41 111.25 116.38 119.98
42 111.04 115.44 117.58
43 110.97 114.96 117.29
44 111.31 114.48 119.02
45 111.02 114.30 117.76
46 111.07 114.66 118.06
47 111.36 114.97 118.76
48 111.54 114.79 119.04
49 112.05 116.16 120.34
50 112.52 116.52 120.74
51 112.94 117.14 122.26
52 113.33 117.27 123.41
53 113.78 117.58 124.12
54 113.77 117.21 124.29
55 113.82 117.08 124.02
56 113.89 117.06 124.35
57 114.25 117.55 125.56
58 114.41 117.61 125.99
59 114.55 117.74 126.35
60 115.00 117.87 127.53
61 115.66 118.59 128.42
62 116.33 119.09 130.11
63 116.91 118.93 132.15
64 117.20 119.62 132.91
65 117.59 120.09 133.84
66 117.95 120.38 135.52
67 118.09 120.49 135.29
68 117.99 120.02 135.13
69 118.31 120.17 136.43
70 118.49 120.58 136.29
71 118.96 121.54 137.32
72 119.01 121.52 137.30
73 119.88 121.81 138.38
74 120.59 122.85 139.39
75 120.85 122.97 140.03
76 120.93 122.96 140.05
77 120.89 123.40 139.47
78 120.61 123.23 138.31
79 120.83 123.24 138.50
80 121.36 123.72 139.31
81 121.57 123.99 139.66
82 121.79 125.10 139.63
Vervoer Recreatie_en_cultuur
1 106.34 100.17
2 106.35 102.01
3 106.61 100.30
4 108.03 99.94
5 108.50 100.16
6 108.49 100.18
7 109.09 99.98
8 109.21 100.04
9 107.20 100.05
10 106.15 100.11
11 106.25 100.11
12 106.52 101.03
13 105.16 100.84
14 105.68 102.68
15 107.01 101.27
16 107.90 100.28
17 108.12 100.82
18 108.43 100.87
19 109.02 101.23
20 108.39 101.09
21 108.65 101.22
22 109.55 101.33
23 111.69 101.30
24 110.76 102.39
25 110.78 101.69
26 110.76 103.75
27 112.38 102.99
28 112.86 100.80
29 114.74 102.21
30 116.21 102.45
31 116.86 102.49
32 114.51 102.40
33 114.11 102.99
34 112.12 103.19
35 108.90 103.35
36 106.62 104.44
37 105.95 103.42
38 107.03 105.81
39 107.10 104.25
40 108.00 103.78
41 108.24 104.53
42 109.72 105.01
43 109.53 104.83
44 110.64 104.55
45 110.03 105.16
46 109.38 105.06
47 110.62 105.20
48 110.57 105.87
49 111.52 105.41
50 111.47 107.89
51 112.97 106.06
52 114.24 105.50
53 114.97 106.71
54 114.82 106.34
55 114.61 106.11
56 114.68 106.15
57 114.90 106.61
58 115.05 106.63
59 115.67 106.27
60 117.17 105.59
61 118.17 107.09
62 118.61 108.53
63 120.38 108.01
64 121.27 106.52
65 121.55 107.27
66 121.08 107.58
67 121.01 107.36
68 121.15 107.23
69 121.84 107.54
70 121.83 107.64
71 121.86 108.23
72 121.56 108.42
73 122.81 109.33
74 123.24 111.30
75 124.52 110.52
76 125.03 109.86
77 123.56 110.94
78 122.58 111.35
79 122.95 111.01
80 124.73 110.84
81 125.75 110.79
82 125.16 110.87
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Voedingsmiddelen_en_dranken
5.2405 0.3260
Huisv_wat_elektr_gas_ed Vervoer
0.1273 0.1957
Recreatie_en_cultuur
0.3024
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.55453 -0.09658 0.03630 0.12714 0.34121
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.240529 1.010589 5.186 1.69e-06 ***
Voedingsmiddelen_en_dranken 0.325965 0.014215 22.931 < 2e-16 ***
Huisv_wat_elektr_gas_ed 0.127262 0.009497 13.400 < 2e-16 ***
Vervoer 0.195713 0.010174 19.237 < 2e-16 ***
Recreatie_en_cultuur 0.302356 0.018539 16.309 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.197 on 77 degrees of freedom
Multiple R-squared: 0.9987, Adjusted R-squared: 0.9986
F-statistic: 1.478e+04 on 4 and 77 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.0247931273 0.0495862546 0.975206873
[2,] 0.0208938887 0.0417877775 0.979106111
[3,] 0.0077167753 0.0154335506 0.992283225
[4,] 0.0024643594 0.0049287188 0.997535641
[5,] 0.0008076897 0.0016153794 0.999192310
[6,] 0.0002542801 0.0005085602 0.999745720
[7,] 0.0000680517 0.0001361034 0.999931948
[8,] 0.0046974858 0.0093949717 0.995302514
[9,] 0.0031033586 0.0062067171 0.996896641
[10,] 0.0026949608 0.0053899216 0.997305039
[11,] 0.0013444650 0.0026889300 0.998655535
[12,] 0.0007292809 0.0014585618 0.999270719
[13,] 0.0040602371 0.0081204743 0.995939763
[14,] 0.0038141256 0.0076282511 0.996185874
[15,] 0.0093926571 0.0187853143 0.990607343
[16,] 0.0118913847 0.0237827694 0.988108615
[17,] 0.0077560312 0.0155120624 0.992243969
[18,] 0.0049750482 0.0099500964 0.995024952
[19,] 0.0098856471 0.0197712943 0.990114353
[20,] 0.0311053933 0.0622107865 0.968894607
[21,] 0.0268238331 0.0536476662 0.973176167
[22,] 0.0346803666 0.0693607331 0.965319633
[23,] 0.0652271761 0.1304543521 0.934772824
[24,] 0.1339477685 0.2678955370 0.866052232
[25,] 0.2896709165 0.5793418330 0.710329083
[26,] 0.4202723404 0.8405446808 0.579727660
[27,] 0.5395503077 0.9208993847 0.460449692
[28,] 0.5510479888 0.8979040225 0.448952011
[29,] 0.5036392870 0.9927214260 0.496360713
[30,] 0.4412552736 0.8825105473 0.558744726
[31,] 0.4539839490 0.9079678979 0.546016051
[32,] 0.4351141986 0.8702283972 0.564885801
[33,] 0.4318768226 0.8637536452 0.568123177
[34,] 0.4518663229 0.9037326459 0.548133677
[35,] 0.4581629229 0.9163258457 0.541837077
[36,] 0.5801220677 0.8397558645 0.419877932
[37,] 0.8191396871 0.3617206259 0.180860313
[38,] 0.8955722161 0.2088555678 0.104427784
[39,] 0.9486024112 0.1027951776 0.051397589
[40,] 0.9493482797 0.1013034405 0.050651720
[41,] 0.9786203170 0.0427593660 0.021379683
[42,] 0.9682821550 0.0634356900 0.031717845
[43,] 0.9767833251 0.0464333498 0.023216675
[44,] 0.9761073438 0.0477853124 0.023892656
[45,] 0.9741832451 0.0516335097 0.025816755
[46,] 0.9903287684 0.0193424632 0.009671232
[47,] 0.9889407971 0.0221184058 0.011059203
[48,] 0.9903082888 0.0193834225 0.009691711
[49,] 0.9923683774 0.0152632453 0.007631623
[50,] 0.9883873500 0.0232252999 0.011612650
[51,] 0.9842365189 0.0315269623 0.015763481
[52,] 0.9800939081 0.0398121837 0.019906092
[53,] 0.9921972700 0.0156054601 0.007802730
[54,] 0.9882526258 0.0234947484 0.011747374
[55,] 0.9817455801 0.0365088398 0.018254420
[56,] 0.9710709016 0.0578581967 0.028929098
[57,] 0.9596500663 0.0806998675 0.040349934
[58,] 0.9790144052 0.0419711896 0.020985595
[59,] 0.9903878239 0.0192243523 0.009612176
[60,] 0.9850846242 0.0298307516 0.014915376
[61,] 0.9757175533 0.0485648934 0.024282447
[62,] 0.9599025997 0.0801948005 0.040097400
[63,] 0.9411848074 0.1176303851 0.058815193
[64,] 0.9348411731 0.1303176538 0.065158827
[65,] 0.9688992211 0.0622015578 0.031100779
[66,] 0.9665496476 0.0669007048 0.033450352
[67,] 0.9056359450 0.1887281099 0.094364055
> postscript(file="/var/fisher/rcomp/tmp/1i2lf1353457403.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/fisher/rcomp/tmp/2zmh91353457403.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/fisher/rcomp/tmp/3yf6c1353457403.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/fisher/rcomp/tmp/428au1353457403.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/fisher/rcomp/tmp/5e4i71353457403.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 = 82
Frequency = 1
1 2 3 4 5 6
0.113680367 -0.241721497 0.052003590 0.066928650 -0.109924971 -0.012380999
7 8 9 10 11 12
0.146567146 0.128398503 0.017642059 0.117772339 0.017120516 -0.020396770
13 14 15 16 17 18
0.046902347 -0.196999098 0.126158176 0.211659778 0.229070691 0.123501245
19 20 21 22 23 24
0.167579098 0.322921489 0.066285905 -0.088094531 -0.246278352 -0.385730551
25 26 27 28 29 30
-0.298279081 -0.554526279 -0.359989976 -0.090153532 -0.394686724 -0.301463437
31 32 33 34 35 36
-0.217483105 0.022566915 -0.106560630 0.010091442 0.122647778 0.060077421
37 38 39 40 41 42
0.142517867 -0.198889398 0.079194453 0.190097254 0.015463041 -0.017486270
43 44 45 46 47 48
0.197492655 0.341211337 0.205182615 0.257105320 0.071959034 0.082206192
49 50 51 52 53 54
-0.066650049 -0.504960822 -0.220754326 -0.098716660 -0.348843553 -0.118642162
55 56 57 58 59 60
0.118735738 0.127464403 -0.008386515 0.041928832 0.081245483 0.250734159
61 62 63 64 65 66
-0.086471476 -0.316033982 -0.132680233 0.112011402 -0.051112950 -0.001188824
67 68 69 70 71 72
0.212443587 0.297915795 0.174808028 0.210700428 0.052432055 0.112762660
73 74 75 76 77 78
0.231004467 -0.206332866 -0.081570569 0.098885675 -0.049574465 -0.058704087
79 80 81 82
0.164243987 0.137730456 0.030669030 -0.016052668
> postscript(file="/var/fisher/rcomp/tmp/6vr7x1353457403.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 = 82
Frequency = 1
lag(myerror, k = 1) myerror
0 0.113680367 NA
1 -0.241721497 0.113680367
2 0.052003590 -0.241721497
3 0.066928650 0.052003590
4 -0.109924971 0.066928650
5 -0.012380999 -0.109924971
6 0.146567146 -0.012380999
7 0.128398503 0.146567146
8 0.017642059 0.128398503
9 0.117772339 0.017642059
10 0.017120516 0.117772339
11 -0.020396770 0.017120516
12 0.046902347 -0.020396770
13 -0.196999098 0.046902347
14 0.126158176 -0.196999098
15 0.211659778 0.126158176
16 0.229070691 0.211659778
17 0.123501245 0.229070691
18 0.167579098 0.123501245
19 0.322921489 0.167579098
20 0.066285905 0.322921489
21 -0.088094531 0.066285905
22 -0.246278352 -0.088094531
23 -0.385730551 -0.246278352
24 -0.298279081 -0.385730551
25 -0.554526279 -0.298279081
26 -0.359989976 -0.554526279
27 -0.090153532 -0.359989976
28 -0.394686724 -0.090153532
29 -0.301463437 -0.394686724
30 -0.217483105 -0.301463437
31 0.022566915 -0.217483105
32 -0.106560630 0.022566915
33 0.010091442 -0.106560630
34 0.122647778 0.010091442
35 0.060077421 0.122647778
36 0.142517867 0.060077421
37 -0.198889398 0.142517867
38 0.079194453 -0.198889398
39 0.190097254 0.079194453
40 0.015463041 0.190097254
41 -0.017486270 0.015463041
42 0.197492655 -0.017486270
43 0.341211337 0.197492655
44 0.205182615 0.341211337
45 0.257105320 0.205182615
46 0.071959034 0.257105320
47 0.082206192 0.071959034
48 -0.066650049 0.082206192
49 -0.504960822 -0.066650049
50 -0.220754326 -0.504960822
51 -0.098716660 -0.220754326
52 -0.348843553 -0.098716660
53 -0.118642162 -0.348843553
54 0.118735738 -0.118642162
55 0.127464403 0.118735738
56 -0.008386515 0.127464403
57 0.041928832 -0.008386515
58 0.081245483 0.041928832
59 0.250734159 0.081245483
60 -0.086471476 0.250734159
61 -0.316033982 -0.086471476
62 -0.132680233 -0.316033982
63 0.112011402 -0.132680233
64 -0.051112950 0.112011402
65 -0.001188824 -0.051112950
66 0.212443587 -0.001188824
67 0.297915795 0.212443587
68 0.174808028 0.297915795
69 0.210700428 0.174808028
70 0.052432055 0.210700428
71 0.112762660 0.052432055
72 0.231004467 0.112762660
73 -0.206332866 0.231004467
74 -0.081570569 -0.206332866
75 0.098885675 -0.081570569
76 -0.049574465 0.098885675
77 -0.058704087 -0.049574465
78 0.164243987 -0.058704087
79 0.137730456 0.164243987
80 0.030669030 0.137730456
81 -0.016052668 0.030669030
82 NA -0.016052668
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.241721497 0.113680367
[2,] 0.052003590 -0.241721497
[3,] 0.066928650 0.052003590
[4,] -0.109924971 0.066928650
[5,] -0.012380999 -0.109924971
[6,] 0.146567146 -0.012380999
[7,] 0.128398503 0.146567146
[8,] 0.017642059 0.128398503
[9,] 0.117772339 0.017642059
[10,] 0.017120516 0.117772339
[11,] -0.020396770 0.017120516
[12,] 0.046902347 -0.020396770
[13,] -0.196999098 0.046902347
[14,] 0.126158176 -0.196999098
[15,] 0.211659778 0.126158176
[16,] 0.229070691 0.211659778
[17,] 0.123501245 0.229070691
[18,] 0.167579098 0.123501245
[19,] 0.322921489 0.167579098
[20,] 0.066285905 0.322921489
[21,] -0.088094531 0.066285905
[22,] -0.246278352 -0.088094531
[23,] -0.385730551 -0.246278352
[24,] -0.298279081 -0.385730551
[25,] -0.554526279 -0.298279081
[26,] -0.359989976 -0.554526279
[27,] -0.090153532 -0.359989976
[28,] -0.394686724 -0.090153532
[29,] -0.301463437 -0.394686724
[30,] -0.217483105 -0.301463437
[31,] 0.022566915 -0.217483105
[32,] -0.106560630 0.022566915
[33,] 0.010091442 -0.106560630
[34,] 0.122647778 0.010091442
[35,] 0.060077421 0.122647778
[36,] 0.142517867 0.060077421
[37,] -0.198889398 0.142517867
[38,] 0.079194453 -0.198889398
[39,] 0.190097254 0.079194453
[40,] 0.015463041 0.190097254
[41,] -0.017486270 0.015463041
[42,] 0.197492655 -0.017486270
[43,] 0.341211337 0.197492655
[44,] 0.205182615 0.341211337
[45,] 0.257105320 0.205182615
[46,] 0.071959034 0.257105320
[47,] 0.082206192 0.071959034
[48,] -0.066650049 0.082206192
[49,] -0.504960822 -0.066650049
[50,] -0.220754326 -0.504960822
[51,] -0.098716660 -0.220754326
[52,] -0.348843553 -0.098716660
[53,] -0.118642162 -0.348843553
[54,] 0.118735738 -0.118642162
[55,] 0.127464403 0.118735738
[56,] -0.008386515 0.127464403
[57,] 0.041928832 -0.008386515
[58,] 0.081245483 0.041928832
[59,] 0.250734159 0.081245483
[60,] -0.086471476 0.250734159
[61,] -0.316033982 -0.086471476
[62,] -0.132680233 -0.316033982
[63,] 0.112011402 -0.132680233
[64,] -0.051112950 0.112011402
[65,] -0.001188824 -0.051112950
[66,] 0.212443587 -0.001188824
[67,] 0.297915795 0.212443587
[68,] 0.174808028 0.297915795
[69,] 0.210700428 0.174808028
[70,] 0.052432055 0.210700428
[71,] 0.112762660 0.052432055
[72,] 0.231004467 0.112762660
[73,] -0.206332866 0.231004467
[74,] -0.081570569 -0.206332866
[75,] 0.098885675 -0.081570569
[76,] -0.049574465 0.098885675
[77,] -0.058704087 -0.049574465
[78,] 0.164243987 -0.058704087
[79,] 0.137730456 0.164243987
[80,] 0.030669030 0.137730456
[81,] -0.016052668 0.030669030
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.241721497 0.113680367
2 0.052003590 -0.241721497
3 0.066928650 0.052003590
4 -0.109924971 0.066928650
5 -0.012380999 -0.109924971
6 0.146567146 -0.012380999
7 0.128398503 0.146567146
8 0.017642059 0.128398503
9 0.117772339 0.017642059
10 0.017120516 0.117772339
11 -0.020396770 0.017120516
12 0.046902347 -0.020396770
13 -0.196999098 0.046902347
14 0.126158176 -0.196999098
15 0.211659778 0.126158176
16 0.229070691 0.211659778
17 0.123501245 0.229070691
18 0.167579098 0.123501245
19 0.322921489 0.167579098
20 0.066285905 0.322921489
21 -0.088094531 0.066285905
22 -0.246278352 -0.088094531
23 -0.385730551 -0.246278352
24 -0.298279081 -0.385730551
25 -0.554526279 -0.298279081
26 -0.359989976 -0.554526279
27 -0.090153532 -0.359989976
28 -0.394686724 -0.090153532
29 -0.301463437 -0.394686724
30 -0.217483105 -0.301463437
31 0.022566915 -0.217483105
32 -0.106560630 0.022566915
33 0.010091442 -0.106560630
34 0.122647778 0.010091442
35 0.060077421 0.122647778
36 0.142517867 0.060077421
37 -0.198889398 0.142517867
38 0.079194453 -0.198889398
39 0.190097254 0.079194453
40 0.015463041 0.190097254
41 -0.017486270 0.015463041
42 0.197492655 -0.017486270
43 0.341211337 0.197492655
44 0.205182615 0.341211337
45 0.257105320 0.205182615
46 0.071959034 0.257105320
47 0.082206192 0.071959034
48 -0.066650049 0.082206192
49 -0.504960822 -0.066650049
50 -0.220754326 -0.504960822
51 -0.098716660 -0.220754326
52 -0.348843553 -0.098716660
53 -0.118642162 -0.348843553
54 0.118735738 -0.118642162
55 0.127464403 0.118735738
56 -0.008386515 0.127464403
57 0.041928832 -0.008386515
58 0.081245483 0.041928832
59 0.250734159 0.081245483
60 -0.086471476 0.250734159
61 -0.316033982 -0.086471476
62 -0.132680233 -0.316033982
63 0.112011402 -0.132680233
64 -0.051112950 0.112011402
65 -0.001188824 -0.051112950
66 0.212443587 -0.001188824
67 0.297915795 0.212443587
68 0.174808028 0.297915795
69 0.210700428 0.174808028
70 0.052432055 0.210700428
71 0.112762660 0.052432055
72 0.231004467 0.112762660
73 -0.206332866 0.231004467
74 -0.081570569 -0.206332866
75 0.098885675 -0.081570569
76 -0.049574465 0.098885675
77 -0.058704087 -0.049574465
78 0.164243987 -0.058704087
79 0.137730456 0.164243987
80 0.030669030 0.137730456
81 -0.016052668 0.030669030
> 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/fisher/rcomp/tmp/7z1bc1353457403.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/fisher/rcomp/tmp/8q06v1353457403.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/fisher/rcomp/tmp/9qnbf1353457403.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/fisher/rcomp/tmp/10ur3y1353457403.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/113i2n1353457403.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/fisher/rcomp/tmp/12tzgp1353457403.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/fisher/rcomp/tmp/13r3eo1353457403.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/fisher/rcomp/tmp/148iml1353457403.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/fisher/rcomp/tmp/15vrq61353457403.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/fisher/rcomp/tmp/16auly1353457403.tab")
+ }
>
> try(system("convert tmp/1i2lf1353457403.ps tmp/1i2lf1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/2zmh91353457403.ps tmp/2zmh91353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/3yf6c1353457403.ps tmp/3yf6c1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/428au1353457403.ps tmp/428au1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/5e4i71353457403.ps tmp/5e4i71353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/6vr7x1353457403.ps tmp/6vr7x1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/7z1bc1353457403.ps tmp/7z1bc1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/8q06v1353457403.ps tmp/8q06v1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/9qnbf1353457403.ps tmp/9qnbf1353457403.png",intern=TRUE))
character(0)
> try(system("convert tmp/10ur3y1353457403.ps tmp/10ur3y1353457403.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.178 1.272 7.460