R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-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(101.82
+ ,107.34
+ ,93.63
+ ,99.85
+ ,101.76
+ ,101.68
+ ,107.34
+ ,93.63
+ ,99.91
+ ,102.37
+ ,101.68
+ ,107.34
+ ,93.63
+ ,99.87
+ ,102.38
+ ,102.45
+ ,107.34
+ ,96.13
+ ,99.86
+ ,102.86
+ ,102.45
+ ,107.34
+ ,96.13
+ ,100.10
+ ,102.87
+ ,102.45
+ ,107.34
+ ,96.13
+ ,100.10
+ ,102.92
+ ,102.45
+ ,107.34
+ ,96.13
+ ,100.12
+ ,102.95
+ ,102.45
+ ,107.34
+ ,96.13
+ ,99.95
+ ,103.02
+ ,102.45
+ ,112.60
+ ,96.13
+ ,99.94
+ ,104.08
+ ,102.52
+ ,112.60
+ ,96.13
+ ,100.18
+ ,104.16
+ ,102.52
+ ,112.60
+ ,96.13
+ ,100.31
+ ,104.24
+ ,102.85
+ ,112.60
+ ,96.13
+ ,100.65
+ ,104.33
+ ,102.85
+ ,112.61
+ ,96.13
+ ,100.65
+ ,104.73
+ ,102.85
+ ,112.61
+ ,96.13
+ ,100.69
+ ,104.86
+ ,103.25
+ ,112.61
+ ,96.13
+ ,101.26
+ ,105.03
+ ,103.25
+ ,112.61
+ ,98.73
+ ,101.26
+ ,105.62
+ ,103.25
+ ,112.61
+ ,98.73
+ ,101.38
+ ,105.63
+ ,103.25
+ ,112.61
+ ,98.73
+ ,101.38
+ ,105.63
+ ,104.45
+ ,112.61
+ ,98.73
+ ,101.38
+ ,105.94
+ ,104.45
+ ,112.61
+ ,98.73
+ ,101.44
+ ,106.61
+ ,104.45
+ ,118.65
+ ,98.73
+ ,101.40
+ ,107.69
+ ,104.80
+ ,118.65
+ ,98.73
+ ,101.40
+ ,107.78
+ ,104.80
+ ,118.65
+ ,98.73
+ ,100.58
+ ,107.93
+ ,105.29
+ ,118.65
+ ,98.73
+ ,100.58
+ ,108.48
+ ,105.29
+ ,114.29
+ ,98.73
+ ,100.58
+ ,108.14
+ ,105.29
+ ,114.29
+ ,98.73
+ ,100.59
+ ,108.48
+ ,105.29
+ ,114.29
+ ,98.73
+ ,100.81
+ ,108.48
+ ,106.04
+ ,114.29
+ ,101.67
+ ,100.75
+ ,108.89
+ ,105.94
+ ,114.29
+ ,101.67
+ ,100.75
+ ,108.93
+ ,105.94
+ ,114.29
+ ,101.67
+ ,100.96
+ ,109.21
+ ,105.94
+ ,114.29
+ ,101.67
+ ,101.31
+ ,109.47
+ ,106.28
+ ,114.29
+ ,101.67
+ ,101.64
+ ,109.80
+ ,106.48
+ ,123.33
+ ,101.67
+ ,101.46
+ ,111.73
+ ,107.19
+ ,123.33
+ ,101.67
+ ,101.73
+ ,111.85
+ ,108.14
+ ,123.33
+ ,101.67
+ ,101.73
+ ,112.12
+ ,108.22
+ ,123.33
+ ,101.67
+ ,101.64
+ ,112.15
+ ,108.22
+ ,123.33
+ ,101.67
+ ,101.77
+ ,112.17
+ ,108.61
+ ,123.33
+ ,101.67
+ ,101.74
+ ,112.67
+ ,108.61
+ ,123.33
+ ,101.67
+ ,101.89
+ ,112.80
+ ,108.61
+ ,123.33
+ ,107.94
+ ,101.89
+ ,113.44
+ ,108.61
+ ,123.33
+ ,107.94
+ ,101.93
+ ,113.53
+ ,109.06
+ ,123.33
+ ,107.94
+ ,101.93
+ ,114.53
+ ,109.06
+ ,123.33
+ ,107.94
+ ,102.32
+ ,114.51
+ ,112.93
+ ,123.33
+ ,107.94
+ ,102.41
+ ,115.05
+ ,115.84
+ ,129.03
+ ,107.94
+ ,103.58
+ ,116.67
+ ,118.57
+ ,128.76
+ ,107.94
+ ,104.12
+ ,117.07
+ ,118.57
+ ,128.76
+ ,107.94
+ ,104.10
+ ,116.92
+ ,118.86
+ ,128.76
+ ,107.94
+ ,104.15
+ ,117.00
+ ,118.98
+ ,128.76
+ ,107.94
+ ,104.15
+ ,117.02
+ ,119.27
+ ,128.76
+ ,107.94
+ ,104.16
+ ,117.35
+ ,119.39
+ ,128.76
+ ,107.94
+ ,102.94
+ ,117.36
+ ,119.49
+ ,128.76
+ ,110.30
+ ,103.07
+ ,117.82
+ ,119.59
+ ,128.76
+ ,110.30
+ ,103.04
+ ,117.88
+ ,120.12
+ ,128.76
+ ,110.30
+ ,103.06
+ ,118.24
+ ,120.14
+ ,128.76
+ ,110.30
+ ,103.05
+ ,118.50
+ ,120.14
+ ,128.76
+ ,110.30
+ ,102.95
+ ,118.80
+ ,120.14
+ ,132.63
+ ,110.30
+ ,102.95
+ ,119.76
+ ,120.14
+ ,132.63
+ ,110.30
+ ,103.05
+ ,120.09)
+ ,dim=c(5
+ ,58)
+ ,dimnames=list(c('bios'
+ ,'schouwburg'
+ ,'eedagsacttractie'
+ ,'huurDVD'
+ ,'vrijetijdsbesteding')
+ ,1:58))
> y <- array(NA,dim=c(5,58),dimnames=list(c('bios','schouwburg','eedagsacttractie','huurDVD','vrijetijdsbesteding'),1:58))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '5'
> #'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
> 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
vrijetijdsbesteding bios schouwburg eedagsacttractie huurDVD M1 M2 M3 M4
1 101.76 101.82 107.34 93.63 99.85 1 0 0 0
2 102.37 101.68 107.34 93.63 99.91 0 1 0 0
3 102.38 101.68 107.34 93.63 99.87 0 0 1 0
4 102.86 102.45 107.34 96.13 99.86 0 0 0 1
5 102.87 102.45 107.34 96.13 100.10 0 0 0 0
6 102.92 102.45 107.34 96.13 100.10 0 0 0 0
7 102.95 102.45 107.34 96.13 100.12 0 0 0 0
8 103.02 102.45 107.34 96.13 99.95 0 0 0 0
9 104.08 102.45 112.60 96.13 99.94 0 0 0 0
10 104.16 102.52 112.60 96.13 100.18 0 0 0 0
11 104.24 102.52 112.60 96.13 100.31 0 0 0 0
12 104.33 102.85 112.60 96.13 100.65 0 0 0 0
13 104.73 102.85 112.61 96.13 100.65 1 0 0 0
14 104.86 102.85 112.61 96.13 100.69 0 1 0 0
15 105.03 103.25 112.61 96.13 101.26 0 0 1 0
16 105.62 103.25 112.61 98.73 101.26 0 0 0 1
17 105.63 103.25 112.61 98.73 101.38 0 0 0 0
18 105.63 103.25 112.61 98.73 101.38 0 0 0 0
19 105.94 104.45 112.61 98.73 101.38 0 0 0 0
20 106.61 104.45 112.61 98.73 101.44 0 0 0 0
21 107.69 104.45 118.65 98.73 101.40 0 0 0 0
22 107.78 104.80 118.65 98.73 101.40 0 0 0 0
23 107.93 104.80 118.65 98.73 100.58 0 0 0 0
24 108.48 105.29 118.65 98.73 100.58 0 0 0 0
25 108.14 105.29 114.29 98.73 100.58 1 0 0 0
26 108.48 105.29 114.29 98.73 100.59 0 1 0 0
27 108.48 105.29 114.29 98.73 100.81 0 0 1 0
28 108.89 106.04 114.29 101.67 100.75 0 0 0 1
29 108.93 105.94 114.29 101.67 100.75 0 0 0 0
30 109.21 105.94 114.29 101.67 100.96 0 0 0 0
31 109.47 105.94 114.29 101.67 101.31 0 0 0 0
32 109.80 106.28 114.29 101.67 101.64 0 0 0 0
33 111.73 106.48 123.33 101.67 101.46 0 0 0 0
34 111.85 107.19 123.33 101.67 101.73 0 0 0 0
35 112.12 108.14 123.33 101.67 101.73 0 0 0 0
36 112.15 108.22 123.33 101.67 101.64 0 0 0 0
37 112.17 108.22 123.33 101.67 101.77 1 0 0 0
38 112.67 108.61 123.33 101.67 101.74 0 1 0 0
39 112.80 108.61 123.33 101.67 101.89 0 0 1 0
40 113.44 108.61 123.33 107.94 101.89 0 0 0 1
41 113.53 108.61 123.33 107.94 101.93 0 0 0 0
42 114.53 109.06 123.33 107.94 101.93 0 0 0 0
43 114.51 109.06 123.33 107.94 102.32 0 0 0 0
44 115.05 112.93 123.33 107.94 102.41 0 0 0 0
45 116.67 115.84 129.03 107.94 103.58 0 0 0 0
46 117.07 118.57 128.76 107.94 104.12 0 0 0 0
47 116.92 118.57 128.76 107.94 104.10 0 0 0 0
48 117.00 118.86 128.76 107.94 104.15 0 0 0 0
49 117.02 118.98 128.76 107.94 104.15 1 0 0 0
50 117.35 119.27 128.76 107.94 104.16 0 1 0 0
51 117.36 119.39 128.76 107.94 102.94 0 0 1 0
52 117.82 119.49 128.76 110.30 103.07 0 0 0 1
53 117.88 119.59 128.76 110.30 103.04 0 0 0 0
54 118.24 120.12 128.76 110.30 103.06 0 0 0 0
55 118.50 120.14 128.76 110.30 103.05 0 0 0 0
56 118.80 120.14 128.76 110.30 102.95 0 0 0 0
57 119.76 120.14 132.63 110.30 102.95 0 0 0 0
58 120.09 120.14 132.63 110.30 103.05 0 0 0 0
M5 M6 M7 M8 M9 M10 M11 t
1 0 0 0 0 0 0 0 1
2 0 0 0 0 0 0 0 2
3 0 0 0 0 0 0 0 3
4 0 0 0 0 0 0 0 4
5 1 0 0 0 0 0 0 5
6 0 1 0 0 0 0 0 6
7 0 0 1 0 0 0 0 7
8 0 0 0 1 0 0 0 8
9 0 0 0 0 1 0 0 9
10 0 0 0 0 0 1 0 10
11 0 0 0 0 0 0 1 11
12 0 0 0 0 0 0 0 12
13 0 0 0 0 0 0 0 13
14 0 0 0 0 0 0 0 14
15 0 0 0 0 0 0 0 15
16 0 0 0 0 0 0 0 16
17 1 0 0 0 0 0 0 17
18 0 1 0 0 0 0 0 18
19 0 0 1 0 0 0 0 19
20 0 0 0 1 0 0 0 20
21 0 0 0 0 1 0 0 21
22 0 0 0 0 0 1 0 22
23 0 0 0 0 0 0 1 23
24 0 0 0 0 0 0 0 24
25 0 0 0 0 0 0 0 25
26 0 0 0 0 0 0 0 26
27 0 0 0 0 0 0 0 27
28 0 0 0 0 0 0 0 28
29 1 0 0 0 0 0 0 29
30 0 1 0 0 0 0 0 30
31 0 0 1 0 0 0 0 31
32 0 0 0 1 0 0 0 32
33 0 0 0 0 1 0 0 33
34 0 0 0 0 0 1 0 34
35 0 0 0 0 0 0 1 35
36 0 0 0 0 0 0 0 36
37 0 0 0 0 0 0 0 37
38 0 0 0 0 0 0 0 38
39 0 0 0 0 0 0 0 39
40 0 0 0 0 0 0 0 40
41 1 0 0 0 0 0 0 41
42 0 1 0 0 0 0 0 42
43 0 0 1 0 0 0 0 43
44 0 0 0 1 0 0 0 44
45 0 0 0 0 1 0 0 45
46 0 0 0 0 0 1 0 46
47 0 0 0 0 0 0 1 47
48 0 0 0 0 0 0 0 48
49 0 0 0 0 0 0 0 49
50 0 0 0 0 0 0 0 50
51 0 0 0 0 0 0 0 51
52 0 0 0 0 0 0 0 52
53 1 0 0 0 0 0 0 53
54 0 1 0 0 0 0 0 54
55 0 0 1 0 0 0 0 55
56 0 0 0 1 0 0 0 56
57 0 0 0 0 1 0 0 57
58 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) bios schouwburg eedagsacttractie
65.570132 0.093467 0.112235 0.249401
huurDVD M1 M2 M3
-0.090896 0.013883 0.213469 0.087975
M4 M5 M6 M7
-0.430674 -0.555903 -0.405997 -0.421124
M8 M9 M10 M11
-0.287961 0.155647 0.140502 0.007445
t
0.173956
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.4334 -0.1810 -0.0073 0.1746 0.5038
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 65.570132 7.813237 8.392 1.93e-10 ***
bios 0.093467 0.020909 4.470 6.05e-05 ***
schouwburg 0.112235 0.035874 3.129 0.00323 **
eedagsacttractie 0.249401 0.053145 4.693 3.00e-05 ***
huurDVD -0.090896 0.090236 -1.007 0.31970
M1 0.013883 0.203923 0.068 0.94605
M2 0.213469 0.206838 1.032 0.30809
M3 0.087975 0.210591 0.418 0.67831
M4 -0.430674 0.270129 -1.594 0.11854
M5 -0.555903 0.269783 -2.061 0.04573 *
M6 -0.405997 0.269908 -1.504 0.14019
M7 -0.421124 0.271415 -1.552 0.12845
M8 -0.287961 0.272373 -1.057 0.29660
M9 0.155647 0.205308 0.758 0.45272
M10 0.140502 0.199681 0.704 0.48564
M11 0.007445 0.208953 0.036 0.97175
t 0.173956 0.015756 11.041 7.42e-14 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2943 on 41 degrees of freedom
Multiple R-squared: 0.998, Adjusted R-squared: 0.9972
F-statistic: 1276 on 16 and 41 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.7783702 0.4432597 0.2216298
[2,] 0.6552492 0.6895016 0.3447508
[3,] 0.6596850 0.6806299 0.3403150
[4,] 0.7235367 0.5529266 0.2764633
[5,] 0.7307035 0.5385929 0.2692965
[6,] 0.6851766 0.6296467 0.3148234
[7,] 0.5964204 0.8071591 0.4035796
[8,] 0.4925392 0.9850784 0.5074608
[9,] 0.7843621 0.4312758 0.2156379
[10,] 0.8103585 0.3792830 0.1896415
[11,] 0.7552230 0.4895541 0.2447770
[12,] 0.8459621 0.3080757 0.1540379
[13,] 0.7902278 0.4195443 0.2097722
[14,] 0.7857011 0.4285977 0.2142989
[15,] 0.8524912 0.2950176 0.1475088
[16,] 0.7614123 0.4771755 0.2385877
[17,] 0.6531771 0.6936458 0.3468229
[18,] 0.5701943 0.8596113 0.4298057
[19,] 0.4422444 0.8844888 0.5577556
> postscript(file="/var/www/rcomp/tmp/1raut1292586958.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/www/rcomp/tmp/21kuv1292586958.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/www/rcomp/tmp/31kuv1292586958.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/www/rcomp/tmp/41kuv1292586958.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/www/rcomp/tmp/5uttg1292586958.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 = 58
Frequency = 1
1 2 3 4 5 6
0.162532799 0.417530157 0.375432189 0.503746382 0.486835052 0.212973329
7 8 9 10 11 12
0.085962776 -0.166608127 -0.315435725 -0.378973816 -0.328055923 -0.404506256
13 14 15 16 17 18
-0.193467126 -0.433373019 -0.297411351 -0.011158893 -0.038977695 -0.362839419
19 20 21 22 23 24
-0.323827929 0.044507157 -0.174590362 -0.276114074 -0.241547004 0.096143485
25 26 27 28 29 30
0.057648178 0.025015418 -0.003449694 -0.057547182 -0.056926787 -0.081700434
31 32 33 34 35 36
0.051284563 0.072382782 0.335162490 0.254532576 0.394840672 0.242671905
37 38 39 40 41 42
0.086649811 0.173929211 0.269101407 -0.309946100 -0.265036550 0.369041709
43 44 45 46 47 48
0.225662530 0.105008338 0.302066182 0.367478703 0.174762255 0.065690866
49 50 51 52 53 54
-0.113363662 -0.183101767 -0.343672552 -0.125094207 -0.125894020 -0.137475185
55 56 57 58
-0.039081940 -0.055290151 -0.147202584 0.033076610
> postscript(file="/var/www/rcomp/tmp/6uttg1292586958.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 0.162532799 NA
1 0.417530157 0.162532799
2 0.375432189 0.417530157
3 0.503746382 0.375432189
4 0.486835052 0.503746382
5 0.212973329 0.486835052
6 0.085962776 0.212973329
7 -0.166608127 0.085962776
8 -0.315435725 -0.166608127
9 -0.378973816 -0.315435725
10 -0.328055923 -0.378973816
11 -0.404506256 -0.328055923
12 -0.193467126 -0.404506256
13 -0.433373019 -0.193467126
14 -0.297411351 -0.433373019
15 -0.011158893 -0.297411351
16 -0.038977695 -0.011158893
17 -0.362839419 -0.038977695
18 -0.323827929 -0.362839419
19 0.044507157 -0.323827929
20 -0.174590362 0.044507157
21 -0.276114074 -0.174590362
22 -0.241547004 -0.276114074
23 0.096143485 -0.241547004
24 0.057648178 0.096143485
25 0.025015418 0.057648178
26 -0.003449694 0.025015418
27 -0.057547182 -0.003449694
28 -0.056926787 -0.057547182
29 -0.081700434 -0.056926787
30 0.051284563 -0.081700434
31 0.072382782 0.051284563
32 0.335162490 0.072382782
33 0.254532576 0.335162490
34 0.394840672 0.254532576
35 0.242671905 0.394840672
36 0.086649811 0.242671905
37 0.173929211 0.086649811
38 0.269101407 0.173929211
39 -0.309946100 0.269101407
40 -0.265036550 -0.309946100
41 0.369041709 -0.265036550
42 0.225662530 0.369041709
43 0.105008338 0.225662530
44 0.302066182 0.105008338
45 0.367478703 0.302066182
46 0.174762255 0.367478703
47 0.065690866 0.174762255
48 -0.113363662 0.065690866
49 -0.183101767 -0.113363662
50 -0.343672552 -0.183101767
51 -0.125094207 -0.343672552
52 -0.125894020 -0.125094207
53 -0.137475185 -0.125894020
54 -0.039081940 -0.137475185
55 -0.055290151 -0.039081940
56 -0.147202584 -0.055290151
57 0.033076610 -0.147202584
58 NA 0.033076610
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.417530157 0.162532799
[2,] 0.375432189 0.417530157
[3,] 0.503746382 0.375432189
[4,] 0.486835052 0.503746382
[5,] 0.212973329 0.486835052
[6,] 0.085962776 0.212973329
[7,] -0.166608127 0.085962776
[8,] -0.315435725 -0.166608127
[9,] -0.378973816 -0.315435725
[10,] -0.328055923 -0.378973816
[11,] -0.404506256 -0.328055923
[12,] -0.193467126 -0.404506256
[13,] -0.433373019 -0.193467126
[14,] -0.297411351 -0.433373019
[15,] -0.011158893 -0.297411351
[16,] -0.038977695 -0.011158893
[17,] -0.362839419 -0.038977695
[18,] -0.323827929 -0.362839419
[19,] 0.044507157 -0.323827929
[20,] -0.174590362 0.044507157
[21,] -0.276114074 -0.174590362
[22,] -0.241547004 -0.276114074
[23,] 0.096143485 -0.241547004
[24,] 0.057648178 0.096143485
[25,] 0.025015418 0.057648178
[26,] -0.003449694 0.025015418
[27,] -0.057547182 -0.003449694
[28,] -0.056926787 -0.057547182
[29,] -0.081700434 -0.056926787
[30,] 0.051284563 -0.081700434
[31,] 0.072382782 0.051284563
[32,] 0.335162490 0.072382782
[33,] 0.254532576 0.335162490
[34,] 0.394840672 0.254532576
[35,] 0.242671905 0.394840672
[36,] 0.086649811 0.242671905
[37,] 0.173929211 0.086649811
[38,] 0.269101407 0.173929211
[39,] -0.309946100 0.269101407
[40,] -0.265036550 -0.309946100
[41,] 0.369041709 -0.265036550
[42,] 0.225662530 0.369041709
[43,] 0.105008338 0.225662530
[44,] 0.302066182 0.105008338
[45,] 0.367478703 0.302066182
[46,] 0.174762255 0.367478703
[47,] 0.065690866 0.174762255
[48,] -0.113363662 0.065690866
[49,] -0.183101767 -0.113363662
[50,] -0.343672552 -0.183101767
[51,] -0.125094207 -0.343672552
[52,] -0.125894020 -0.125094207
[53,] -0.137475185 -0.125894020
[54,] -0.039081940 -0.137475185
[55,] -0.055290151 -0.039081940
[56,] -0.147202584 -0.055290151
[57,] 0.033076610 -0.147202584
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.417530157 0.162532799
2 0.375432189 0.417530157
3 0.503746382 0.375432189
4 0.486835052 0.503746382
5 0.212973329 0.486835052
6 0.085962776 0.212973329
7 -0.166608127 0.085962776
8 -0.315435725 -0.166608127
9 -0.378973816 -0.315435725
10 -0.328055923 -0.378973816
11 -0.404506256 -0.328055923
12 -0.193467126 -0.404506256
13 -0.433373019 -0.193467126
14 -0.297411351 -0.433373019
15 -0.011158893 -0.297411351
16 -0.038977695 -0.011158893
17 -0.362839419 -0.038977695
18 -0.323827929 -0.362839419
19 0.044507157 -0.323827929
20 -0.174590362 0.044507157
21 -0.276114074 -0.174590362
22 -0.241547004 -0.276114074
23 0.096143485 -0.241547004
24 0.057648178 0.096143485
25 0.025015418 0.057648178
26 -0.003449694 0.025015418
27 -0.057547182 -0.003449694
28 -0.056926787 -0.057547182
29 -0.081700434 -0.056926787
30 0.051284563 -0.081700434
31 0.072382782 0.051284563
32 0.335162490 0.072382782
33 0.254532576 0.335162490
34 0.394840672 0.254532576
35 0.242671905 0.394840672
36 0.086649811 0.242671905
37 0.173929211 0.086649811
38 0.269101407 0.173929211
39 -0.309946100 0.269101407
40 -0.265036550 -0.309946100
41 0.369041709 -0.265036550
42 0.225662530 0.369041709
43 0.105008338 0.225662530
44 0.302066182 0.105008338
45 0.367478703 0.302066182
46 0.174762255 0.367478703
47 0.065690866 0.174762255
48 -0.113363662 0.065690866
49 -0.183101767 -0.113363662
50 -0.343672552 -0.183101767
51 -0.125094207 -0.343672552
52 -0.125894020 -0.125094207
53 -0.137475185 -0.125894020
54 -0.039081940 -0.137475185
55 -0.055290151 -0.039081940
56 -0.147202584 -0.055290151
57 0.033076610 -0.147202584
> 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/rcomp/tmp/7n2a11292586958.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/www/rcomp/tmp/8n2a11292586958.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/www/rcomp/tmp/9ftrm1292586958.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/www/rcomp/tmp/10ftrm1292586958.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11jcqa1292586958.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/rcomp/tmp/124uoy1292586958.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/rcomp/tmp/13yzsg1292586958.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/rcomp/tmp/144n3v1292586958.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/rcomp/tmp/1575jj1292586958.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/rcomp/tmp/163xhr1292586958.tab")
+ }
>
> try(system("convert tmp/1raut1292586958.ps tmp/1raut1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/21kuv1292586958.ps tmp/21kuv1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/31kuv1292586958.ps tmp/31kuv1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/41kuv1292586958.ps tmp/41kuv1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/5uttg1292586958.ps tmp/5uttg1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/6uttg1292586958.ps tmp/6uttg1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/7n2a11292586958.ps tmp/7n2a11292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/8n2a11292586958.ps tmp/8n2a11292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/9ftrm1292586958.ps tmp/9ftrm1292586958.png",intern=TRUE))
character(0)
> try(system("convert tmp/10ftrm1292586958.ps tmp/10ftrm1292586958.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.150 1.530 4.666