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(31514,27071,29462,26105,22397,23843,21705,18089,20764,25316,17704,15548,28029,29383,36438,32034,22679,24319,18004,17537,20366,22782,19169,13807,29743,25591,29096,26482,22405,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,20995,17382,9367,31124,26551,30651,25859,25100,25778,20418,18688,20424,24776,19814,12738,31566,30111,30019,31934,25826,26835,20205,17789,20520,22518,15572,11509,25447,24090,27786,26195,20516,22759,19028,16971,20036,22485,18730,14538,27561,25985,34670,32066,27186,29586,21359,21553,19573,24256),dim=c(1,94),dimnames=list(c('X'),1:94))
> y <- array(NA,dim=c(1,94),dimnames=list(c('X'),1:94))
> 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 = '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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 31514 1 0 0 0 0 0 0 0 0 0 0
2 27071 0 1 0 0 0 0 0 0 0 0 0
3 29462 0 0 1 0 0 0 0 0 0 0 0
4 26105 0 0 0 1 0 0 0 0 0 0 0
5 22397 0 0 0 0 1 0 0 0 0 0 0
6 23843 0 0 0 0 0 1 0 0 0 0 0
7 21705 0 0 0 0 0 0 1 0 0 0 0
8 18089 0 0 0 0 0 0 0 1 0 0 0
9 20764 0 0 0 0 0 0 0 0 1 0 0
10 25316 0 0 0 0 0 0 0 0 0 1 0
11 17704 0 0 0 0 0 0 0 0 0 0 1
12 15548 0 0 0 0 0 0 0 0 0 0 0
13 28029 1 0 0 0 0 0 0 0 0 0 0
14 29383 0 1 0 0 0 0 0 0 0 0 0
15 36438 0 0 1 0 0 0 0 0 0 0 0
16 32034 0 0 0 1 0 0 0 0 0 0 0
17 22679 0 0 0 0 1 0 0 0 0 0 0
18 24319 0 0 0 0 0 1 0 0 0 0 0
19 18004 0 0 0 0 0 0 1 0 0 0 0
20 17537 0 0 0 0 0 0 0 1 0 0 0
21 20366 0 0 0 0 0 0 0 0 1 0 0
22 22782 0 0 0 0 0 0 0 0 0 1 0
23 19169 0 0 0 0 0 0 0 0 0 0 1
24 13807 0 0 0 0 0 0 0 0 0 0 0
25 29743 1 0 0 0 0 0 0 0 0 0 0
26 25591 0 1 0 0 0 0 0 0 0 0 0
27 29096 0 0 1 0 0 0 0 0 0 0 0
28 26482 0 0 0 1 0 0 0 0 0 0 0
29 22405 0 0 0 0 1 0 0 0 0 0 0
30 27044 0 0 0 0 0 1 0 0 0 0 0
31 17970 0 0 0 0 0 0 1 0 0 0 0
32 18730 0 0 0 0 0 0 0 1 0 0 0
33 19684 0 0 0 0 0 0 0 0 1 0 0
34 19785 0 0 0 0 0 0 0 0 0 1 0
35 18479 0 0 0 0 0 0 0 0 0 0 1
36 10698 0 0 0 0 0 0 0 0 0 0 0
37 31956 1 0 0 0 0 0 0 0 0 0 0
38 29506 0 1 0 0 0 0 0 0 0 0 0
39 34506 0 0 1 0 0 0 0 0 0 0 0
40 27165 0 0 0 1 0 0 0 0 0 0 0
41 26736 0 0 0 0 1 0 0 0 0 0 0
42 23691 0 0 0 0 0 1 0 0 0 0 0
43 18157 0 0 0 0 0 0 1 0 0 0 0
44 17328 0 0 0 0 0 0 0 1 0 0 0
45 18205 0 0 0 0 0 0 0 0 1 0 0
46 20995 0 0 0 0 0 0 0 0 0 1 0
47 17382 0 0 0 0 0 0 0 0 0 0 1
48 9367 0 0 0 0 0 0 0 0 0 0 0
49 31124 1 0 0 0 0 0 0 0 0 0 0
50 26551 0 1 0 0 0 0 0 0 0 0 0
51 30651 0 0 1 0 0 0 0 0 0 0 0
52 25859 0 0 0 1 0 0 0 0 0 0 0
53 25100 0 0 0 0 1 0 0 0 0 0 0
54 25778 0 0 0 0 0 1 0 0 0 0 0
55 20418 0 0 0 0 0 0 1 0 0 0 0
56 18688 0 0 0 0 0 0 0 1 0 0 0
57 20424 0 0 0 0 0 0 0 0 1 0 0
58 24776 0 0 0 0 0 0 0 0 0 1 0
59 19814 0 0 0 0 0 0 0 0 0 0 1
60 12738 0 0 0 0 0 0 0 0 0 0 0
61 31566 1 0 0 0 0 0 0 0 0 0 0
62 30111 0 1 0 0 0 0 0 0 0 0 0
63 30019 0 0 1 0 0 0 0 0 0 0 0
64 31934 0 0 0 1 0 0 0 0 0 0 0
65 25826 0 0 0 0 1 0 0 0 0 0 0
66 26835 0 0 0 0 0 1 0 0 0 0 0
67 20205 0 0 0 0 0 0 1 0 0 0 0
68 17789 0 0 0 0 0 0 0 1 0 0 0
69 20520 0 0 0 0 0 0 0 0 1 0 0
70 22518 0 0 0 0 0 0 0 0 0 1 0
71 15572 0 0 0 0 0 0 0 0 0 0 1
72 11509 0 0 0 0 0 0 0 0 0 0 0
73 25447 1 0 0 0 0 0 0 0 0 0 0
74 24090 0 1 0 0 0 0 0 0 0 0 0
75 27786 0 0 1 0 0 0 0 0 0 0 0
76 26195 0 0 0 1 0 0 0 0 0 0 0
77 20516 0 0 0 0 1 0 0 0 0 0 0
78 22759 0 0 0 0 0 1 0 0 0 0 0
79 19028 0 0 0 0 0 0 1 0 0 0 0
80 16971 0 0 0 0 0 0 0 1 0 0 0
81 20036 0 0 0 0 0 0 0 0 1 0 0
82 22485 0 0 0 0 0 0 0 0 0 1 0
83 18730 0 0 0 0 0 0 0 0 0 0 1
84 14538 0 0 0 0 0 0 0 0 0 0 0
85 27561 1 0 0 0 0 0 0 0 0 0 0
86 25985 0 1 0 0 0 0 0 0 0 0 0
87 34670 0 0 1 0 0 0 0 0 0 0 0
88 32066 0 0 0 1 0 0 0 0 0 0 0
89 27186 0 0 0 0 1 0 0 0 0 0 0
90 29586 0 0 0 0 0 1 0 0 0 0 0
91 21359 0 0 0 0 0 0 1 0 0 0 0
92 21553 0 0 0 0 0 0 0 1 0 0 0
93 19573 0 0 0 0 0 0 0 0 1 0 0
94 24256 0 0 0 0 0 0 0 0 0 1 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) M1 M2 M3 M4 M5
12601 17017 14685 18978 15879 11505
M6 M7 M8 M9 M10 M11
12881 7005 5735 7346 10263 5521
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4170.5 -1627.2 -230.8 1660.0 4859.5
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 12600.7 814.6 15.469 < 2e-16 ***
M1 17016.8 1115.4 15.256 < 2e-16 ***
M2 14685.3 1115.4 13.165 < 2e-16 ***
M3 18977.8 1115.4 17.014 < 2e-16 ***
M4 15879.3 1115.4 14.236 < 2e-16 ***
M5 11504.9 1115.4 10.314 < 2e-16 ***
M6 12881.2 1115.4 11.548 < 2e-16 ***
M7 7005.0 1115.4 6.280 1.53e-08 ***
M8 5734.9 1115.4 5.141 1.82e-06 ***
M9 7345.8 1115.4 6.586 4.03e-09 ***
M10 10263.4 1115.4 9.201 2.86e-14 ***
M11 5520.7 1152.0 4.792 7.25e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2155 on 82 degrees of freedom
Multiple R-squared: 0.8739, Adjusted R-squared: 0.857
F-statistic: 51.66 on 11 and 82 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.926859778 0.14628044 0.07314022
[2,] 0.969866970 0.06026606 0.03013303
[3,] 0.943164729 0.11367054 0.05683527
[4,] 0.903745453 0.19250909 0.09625455
[5,] 0.901396220 0.19720756 0.09860378
[6,] 0.849893739 0.30021252 0.15010626
[7,] 0.784217022 0.43156596 0.21578298
[8,] 0.744546347 0.51090731 0.25545365
[9,] 0.679789440 0.64042112 0.32021056
[10,] 0.624731104 0.75053779 0.37526890
[11,] 0.537269294 0.92546141 0.46273071
[12,] 0.522215215 0.95556957 0.47778478
[13,] 0.582779988 0.83444002 0.41722001
[14,] 0.569136424 0.86172715 0.43086358
[15,] 0.511102937 0.97779413 0.48889706
[16,] 0.506440199 0.98711960 0.49355980
[17,] 0.467057897 0.93411579 0.53294210
[18,] 0.397848685 0.79569737 0.60215131
[19,] 0.331867024 0.66373405 0.66813298
[20,] 0.419718430 0.83943686 0.58028157
[21,] 0.350343457 0.70068691 0.64965654
[22,] 0.386705430 0.77341086 0.61329457
[23,] 0.382315351 0.76463070 0.61768465
[24,] 0.373728944 0.74745789 0.62627106
[25,] 0.410984375 0.82196875 0.58901563
[26,] 0.364007007 0.72801401 0.63599299
[27,] 0.424201267 0.84840253 0.57579873
[28,] 0.395162738 0.79032548 0.60483726
[29,] 0.354560300 0.70912060 0.64543970
[30,] 0.303839708 0.60767942 0.69616029
[31,] 0.281213847 0.56242769 0.71878615
[32,] 0.261693060 0.52338612 0.73830694
[33,] 0.215315238 0.43063048 0.78468476
[34,] 0.276823857 0.55364771 0.72317614
[35,] 0.257387141 0.51477428 0.74261286
[36,] 0.212815105 0.42563021 0.78718489
[37,] 0.177307961 0.35461592 0.82269204
[38,] 0.207765531 0.41553106 0.79223447
[39,] 0.171245630 0.34249126 0.82875437
[40,] 0.135226660 0.27045332 0.86477334
[41,] 0.106353233 0.21270647 0.89364677
[42,] 0.078940107 0.15788021 0.92105989
[43,] 0.057149676 0.11429935 0.94285032
[44,] 0.051300751 0.10260150 0.94869925
[45,] 0.045374838 0.09074968 0.95462516
[46,] 0.030966941 0.06193388 0.96903306
[47,] 0.043810186 0.08762037 0.95618981
[48,] 0.073413127 0.14682625 0.92658687
[49,] 0.058839724 0.11767945 0.94116028
[50,] 0.079180227 0.15836045 0.92081977
[51,] 0.066838868 0.13367774 0.93316113
[52,] 0.049645489 0.09929098 0.95035451
[53,] 0.033243431 0.06648686 0.96675657
[54,] 0.022727279 0.04545456 0.97727272
[55,] 0.014213454 0.02842691 0.98578655
[56,] 0.008506342 0.01701268 0.99149366
[57,] 0.008255744 0.01651149 0.99174426
[58,] 0.006244625 0.01248925 0.99375538
[59,] 0.007692826 0.01538565 0.99230717
[60,] 0.006433586 0.01286717 0.99356641
[61,] 0.022377977 0.04475595 0.97762202
[62,] 0.043373761 0.08674752 0.95662624
[63,] 0.143545352 0.28709070 0.85645465
[64,] 0.508753287 0.98249343 0.49124671
[65,] 0.435123011 0.87024602 0.56487699
> postscript(file="/var/www/html/rcomp/tmp/16hiq1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2hqic1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3hqic1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4hqic1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/590zw1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 94
Frequency = 1
1 2 3 4 5 6 7
1896.5000 -215.0000 -2116.5000 -2375.0000 -1708.6250 -1638.8750 2099.2500
8 9 10 11 12 13 14
-246.6250 817.5000 2451.8750 -417.4286 2947.2857 -1588.5000 2097.0000
15 16 17 18 19 20 21
4859.5000 3554.0000 -1426.6250 -1162.8750 -1601.7500 -798.6250 419.5000
22 23 24 25 26 27 28
-82.1250 1047.5714 1206.2857 125.5000 -1695.0000 -2482.5000 -1998.0000
29 30 31 32 33 34 35
-1700.6250 1562.1250 -1635.7500 394.3750 -262.5000 -3079.1250 357.5714
36 37 38 39 40 41 42
-1902.7143 2338.5000 2220.0000 2927.5000 -1315.0000 2630.3750 -1790.8750
43 44 45 46 47 48 49
-1448.7500 -1007.6250 -1741.5000 -1869.1250 -739.4286 -3233.7143 1506.5000
50 51 52 53 54 55 56
-735.0000 -927.5000 -2621.0000 994.3750 296.1250 812.2500 352.3750
57 58 59 60 61 62 63
477.5000 1911.8750 1692.5714 137.2857 1948.5000 2825.0000 -1559.5000
64 65 66 67 68 69 70
3454.0000 1720.3750 1353.1250 599.2500 -546.6250 573.5000 -346.1250
71 72 73 74 75 76 77
-2549.4286 -1091.7143 -4170.5000 -3196.0000 -3792.5000 -2285.0000 -3589.6250
78 79 80 81 82 83 84
-2722.8750 -577.7500 -1364.6250 89.5000 -379.1250 608.5714 1937.2857
85 86 87 88 89 90 91
-2056.5000 -1301.0000 3091.5000 3586.0000 3080.3750 4104.1250 1753.2500
92 93 94
3217.3750 -373.5000 1391.8750
> postscript(file="/var/www/html/rcomp/tmp/690zw1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 94
Frequency = 1
lag(myerror, k = 1) myerror
0 1896.5000 NA
1 -215.0000 1896.5000
2 -2116.5000 -215.0000
3 -2375.0000 -2116.5000
4 -1708.6250 -2375.0000
5 -1638.8750 -1708.6250
6 2099.2500 -1638.8750
7 -246.6250 2099.2500
8 817.5000 -246.6250
9 2451.8750 817.5000
10 -417.4286 2451.8750
11 2947.2857 -417.4286
12 -1588.5000 2947.2857
13 2097.0000 -1588.5000
14 4859.5000 2097.0000
15 3554.0000 4859.5000
16 -1426.6250 3554.0000
17 -1162.8750 -1426.6250
18 -1601.7500 -1162.8750
19 -798.6250 -1601.7500
20 419.5000 -798.6250
21 -82.1250 419.5000
22 1047.5714 -82.1250
23 1206.2857 1047.5714
24 125.5000 1206.2857
25 -1695.0000 125.5000
26 -2482.5000 -1695.0000
27 -1998.0000 -2482.5000
28 -1700.6250 -1998.0000
29 1562.1250 -1700.6250
30 -1635.7500 1562.1250
31 394.3750 -1635.7500
32 -262.5000 394.3750
33 -3079.1250 -262.5000
34 357.5714 -3079.1250
35 -1902.7143 357.5714
36 2338.5000 -1902.7143
37 2220.0000 2338.5000
38 2927.5000 2220.0000
39 -1315.0000 2927.5000
40 2630.3750 -1315.0000
41 -1790.8750 2630.3750
42 -1448.7500 -1790.8750
43 -1007.6250 -1448.7500
44 -1741.5000 -1007.6250
45 -1869.1250 -1741.5000
46 -739.4286 -1869.1250
47 -3233.7143 -739.4286
48 1506.5000 -3233.7143
49 -735.0000 1506.5000
50 -927.5000 -735.0000
51 -2621.0000 -927.5000
52 994.3750 -2621.0000
53 296.1250 994.3750
54 812.2500 296.1250
55 352.3750 812.2500
56 477.5000 352.3750
57 1911.8750 477.5000
58 1692.5714 1911.8750
59 137.2857 1692.5714
60 1948.5000 137.2857
61 2825.0000 1948.5000
62 -1559.5000 2825.0000
63 3454.0000 -1559.5000
64 1720.3750 3454.0000
65 1353.1250 1720.3750
66 599.2500 1353.1250
67 -546.6250 599.2500
68 573.5000 -546.6250
69 -346.1250 573.5000
70 -2549.4286 -346.1250
71 -1091.7143 -2549.4286
72 -4170.5000 -1091.7143
73 -3196.0000 -4170.5000
74 -3792.5000 -3196.0000
75 -2285.0000 -3792.5000
76 -3589.6250 -2285.0000
77 -2722.8750 -3589.6250
78 -577.7500 -2722.8750
79 -1364.6250 -577.7500
80 89.5000 -1364.6250
81 -379.1250 89.5000
82 608.5714 -379.1250
83 1937.2857 608.5714
84 -2056.5000 1937.2857
85 -1301.0000 -2056.5000
86 3091.5000 -1301.0000
87 3586.0000 3091.5000
88 3080.3750 3586.0000
89 4104.1250 3080.3750
90 1753.2500 4104.1250
91 3217.3750 1753.2500
92 -373.5000 3217.3750
93 1391.8750 -373.5000
94 NA 1391.8750
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -215.0000 1896.5000
[2,] -2116.5000 -215.0000
[3,] -2375.0000 -2116.5000
[4,] -1708.6250 -2375.0000
[5,] -1638.8750 -1708.6250
[6,] 2099.2500 -1638.8750
[7,] -246.6250 2099.2500
[8,] 817.5000 -246.6250
[9,] 2451.8750 817.5000
[10,] -417.4286 2451.8750
[11,] 2947.2857 -417.4286
[12,] -1588.5000 2947.2857
[13,] 2097.0000 -1588.5000
[14,] 4859.5000 2097.0000
[15,] 3554.0000 4859.5000
[16,] -1426.6250 3554.0000
[17,] -1162.8750 -1426.6250
[18,] -1601.7500 -1162.8750
[19,] -798.6250 -1601.7500
[20,] 419.5000 -798.6250
[21,] -82.1250 419.5000
[22,] 1047.5714 -82.1250
[23,] 1206.2857 1047.5714
[24,] 125.5000 1206.2857
[25,] -1695.0000 125.5000
[26,] -2482.5000 -1695.0000
[27,] -1998.0000 -2482.5000
[28,] -1700.6250 -1998.0000
[29,] 1562.1250 -1700.6250
[30,] -1635.7500 1562.1250
[31,] 394.3750 -1635.7500
[32,] -262.5000 394.3750
[33,] -3079.1250 -262.5000
[34,] 357.5714 -3079.1250
[35,] -1902.7143 357.5714
[36,] 2338.5000 -1902.7143
[37,] 2220.0000 2338.5000
[38,] 2927.5000 2220.0000
[39,] -1315.0000 2927.5000
[40,] 2630.3750 -1315.0000
[41,] -1790.8750 2630.3750
[42,] -1448.7500 -1790.8750
[43,] -1007.6250 -1448.7500
[44,] -1741.5000 -1007.6250
[45,] -1869.1250 -1741.5000
[46,] -739.4286 -1869.1250
[47,] -3233.7143 -739.4286
[48,] 1506.5000 -3233.7143
[49,] -735.0000 1506.5000
[50,] -927.5000 -735.0000
[51,] -2621.0000 -927.5000
[52,] 994.3750 -2621.0000
[53,] 296.1250 994.3750
[54,] 812.2500 296.1250
[55,] 352.3750 812.2500
[56,] 477.5000 352.3750
[57,] 1911.8750 477.5000
[58,] 1692.5714 1911.8750
[59,] 137.2857 1692.5714
[60,] 1948.5000 137.2857
[61,] 2825.0000 1948.5000
[62,] -1559.5000 2825.0000
[63,] 3454.0000 -1559.5000
[64,] 1720.3750 3454.0000
[65,] 1353.1250 1720.3750
[66,] 599.2500 1353.1250
[67,] -546.6250 599.2500
[68,] 573.5000 -546.6250
[69,] -346.1250 573.5000
[70,] -2549.4286 -346.1250
[71,] -1091.7143 -2549.4286
[72,] -4170.5000 -1091.7143
[73,] -3196.0000 -4170.5000
[74,] -3792.5000 -3196.0000
[75,] -2285.0000 -3792.5000
[76,] -3589.6250 -2285.0000
[77,] -2722.8750 -3589.6250
[78,] -577.7500 -2722.8750
[79,] -1364.6250 -577.7500
[80,] 89.5000 -1364.6250
[81,] -379.1250 89.5000
[82,] 608.5714 -379.1250
[83,] 1937.2857 608.5714
[84,] -2056.5000 1937.2857
[85,] -1301.0000 -2056.5000
[86,] 3091.5000 -1301.0000
[87,] 3586.0000 3091.5000
[88,] 3080.3750 3586.0000
[89,] 4104.1250 3080.3750
[90,] 1753.2500 4104.1250
[91,] 3217.3750 1753.2500
[92,] -373.5000 3217.3750
[93,] 1391.8750 -373.5000
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -215.0000 1896.5000
2 -2116.5000 -215.0000
3 -2375.0000 -2116.5000
4 -1708.6250 -2375.0000
5 -1638.8750 -1708.6250
6 2099.2500 -1638.8750
7 -246.6250 2099.2500
8 817.5000 -246.6250
9 2451.8750 817.5000
10 -417.4286 2451.8750
11 2947.2857 -417.4286
12 -1588.5000 2947.2857
13 2097.0000 -1588.5000
14 4859.5000 2097.0000
15 3554.0000 4859.5000
16 -1426.6250 3554.0000
17 -1162.8750 -1426.6250
18 -1601.7500 -1162.8750
19 -798.6250 -1601.7500
20 419.5000 -798.6250
21 -82.1250 419.5000
22 1047.5714 -82.1250
23 1206.2857 1047.5714
24 125.5000 1206.2857
25 -1695.0000 125.5000
26 -2482.5000 -1695.0000
27 -1998.0000 -2482.5000
28 -1700.6250 -1998.0000
29 1562.1250 -1700.6250
30 -1635.7500 1562.1250
31 394.3750 -1635.7500
32 -262.5000 394.3750
33 -3079.1250 -262.5000
34 357.5714 -3079.1250
35 -1902.7143 357.5714
36 2338.5000 -1902.7143
37 2220.0000 2338.5000
38 2927.5000 2220.0000
39 -1315.0000 2927.5000
40 2630.3750 -1315.0000
41 -1790.8750 2630.3750
42 -1448.7500 -1790.8750
43 -1007.6250 -1448.7500
44 -1741.5000 -1007.6250
45 -1869.1250 -1741.5000
46 -739.4286 -1869.1250
47 -3233.7143 -739.4286
48 1506.5000 -3233.7143
49 -735.0000 1506.5000
50 -927.5000 -735.0000
51 -2621.0000 -927.5000
52 994.3750 -2621.0000
53 296.1250 994.3750
54 812.2500 296.1250
55 352.3750 812.2500
56 477.5000 352.3750
57 1911.8750 477.5000
58 1692.5714 1911.8750
59 137.2857 1692.5714
60 1948.5000 137.2857
61 2825.0000 1948.5000
62 -1559.5000 2825.0000
63 3454.0000 -1559.5000
64 1720.3750 3454.0000
65 1353.1250 1720.3750
66 599.2500 1353.1250
67 -546.6250 599.2500
68 573.5000 -546.6250
69 -346.1250 573.5000
70 -2549.4286 -346.1250
71 -1091.7143 -2549.4286
72 -4170.5000 -1091.7143
73 -3196.0000 -4170.5000
74 -3792.5000 -3196.0000
75 -2285.0000 -3792.5000
76 -3589.6250 -2285.0000
77 -2722.8750 -3589.6250
78 -577.7500 -2722.8750
79 -1364.6250 -577.7500
80 89.5000 -1364.6250
81 -379.1250 89.5000
82 608.5714 -379.1250
83 1937.2857 608.5714
84 -2056.5000 1937.2857
85 -1301.0000 -2056.5000
86 3091.5000 -1301.0000
87 3586.0000 3091.5000
88 3080.3750 3586.0000
89 4104.1250 3080.3750
90 1753.2500 4104.1250
91 3217.3750 1753.2500
92 -373.5000 3217.3750
93 1391.8750 -373.5000
> 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/7k9g01292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8k9g01292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9d0gl1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10d0gl1292179981.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/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/11hjw81292179981.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/1221cw1292179981.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/13rks81292179981.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/14u3qe1292179981.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/15f3721292179981.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/16jm5q1292179981.tab")
+ }
>
> try(system("convert tmp/16hiq1292179981.ps tmp/16hiq1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/2hqic1292179981.ps tmp/2hqic1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/3hqic1292179981.ps tmp/3hqic1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/4hqic1292179981.ps tmp/4hqic1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/590zw1292179981.ps tmp/590zw1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/690zw1292179981.ps tmp/690zw1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/7k9g01292179981.ps tmp/7k9g01292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/8k9g01292179981.ps tmp/8k9g01292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/9d0gl1292179981.ps tmp/9d0gl1292179981.png",intern=TRUE))
character(0)
> try(system("convert tmp/10d0gl1292179981.ps tmp/10d0gl1292179981.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.963 1.685 6.979