R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(2863.36
+ ,99.9
+ ,2882.6
+ ,2767.63
+ ,2803.47
+ ,3030.29
+ ,2897.06
+ ,99.7
+ ,2863.36
+ ,2882.6
+ ,2767.63
+ ,2803.47
+ ,3012.61
+ ,99.5
+ ,2897.06
+ ,2863.36
+ ,2882.6
+ ,2767.63
+ ,3142.95
+ ,99.2
+ ,3012.61
+ ,2897.06
+ ,2863.36
+ ,2882.6
+ ,3032.93
+ ,99
+ ,3142.95
+ ,3012.61
+ ,2897.06
+ ,2863.36
+ ,3045.78
+ ,99
+ ,3032.93
+ ,3142.95
+ ,3012.61
+ ,2897.06
+ ,3110.52
+ ,99.3
+ ,3045.78
+ ,3032.93
+ ,3142.95
+ ,3012.61
+ ,3013.24
+ ,99.5
+ ,3110.52
+ ,3045.78
+ ,3032.93
+ ,3142.95
+ ,2987.1
+ ,99.7
+ ,3013.24
+ ,3110.52
+ ,3045.78
+ ,3032.93
+ ,2995.55
+ ,100
+ ,2987.1
+ ,3013.24
+ ,3110.52
+ ,3045.78
+ ,2833.18
+ ,100.4
+ ,2995.55
+ ,2987.1
+ ,3013.24
+ ,3110.52
+ ,2848.96
+ ,100.6
+ ,2833.18
+ ,2995.55
+ ,2987.1
+ ,3013.24
+ ,2794.83
+ ,100.7
+ ,2848.96
+ ,2833.18
+ ,2995.55
+ ,2987.1
+ ,2845.26
+ ,100.7
+ ,2794.83
+ ,2848.96
+ ,2833.18
+ ,2995.55
+ ,2915.02
+ ,100.6
+ ,2845.26
+ ,2794.83
+ ,2848.96
+ ,2833.18
+ ,2892.63
+ ,100.5
+ ,2915.02
+ ,2845.26
+ ,2794.83
+ ,2848.96
+ ,2604.42
+ ,100.6
+ ,2892.63
+ ,2915.02
+ ,2845.26
+ ,2794.83
+ ,2641.65
+ ,100.5
+ ,2604.42
+ ,2892.63
+ ,2915.02
+ ,2845.26
+ ,2659.81
+ ,100.4
+ ,2641.65
+ ,2604.42
+ ,2892.63
+ ,2915.02
+ ,2638.53
+ ,100.3
+ ,2659.81
+ ,2641.65
+ ,2604.42
+ ,2892.63
+ ,2720.25
+ ,100.4
+ ,2638.53
+ ,2659.81
+ ,2641.65
+ ,2604.42
+ ,2745.88
+ ,100.4
+ ,2720.25
+ ,2638.53
+ ,2659.81
+ ,2641.65
+ ,2735.7
+ ,100.4
+ ,2745.88
+ ,2720.25
+ ,2638.53
+ ,2659.81
+ ,2811.7
+ ,100.4
+ ,2735.7
+ ,2745.88
+ ,2720.25
+ ,2638.53
+ ,2799.43
+ ,100.4
+ ,2811.7
+ ,2735.7
+ ,2745.88
+ ,2720.25
+ ,2555.28
+ ,100.5
+ ,2799.43
+ ,2811.7
+ ,2735.7
+ ,2745.88
+ ,2304.98
+ ,100.6
+ ,2555.28
+ ,2799.43
+ ,2811.7
+ ,2735.7
+ ,2214.95
+ ,100.6
+ ,2304.98
+ ,2555.28
+ ,2799.43
+ ,2811.7
+ ,2065.81
+ ,100.5
+ ,2214.95
+ ,2304.98
+ ,2555.28
+ ,2799.43
+ ,1940.49
+ ,100.5
+ ,2065.81
+ ,2214.95
+ ,2304.98
+ ,2555.28
+ ,2042
+ ,100.7
+ ,1940.49
+ ,2065.81
+ ,2214.95
+ ,2304.98
+ ,1995.37
+ ,101.1
+ ,2042
+ ,1940.49
+ ,2065.81
+ ,2214.95
+ ,1946.81
+ ,101.5
+ ,1995.37
+ ,2042
+ ,1940.49
+ ,2065.81
+ ,1765.9
+ ,101.9
+ ,1946.81
+ ,1995.37
+ ,2042
+ ,1940.49
+ ,1635.25
+ ,102.1
+ ,1765.9
+ ,1946.81
+ ,1995.37
+ ,2042
+ ,1833.42
+ ,102.1
+ ,1635.25
+ ,1765.9
+ ,1946.81
+ ,1995.37
+ ,1910.43
+ ,102.1
+ ,1833.42
+ ,1635.25
+ ,1765.9
+ ,1946.81
+ ,1959.67
+ ,102.4
+ ,1910.43
+ ,1833.42
+ ,1635.25
+ ,1765.9
+ ,1969.6
+ ,102.8
+ ,1959.67
+ ,1910.43
+ ,1833.42
+ ,1635.25
+ ,2061.41
+ ,103.1
+ ,1969.6
+ ,1959.67
+ ,1910.43
+ ,1833.42
+ ,2093.48
+ ,103.1
+ ,2061.41
+ ,1969.6
+ ,1959.67
+ ,1910.43
+ ,2120.88
+ ,102.9
+ ,2093.48
+ ,2061.41
+ ,1969.6
+ ,1959.67
+ ,2174.56
+ ,102.4
+ ,2120.88
+ ,2093.48
+ ,2061.41
+ ,1969.6
+ ,2196.72
+ ,101.9
+ ,2174.56
+ ,2120.88
+ ,2093.48
+ ,2061.41
+ ,2350.44
+ ,101.3
+ ,2196.72
+ ,2174.56
+ ,2120.88
+ ,2093.48
+ ,2440.25
+ ,100.7
+ ,2350.44
+ ,2196.72
+ ,2174.56
+ ,2120.88
+ ,2408.64
+ ,100.6
+ ,2440.25
+ ,2350.44
+ ,2196.72
+ ,2174.56
+ ,2472.81
+ ,101
+ ,2408.64
+ ,2440.25
+ ,2350.44
+ ,2196.72
+ ,2407.6
+ ,101.5
+ ,2472.81
+ ,2408.64
+ ,2440.25
+ ,2350.44
+ ,2454.62
+ ,101.9
+ ,2407.6
+ ,2472.81
+ ,2408.64
+ ,2440.25
+ ,2448.05
+ ,102.1
+ ,2454.62
+ ,2407.6
+ ,2472.81
+ ,2408.64
+ ,2497.84
+ ,102.3
+ ,2448.05
+ ,2454.62
+ ,2407.6
+ ,2472.81
+ ,2645.64
+ ,102.5
+ ,2497.84
+ ,2448.05
+ ,2454.62
+ ,2407.6
+ ,2756.76
+ ,102.9
+ ,2645.64
+ ,2497.84
+ ,2448.05
+ ,2454.62
+ ,2849.27
+ ,103.6
+ ,2756.76
+ ,2645.64
+ ,2497.84
+ ,2448.05
+ ,2921.44
+ ,104.3
+ ,2849.27
+ ,2756.76
+ ,2645.64
+ ,2497.84)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Bel20'
+ ,'Gzhind'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Bel20','Gzhind','Y1','Y2','Y3','Y4'),1:56))
> 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 = '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
Bel20 Gzhind Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9
1 2863.36 99.9 2882.60 2767.63 2803.47 3030.29 1 0 0 0 0 0 0 0 0
2 2897.06 99.7 2863.36 2882.60 2767.63 2803.47 0 1 0 0 0 0 0 0 0
3 3012.61 99.5 2897.06 2863.36 2882.60 2767.63 0 0 1 0 0 0 0 0 0
4 3142.95 99.2 3012.61 2897.06 2863.36 2882.60 0 0 0 1 0 0 0 0 0
5 3032.93 99.0 3142.95 3012.61 2897.06 2863.36 0 0 0 0 1 0 0 0 0
6 3045.78 99.0 3032.93 3142.95 3012.61 2897.06 0 0 0 0 0 1 0 0 0
7 3110.52 99.3 3045.78 3032.93 3142.95 3012.61 0 0 0 0 0 0 1 0 0
8 3013.24 99.5 3110.52 3045.78 3032.93 3142.95 0 0 0 0 0 0 0 1 0
9 2987.10 99.7 3013.24 3110.52 3045.78 3032.93 0 0 0 0 0 0 0 0 1
10 2995.55 100.0 2987.10 3013.24 3110.52 3045.78 0 0 0 0 0 0 0 0 0
11 2833.18 100.4 2995.55 2987.10 3013.24 3110.52 0 0 0 0 0 0 0 0 0
12 2848.96 100.6 2833.18 2995.55 2987.10 3013.24 0 0 0 0 0 0 0 0 0
13 2794.83 100.7 2848.96 2833.18 2995.55 2987.10 1 0 0 0 0 0 0 0 0
14 2845.26 100.7 2794.83 2848.96 2833.18 2995.55 0 1 0 0 0 0 0 0 0
15 2915.02 100.6 2845.26 2794.83 2848.96 2833.18 0 0 1 0 0 0 0 0 0
16 2892.63 100.5 2915.02 2845.26 2794.83 2848.96 0 0 0 1 0 0 0 0 0
17 2604.42 100.6 2892.63 2915.02 2845.26 2794.83 0 0 0 0 1 0 0 0 0
18 2641.65 100.5 2604.42 2892.63 2915.02 2845.26 0 0 0 0 0 1 0 0 0
19 2659.81 100.4 2641.65 2604.42 2892.63 2915.02 0 0 0 0 0 0 1 0 0
20 2638.53 100.3 2659.81 2641.65 2604.42 2892.63 0 0 0 0 0 0 0 1 0
21 2720.25 100.4 2638.53 2659.81 2641.65 2604.42 0 0 0 0 0 0 0 0 1
22 2745.88 100.4 2720.25 2638.53 2659.81 2641.65 0 0 0 0 0 0 0 0 0
23 2735.70 100.4 2745.88 2720.25 2638.53 2659.81 0 0 0 0 0 0 0 0 0
24 2811.70 100.4 2735.70 2745.88 2720.25 2638.53 0 0 0 0 0 0 0 0 0
25 2799.43 100.4 2811.70 2735.70 2745.88 2720.25 1 0 0 0 0 0 0 0 0
26 2555.28 100.5 2799.43 2811.70 2735.70 2745.88 0 1 0 0 0 0 0 0 0
27 2304.98 100.6 2555.28 2799.43 2811.70 2735.70 0 0 1 0 0 0 0 0 0
28 2214.95 100.6 2304.98 2555.28 2799.43 2811.70 0 0 0 1 0 0 0 0 0
29 2065.81 100.5 2214.95 2304.98 2555.28 2799.43 0 0 0 0 1 0 0 0 0
30 1940.49 100.5 2065.81 2214.95 2304.98 2555.28 0 0 0 0 0 1 0 0 0
31 2042.00 100.7 1940.49 2065.81 2214.95 2304.98 0 0 0 0 0 0 1 0 0
32 1995.37 101.1 2042.00 1940.49 2065.81 2214.95 0 0 0 0 0 0 0 1 0
33 1946.81 101.5 1995.37 2042.00 1940.49 2065.81 0 0 0 0 0 0 0 0 1
34 1765.90 101.9 1946.81 1995.37 2042.00 1940.49 0 0 0 0 0 0 0 0 0
35 1635.25 102.1 1765.90 1946.81 1995.37 2042.00 0 0 0 0 0 0 0 0 0
36 1833.42 102.1 1635.25 1765.90 1946.81 1995.37 0 0 0 0 0 0 0 0 0
37 1910.43 102.1 1833.42 1635.25 1765.90 1946.81 1 0 0 0 0 0 0 0 0
38 1959.67 102.4 1910.43 1833.42 1635.25 1765.90 0 1 0 0 0 0 0 0 0
39 1969.60 102.8 1959.67 1910.43 1833.42 1635.25 0 0 1 0 0 0 0 0 0
40 2061.41 103.1 1969.60 1959.67 1910.43 1833.42 0 0 0 1 0 0 0 0 0
41 2093.48 103.1 2061.41 1969.60 1959.67 1910.43 0 0 0 0 1 0 0 0 0
42 2120.88 102.9 2093.48 2061.41 1969.60 1959.67 0 0 0 0 0 1 0 0 0
43 2174.56 102.4 2120.88 2093.48 2061.41 1969.60 0 0 0 0 0 0 1 0 0
44 2196.72 101.9 2174.56 2120.88 2093.48 2061.41 0 0 0 0 0 0 0 1 0
45 2350.44 101.3 2196.72 2174.56 2120.88 2093.48 0 0 0 0 0 0 0 0 1
46 2440.25 100.7 2350.44 2196.72 2174.56 2120.88 0 0 0 0 0 0 0 0 0
47 2408.64 100.6 2440.25 2350.44 2196.72 2174.56 0 0 0 0 0 0 0 0 0
48 2472.81 101.0 2408.64 2440.25 2350.44 2196.72 0 0 0 0 0 0 0 0 0
49 2407.60 101.5 2472.81 2408.64 2440.25 2350.44 1 0 0 0 0 0 0 0 0
50 2454.62 101.9 2407.60 2472.81 2408.64 2440.25 0 1 0 0 0 0 0 0 0
51 2448.05 102.1 2454.62 2407.60 2472.81 2408.64 0 0 1 0 0 0 0 0 0
52 2497.84 102.3 2448.05 2454.62 2407.60 2472.81 0 0 0 1 0 0 0 0 0
53 2645.64 102.5 2497.84 2448.05 2454.62 2407.60 0 0 0 0 1 0 0 0 0
54 2756.76 102.9 2645.64 2497.84 2448.05 2454.62 0 0 0 0 0 1 0 0 0
55 2849.27 103.6 2756.76 2645.64 2497.84 2448.05 0 0 0 0 0 0 1 0 0
56 2921.44 104.3 2849.27 2756.76 2645.64 2497.84 0 0 0 0 0 0 0 1 0
M10 M11 t
1 0 0 1
2 0 0 2
3 0 0 3
4 0 0 4
5 0 0 5
6 0 0 6
7 0 0 7
8 0 0 8
9 0 0 9
10 1 0 10
11 0 1 11
12 0 0 12
13 0 0 13
14 0 0 14
15 0 0 15
16 0 0 16
17 0 0 17
18 0 0 18
19 0 0 19
20 0 0 20
21 0 0 21
22 1 0 22
23 0 1 23
24 0 0 24
25 0 0 25
26 0 0 26
27 0 0 27
28 0 0 28
29 0 0 29
30 0 0 30
31 0 0 31
32 0 0 32
33 0 0 33
34 1 0 34
35 0 1 35
36 0 0 36
37 0 0 37
38 0 0 38
39 0 0 39
40 0 0 40
41 0 0 41
42 0 0 42
43 0 0 43
44 0 0 44
45 0 0 45
46 1 0 46
47 0 1 47
48 0 0 48
49 0 0 49
50 0 0 50
51 0 0 51
52 0 0 52
53 0 0 53
54 0 0 54
55 0 0 55
56 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Gzhind Y1 Y2 Y3 Y4
-1092.7827 12.5769 1.5492 -0.7637 0.3390 -0.1420
M1 M2 M3 M4 M5 M6
-199.1070 -101.4918 -148.3931 -88.7735 -218.6055 -65.3178
M7 M8 M9 M10 M11 t
-88.7274 -167.7029 -49.6420 -175.3684 -187.0152 -0.2821
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-234.35 -43.58 9.44 55.80 192.36
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1092.7827 2068.7665 -0.528 0.60041
Gzhind 12.5769 20.3265 0.619 0.53978
Y1 1.5492 0.1614 9.601 1.05e-11 ***
Y2 -0.7637 0.2918 -2.617 0.01266 *
Y3 0.3390 0.2819 1.203 0.23659
Y4 -0.1420 0.1626 -0.873 0.38802
M1 -199.1070 70.7667 -2.814 0.00772 **
M2 -101.4918 67.9878 -1.493 0.14375
M3 -148.3931 63.4163 -2.340 0.02464 *
M4 -88.7735 63.1221 -1.406 0.16774
M5 -218.6055 64.5544 -3.386 0.00166 **
M6 -65.3178 62.9305 -1.038 0.30586
M7 -88.7274 65.5335 -1.354 0.18376
M8 -167.7029 68.1141 -2.462 0.01846 *
M9 -49.6420 66.7099 -0.744 0.46136
M10 -175.3684 68.6570 -2.554 0.01477 *
M11 -187.0152 66.9196 -2.795 0.00810 **
t -0.2821 1.5130 -0.186 0.85308
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 91.23 on 38 degrees of freedom
Multiple R-squared: 0.9649, Adjusted R-squared: 0.9493
F-statistic: 61.51 on 17 and 38 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.23646085 0.472921696 0.763539152
[2,] 0.15951582 0.319031630 0.840484185
[3,] 0.09610975 0.192219498 0.903890251
[4,] 0.07145644 0.142912885 0.928543558
[5,] 0.15650559 0.313011172 0.843494414
[6,] 0.75316649 0.493667016 0.246833508
[7,] 0.84441348 0.311173030 0.155586515
[8,] 0.78419608 0.431607834 0.215803917
[9,] 0.69559464 0.608810727 0.304405363
[10,] 0.74834081 0.503318380 0.251659190
[11,] 0.95445022 0.091099551 0.045549776
[12,] 0.94979021 0.100419589 0.050209795
[13,] 0.99708593 0.005828147 0.002914074
[14,] 0.99475361 0.010492781 0.005246390
[15,] 0.98012544 0.039749111 0.019874556
> postscript(file="/var/www/html/rcomp/tmp/1pjg21258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2vqcj1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3zt9v1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4616d1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5ke8g1258566690.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 = 56
Frequency = 1
1 2 3 4 5 6
26.739399 63.171659 117.455154 61.798433 -43.433728 52.009871
7 8 9 10 11 12
4.964377 -50.255182 -16.516893 60.253949 -86.101882 -6.518593
13 14 15 16 17 18
-17.537821 87.712106 58.043053 -71.399670 -167.573196 130.829631
19 20 21 22 23 24
-86.342031 67.712150 23.687993 31.601789 65.843216 -40.269613
25 26 27 28 29 30
24.248098 -234.354251 -97.060304 -30.152684 -18.567391 -84.410079
31 32 33 34 35 36
113.512231 -74.084087 -74.386245 -146.902629 5.270828 90.800512
37 38 39 40 41 42
14.844498 13.609941 -37.510636 15.440553 37.214845 -61.821401
43 44 45 46 47 48
-25.832293 21.799843 67.215144 55.046891 14.987838 -44.012306
49 50 51 52 53 54
-48.294173 69.860545 -40.927267 24.313367 192.359470 -36.608023
55 56
-6.302284 34.827276
> postscript(file="/var/www/html/rcomp/tmp/6hdns1258566690.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 26.739399 NA
1 63.171659 26.739399
2 117.455154 63.171659
3 61.798433 117.455154
4 -43.433728 61.798433
5 52.009871 -43.433728
6 4.964377 52.009871
7 -50.255182 4.964377
8 -16.516893 -50.255182
9 60.253949 -16.516893
10 -86.101882 60.253949
11 -6.518593 -86.101882
12 -17.537821 -6.518593
13 87.712106 -17.537821
14 58.043053 87.712106
15 -71.399670 58.043053
16 -167.573196 -71.399670
17 130.829631 -167.573196
18 -86.342031 130.829631
19 67.712150 -86.342031
20 23.687993 67.712150
21 31.601789 23.687993
22 65.843216 31.601789
23 -40.269613 65.843216
24 24.248098 -40.269613
25 -234.354251 24.248098
26 -97.060304 -234.354251
27 -30.152684 -97.060304
28 -18.567391 -30.152684
29 -84.410079 -18.567391
30 113.512231 -84.410079
31 -74.084087 113.512231
32 -74.386245 -74.084087
33 -146.902629 -74.386245
34 5.270828 -146.902629
35 90.800512 5.270828
36 14.844498 90.800512
37 13.609941 14.844498
38 -37.510636 13.609941
39 15.440553 -37.510636
40 37.214845 15.440553
41 -61.821401 37.214845
42 -25.832293 -61.821401
43 21.799843 -25.832293
44 67.215144 21.799843
45 55.046891 67.215144
46 14.987838 55.046891
47 -44.012306 14.987838
48 -48.294173 -44.012306
49 69.860545 -48.294173
50 -40.927267 69.860545
51 24.313367 -40.927267
52 192.359470 24.313367
53 -36.608023 192.359470
54 -6.302284 -36.608023
55 34.827276 -6.302284
56 NA 34.827276
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 63.171659 26.739399
[2,] 117.455154 63.171659
[3,] 61.798433 117.455154
[4,] -43.433728 61.798433
[5,] 52.009871 -43.433728
[6,] 4.964377 52.009871
[7,] -50.255182 4.964377
[8,] -16.516893 -50.255182
[9,] 60.253949 -16.516893
[10,] -86.101882 60.253949
[11,] -6.518593 -86.101882
[12,] -17.537821 -6.518593
[13,] 87.712106 -17.537821
[14,] 58.043053 87.712106
[15,] -71.399670 58.043053
[16,] -167.573196 -71.399670
[17,] 130.829631 -167.573196
[18,] -86.342031 130.829631
[19,] 67.712150 -86.342031
[20,] 23.687993 67.712150
[21,] 31.601789 23.687993
[22,] 65.843216 31.601789
[23,] -40.269613 65.843216
[24,] 24.248098 -40.269613
[25,] -234.354251 24.248098
[26,] -97.060304 -234.354251
[27,] -30.152684 -97.060304
[28,] -18.567391 -30.152684
[29,] -84.410079 -18.567391
[30,] 113.512231 -84.410079
[31,] -74.084087 113.512231
[32,] -74.386245 -74.084087
[33,] -146.902629 -74.386245
[34,] 5.270828 -146.902629
[35,] 90.800512 5.270828
[36,] 14.844498 90.800512
[37,] 13.609941 14.844498
[38,] -37.510636 13.609941
[39,] 15.440553 -37.510636
[40,] 37.214845 15.440553
[41,] -61.821401 37.214845
[42,] -25.832293 -61.821401
[43,] 21.799843 -25.832293
[44,] 67.215144 21.799843
[45,] 55.046891 67.215144
[46,] 14.987838 55.046891
[47,] -44.012306 14.987838
[48,] -48.294173 -44.012306
[49,] 69.860545 -48.294173
[50,] -40.927267 69.860545
[51,] 24.313367 -40.927267
[52,] 192.359470 24.313367
[53,] -36.608023 192.359470
[54,] -6.302284 -36.608023
[55,] 34.827276 -6.302284
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 63.171659 26.739399
2 117.455154 63.171659
3 61.798433 117.455154
4 -43.433728 61.798433
5 52.009871 -43.433728
6 4.964377 52.009871
7 -50.255182 4.964377
8 -16.516893 -50.255182
9 60.253949 -16.516893
10 -86.101882 60.253949
11 -6.518593 -86.101882
12 -17.537821 -6.518593
13 87.712106 -17.537821
14 58.043053 87.712106
15 -71.399670 58.043053
16 -167.573196 -71.399670
17 130.829631 -167.573196
18 -86.342031 130.829631
19 67.712150 -86.342031
20 23.687993 67.712150
21 31.601789 23.687993
22 65.843216 31.601789
23 -40.269613 65.843216
24 24.248098 -40.269613
25 -234.354251 24.248098
26 -97.060304 -234.354251
27 -30.152684 -97.060304
28 -18.567391 -30.152684
29 -84.410079 -18.567391
30 113.512231 -84.410079
31 -74.084087 113.512231
32 -74.386245 -74.084087
33 -146.902629 -74.386245
34 5.270828 -146.902629
35 90.800512 5.270828
36 14.844498 90.800512
37 13.609941 14.844498
38 -37.510636 13.609941
39 15.440553 -37.510636
40 37.214845 15.440553
41 -61.821401 37.214845
42 -25.832293 -61.821401
43 21.799843 -25.832293
44 67.215144 21.799843
45 55.046891 67.215144
46 14.987838 55.046891
47 -44.012306 14.987838
48 -48.294173 -44.012306
49 69.860545 -48.294173
50 -40.927267 69.860545
51 24.313367 -40.927267
52 192.359470 24.313367
53 -36.608023 192.359470
54 -6.302284 -36.608023
55 34.827276 -6.302284
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7tvml1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/89byj1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/932su1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10vzqw1258566690.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11r8za1258566690.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/12xghw1258566690.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/13lhkw1258566690.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/14mrqw1258566690.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/15zj6l1258566690.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/16qy3h1258566690.tab")
+ }
>
> system("convert tmp/1pjg21258566690.ps tmp/1pjg21258566690.png")
> system("convert tmp/2vqcj1258566690.ps tmp/2vqcj1258566690.png")
> system("convert tmp/3zt9v1258566690.ps tmp/3zt9v1258566690.png")
> system("convert tmp/4616d1258566690.ps tmp/4616d1258566690.png")
> system("convert tmp/5ke8g1258566690.ps tmp/5ke8g1258566690.png")
> system("convert tmp/6hdns1258566690.ps tmp/6hdns1258566690.png")
> system("convert tmp/7tvml1258566690.ps tmp/7tvml1258566690.png")
> system("convert tmp/89byj1258566690.ps tmp/89byj1258566690.png")
> system("convert tmp/932su1258566690.ps tmp/932su1258566690.png")
> system("convert tmp/10vzqw1258566690.ps tmp/10vzqw1258566690.png")
>
>
> proc.time()
user system elapsed
2.379 1.587 2.991