R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(15107,0,15024,0,12083,0,15761,0,16943,0,15070,0,13660,0,14769,0,14725,0,15998,0,15371,0,14957,0,15470,0,15102,0,11704,0,16284,0,16727,0,14969,0,14861,0,14583,0,15306,0,17904,0,16379,0,15420,0,17871,0,15913,0,13867,0,17823,0,17872,0,17422,0,16705,0,15991,0,16584,0,19124,0,17839,0,17209,0,18587,0,16258,0,15142,1,19202,1,17747,1,19090,1,18040,1,17516,1,17752,1,21073,1,17170,1,19440,1,19795,1,17575,1,16165,1,19465,1,19932,1,19961,1,17343,1,18924,1,18574,1,21351,1,18595,1,19823,1,20844,1,19640,1,17735,1,19814,1,22239,1,20682,1,17819,1,21872,1,22117,1,21866,1),dim=c(2,70),dimnames=list(c('x','y'),1:70))
> y <- array(NA,dim=c(2,70),dimnames=list(c('x','y'),1:70))
> 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
x y M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 15107 0 1 0 0 0 0 0 0 0 0 0 0 1
2 15024 0 0 1 0 0 0 0 0 0 0 0 0 2
3 12083 0 0 0 1 0 0 0 0 0 0 0 0 3
4 15761 0 0 0 0 1 0 0 0 0 0 0 0 4
5 16943 0 0 0 0 0 1 0 0 0 0 0 0 5
6 15070 0 0 0 0 0 0 1 0 0 0 0 0 6
7 13660 0 0 0 0 0 0 0 1 0 0 0 0 7
8 14769 0 0 0 0 0 0 0 0 1 0 0 0 8
9 14725 0 0 0 0 0 0 0 0 0 1 0 0 9
10 15998 0 0 0 0 0 0 0 0 0 0 1 0 10
11 15371 0 0 0 0 0 0 0 0 0 0 0 1 11
12 14957 0 0 0 0 0 0 0 0 0 0 0 0 12
13 15470 0 1 0 0 0 0 0 0 0 0 0 0 13
14 15102 0 0 1 0 0 0 0 0 0 0 0 0 14
15 11704 0 0 0 1 0 0 0 0 0 0 0 0 15
16 16284 0 0 0 0 1 0 0 0 0 0 0 0 16
17 16727 0 0 0 0 0 1 0 0 0 0 0 0 17
18 14969 0 0 0 0 0 0 1 0 0 0 0 0 18
19 14861 0 0 0 0 0 0 0 1 0 0 0 0 19
20 14583 0 0 0 0 0 0 0 0 1 0 0 0 20
21 15306 0 0 0 0 0 0 0 0 0 1 0 0 21
22 17904 0 0 0 0 0 0 0 0 0 0 1 0 22
23 16379 0 0 0 0 0 0 0 0 0 0 0 1 23
24 15420 0 0 0 0 0 0 0 0 0 0 0 0 24
25 17871 0 1 0 0 0 0 0 0 0 0 0 0 25
26 15913 0 0 1 0 0 0 0 0 0 0 0 0 26
27 13867 0 0 0 1 0 0 0 0 0 0 0 0 27
28 17823 0 0 0 0 1 0 0 0 0 0 0 0 28
29 17872 0 0 0 0 0 1 0 0 0 0 0 0 29
30 17422 0 0 0 0 0 0 1 0 0 0 0 0 30
31 16705 0 0 0 0 0 0 0 1 0 0 0 0 31
32 15991 0 0 0 0 0 0 0 0 1 0 0 0 32
33 16584 0 0 0 0 0 0 0 0 0 1 0 0 33
34 19124 0 0 0 0 0 0 0 0 0 0 1 0 34
35 17839 0 0 0 0 0 0 0 0 0 0 0 1 35
36 17209 0 0 0 0 0 0 0 0 0 0 0 0 36
37 18587 0 1 0 0 0 0 0 0 0 0 0 0 37
38 16258 0 0 1 0 0 0 0 0 0 0 0 0 38
39 15142 1 0 0 1 0 0 0 0 0 0 0 0 39
40 19202 1 0 0 0 1 0 0 0 0 0 0 0 40
41 17747 1 0 0 0 0 1 0 0 0 0 0 0 41
42 19090 1 0 0 0 0 0 1 0 0 0 0 0 42
43 18040 1 0 0 0 0 0 0 1 0 0 0 0 43
44 17516 1 0 0 0 0 0 0 0 1 0 0 0 44
45 17752 1 0 0 0 0 0 0 0 0 1 0 0 45
46 21073 1 0 0 0 0 0 0 0 0 0 1 0 46
47 17170 1 0 0 0 0 0 0 0 0 0 0 1 47
48 19440 1 0 0 0 0 0 0 0 0 0 0 0 48
49 19795 1 1 0 0 0 0 0 0 0 0 0 0 49
50 17575 1 0 1 0 0 0 0 0 0 0 0 0 50
51 16165 1 0 0 1 0 0 0 0 0 0 0 0 51
52 19465 1 0 0 0 1 0 0 0 0 0 0 0 52
53 19932 1 0 0 0 0 1 0 0 0 0 0 0 53
54 19961 1 0 0 0 0 0 1 0 0 0 0 0 54
55 17343 1 0 0 0 0 0 0 1 0 0 0 0 55
56 18924 1 0 0 0 0 0 0 0 1 0 0 0 56
57 18574 1 0 0 0 0 0 0 0 0 1 0 0 57
58 21351 1 0 0 0 0 0 0 0 0 0 1 0 58
59 18595 1 0 0 0 0 0 0 0 0 0 0 1 59
60 19823 1 0 0 0 0 0 0 0 0 0 0 0 60
61 20844 1 1 0 0 0 0 0 0 0 0 0 0 61
62 19640 1 0 1 0 0 0 0 0 0 0 0 0 62
63 17735 1 0 0 1 0 0 0 0 0 0 0 0 63
64 19814 1 0 0 0 1 0 0 0 0 0 0 0 64
65 22239 1 0 0 0 0 1 0 0 0 0 0 0 65
66 20682 1 0 0 0 0 0 1 0 0 0 0 0 66
67 17819 1 0 0 0 0 0 0 1 0 0 0 0 67
68 21872 1 0 0 0 0 0 0 0 1 0 0 0 68
69 22117 1 0 0 0 0 0 0 0 0 1 0 0 69
70 21866 1 0 0 0 0 0 0 0 0 0 1 0 70
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) y M1 M2 M3 M4
14076.38 229.95 1035.84 -413.42 -2676.68 843.23
M5 M6 M7 M8 M9 M10
1272.80 472.87 -1077.06 -294.82 -149.91 1804.16
M11 t
-210.07 88.93
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1478.22 -454.23 35.83 415.73 1824.49
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 14076.383 404.508 34.799 < 2e-16 ***
y 229.953 372.137 0.618 0.539129
M1 1035.841 465.144 2.227 0.029991 *
M2 -413.421 464.754 -0.890 0.377513
M3 -2676.676 468.540 -5.713 4.44e-07 ***
M4 843.229 467.458 1.804 0.076633 .
M5 1272.800 466.554 2.728 0.008494 **
M6 472.871 465.829 1.015 0.314416
M7 -1077.057 465.284 -2.315 0.024312 *
M8 -294.820 464.919 -0.634 0.528577
M9 -149.915 464.735 -0.323 0.748214
M10 1804.156 464.732 3.882 0.000275 ***
M11 -210.071 485.074 -0.433 0.666627
t 88.929 9.174 9.693 1.40e-13 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 766.8 on 56 degrees of freedom
Multiple R-squared: 0.9145, Adjusted R-squared: 0.8946
F-statistic: 46.07 on 13 and 56 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.07062709 0.14125418 0.9293729
[2,] 0.02583784 0.05167568 0.9741622
[3,] 0.07626722 0.15253444 0.9237328
[4,] 0.04396600 0.08793200 0.9560340
[5,] 0.02432591 0.04865182 0.9756741
[6,] 0.11279232 0.22558463 0.8872077
[7,] 0.08509549 0.17019097 0.9149045
[8,] 0.05515170 0.11030340 0.9448483
[9,] 0.19259627 0.38519253 0.8074037
[10,] 0.13270425 0.26540850 0.8672958
[11,] 0.12358706 0.24717413 0.8764129
[12,] 0.09905138 0.19810276 0.9009486
[13,] 0.06420452 0.12840904 0.9357955
[14,] 0.07211469 0.14422937 0.9278853
[15,] 0.09640112 0.19280225 0.9035989
[16,] 0.07399992 0.14799984 0.9260001
[17,] 0.05041104 0.10082208 0.9495890
[18,] 0.03874300 0.07748600 0.9612570
[19,] 0.04901367 0.09802734 0.9509863
[20,] 0.03412486 0.06824973 0.9658751
[21,] 0.02262695 0.04525390 0.9773730
[22,] 0.02473656 0.04947312 0.9752634
[23,] 0.01432881 0.02865762 0.9856712
[24,] 0.01317611 0.02635222 0.9868239
[25,] 0.04425033 0.08850067 0.9557497
[26,] 0.04540646 0.09081292 0.9545935
[27,] 0.14812668 0.29625336 0.8518733
[28,] 0.12377226 0.24754453 0.8762277
[29,] 0.09529273 0.19058546 0.9047073
[30,] 0.15599266 0.31198533 0.8440073
[31,] 0.17556529 0.35113057 0.8244347
[32,] 0.19525633 0.39051267 0.8047437
[33,] 0.13749933 0.27499866 0.8625007
[34,] 0.10079536 0.20159072 0.8992046
[35,] 0.05660511 0.11321021 0.9433949
[36,] 0.05463315 0.10926631 0.9453668
[37,] 0.02860629 0.05721258 0.9713937
> postscript(file="/var/www/html/rcomp/tmp/1basi1227369420.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/2emf61227369420.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/33dbq1227369420.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/4vdpo1227369420.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/5jwzp1227369420.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 = 70
Frequency = 1
1 2 3 4 5
-9.415217e+01 1.183181e+03 4.165066e+02 4.856733e+02 1.149173e+03
6 7 8 9 10
-1.282669e+01 3.817331e+01 2.760066e+02 -1.826691e+00 -7.718267e+02
11 12 13 14 15
5.264720e+02 -1.865280e+02 -7.982976e+02 1.940357e+02 -1.029639e+03
16 17 18 19 20
-5.847210e+01 -1.339721e+02 -1.180972e+03 1.720279e+02 -9.771388e+02
21 22 23 24 25
-4.879721e+02 6.702790e+01 4.673266e+02 -7.906734e+02 5.355570e+02
26 27 28 29 30
-6.210966e+01 6.621582e+01 4.133825e+02 -5.611751e+01 2.048825e+02
31 32 33 34 35
9.488825e+02 -6.362842e+02 -2.771175e+02 2.198825e+02 8.601812e+02
36 37 38 39 40
-6.881884e+01 1.844116e+02 -7.842551e+02 4.411751e+01 4.952842e+02
41 42 43 44 45
-1.478216e+03 5.757842e+02 9.867842e+02 -4.083825e+02 -4.062158e+02
46 47 48 49 50
8.717842e+02 -1.105917e+03 8.650829e+02 9.531329e+01 -7.643534e+02
51 52 53 54 55
-2.789855e-02 -3.088612e+02 -3.603612e+02 3.796388e+02 -7.773612e+02
56 57 58 59 60
-6.752790e+01 -6.513612e+02 8.263877e+01 -7.480626e+02 1.809374e+02
61 62 63 64 65
7.716787e+01 2.335012e+02 5.028267e+02 -1.027007e+03 8.794934e+02
66 67 68 69 70
3.349336e+01 -1.368507e+03 1.813327e+03 1.824493e+03 -4.695066e+02
> postscript(file="/var/www/html/rcomp/tmp/6dywf1227369420.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 = 70
Frequency = 1
lag(myerror, k = 1) myerror
0 -9.415217e+01 NA
1 1.183181e+03 -9.415217e+01
2 4.165066e+02 1.183181e+03
3 4.856733e+02 4.165066e+02
4 1.149173e+03 4.856733e+02
5 -1.282669e+01 1.149173e+03
6 3.817331e+01 -1.282669e+01
7 2.760066e+02 3.817331e+01
8 -1.826691e+00 2.760066e+02
9 -7.718267e+02 -1.826691e+00
10 5.264720e+02 -7.718267e+02
11 -1.865280e+02 5.264720e+02
12 -7.982976e+02 -1.865280e+02
13 1.940357e+02 -7.982976e+02
14 -1.029639e+03 1.940357e+02
15 -5.847210e+01 -1.029639e+03
16 -1.339721e+02 -5.847210e+01
17 -1.180972e+03 -1.339721e+02
18 1.720279e+02 -1.180972e+03
19 -9.771388e+02 1.720279e+02
20 -4.879721e+02 -9.771388e+02
21 6.702790e+01 -4.879721e+02
22 4.673266e+02 6.702790e+01
23 -7.906734e+02 4.673266e+02
24 5.355570e+02 -7.906734e+02
25 -6.210966e+01 5.355570e+02
26 6.621582e+01 -6.210966e+01
27 4.133825e+02 6.621582e+01
28 -5.611751e+01 4.133825e+02
29 2.048825e+02 -5.611751e+01
30 9.488825e+02 2.048825e+02
31 -6.362842e+02 9.488825e+02
32 -2.771175e+02 -6.362842e+02
33 2.198825e+02 -2.771175e+02
34 8.601812e+02 2.198825e+02
35 -6.881884e+01 8.601812e+02
36 1.844116e+02 -6.881884e+01
37 -7.842551e+02 1.844116e+02
38 4.411751e+01 -7.842551e+02
39 4.952842e+02 4.411751e+01
40 -1.478216e+03 4.952842e+02
41 5.757842e+02 -1.478216e+03
42 9.867842e+02 5.757842e+02
43 -4.083825e+02 9.867842e+02
44 -4.062158e+02 -4.083825e+02
45 8.717842e+02 -4.062158e+02
46 -1.105917e+03 8.717842e+02
47 8.650829e+02 -1.105917e+03
48 9.531329e+01 8.650829e+02
49 -7.643534e+02 9.531329e+01
50 -2.789855e-02 -7.643534e+02
51 -3.088612e+02 -2.789855e-02
52 -3.603612e+02 -3.088612e+02
53 3.796388e+02 -3.603612e+02
54 -7.773612e+02 3.796388e+02
55 -6.752790e+01 -7.773612e+02
56 -6.513612e+02 -6.752790e+01
57 8.263877e+01 -6.513612e+02
58 -7.480626e+02 8.263877e+01
59 1.809374e+02 -7.480626e+02
60 7.716787e+01 1.809374e+02
61 2.335012e+02 7.716787e+01
62 5.028267e+02 2.335012e+02
63 -1.027007e+03 5.028267e+02
64 8.794934e+02 -1.027007e+03
65 3.349336e+01 8.794934e+02
66 -1.368507e+03 3.349336e+01
67 1.813327e+03 -1.368507e+03
68 1.824493e+03 1.813327e+03
69 -4.695066e+02 1.824493e+03
70 NA -4.695066e+02
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.183181e+03 -9.415217e+01
[2,] 4.165066e+02 1.183181e+03
[3,] 4.856733e+02 4.165066e+02
[4,] 1.149173e+03 4.856733e+02
[5,] -1.282669e+01 1.149173e+03
[6,] 3.817331e+01 -1.282669e+01
[7,] 2.760066e+02 3.817331e+01
[8,] -1.826691e+00 2.760066e+02
[9,] -7.718267e+02 -1.826691e+00
[10,] 5.264720e+02 -7.718267e+02
[11,] -1.865280e+02 5.264720e+02
[12,] -7.982976e+02 -1.865280e+02
[13,] 1.940357e+02 -7.982976e+02
[14,] -1.029639e+03 1.940357e+02
[15,] -5.847210e+01 -1.029639e+03
[16,] -1.339721e+02 -5.847210e+01
[17,] -1.180972e+03 -1.339721e+02
[18,] 1.720279e+02 -1.180972e+03
[19,] -9.771388e+02 1.720279e+02
[20,] -4.879721e+02 -9.771388e+02
[21,] 6.702790e+01 -4.879721e+02
[22,] 4.673266e+02 6.702790e+01
[23,] -7.906734e+02 4.673266e+02
[24,] 5.355570e+02 -7.906734e+02
[25,] -6.210966e+01 5.355570e+02
[26,] 6.621582e+01 -6.210966e+01
[27,] 4.133825e+02 6.621582e+01
[28,] -5.611751e+01 4.133825e+02
[29,] 2.048825e+02 -5.611751e+01
[30,] 9.488825e+02 2.048825e+02
[31,] -6.362842e+02 9.488825e+02
[32,] -2.771175e+02 -6.362842e+02
[33,] 2.198825e+02 -2.771175e+02
[34,] 8.601812e+02 2.198825e+02
[35,] -6.881884e+01 8.601812e+02
[36,] 1.844116e+02 -6.881884e+01
[37,] -7.842551e+02 1.844116e+02
[38,] 4.411751e+01 -7.842551e+02
[39,] 4.952842e+02 4.411751e+01
[40,] -1.478216e+03 4.952842e+02
[41,] 5.757842e+02 -1.478216e+03
[42,] 9.867842e+02 5.757842e+02
[43,] -4.083825e+02 9.867842e+02
[44,] -4.062158e+02 -4.083825e+02
[45,] 8.717842e+02 -4.062158e+02
[46,] -1.105917e+03 8.717842e+02
[47,] 8.650829e+02 -1.105917e+03
[48,] 9.531329e+01 8.650829e+02
[49,] -7.643534e+02 9.531329e+01
[50,] -2.789855e-02 -7.643534e+02
[51,] -3.088612e+02 -2.789855e-02
[52,] -3.603612e+02 -3.088612e+02
[53,] 3.796388e+02 -3.603612e+02
[54,] -7.773612e+02 3.796388e+02
[55,] -6.752790e+01 -7.773612e+02
[56,] -6.513612e+02 -6.752790e+01
[57,] 8.263877e+01 -6.513612e+02
[58,] -7.480626e+02 8.263877e+01
[59,] 1.809374e+02 -7.480626e+02
[60,] 7.716787e+01 1.809374e+02
[61,] 2.335012e+02 7.716787e+01
[62,] 5.028267e+02 2.335012e+02
[63,] -1.027007e+03 5.028267e+02
[64,] 8.794934e+02 -1.027007e+03
[65,] 3.349336e+01 8.794934e+02
[66,] -1.368507e+03 3.349336e+01
[67,] 1.813327e+03 -1.368507e+03
[68,] 1.824493e+03 1.813327e+03
[69,] -4.695066e+02 1.824493e+03
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.183181e+03 -9.415217e+01
2 4.165066e+02 1.183181e+03
3 4.856733e+02 4.165066e+02
4 1.149173e+03 4.856733e+02
5 -1.282669e+01 1.149173e+03
6 3.817331e+01 -1.282669e+01
7 2.760066e+02 3.817331e+01
8 -1.826691e+00 2.760066e+02
9 -7.718267e+02 -1.826691e+00
10 5.264720e+02 -7.718267e+02
11 -1.865280e+02 5.264720e+02
12 -7.982976e+02 -1.865280e+02
13 1.940357e+02 -7.982976e+02
14 -1.029639e+03 1.940357e+02
15 -5.847210e+01 -1.029639e+03
16 -1.339721e+02 -5.847210e+01
17 -1.180972e+03 -1.339721e+02
18 1.720279e+02 -1.180972e+03
19 -9.771388e+02 1.720279e+02
20 -4.879721e+02 -9.771388e+02
21 6.702790e+01 -4.879721e+02
22 4.673266e+02 6.702790e+01
23 -7.906734e+02 4.673266e+02
24 5.355570e+02 -7.906734e+02
25 -6.210966e+01 5.355570e+02
26 6.621582e+01 -6.210966e+01
27 4.133825e+02 6.621582e+01
28 -5.611751e+01 4.133825e+02
29 2.048825e+02 -5.611751e+01
30 9.488825e+02 2.048825e+02
31 -6.362842e+02 9.488825e+02
32 -2.771175e+02 -6.362842e+02
33 2.198825e+02 -2.771175e+02
34 8.601812e+02 2.198825e+02
35 -6.881884e+01 8.601812e+02
36 1.844116e+02 -6.881884e+01
37 -7.842551e+02 1.844116e+02
38 4.411751e+01 -7.842551e+02
39 4.952842e+02 4.411751e+01
40 -1.478216e+03 4.952842e+02
41 5.757842e+02 -1.478216e+03
42 9.867842e+02 5.757842e+02
43 -4.083825e+02 9.867842e+02
44 -4.062158e+02 -4.083825e+02
45 8.717842e+02 -4.062158e+02
46 -1.105917e+03 8.717842e+02
47 8.650829e+02 -1.105917e+03
48 9.531329e+01 8.650829e+02
49 -7.643534e+02 9.531329e+01
50 -2.789855e-02 -7.643534e+02
51 -3.088612e+02 -2.789855e-02
52 -3.603612e+02 -3.088612e+02
53 3.796388e+02 -3.603612e+02
54 -7.773612e+02 3.796388e+02
55 -6.752790e+01 -7.773612e+02
56 -6.513612e+02 -6.752790e+01
57 8.263877e+01 -6.513612e+02
58 -7.480626e+02 8.263877e+01
59 1.809374e+02 -7.480626e+02
60 7.716787e+01 1.809374e+02
61 2.335012e+02 7.716787e+01
62 5.028267e+02 2.335012e+02
63 -1.027007e+03 5.028267e+02
64 8.794934e+02 -1.027007e+03
65 3.349336e+01 8.794934e+02
66 -1.368507e+03 3.349336e+01
67 1.813327e+03 -1.368507e+03
68 1.824493e+03 1.813327e+03
69 -4.695066e+02 1.824493e+03
> 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/7mrt11227369420.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/8qc8z1227369420.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/9fi4c1227369420.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/10jalw1227369420.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/1189xa1227369420.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/12k2v01227369420.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/1342e11227369420.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/14pm6q1227369420.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/15clyo1227369420.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/163bq21227369420.tab")
+ }
>
> system("convert tmp/1basi1227369420.ps tmp/1basi1227369420.png")
> system("convert tmp/2emf61227369420.ps tmp/2emf61227369420.png")
> system("convert tmp/33dbq1227369420.ps tmp/33dbq1227369420.png")
> system("convert tmp/4vdpo1227369420.ps tmp/4vdpo1227369420.png")
> system("convert tmp/5jwzp1227369420.ps tmp/5jwzp1227369420.png")
> system("convert tmp/6dywf1227369420.ps tmp/6dywf1227369420.png")
> system("convert tmp/7mrt11227369420.ps tmp/7mrt11227369420.png")
> system("convert tmp/8qc8z1227369420.ps tmp/8qc8z1227369420.png")
> system("convert tmp/9fi4c1227369420.ps tmp/9fi4c1227369420.png")
> system("convert tmp/10jalw1227369420.ps tmp/10jalw1227369420.png")
>
>
> proc.time()
user system elapsed
2.549 1.590 2.957