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(16224.2
+ ,14931.4
+ ,17318.8
+ ,16913
+ ,17665.9
+ ,13132.1
+ ,15469.6
+ ,13333.7
+ ,16224.2
+ ,17318.8
+ ,16913
+ ,17665.9
+ ,16557.5
+ ,14711.2
+ ,15469.6
+ ,16224.2
+ ,17318.8
+ ,16913
+ ,19414.8
+ ,17197.3
+ ,16557.5
+ ,15469.6
+ ,16224.2
+ ,17318.8
+ ,17335
+ ,14985.2
+ ,19414.8
+ ,16557.5
+ ,15469.6
+ ,16224.2
+ ,16525.2
+ ,14734.4
+ ,17335
+ ,19414.8
+ ,16557.5
+ ,15469.6
+ ,18160.4
+ ,15937.8
+ ,16525.2
+ ,17335
+ ,19414.8
+ ,16557.5
+ ,15553.8
+ ,13028.1
+ ,18160.4
+ ,16525.2
+ ,17335
+ ,19414.8
+ ,15262.2
+ ,13836.8
+ ,15553.8
+ ,18160.4
+ ,16525.2
+ ,17335
+ ,18581
+ ,16677.5
+ ,15262.2
+ ,15553.8
+ ,18160.4
+ ,16525.2
+ ,17564.1
+ ,15130
+ ,18581
+ ,15262.2
+ ,15553.8
+ ,18160.4
+ ,18948.6
+ ,17504
+ ,17564.1
+ ,18581
+ ,15262.2
+ ,15553.8
+ ,17187.8
+ ,16979.9
+ ,18948.6
+ ,17564.1
+ ,18581
+ ,15262.2
+ ,17564.8
+ ,16012.5
+ ,17187.8
+ ,18948.6
+ ,17564.1
+ ,18581
+ ,17668.4
+ ,16247.7
+ ,17564.8
+ ,17187.8
+ ,18948.6
+ ,17564.1
+ ,20811.7
+ ,19268.2
+ ,17668.4
+ ,17564.8
+ ,17187.8
+ ,18948.6
+ ,17257.8
+ ,15533
+ ,20811.7
+ ,17668.4
+ ,17564.8
+ ,17187.8
+ ,18984.2
+ ,16803.3
+ ,17257.8
+ ,20811.7
+ ,17668.4
+ ,17564.8
+ ,20532.6
+ ,17396.1
+ ,18984.2
+ ,17257.8
+ ,20811.7
+ ,17668.4
+ ,17082.3
+ ,15155.4
+ ,20532.6
+ ,18984.2
+ ,17257.8
+ ,20811.7
+ ,16894.9
+ ,15692.4
+ ,17082.3
+ ,20532.6
+ ,18984.2
+ ,17257.8
+ ,20274.9
+ ,18063.7
+ ,16894.9
+ ,17082.3
+ ,20532.6
+ ,18984.2
+ ,20078.6
+ ,17568.6
+ ,20274.9
+ ,16894.9
+ ,17082.3
+ ,20532.6
+ ,19900.9
+ ,18154.3
+ ,20078.6
+ ,20274.9
+ ,16894.9
+ ,17082.3
+ ,17012.2
+ ,15467.4
+ ,19900.9
+ ,20078.6
+ ,20274.9
+ ,16894.9
+ ,19642.9
+ ,16956.1
+ ,17012.2
+ ,19900.9
+ ,20078.6
+ ,20274.9
+ ,19024
+ ,16854
+ ,19642.9
+ ,17012.2
+ ,19900.9
+ ,20078.6
+ ,21691
+ ,19396.4
+ ,19024
+ ,19642.9
+ ,17012.2
+ ,19900.9
+ ,18835.9
+ ,16457.6
+ ,21691
+ ,19024
+ ,19642.9
+ ,17012.2
+ ,19873.4
+ ,17284.5
+ ,18835.9
+ ,21691
+ ,19024
+ ,19642.9
+ ,21468.2
+ ,18395.3
+ ,19873.4
+ ,18835.9
+ ,21691
+ ,19024
+ ,19406.8
+ ,16938.7
+ ,21468.2
+ ,19873.4
+ ,18835.9
+ ,21691
+ ,18385.3
+ ,16414.3
+ ,19406.8
+ ,21468.2
+ ,19873.4
+ ,18835.9
+ ,20739.3
+ ,18173.4
+ ,18385.3
+ ,19406.8
+ ,21468.2
+ ,19873.4
+ ,22268.3
+ ,19919.7
+ ,20739.3
+ ,18385.3
+ ,19406.8
+ ,21468.2
+ ,21569
+ ,19623.8
+ ,22268.3
+ ,20739.3
+ ,18385.3
+ ,19406.8
+ ,17514.8
+ ,17228.1
+ ,21569
+ ,22268.3
+ ,20739.3
+ ,18385.3
+ ,21124.7
+ ,18730.3
+ ,17514.8
+ ,21569
+ ,22268.3
+ ,20739.3
+ ,21251
+ ,19039.1
+ ,21124.7
+ ,17514.8
+ ,21569
+ ,22268.3
+ ,21393
+ ,19413.3
+ ,21251
+ ,21124.7
+ ,17514.8
+ ,21569
+ ,22145.2
+ ,20013.6
+ ,21393
+ ,21251
+ ,21124.7
+ ,17514.8
+ ,20310.5
+ ,17917.2
+ ,22145.2
+ ,21393
+ ,21251
+ ,21124.7
+ ,23466.9
+ ,21270.3
+ ,20310.5
+ ,22145.2
+ ,21393
+ ,21251
+ ,21264.6
+ ,18766.1
+ ,23466.9
+ ,20310.5
+ ,22145.2
+ ,21393
+ ,18388.1
+ ,16790.8
+ ,21264.6
+ ,23466.9
+ ,20310.5
+ ,22145.2
+ ,22635.4
+ ,19960.6
+ ,18388.1
+ ,21264.6
+ ,23466.9
+ ,20310.5
+ ,22014.3
+ ,19586.7
+ ,22635.4
+ ,18388.1
+ ,21264.6
+ ,23466.9
+ ,18422.7
+ ,17179
+ ,22014.3
+ ,22635.4
+ ,18388.1
+ ,21264.6
+ ,16120.2
+ ,14964.9
+ ,18422.7
+ ,22014.3
+ ,22635.4
+ ,18388.1
+ ,16037.7
+ ,13918.5
+ ,16120.2
+ ,18422.7
+ ,22014.3
+ ,22635.4
+ ,16410.7
+ ,14401.3
+ ,16037.7
+ ,16120.2
+ ,18422.7
+ ,22014.3
+ ,17749.8
+ ,15994.6
+ ,16410.7
+ ,16037.7
+ ,16120.2
+ ,18422.7
+ ,16349.8
+ ,14521.1
+ ,17749.8
+ ,16410.7
+ ,16037.7
+ ,16120.2
+ ,15662.3
+ ,13746.5
+ ,16349.8
+ ,17749.8
+ ,16410.7
+ ,16037.7
+ ,17782.3
+ ,15956
+ ,15662.3
+ ,16349.8
+ ,17749.8
+ ,16410.7
+ ,16398.9
+ ,14332.2
+ ,17782.3
+ ,15662.3
+ ,16349.8
+ ,17749.8)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('U'
+ ,'I'
+ ,'m1'
+ ,'m2'
+ ,'m3'
+ ,'m4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('U','I','m1','m2','m3','m4'),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
U I m1 m2 m3 m4 M1 M2 M3 M4 M5 M6 M7 M8 M9
1 16224.2 14931.4 17318.8 16913.0 17665.9 13132.1 1 0 0 0 0 0 0 0 0
2 15469.6 13333.7 16224.2 17318.8 16913.0 17665.9 0 1 0 0 0 0 0 0 0
3 16557.5 14711.2 15469.6 16224.2 17318.8 16913.0 0 0 1 0 0 0 0 0 0
4 19414.8 17197.3 16557.5 15469.6 16224.2 17318.8 0 0 0 1 0 0 0 0 0
5 17335.0 14985.2 19414.8 16557.5 15469.6 16224.2 0 0 0 0 1 0 0 0 0
6 16525.2 14734.4 17335.0 19414.8 16557.5 15469.6 0 0 0 0 0 1 0 0 0
7 18160.4 15937.8 16525.2 17335.0 19414.8 16557.5 0 0 0 0 0 0 1 0 0
8 15553.8 13028.1 18160.4 16525.2 17335.0 19414.8 0 0 0 0 0 0 0 1 0
9 15262.2 13836.8 15553.8 18160.4 16525.2 17335.0 0 0 0 0 0 0 0 0 1
10 18581.0 16677.5 15262.2 15553.8 18160.4 16525.2 0 0 0 0 0 0 0 0 0
11 17564.1 15130.0 18581.0 15262.2 15553.8 18160.4 0 0 0 0 0 0 0 0 0
12 18948.6 17504.0 17564.1 18581.0 15262.2 15553.8 0 0 0 0 0 0 0 0 0
13 17187.8 16979.9 18948.6 17564.1 18581.0 15262.2 1 0 0 0 0 0 0 0 0
14 17564.8 16012.5 17187.8 18948.6 17564.1 18581.0 0 1 0 0 0 0 0 0 0
15 17668.4 16247.7 17564.8 17187.8 18948.6 17564.1 0 0 1 0 0 0 0 0 0
16 20811.7 19268.2 17668.4 17564.8 17187.8 18948.6 0 0 0 1 0 0 0 0 0
17 17257.8 15533.0 20811.7 17668.4 17564.8 17187.8 0 0 0 0 1 0 0 0 0
18 18984.2 16803.3 17257.8 20811.7 17668.4 17564.8 0 0 0 0 0 1 0 0 0
19 20532.6 17396.1 18984.2 17257.8 20811.7 17668.4 0 0 0 0 0 0 1 0 0
20 17082.3 15155.4 20532.6 18984.2 17257.8 20811.7 0 0 0 0 0 0 0 1 0
21 16894.9 15692.4 17082.3 20532.6 18984.2 17257.8 0 0 0 0 0 0 0 0 1
22 20274.9 18063.7 16894.9 17082.3 20532.6 18984.2 0 0 0 0 0 0 0 0 0
23 20078.6 17568.6 20274.9 16894.9 17082.3 20532.6 0 0 0 0 0 0 0 0 0
24 19900.9 18154.3 20078.6 20274.9 16894.9 17082.3 0 0 0 0 0 0 0 0 0
25 17012.2 15467.4 19900.9 20078.6 20274.9 16894.9 1 0 0 0 0 0 0 0 0
26 19642.9 16956.1 17012.2 19900.9 20078.6 20274.9 0 1 0 0 0 0 0 0 0
27 19024.0 16854.0 19642.9 17012.2 19900.9 20078.6 0 0 1 0 0 0 0 0 0
28 21691.0 19396.4 19024.0 19642.9 17012.2 19900.9 0 0 0 1 0 0 0 0 0
29 18835.9 16457.6 21691.0 19024.0 19642.9 17012.2 0 0 0 0 1 0 0 0 0
30 19873.4 17284.5 18835.9 21691.0 19024.0 19642.9 0 0 0 0 0 1 0 0 0
31 21468.2 18395.3 19873.4 18835.9 21691.0 19024.0 0 0 0 0 0 0 1 0 0
32 19406.8 16938.7 21468.2 19873.4 18835.9 21691.0 0 0 0 0 0 0 0 1 0
33 18385.3 16414.3 19406.8 21468.2 19873.4 18835.9 0 0 0 0 0 0 0 0 1
34 20739.3 18173.4 18385.3 19406.8 21468.2 19873.4 0 0 0 0 0 0 0 0 0
35 22268.3 19919.7 20739.3 18385.3 19406.8 21468.2 0 0 0 0 0 0 0 0 0
36 21569.0 19623.8 22268.3 20739.3 18385.3 19406.8 0 0 0 0 0 0 0 0 0
37 17514.8 17228.1 21569.0 22268.3 20739.3 18385.3 1 0 0 0 0 0 0 0 0
38 21124.7 18730.3 17514.8 21569.0 22268.3 20739.3 0 1 0 0 0 0 0 0 0
39 21251.0 19039.1 21124.7 17514.8 21569.0 22268.3 0 0 1 0 0 0 0 0 0
40 21393.0 19413.3 21251.0 21124.7 17514.8 21569.0 0 0 0 1 0 0 0 0 0
41 22145.2 20013.6 21393.0 21251.0 21124.7 17514.8 0 0 0 0 1 0 0 0 0
42 20310.5 17917.2 22145.2 21393.0 21251.0 21124.7 0 0 0 0 0 1 0 0 0
43 23466.9 21270.3 20310.5 22145.2 21393.0 21251.0 0 0 0 0 0 0 1 0 0
44 21264.6 18766.1 23466.9 20310.5 22145.2 21393.0 0 0 0 0 0 0 0 1 0
45 18388.1 16790.8 21264.6 23466.9 20310.5 22145.2 0 0 0 0 0 0 0 0 1
46 22635.4 19960.6 18388.1 21264.6 23466.9 20310.5 0 0 0 0 0 0 0 0 0
47 22014.3 19586.7 22635.4 18388.1 21264.6 23466.9 0 0 0 0 0 0 0 0 0
48 18422.7 17179.0 22014.3 22635.4 18388.1 21264.6 0 0 0 0 0 0 0 0 0
49 16120.2 14964.9 18422.7 22014.3 22635.4 18388.1 1 0 0 0 0 0 0 0 0
50 16037.7 13918.5 16120.2 18422.7 22014.3 22635.4 0 1 0 0 0 0 0 0 0
51 16410.7 14401.3 16037.7 16120.2 18422.7 22014.3 0 0 1 0 0 0 0 0 0
52 17749.8 15994.6 16410.7 16037.7 16120.2 18422.7 0 0 0 1 0 0 0 0 0
53 16349.8 14521.1 17749.8 16410.7 16037.7 16120.2 0 0 0 0 1 0 0 0 0
54 15662.3 13746.5 16349.8 17749.8 16410.7 16037.7 0 0 0 0 0 1 0 0 0
55 17782.3 15956.0 15662.3 16349.8 17749.8 16410.7 0 0 0 0 0 0 1 0 0
56 16398.9 14332.2 17782.3 15662.3 16349.8 17749.8 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) I m1 m2 m3 m4
2.457e+02 9.552e-01 2.226e-02 -4.022e-02 1.469e-01 1.031e-02
M1 M2 M3 M4 M5 M6
-1.215e+03 9.223e+01 -1.691e+02 3.562e+02 2.181e+02 3.854e+02
M7 M8 M9 M10 M11 t
4.133e+02 3.278e+02 -3.660e+02 1.725e+02 5.031e+02 -6.292e+00
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-582.38 -244.02 59.72 186.15 576.49
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.457e+02 6.582e+02 0.373 0.71101
I 9.552e-01 5.498e-02 17.374 < 2e-16 ***
m1 2.226e-02 5.791e-02 0.384 0.70285
m2 -4.022e-02 5.562e-02 -0.723 0.47400
m3 1.469e-01 5.536e-02 2.654 0.01156 *
m4 1.031e-02 5.947e-02 0.173 0.86328
M1 -1.215e+03 3.564e+02 -3.410 0.00155 **
M2 9.223e+01 3.968e+02 0.232 0.81745
M3 -1.691e+02 3.885e+02 -0.435 0.66581
M4 3.562e+02 3.300e+02 1.079 0.28718
M5 2.181e+02 2.904e+02 0.751 0.45719
M6 3.854e+02 2.819e+02 1.367 0.17964
M7 4.133e+02 3.472e+02 1.190 0.24136
M8 3.278e+02 3.120e+02 1.050 0.30013
M9 -3.660e+02 3.280e+02 -1.116 0.27143
M10 1.725e+02 4.218e+02 0.409 0.68490
M11 5.031e+02 3.767e+02 1.336 0.18961
t -6.292e+00 4.060e+00 -1.550 0.12955
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 355.1 on 38 degrees of freedom
Multiple R-squared: 0.9814, Adjusted R-squared: 0.973
F-statistic: 117.8 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.9897339 0.020532171 0.010266086
[2,] 0.9969584 0.006083126 0.003041563
[3,] 0.9914336 0.017132818 0.008566409
[4,] 0.9900998 0.019800436 0.009900218
[5,] 0.9917052 0.016589610 0.008294805
[6,] 0.9938045 0.012390968 0.006195484
[7,] 0.9873914 0.025217151 0.012608575
[8,] 0.9779465 0.044107058 0.022053529
[9,] 0.9536425 0.092714962 0.046357481
[10,] 0.9091802 0.181639682 0.090819841
[11,] 0.9248827 0.150234520 0.075117260
[12,] 0.8699008 0.260198392 0.130099196
[13,] 0.8011487 0.397702545 0.198851272
[14,] 0.6705448 0.658910373 0.329455187
[15,] 0.5560508 0.887898445 0.443949223
> postscript(file="/var/www/html/rcomp/tmp/1ur1y1258579956.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/2r8ax1258579956.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/3drb21258579956.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/4jwvw1258579956.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/5c4yj1258579956.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
5.017303e+02 7.649361e+01 3.715487e+01 1.027980e+02 3.826588e+02
6 7 8 9 10
-3.394266e+02 -3.718939e+02 9.975556e+01 2.343709e-03 -2.570823e+02
11 12 13 14 15
1.603620e+02 1.245156e+01 -5.823799e+02 -3.725671e+02 -4.981398e+02
16 17 18 19 20
-5.017418e+02 -4.464664e+02 9.196432e+01 4.083236e+02 -2.851870e+02
21 22 23 24 25
-3.633393e+02 -1.605079e+02 1.999700e+02 1.756161e+02 5.764884e+02
26 27 28 29 30
5.350338e+02 1.346701e+02 3.999904e+02 5.541359e+01 3.766755e+02
31 32 33 34 35
3.655125e+02 1.854391e+02 3.519849e+02 1.883009e+02 -8.213257e+01
36 37 38 39 40
2.425639e+02 -5.598741e+02 1.270417e+02 6.955863e+01 8.033488e+01
41 42 43 44 45
-8.313091e+01 -1.431886e+02 -1.622727e+02 -1.368122e+02 1.135204e+01
46 47 48 49 50
2.292892e+02 -2.781994e+02 -4.306316e+02 6.403528e+01 -3.660021e+02
51 52 53 54 55
2.567562e+02 -8.138144e+01 9.152491e+01 1.397534e+01 -2.396695e+02
56
1.368045e+02
> postscript(file="/var/www/html/rcomp/tmp/6v59e1258579956.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 5.017303e+02 NA
1 7.649361e+01 5.017303e+02
2 3.715487e+01 7.649361e+01
3 1.027980e+02 3.715487e+01
4 3.826588e+02 1.027980e+02
5 -3.394266e+02 3.826588e+02
6 -3.718939e+02 -3.394266e+02
7 9.975556e+01 -3.718939e+02
8 2.343709e-03 9.975556e+01
9 -2.570823e+02 2.343709e-03
10 1.603620e+02 -2.570823e+02
11 1.245156e+01 1.603620e+02
12 -5.823799e+02 1.245156e+01
13 -3.725671e+02 -5.823799e+02
14 -4.981398e+02 -3.725671e+02
15 -5.017418e+02 -4.981398e+02
16 -4.464664e+02 -5.017418e+02
17 9.196432e+01 -4.464664e+02
18 4.083236e+02 9.196432e+01
19 -2.851870e+02 4.083236e+02
20 -3.633393e+02 -2.851870e+02
21 -1.605079e+02 -3.633393e+02
22 1.999700e+02 -1.605079e+02
23 1.756161e+02 1.999700e+02
24 5.764884e+02 1.756161e+02
25 5.350338e+02 5.764884e+02
26 1.346701e+02 5.350338e+02
27 3.999904e+02 1.346701e+02
28 5.541359e+01 3.999904e+02
29 3.766755e+02 5.541359e+01
30 3.655125e+02 3.766755e+02
31 1.854391e+02 3.655125e+02
32 3.519849e+02 1.854391e+02
33 1.883009e+02 3.519849e+02
34 -8.213257e+01 1.883009e+02
35 2.425639e+02 -8.213257e+01
36 -5.598741e+02 2.425639e+02
37 1.270417e+02 -5.598741e+02
38 6.955863e+01 1.270417e+02
39 8.033488e+01 6.955863e+01
40 -8.313091e+01 8.033488e+01
41 -1.431886e+02 -8.313091e+01
42 -1.622727e+02 -1.431886e+02
43 -1.368122e+02 -1.622727e+02
44 1.135204e+01 -1.368122e+02
45 2.292892e+02 1.135204e+01
46 -2.781994e+02 2.292892e+02
47 -4.306316e+02 -2.781994e+02
48 6.403528e+01 -4.306316e+02
49 -3.660021e+02 6.403528e+01
50 2.567562e+02 -3.660021e+02
51 -8.138144e+01 2.567562e+02
52 9.152491e+01 -8.138144e+01
53 1.397534e+01 9.152491e+01
54 -2.396695e+02 1.397534e+01
55 1.368045e+02 -2.396695e+02
56 NA 1.368045e+02
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 7.649361e+01 5.017303e+02
[2,] 3.715487e+01 7.649361e+01
[3,] 1.027980e+02 3.715487e+01
[4,] 3.826588e+02 1.027980e+02
[5,] -3.394266e+02 3.826588e+02
[6,] -3.718939e+02 -3.394266e+02
[7,] 9.975556e+01 -3.718939e+02
[8,] 2.343709e-03 9.975556e+01
[9,] -2.570823e+02 2.343709e-03
[10,] 1.603620e+02 -2.570823e+02
[11,] 1.245156e+01 1.603620e+02
[12,] -5.823799e+02 1.245156e+01
[13,] -3.725671e+02 -5.823799e+02
[14,] -4.981398e+02 -3.725671e+02
[15,] -5.017418e+02 -4.981398e+02
[16,] -4.464664e+02 -5.017418e+02
[17,] 9.196432e+01 -4.464664e+02
[18,] 4.083236e+02 9.196432e+01
[19,] -2.851870e+02 4.083236e+02
[20,] -3.633393e+02 -2.851870e+02
[21,] -1.605079e+02 -3.633393e+02
[22,] 1.999700e+02 -1.605079e+02
[23,] 1.756161e+02 1.999700e+02
[24,] 5.764884e+02 1.756161e+02
[25,] 5.350338e+02 5.764884e+02
[26,] 1.346701e+02 5.350338e+02
[27,] 3.999904e+02 1.346701e+02
[28,] 5.541359e+01 3.999904e+02
[29,] 3.766755e+02 5.541359e+01
[30,] 3.655125e+02 3.766755e+02
[31,] 1.854391e+02 3.655125e+02
[32,] 3.519849e+02 1.854391e+02
[33,] 1.883009e+02 3.519849e+02
[34,] -8.213257e+01 1.883009e+02
[35,] 2.425639e+02 -8.213257e+01
[36,] -5.598741e+02 2.425639e+02
[37,] 1.270417e+02 -5.598741e+02
[38,] 6.955863e+01 1.270417e+02
[39,] 8.033488e+01 6.955863e+01
[40,] -8.313091e+01 8.033488e+01
[41,] -1.431886e+02 -8.313091e+01
[42,] -1.622727e+02 -1.431886e+02
[43,] -1.368122e+02 -1.622727e+02
[44,] 1.135204e+01 -1.368122e+02
[45,] 2.292892e+02 1.135204e+01
[46,] -2.781994e+02 2.292892e+02
[47,] -4.306316e+02 -2.781994e+02
[48,] 6.403528e+01 -4.306316e+02
[49,] -3.660021e+02 6.403528e+01
[50,] 2.567562e+02 -3.660021e+02
[51,] -8.138144e+01 2.567562e+02
[52,] 9.152491e+01 -8.138144e+01
[53,] 1.397534e+01 9.152491e+01
[54,] -2.396695e+02 1.397534e+01
[55,] 1.368045e+02 -2.396695e+02
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 7.649361e+01 5.017303e+02
2 3.715487e+01 7.649361e+01
3 1.027980e+02 3.715487e+01
4 3.826588e+02 1.027980e+02
5 -3.394266e+02 3.826588e+02
6 -3.718939e+02 -3.394266e+02
7 9.975556e+01 -3.718939e+02
8 2.343709e-03 9.975556e+01
9 -2.570823e+02 2.343709e-03
10 1.603620e+02 -2.570823e+02
11 1.245156e+01 1.603620e+02
12 -5.823799e+02 1.245156e+01
13 -3.725671e+02 -5.823799e+02
14 -4.981398e+02 -3.725671e+02
15 -5.017418e+02 -4.981398e+02
16 -4.464664e+02 -5.017418e+02
17 9.196432e+01 -4.464664e+02
18 4.083236e+02 9.196432e+01
19 -2.851870e+02 4.083236e+02
20 -3.633393e+02 -2.851870e+02
21 -1.605079e+02 -3.633393e+02
22 1.999700e+02 -1.605079e+02
23 1.756161e+02 1.999700e+02
24 5.764884e+02 1.756161e+02
25 5.350338e+02 5.764884e+02
26 1.346701e+02 5.350338e+02
27 3.999904e+02 1.346701e+02
28 5.541359e+01 3.999904e+02
29 3.766755e+02 5.541359e+01
30 3.655125e+02 3.766755e+02
31 1.854391e+02 3.655125e+02
32 3.519849e+02 1.854391e+02
33 1.883009e+02 3.519849e+02
34 -8.213257e+01 1.883009e+02
35 2.425639e+02 -8.213257e+01
36 -5.598741e+02 2.425639e+02
37 1.270417e+02 -5.598741e+02
38 6.955863e+01 1.270417e+02
39 8.033488e+01 6.955863e+01
40 -8.313091e+01 8.033488e+01
41 -1.431886e+02 -8.313091e+01
42 -1.622727e+02 -1.431886e+02
43 -1.368122e+02 -1.622727e+02
44 1.135204e+01 -1.368122e+02
45 2.292892e+02 1.135204e+01
46 -2.781994e+02 2.292892e+02
47 -4.306316e+02 -2.781994e+02
48 6.403528e+01 -4.306316e+02
49 -3.660021e+02 6.403528e+01
50 2.567562e+02 -3.660021e+02
51 -8.138144e+01 2.567562e+02
52 9.152491e+01 -8.138144e+01
53 1.397534e+01 9.152491e+01
54 -2.396695e+02 1.397534e+01
55 1.368045e+02 -2.396695e+02
> 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/7gdku1258579956.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/80wfx1258579956.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/9er4v1258579956.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/1000r51258579956.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/11h7gl1258579956.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/122da91258579956.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/132i0x1258579956.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/14sq0b1258579956.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/15bqdx1258579956.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/16tms61258579956.tab")
+ }
>
> system("convert tmp/1ur1y1258579956.ps tmp/1ur1y1258579956.png")
> system("convert tmp/2r8ax1258579956.ps tmp/2r8ax1258579956.png")
> system("convert tmp/3drb21258579956.ps tmp/3drb21258579956.png")
> system("convert tmp/4jwvw1258579956.ps tmp/4jwvw1258579956.png")
> system("convert tmp/5c4yj1258579956.ps tmp/5c4yj1258579956.png")
> system("convert tmp/6v59e1258579956.ps tmp/6v59e1258579956.png")
> system("convert tmp/7gdku1258579956.ps tmp/7gdku1258579956.png")
> system("convert tmp/80wfx1258579956.ps tmp/80wfx1258579956.png")
> system("convert tmp/9er4v1258579956.ps tmp/9er4v1258579956.png")
> system("convert tmp/1000r51258579956.ps tmp/1000r51258579956.png")
>
>
> proc.time()
user system elapsed
2.370 1.608 3.757