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(128.7,0,136.9,0,156.9,0,109.1,0,122.3,0,123.9,0,90.9,0,77.9,0,120.3,0,118.9,0,125.5,0,98.9,0,102.9,0,105.9,0,117.6,0,113.6,0,115.9,0,118.9,0,77.6,0,81.2,0,123.1,0,136.6,0,112.1,0,95.1,0,96.3,0,105.7,0,115.8,0,105.7,0,105.7,0,111.1,0,82.4,0,60,0,107.3,0,99.3,0,113.5,0,108.9,0,100.2,0,103.9,0,138.7,0,120.2,0,100.2,0,143.2,0,70.9,0,85.2,0,133,0,136.6,0,117.9,0,106.3,0,122.3,0,125.5,0,148.4,0,126.3,0,99.6,0,140.4,0,80.3,0,92.6,0,138.5,0,110.9,0,119.6,0,105,0,109,0,129.4,0,148.6,0,101.4,0,134.8,0,143.7,0,81.6,0,90.3,0,141.5,0,140.7,0,140.2,0,100.2,0,125.7,0,119.6,0,134.7,0,109,0,116.3,0,146.9,0,97.4,0,89.4,0,132.1,1,139.8,1,129,1,112.5,1,121.9,1,121.7,1,123.1,1,131.6,1,119.3,1,132.5,1,98.3,1,85.1,1,131.7,1,129.3,1,90.7,1,78.6,1,68.9,1,79.1,1,83.5,1,74.1,1,59.7,1,93.3,1,61.3,1,56.6,1,98.5,1),dim=c(2,105),dimnames=list(c('Y','X'),1:105))
> y <- array(NA,dim=c(2,105),dimnames=list(c('Y','X'),1:105))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '1'
> #'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
Y X
1 128.7 0
2 136.9 0
3 156.9 0
4 109.1 0
5 122.3 0
6 123.9 0
7 90.9 0
8 77.9 0
9 120.3 0
10 118.9 0
11 125.5 0
12 98.9 0
13 102.9 0
14 105.9 0
15 117.6 0
16 113.6 0
17 115.9 0
18 118.9 0
19 77.6 0
20 81.2 0
21 123.1 0
22 136.6 0
23 112.1 0
24 95.1 0
25 96.3 0
26 105.7 0
27 115.8 0
28 105.7 0
29 105.7 0
30 111.1 0
31 82.4 0
32 60.0 0
33 107.3 0
34 99.3 0
35 113.5 0
36 108.9 0
37 100.2 0
38 103.9 0
39 138.7 0
40 120.2 0
41 100.2 0
42 143.2 0
43 70.9 0
44 85.2 0
45 133.0 0
46 136.6 0
47 117.9 0
48 106.3 0
49 122.3 0
50 125.5 0
51 148.4 0
52 126.3 0
53 99.6 0
54 140.4 0
55 80.3 0
56 92.6 0
57 138.5 0
58 110.9 0
59 119.6 0
60 105.0 0
61 109.0 0
62 129.4 0
63 148.6 0
64 101.4 0
65 134.8 0
66 143.7 0
67 81.6 0
68 90.3 0
69 141.5 0
70 140.7 0
71 140.2 0
72 100.2 0
73 125.7 0
74 119.6 0
75 134.7 0
76 109.0 0
77 116.3 0
78 146.9 0
79 97.4 0
80 89.4 0
81 132.1 1
82 139.8 1
83 129.0 1
84 112.5 1
85 121.9 1
86 121.7 1
87 123.1 1
88 131.6 1
89 119.3 1
90 132.5 1
91 98.3 1
92 85.1 1
93 131.7 1
94 129.3 1
95 90.7 1
96 78.6 1
97 68.9 1
98 79.1 1
99 83.5 1
100 74.1 1
101 59.7 1
102 93.3 1
103 61.3 1
104 56.6 1
105 98.5 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X
113.61 -11.52
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-53.6063 -14.3063 -0.1062 19.6120 43.2938
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 113.606 2.479 45.827 <2e-16 ***
X -11.518 5.080 -2.267 0.0255 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 22.17 on 103 degrees of freedom
Multiple R-squared: 0.04753, Adjusted R-squared: 0.03828
F-statistic: 5.14 on 1 and 103 DF, p-value: 0.02547
> 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.53806345 0.92387310 0.4619366
[2,] 0.38157633 0.76315267 0.6184237
[3,] 0.60921169 0.78157662 0.3907883
[4,] 0.82501831 0.34996338 0.1749817
[5,] 0.74332815 0.51334371 0.2566719
[6,] 0.64952992 0.70094016 0.3504701
[7,] 0.55985202 0.88029596 0.4401480
[8,] 0.53019884 0.93960233 0.4698012
[9,] 0.47037100 0.94074200 0.5296290
[10,] 0.39759990 0.79519981 0.6024001
[11,] 0.31505033 0.63010066 0.6849497
[12,] 0.24234775 0.48469550 0.7576522
[13,] 0.18072807 0.36145615 0.8192719
[14,] 0.13214639 0.26429278 0.8678536
[15,] 0.24526823 0.49053646 0.7547318
[16,] 0.32218010 0.64436021 0.6778199
[17,] 0.27175620 0.54351240 0.7282438
[18,] 0.28095663 0.56191325 0.7190434
[19,] 0.22323414 0.44646828 0.7767659
[20,] 0.20863564 0.41727127 0.7913644
[21,] 0.18867891 0.37735783 0.8113211
[22,] 0.14940030 0.29880060 0.8505997
[23,] 0.11373954 0.22747909 0.8862605
[24,] 0.08700024 0.17400047 0.9129998
[25,] 0.06540503 0.13081006 0.9345950
[26,] 0.04676145 0.09352289 0.9532386
[27,] 0.06564944 0.13129887 0.9343506
[28,] 0.23014701 0.46029401 0.7698530
[29,] 0.18728846 0.37457692 0.8127115
[30,] 0.16000719 0.32001438 0.8399928
[31,] 0.12643720 0.25287441 0.8735628
[32,] 0.09820148 0.19640297 0.9017985
[33,] 0.08073460 0.16146920 0.9192654
[34,] 0.06305174 0.12610348 0.9369483
[35,] 0.07737726 0.15475452 0.9226227
[36,] 0.06116471 0.12232942 0.9388353
[37,] 0.04993787 0.09987575 0.9500621
[38,] 0.07027721 0.14055442 0.9297228
[39,] 0.14147916 0.28295831 0.8585208
[40,] 0.16322904 0.32645807 0.8367710
[41,] 0.16084501 0.32169003 0.8391550
[42,] 0.16865325 0.33730650 0.8313467
[43,] 0.13752901 0.27505802 0.8624710
[44,] 0.11219188 0.22438375 0.8878081
[45,] 0.09193449 0.18386899 0.9080655
[46,] 0.07720688 0.15441376 0.9227931
[47,] 0.11353223 0.22706446 0.8864678
[48,] 0.09630948 0.19261897 0.9036905
[49,] 0.08347470 0.16694940 0.9165253
[50,] 0.09314069 0.18628139 0.9068593
[51,] 0.12968070 0.25936139 0.8703193
[52,] 0.13058006 0.26116013 0.8694199
[53,] 0.13520904 0.27041807 0.8647910
[54,] 0.10838761 0.21677523 0.8916124
[55,] 0.08573804 0.17147609 0.9142620
[56,] 0.07015514 0.14031027 0.9298449
[57,] 0.05489799 0.10979597 0.9451020
[58,] 0.04616763 0.09233527 0.9538324
[59,] 0.06502610 0.13005219 0.9349739
[60,] 0.05505588 0.11011176 0.9449441
[61,] 0.05090322 0.10180644 0.9490968
[62,] 0.06018871 0.12037743 0.9398113
[63,] 0.08467356 0.16934713 0.9153264
[64,] 0.09409230 0.18818461 0.9059077
[65,] 0.09822409 0.19644818 0.9017759
[66,] 0.10185555 0.20371111 0.8981444
[67,] 0.10656536 0.21313071 0.8934346
[68,] 0.09149413 0.18298825 0.9085059
[69,] 0.07323164 0.14646328 0.9267684
[70,] 0.05505972 0.11011945 0.9449403
[71,] 0.05183304 0.10366608 0.9481670
[72,] 0.03773107 0.07546215 0.9622689
[73,] 0.02686098 0.05372196 0.9731390
[74,] 0.05153505 0.10307009 0.9484650
[75,] 0.03956041 0.07912083 0.9604396
[76,] 0.03157127 0.06314253 0.9684287
[77,] 0.03267032 0.06534064 0.9673297
[78,] 0.04596722 0.09193444 0.9540328
[79,] 0.04951459 0.09902919 0.9504854
[80,] 0.04095672 0.08191343 0.9590433
[81,] 0.03885057 0.07770115 0.9611494
[82,] 0.03804001 0.07608002 0.9619600
[83,] 0.04080017 0.08160035 0.9591998
[84,] 0.06666088 0.13332176 0.9333391
[85,] 0.07571532 0.15143063 0.9242847
[86,] 0.16887069 0.33774137 0.8311293
[87,] 0.14590019 0.29180038 0.8540998
[88,] 0.12058923 0.24117847 0.8794108
[89,] 0.33761325 0.67522650 0.6623868
[90,] 0.82044283 0.35911433 0.1795572
[91,] 0.80634181 0.38731638 0.1936582
[92,] 0.73963279 0.52073441 0.2603672
[93,] 0.67152360 0.65695280 0.3284764
[94,] 0.56119096 0.87761809 0.4388090
[95,] 0.44911625 0.89823251 0.5508837
[96,] 0.30738245 0.61476489 0.6926176
> postscript(file="/var/www/html/rcomp/tmp/1br2i1261236596.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/2bpw31261236596.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/3aaal1261236596.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/4o24s1261236596.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/5aakw1261236596.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 = 105
Frequency = 1
1 2 3 4 5 6 7 8
15.09375 23.29375 43.29375 -4.50625 8.69375 10.29375 -22.70625 -35.70625
9 10 11 12 13 14 15 16
6.69375 5.29375 11.89375 -14.70625 -10.70625 -7.70625 3.99375 -0.00625
17 18 19 20 21 22 23 24
2.29375 5.29375 -36.00625 -32.40625 9.49375 22.99375 -1.50625 -18.50625
25 26 27 28 29 30 31 32
-17.30625 -7.90625 2.19375 -7.90625 -7.90625 -2.50625 -31.20625 -53.60625
33 34 35 36 37 38 39 40
-6.30625 -14.30625 -0.10625 -4.70625 -13.40625 -9.70625 25.09375 6.59375
41 42 43 44 45 46 47 48
-13.40625 29.59375 -42.70625 -28.40625 19.39375 22.99375 4.29375 -7.30625
49 50 51 52 53 54 55 56
8.69375 11.89375 34.79375 12.69375 -14.00625 26.79375 -33.30625 -21.00625
57 58 59 60 61 62 63 64
24.89375 -2.70625 5.99375 -8.60625 -4.60625 15.79375 34.99375 -12.20625
65 66 67 68 69 70 71 72
21.19375 30.09375 -32.00625 -23.30625 27.89375 27.09375 26.59375 -13.40625
73 74 75 76 77 78 79 80
12.09375 5.99375 21.09375 -4.60625 2.69375 33.29375 -16.20625 -24.20625
81 82 83 84 85 86 87 88
30.01200 37.71200 26.91200 10.41200 19.81200 19.61200 21.01200 29.51200
89 90 91 92 93 94 95 96
17.21200 30.41200 -3.78800 -16.98800 29.61200 27.21200 -11.38800 -23.48800
97 98 99 100 101 102 103 104
-33.18800 -22.98800 -18.58800 -27.98800 -42.38800 -8.78800 -40.78800 -45.48800
105
-3.58800
> postscript(file="/var/www/html/rcomp/tmp/6dzgs1261236596.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 = 105
Frequency = 1
lag(myerror, k = 1) myerror
0 15.09375 NA
1 23.29375 15.09375
2 43.29375 23.29375
3 -4.50625 43.29375
4 8.69375 -4.50625
5 10.29375 8.69375
6 -22.70625 10.29375
7 -35.70625 -22.70625
8 6.69375 -35.70625
9 5.29375 6.69375
10 11.89375 5.29375
11 -14.70625 11.89375
12 -10.70625 -14.70625
13 -7.70625 -10.70625
14 3.99375 -7.70625
15 -0.00625 3.99375
16 2.29375 -0.00625
17 5.29375 2.29375
18 -36.00625 5.29375
19 -32.40625 -36.00625
20 9.49375 -32.40625
21 22.99375 9.49375
22 -1.50625 22.99375
23 -18.50625 -1.50625
24 -17.30625 -18.50625
25 -7.90625 -17.30625
26 2.19375 -7.90625
27 -7.90625 2.19375
28 -7.90625 -7.90625
29 -2.50625 -7.90625
30 -31.20625 -2.50625
31 -53.60625 -31.20625
32 -6.30625 -53.60625
33 -14.30625 -6.30625
34 -0.10625 -14.30625
35 -4.70625 -0.10625
36 -13.40625 -4.70625
37 -9.70625 -13.40625
38 25.09375 -9.70625
39 6.59375 25.09375
40 -13.40625 6.59375
41 29.59375 -13.40625
42 -42.70625 29.59375
43 -28.40625 -42.70625
44 19.39375 -28.40625
45 22.99375 19.39375
46 4.29375 22.99375
47 -7.30625 4.29375
48 8.69375 -7.30625
49 11.89375 8.69375
50 34.79375 11.89375
51 12.69375 34.79375
52 -14.00625 12.69375
53 26.79375 -14.00625
54 -33.30625 26.79375
55 -21.00625 -33.30625
56 24.89375 -21.00625
57 -2.70625 24.89375
58 5.99375 -2.70625
59 -8.60625 5.99375
60 -4.60625 -8.60625
61 15.79375 -4.60625
62 34.99375 15.79375
63 -12.20625 34.99375
64 21.19375 -12.20625
65 30.09375 21.19375
66 -32.00625 30.09375
67 -23.30625 -32.00625
68 27.89375 -23.30625
69 27.09375 27.89375
70 26.59375 27.09375
71 -13.40625 26.59375
72 12.09375 -13.40625
73 5.99375 12.09375
74 21.09375 5.99375
75 -4.60625 21.09375
76 2.69375 -4.60625
77 33.29375 2.69375
78 -16.20625 33.29375
79 -24.20625 -16.20625
80 30.01200 -24.20625
81 37.71200 30.01200
82 26.91200 37.71200
83 10.41200 26.91200
84 19.81200 10.41200
85 19.61200 19.81200
86 21.01200 19.61200
87 29.51200 21.01200
88 17.21200 29.51200
89 30.41200 17.21200
90 -3.78800 30.41200
91 -16.98800 -3.78800
92 29.61200 -16.98800
93 27.21200 29.61200
94 -11.38800 27.21200
95 -23.48800 -11.38800
96 -33.18800 -23.48800
97 -22.98800 -33.18800
98 -18.58800 -22.98800
99 -27.98800 -18.58800
100 -42.38800 -27.98800
101 -8.78800 -42.38800
102 -40.78800 -8.78800
103 -45.48800 -40.78800
104 -3.58800 -45.48800
105 NA -3.58800
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 23.29375 15.09375
[2,] 43.29375 23.29375
[3,] -4.50625 43.29375
[4,] 8.69375 -4.50625
[5,] 10.29375 8.69375
[6,] -22.70625 10.29375
[7,] -35.70625 -22.70625
[8,] 6.69375 -35.70625
[9,] 5.29375 6.69375
[10,] 11.89375 5.29375
[11,] -14.70625 11.89375
[12,] -10.70625 -14.70625
[13,] -7.70625 -10.70625
[14,] 3.99375 -7.70625
[15,] -0.00625 3.99375
[16,] 2.29375 -0.00625
[17,] 5.29375 2.29375
[18,] -36.00625 5.29375
[19,] -32.40625 -36.00625
[20,] 9.49375 -32.40625
[21,] 22.99375 9.49375
[22,] -1.50625 22.99375
[23,] -18.50625 -1.50625
[24,] -17.30625 -18.50625
[25,] -7.90625 -17.30625
[26,] 2.19375 -7.90625
[27,] -7.90625 2.19375
[28,] -7.90625 -7.90625
[29,] -2.50625 -7.90625
[30,] -31.20625 -2.50625
[31,] -53.60625 -31.20625
[32,] -6.30625 -53.60625
[33,] -14.30625 -6.30625
[34,] -0.10625 -14.30625
[35,] -4.70625 -0.10625
[36,] -13.40625 -4.70625
[37,] -9.70625 -13.40625
[38,] 25.09375 -9.70625
[39,] 6.59375 25.09375
[40,] -13.40625 6.59375
[41,] 29.59375 -13.40625
[42,] -42.70625 29.59375
[43,] -28.40625 -42.70625
[44,] 19.39375 -28.40625
[45,] 22.99375 19.39375
[46,] 4.29375 22.99375
[47,] -7.30625 4.29375
[48,] 8.69375 -7.30625
[49,] 11.89375 8.69375
[50,] 34.79375 11.89375
[51,] 12.69375 34.79375
[52,] -14.00625 12.69375
[53,] 26.79375 -14.00625
[54,] -33.30625 26.79375
[55,] -21.00625 -33.30625
[56,] 24.89375 -21.00625
[57,] -2.70625 24.89375
[58,] 5.99375 -2.70625
[59,] -8.60625 5.99375
[60,] -4.60625 -8.60625
[61,] 15.79375 -4.60625
[62,] 34.99375 15.79375
[63,] -12.20625 34.99375
[64,] 21.19375 -12.20625
[65,] 30.09375 21.19375
[66,] -32.00625 30.09375
[67,] -23.30625 -32.00625
[68,] 27.89375 -23.30625
[69,] 27.09375 27.89375
[70,] 26.59375 27.09375
[71,] -13.40625 26.59375
[72,] 12.09375 -13.40625
[73,] 5.99375 12.09375
[74,] 21.09375 5.99375
[75,] -4.60625 21.09375
[76,] 2.69375 -4.60625
[77,] 33.29375 2.69375
[78,] -16.20625 33.29375
[79,] -24.20625 -16.20625
[80,] 30.01200 -24.20625
[81,] 37.71200 30.01200
[82,] 26.91200 37.71200
[83,] 10.41200 26.91200
[84,] 19.81200 10.41200
[85,] 19.61200 19.81200
[86,] 21.01200 19.61200
[87,] 29.51200 21.01200
[88,] 17.21200 29.51200
[89,] 30.41200 17.21200
[90,] -3.78800 30.41200
[91,] -16.98800 -3.78800
[92,] 29.61200 -16.98800
[93,] 27.21200 29.61200
[94,] -11.38800 27.21200
[95,] -23.48800 -11.38800
[96,] -33.18800 -23.48800
[97,] -22.98800 -33.18800
[98,] -18.58800 -22.98800
[99,] -27.98800 -18.58800
[100,] -42.38800 -27.98800
[101,] -8.78800 -42.38800
[102,] -40.78800 -8.78800
[103,] -45.48800 -40.78800
[104,] -3.58800 -45.48800
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 23.29375 15.09375
2 43.29375 23.29375
3 -4.50625 43.29375
4 8.69375 -4.50625
5 10.29375 8.69375
6 -22.70625 10.29375
7 -35.70625 -22.70625
8 6.69375 -35.70625
9 5.29375 6.69375
10 11.89375 5.29375
11 -14.70625 11.89375
12 -10.70625 -14.70625
13 -7.70625 -10.70625
14 3.99375 -7.70625
15 -0.00625 3.99375
16 2.29375 -0.00625
17 5.29375 2.29375
18 -36.00625 5.29375
19 -32.40625 -36.00625
20 9.49375 -32.40625
21 22.99375 9.49375
22 -1.50625 22.99375
23 -18.50625 -1.50625
24 -17.30625 -18.50625
25 -7.90625 -17.30625
26 2.19375 -7.90625
27 -7.90625 2.19375
28 -7.90625 -7.90625
29 -2.50625 -7.90625
30 -31.20625 -2.50625
31 -53.60625 -31.20625
32 -6.30625 -53.60625
33 -14.30625 -6.30625
34 -0.10625 -14.30625
35 -4.70625 -0.10625
36 -13.40625 -4.70625
37 -9.70625 -13.40625
38 25.09375 -9.70625
39 6.59375 25.09375
40 -13.40625 6.59375
41 29.59375 -13.40625
42 -42.70625 29.59375
43 -28.40625 -42.70625
44 19.39375 -28.40625
45 22.99375 19.39375
46 4.29375 22.99375
47 -7.30625 4.29375
48 8.69375 -7.30625
49 11.89375 8.69375
50 34.79375 11.89375
51 12.69375 34.79375
52 -14.00625 12.69375
53 26.79375 -14.00625
54 -33.30625 26.79375
55 -21.00625 -33.30625
56 24.89375 -21.00625
57 -2.70625 24.89375
58 5.99375 -2.70625
59 -8.60625 5.99375
60 -4.60625 -8.60625
61 15.79375 -4.60625
62 34.99375 15.79375
63 -12.20625 34.99375
64 21.19375 -12.20625
65 30.09375 21.19375
66 -32.00625 30.09375
67 -23.30625 -32.00625
68 27.89375 -23.30625
69 27.09375 27.89375
70 26.59375 27.09375
71 -13.40625 26.59375
72 12.09375 -13.40625
73 5.99375 12.09375
74 21.09375 5.99375
75 -4.60625 21.09375
76 2.69375 -4.60625
77 33.29375 2.69375
78 -16.20625 33.29375
79 -24.20625 -16.20625
80 30.01200 -24.20625
81 37.71200 30.01200
82 26.91200 37.71200
83 10.41200 26.91200
84 19.81200 10.41200
85 19.61200 19.81200
86 21.01200 19.61200
87 29.51200 21.01200
88 17.21200 29.51200
89 30.41200 17.21200
90 -3.78800 30.41200
91 -16.98800 -3.78800
92 29.61200 -16.98800
93 27.21200 29.61200
94 -11.38800 27.21200
95 -23.48800 -11.38800
96 -33.18800 -23.48800
97 -22.98800 -33.18800
98 -18.58800 -22.98800
99 -27.98800 -18.58800
100 -42.38800 -27.98800
101 -8.78800 -42.38800
102 -40.78800 -8.78800
103 -45.48800 -40.78800
104 -3.58800 -45.48800
> 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/7rvcu1261236596.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/89g4p1261236596.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/9twl31261236596.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/10q3cq1261236596.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/11z6q51261236596.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/1260bo1261236596.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/13dfrv1261236597.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/1452vv1261236597.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/153zz41261236597.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/16p2071261236597.tab")
+ }
>
> try(system("convert tmp/1br2i1261236596.ps tmp/1br2i1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/2bpw31261236596.ps tmp/2bpw31261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/3aaal1261236596.ps tmp/3aaal1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/4o24s1261236596.ps tmp/4o24s1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/5aakw1261236596.ps tmp/5aakw1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/6dzgs1261236596.ps tmp/6dzgs1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/7rvcu1261236596.ps tmp/7rvcu1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/89g4p1261236596.ps tmp/89g4p1261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/9twl31261236596.ps tmp/9twl31261236596.png",intern=TRUE))
character(0)
> try(system("convert tmp/10q3cq1261236596.ps tmp/10q3cq1261236596.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.944 1.655 7.659