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(631923
+ ,-12
+ ,-10.8
+ ,654294
+ ,-13
+ ,-12.2
+ ,671833
+ ,-16
+ ,-14.1
+ ,586840
+ ,-10
+ ,-15.2
+ ,600969
+ ,-4
+ ,-15.8
+ ,625568
+ ,-9
+ ,-15.8
+ ,558110
+ ,-8
+ ,-14.9
+ ,630577
+ ,-9
+ ,-12.6
+ ,628654
+ ,-3
+ ,-9.9
+ ,603184
+ ,-13
+ ,-7.8
+ ,656255
+ ,-3
+ ,-6
+ ,600730
+ ,-1
+ ,-5
+ ,670326
+ ,-2
+ ,-4.5
+ ,678423
+ ,0
+ ,-3.9
+ ,641502
+ ,0
+ ,-2.9
+ ,625311
+ ,-3
+ ,-1.5
+ ,628177
+ ,0
+ ,-0.5
+ ,589767
+ ,5
+ ,0
+ ,582471
+ ,3
+ ,0.5
+ ,636248
+ ,4
+ ,0.9
+ ,599885
+ ,3
+ ,0.8
+ ,621694
+ ,1
+ ,0.1
+ ,637406
+ ,-1
+ ,-1
+ ,595994
+ ,0
+ ,-2
+ ,696308
+ ,-2
+ ,-3
+ ,674201
+ ,-1
+ ,-3.7
+ ,648861
+ ,2
+ ,-4.7
+ ,649605
+ ,0
+ ,-6.4
+ ,672392
+ ,-6
+ ,-7.5
+ ,598396
+ ,-7
+ ,-7.8
+ ,613177
+ ,-6
+ ,-7.7
+ ,638104
+ ,-4
+ ,-6.6
+ ,615632
+ ,-9
+ ,-4.2
+ ,634465
+ ,-2
+ ,-2
+ ,638686
+ ,-3
+ ,-0.7
+ ,604243
+ ,2
+ ,0.1
+ ,706669
+ ,3
+ ,0.9
+ ,677185
+ ,1
+ ,2.1
+ ,644328
+ ,0
+ ,3.5
+ ,644825
+ ,1
+ ,4.9
+ ,605707
+ ,1
+ ,5.7
+ ,600136
+ ,3
+ ,6.2
+ ,612166
+ ,5
+ ,6.5
+ ,599659
+ ,5
+ ,6.5
+ ,634210
+ ,4
+ ,6.3
+ ,618234
+ ,11
+ ,6.2
+ ,613576
+ ,8
+ ,6.4
+ ,627200
+ ,-1
+ ,6.3
+ ,668973
+ ,4
+ ,5.8
+ ,651479
+ ,4
+ ,5.1
+ ,619661
+ ,4
+ ,5.1
+ ,644260
+ ,6
+ ,5.8
+ ,579936
+ ,6
+ ,6.7
+ ,601752
+ ,6
+ ,7.1
+ ,595376
+ ,6
+ ,6.7
+ ,588902
+ ,4
+ ,5.5
+ ,634341
+ ,1
+ ,4.2
+ ,594305
+ ,6
+ ,3
+ ,606200
+ ,0
+ ,2.2
+ ,610926
+ ,2
+ ,2
+ ,633685
+ ,-2
+ ,1.8
+ ,639696
+ ,0
+ ,1.8
+ ,659451
+ ,1
+ ,1.5
+ ,593248
+ ,-3
+ ,0.4
+ ,606677
+ ,-3
+ ,-0.9
+ ,599434
+ ,-5
+ ,-1.7
+ ,569578
+ ,-7
+ ,-2.6
+ ,629873
+ ,-7
+ ,-4.4
+ ,613438
+ ,-5
+ ,-8.3
+ ,604172
+ ,-13
+ ,-14.4
+ ,658328
+ ,-16
+ ,-21.3
+ ,612633
+ ,-20
+ ,-26.5
+ ,707372
+ ,-18
+ ,-29.2
+ ,739770
+ ,-21
+ ,-30.8
+ ,777535
+ ,-20
+ ,-30.9
+ ,685030
+ ,-16
+ ,-29.5
+ ,730234
+ ,-14
+ ,-27.1
+ ,714154
+ ,-12
+ ,-24.4
+ ,630872
+ ,-10
+ ,-21.9
+ ,719492
+ ,-3
+ ,-19.3
+ ,677023
+ ,-4
+ ,-17
+ ,679272
+ ,-4
+ ,-13.8
+ ,718317
+ ,-1
+ ,-9.9
+ ,645672
+ ,-8
+ ,-7.9)
+ ,dim=c(3
+ ,84)
+ ,dimnames=list(c('Y'
+ ,'X1'
+ ,'X2')
+ ,1:84))
> y <- array(NA,dim=c(3,84),dimnames=list(c('Y','X1','X2'),1:84))
> 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
Y X1 X2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 631923 -12 -10.8 1 0 0 0 0 0 0 0 0 0 0
2 654294 -13 -12.2 0 1 0 0 0 0 0 0 0 0 0
3 671833 -16 -14.1 0 0 1 0 0 0 0 0 0 0 0
4 586840 -10 -15.2 0 0 0 1 0 0 0 0 0 0 0
5 600969 -4 -15.8 0 0 0 0 1 0 0 0 0 0 0
6 625568 -9 -15.8 0 0 0 0 0 1 0 0 0 0 0
7 558110 -8 -14.9 0 0 0 0 0 0 1 0 0 0 0
8 630577 -9 -12.6 0 0 0 0 0 0 0 1 0 0 0
9 628654 -3 -9.9 0 0 0 0 0 0 0 0 1 0 0
10 603184 -13 -7.8 0 0 0 0 0 0 0 0 0 1 0
11 656255 -3 -6.0 0 0 0 0 0 0 0 0 0 0 1
12 600730 -1 -5.0 0 0 0 0 0 0 0 0 0 0 0
13 670326 -2 -4.5 1 0 0 0 0 0 0 0 0 0 0
14 678423 0 -3.9 0 1 0 0 0 0 0 0 0 0 0
15 641502 0 -2.9 0 0 1 0 0 0 0 0 0 0 0
16 625311 -3 -1.5 0 0 0 1 0 0 0 0 0 0 0
17 628177 0 -0.5 0 0 0 0 1 0 0 0 0 0 0
18 589767 5 0.0 0 0 0 0 0 1 0 0 0 0 0
19 582471 3 0.5 0 0 0 0 0 0 1 0 0 0 0
20 636248 4 0.9 0 0 0 0 0 0 0 1 0 0 0
21 599885 3 0.8 0 0 0 0 0 0 0 0 1 0 0
22 621694 1 0.1 0 0 0 0 0 0 0 0 0 1 0
23 637406 -1 -1.0 0 0 0 0 0 0 0 0 0 0 1
24 595994 0 -2.0 0 0 0 0 0 0 0 0 0 0 0
25 696308 -2 -3.0 1 0 0 0 0 0 0 0 0 0 0
26 674201 -1 -3.7 0 1 0 0 0 0 0 0 0 0 0
27 648861 2 -4.7 0 0 1 0 0 0 0 0 0 0 0
28 649605 0 -6.4 0 0 0 1 0 0 0 0 0 0 0
29 672392 -6 -7.5 0 0 0 0 1 0 0 0 0 0 0
30 598396 -7 -7.8 0 0 0 0 0 1 0 0 0 0 0
31 613177 -6 -7.7 0 0 0 0 0 0 1 0 0 0 0
32 638104 -4 -6.6 0 0 0 0 0 0 0 1 0 0 0
33 615632 -9 -4.2 0 0 0 0 0 0 0 0 1 0 0
34 634465 -2 -2.0 0 0 0 0 0 0 0 0 0 1 0
35 638686 -3 -0.7 0 0 0 0 0 0 0 0 0 0 1
36 604243 2 0.1 0 0 0 0 0 0 0 0 0 0 0
37 706669 3 0.9 1 0 0 0 0 0 0 0 0 0 0
38 677185 1 2.1 0 1 0 0 0 0 0 0 0 0 0
39 644328 0 3.5 0 0 1 0 0 0 0 0 0 0 0
40 644825 1 4.9 0 0 0 1 0 0 0 0 0 0 0
41 605707 1 5.7 0 0 0 0 1 0 0 0 0 0 0
42 600136 3 6.2 0 0 0 0 0 1 0 0 0 0 0
43 612166 5 6.5 0 0 0 0 0 0 1 0 0 0 0
44 599659 5 6.5 0 0 0 0 0 0 0 1 0 0 0
45 634210 4 6.3 0 0 0 0 0 0 0 0 1 0 0
46 618234 11 6.2 0 0 0 0 0 0 0 0 0 1 0
47 613576 8 6.4 0 0 0 0 0 0 0 0 0 0 1
48 627200 -1 6.3 0 0 0 0 0 0 0 0 0 0 0
49 668973 4 5.8 1 0 0 0 0 0 0 0 0 0 0
50 651479 4 5.1 0 1 0 0 0 0 0 0 0 0 0
51 619661 4 5.1 0 0 1 0 0 0 0 0 0 0 0
52 644260 6 5.8 0 0 0 1 0 0 0 0 0 0 0
53 579936 6 6.7 0 0 0 0 1 0 0 0 0 0 0
54 601752 6 7.1 0 0 0 0 0 1 0 0 0 0 0
55 595376 6 6.7 0 0 0 0 0 0 1 0 0 0 0
56 588902 4 5.5 0 0 0 0 0 0 0 1 0 0 0
57 634341 1 4.2 0 0 0 0 0 0 0 0 1 0 0
58 594305 6 3.0 0 0 0 0 0 0 0 0 0 1 0
59 606200 0 2.2 0 0 0 0 0 0 0 0 0 0 1
60 610926 2 2.0 0 0 0 0 0 0 0 0 0 0 0
61 633685 -2 1.8 1 0 0 0 0 0 0 0 0 0 0
62 639696 0 1.8 0 1 0 0 0 0 0 0 0 0 0
63 659451 1 1.5 0 0 1 0 0 0 0 0 0 0 0
64 593248 -3 0.4 0 0 0 1 0 0 0 0 0 0 0
65 606677 -3 -0.9 0 0 0 0 1 0 0 0 0 0 0
66 599434 -5 -1.7 0 0 0 0 0 1 0 0 0 0 0
67 569578 -7 -2.6 0 0 0 0 0 0 1 0 0 0 0
68 629873 -7 -4.4 0 0 0 0 0 0 0 1 0 0 0
69 613438 -5 -8.3 0 0 0 0 0 0 0 0 1 0 0
70 604172 -13 -14.4 0 0 0 0 0 0 0 0 0 1 0
71 658328 -16 -21.3 0 0 0 0 0 0 0 0 0 0 1
72 612633 -20 -26.5 0 0 0 0 0 0 0 0 0 0 0
73 707372 -18 -29.2 1 0 0 0 0 0 0 0 0 0 0
74 739770 -21 -30.8 0 1 0 0 0 0 0 0 0 0 0
75 777535 -20 -30.9 0 0 1 0 0 0 0 0 0 0 0
76 685030 -16 -29.5 0 0 0 1 0 0 0 0 0 0 0
77 730234 -14 -27.1 0 0 0 0 1 0 0 0 0 0 0
78 714154 -12 -24.4 0 0 0 0 0 1 0 0 0 0 0
79 630872 -10 -21.9 0 0 0 0 0 0 1 0 0 0 0
80 719492 -3 -19.3 0 0 0 0 0 0 0 1 0 0 0
81 677023 -4 -17.0 0 0 0 0 0 0 0 0 1 0 0
82 679272 -4 -13.8 0 0 0 0 0 0 0 0 0 1 0
83 718317 -1 -9.9 0 0 0 0 0 0 0 0 0 0 1
84 645672 -8 -7.9 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X1 X2 M1 M2 M3
606667.763 2747.688 -3701.926 57698.501 56686.313 48406.824
M4 M5 M6 M7 M8 M9
13929.564 12359.364 -1.623 -23122.566 16085.681 12600.642
M10 M11
5839.146 30555.474
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-65557.80 -18184.12 55.26 15718.64 63024.67
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 606667.763 10718.250 56.601 < 2e-16 ***
X1 2747.688 953.001 2.883 0.005225 **
X2 -3701.926 657.891 -5.627 3.52e-07 ***
M1 57698.501 14984.643 3.851 0.000258 ***
M2 56686.313 14987.723 3.782 0.000324 ***
M3 48406.824 14992.668 3.229 0.001894 **
M4 13929.564 15010.453 0.928 0.356601
M5 12359.364 15045.451 0.821 0.414169
M6 -1.623 15033.796 -0.000108 0.999914
M7 -23122.566 15034.905 -1.538 0.128575
M8 16085.681 15106.202 1.065 0.290608
M9 12600.642 15045.284 0.838 0.405154
M10 5839.146 15037.401 0.388 0.698966
M11 30555.474 15025.580 2.034 0.045788 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 28030 on 70 degrees of freedom
Multiple R-squared: 0.6153, Adjusted R-squared: 0.5438
F-statistic: 8.611 on 13 and 70 DF, p-value: 4.037e-10
> 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.50800251 0.98399497 0.49199749
[2,] 0.63164058 0.73671885 0.36835942
[3,] 0.50716174 0.98567653 0.49283826
[4,] 0.37230889 0.74461777 0.62769111
[5,] 0.39817774 0.79635549 0.60182226
[6,] 0.32241523 0.64483047 0.67758477
[7,] 0.26027919 0.52055837 0.73972081
[8,] 0.19161271 0.38322541 0.80838729
[9,] 0.26404303 0.52808606 0.73595697
[10,] 0.19127614 0.38255229 0.80872386
[11,] 0.16289790 0.32579580 0.83710210
[12,] 0.20762983 0.41525966 0.79237017
[13,] 0.37429989 0.74859977 0.62570011
[14,] 0.32478518 0.64957035 0.67521482
[15,] 0.35224679 0.70449358 0.64775321
[16,] 0.27879789 0.55759578 0.72120211
[17,] 0.21535748 0.43071496 0.78464252
[18,] 0.19991151 0.39982301 0.80008849
[19,] 0.15843453 0.31686907 0.84156547
[20,] 0.12594890 0.25189779 0.87405110
[21,] 0.15324049 0.30648097 0.84675951
[22,] 0.11796454 0.23592908 0.88203546
[23,] 0.09274324 0.18548648 0.90725676
[24,] 0.09325275 0.18650550 0.90674725
[25,] 0.09817627 0.19635253 0.90182373
[26,] 0.07084448 0.14168895 0.92915552
[27,] 0.07103278 0.14206557 0.92896722
[28,] 0.07898722 0.15797443 0.92101278
[29,] 0.07046176 0.14092353 0.92953824
[30,] 0.04910784 0.09821568 0.95089216
[31,] 0.05205341 0.10410682 0.94794659
[32,] 0.08841390 0.17682780 0.91158610
[33,] 0.08410755 0.16821510 0.91589245
[34,] 0.06535635 0.13071270 0.93464365
[35,] 0.10911366 0.21822733 0.89088634
[36,] 0.11766706 0.23533412 0.88233294
[37,] 0.19237526 0.38475051 0.80762474
[38,] 0.15078413 0.30156826 0.84921587
[39,] 0.12716663 0.25433327 0.87283337
[40,] 0.14790814 0.29581627 0.85209186
[41,] 0.24880544 0.49761088 0.75119456
[42,] 0.24228063 0.48456126 0.75771937
[43,] 0.23173976 0.46347952 0.76826024
[44,] 0.16564161 0.33128321 0.83435839
[45,] 0.15120450 0.30240900 0.84879550
[46,] 0.13559023 0.27118046 0.86440977
[47,] 0.29080969 0.58161938 0.70919031
[48,] 0.22906926 0.45813852 0.77093074
[49,] 0.46513931 0.93027861 0.53486069
[50,] 0.93351537 0.13296925 0.06648463
[51,] 0.84574778 0.30850443 0.15425222
> postscript(file="/var/www/html/rcomp/tmp/1vwte1292941789.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/2o5sh1292941789.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/3o5sh1292941789.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/4o5sh1292941789.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/5hw911292941789.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 = 84
Frequency = 1
1 2 3 4 5 6
-39451.8058 -18503.6253 8524.2685 -62549.7162 -65557.7996 -14859.3727
7 8 9 10 11 12
-58612.3849 -14091.5156 -19020.4043 -2477.9861 5063.2729 -21699.7031
13 14 15 16 17 18
-5203.5538 631.4140 -24308.1717 7403.8487 7298.9100 -30637.5795
19 20 21 22 23 24
-7466.2982 5835.5368 -24664.9282 6809.5951 -771.4751 -18077.6143
25 26 27 28 29 30
26331.3345 -102.5129 -29108.0135 5315.3497 42086.5584 -17911.3440
31 32 33 34 35 36
17613.1034 1908.5983 5544.6989 20049.6151 7114.4784 -7549.9464
37 38 39 40 41 42
37391.4047 18857.2796 2210.1520 39619.4207 5033.1606 8178.7349
43 44 45 46 47 48
38944.8794 -12770.3679 27272.9745 -1545.5381 -21936.4170 46602.0559
49 50 51 52 53 54
15087.1521 -3986.0075 -27524.5188 28647.7142 -30774.3534 4883.4041
55 56 57 58 59 60
20147.5766 -24481.6056 27872.9946 -23582.2603 -22879.0011 6166.7122
61 62 63 64 65 66
-18522.4227 -16994.6102 7181.6129 -17625.4927 -7438.7965 213.0262
67 68 69 70 71 72
-4358.3883 10064.8983 -22817.9476 -25922.6949 -13783.2455 -37182.0325
73 74 75 76 77 78
-15632.1088 20098.0623 63024.6706 -811.1244 49352.3206 50133.1311
79 80 81 82 83 84
-6268.4881 33534.4557 5812.6120 26669.2692 47192.3874 31740.5282
> postscript(file="/var/www/html/rcomp/tmp/6hw911292941789.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 = 84
Frequency = 1
lag(myerror, k = 1) myerror
0 -39451.8058 NA
1 -18503.6253 -39451.8058
2 8524.2685 -18503.6253
3 -62549.7162 8524.2685
4 -65557.7996 -62549.7162
5 -14859.3727 -65557.7996
6 -58612.3849 -14859.3727
7 -14091.5156 -58612.3849
8 -19020.4043 -14091.5156
9 -2477.9861 -19020.4043
10 5063.2729 -2477.9861
11 -21699.7031 5063.2729
12 -5203.5538 -21699.7031
13 631.4140 -5203.5538
14 -24308.1717 631.4140
15 7403.8487 -24308.1717
16 7298.9100 7403.8487
17 -30637.5795 7298.9100
18 -7466.2982 -30637.5795
19 5835.5368 -7466.2982
20 -24664.9282 5835.5368
21 6809.5951 -24664.9282
22 -771.4751 6809.5951
23 -18077.6143 -771.4751
24 26331.3345 -18077.6143
25 -102.5129 26331.3345
26 -29108.0135 -102.5129
27 5315.3497 -29108.0135
28 42086.5584 5315.3497
29 -17911.3440 42086.5584
30 17613.1034 -17911.3440
31 1908.5983 17613.1034
32 5544.6989 1908.5983
33 20049.6151 5544.6989
34 7114.4784 20049.6151
35 -7549.9464 7114.4784
36 37391.4047 -7549.9464
37 18857.2796 37391.4047
38 2210.1520 18857.2796
39 39619.4207 2210.1520
40 5033.1606 39619.4207
41 8178.7349 5033.1606
42 38944.8794 8178.7349
43 -12770.3679 38944.8794
44 27272.9745 -12770.3679
45 -1545.5381 27272.9745
46 -21936.4170 -1545.5381
47 46602.0559 -21936.4170
48 15087.1521 46602.0559
49 -3986.0075 15087.1521
50 -27524.5188 -3986.0075
51 28647.7142 -27524.5188
52 -30774.3534 28647.7142
53 4883.4041 -30774.3534
54 20147.5766 4883.4041
55 -24481.6056 20147.5766
56 27872.9946 -24481.6056
57 -23582.2603 27872.9946
58 -22879.0011 -23582.2603
59 6166.7122 -22879.0011
60 -18522.4227 6166.7122
61 -16994.6102 -18522.4227
62 7181.6129 -16994.6102
63 -17625.4927 7181.6129
64 -7438.7965 -17625.4927
65 213.0262 -7438.7965
66 -4358.3883 213.0262
67 10064.8983 -4358.3883
68 -22817.9476 10064.8983
69 -25922.6949 -22817.9476
70 -13783.2455 -25922.6949
71 -37182.0325 -13783.2455
72 -15632.1088 -37182.0325
73 20098.0623 -15632.1088
74 63024.6706 20098.0623
75 -811.1244 63024.6706
76 49352.3206 -811.1244
77 50133.1311 49352.3206
78 -6268.4881 50133.1311
79 33534.4557 -6268.4881
80 5812.6120 33534.4557
81 26669.2692 5812.6120
82 47192.3874 26669.2692
83 31740.5282 47192.3874
84 NA 31740.5282
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -18503.6253 -39451.8058
[2,] 8524.2685 -18503.6253
[3,] -62549.7162 8524.2685
[4,] -65557.7996 -62549.7162
[5,] -14859.3727 -65557.7996
[6,] -58612.3849 -14859.3727
[7,] -14091.5156 -58612.3849
[8,] -19020.4043 -14091.5156
[9,] -2477.9861 -19020.4043
[10,] 5063.2729 -2477.9861
[11,] -21699.7031 5063.2729
[12,] -5203.5538 -21699.7031
[13,] 631.4140 -5203.5538
[14,] -24308.1717 631.4140
[15,] 7403.8487 -24308.1717
[16,] 7298.9100 7403.8487
[17,] -30637.5795 7298.9100
[18,] -7466.2982 -30637.5795
[19,] 5835.5368 -7466.2982
[20,] -24664.9282 5835.5368
[21,] 6809.5951 -24664.9282
[22,] -771.4751 6809.5951
[23,] -18077.6143 -771.4751
[24,] 26331.3345 -18077.6143
[25,] -102.5129 26331.3345
[26,] -29108.0135 -102.5129
[27,] 5315.3497 -29108.0135
[28,] 42086.5584 5315.3497
[29,] -17911.3440 42086.5584
[30,] 17613.1034 -17911.3440
[31,] 1908.5983 17613.1034
[32,] 5544.6989 1908.5983
[33,] 20049.6151 5544.6989
[34,] 7114.4784 20049.6151
[35,] -7549.9464 7114.4784
[36,] 37391.4047 -7549.9464
[37,] 18857.2796 37391.4047
[38,] 2210.1520 18857.2796
[39,] 39619.4207 2210.1520
[40,] 5033.1606 39619.4207
[41,] 8178.7349 5033.1606
[42,] 38944.8794 8178.7349
[43,] -12770.3679 38944.8794
[44,] 27272.9745 -12770.3679
[45,] -1545.5381 27272.9745
[46,] -21936.4170 -1545.5381
[47,] 46602.0559 -21936.4170
[48,] 15087.1521 46602.0559
[49,] -3986.0075 15087.1521
[50,] -27524.5188 -3986.0075
[51,] 28647.7142 -27524.5188
[52,] -30774.3534 28647.7142
[53,] 4883.4041 -30774.3534
[54,] 20147.5766 4883.4041
[55,] -24481.6056 20147.5766
[56,] 27872.9946 -24481.6056
[57,] -23582.2603 27872.9946
[58,] -22879.0011 -23582.2603
[59,] 6166.7122 -22879.0011
[60,] -18522.4227 6166.7122
[61,] -16994.6102 -18522.4227
[62,] 7181.6129 -16994.6102
[63,] -17625.4927 7181.6129
[64,] -7438.7965 -17625.4927
[65,] 213.0262 -7438.7965
[66,] -4358.3883 213.0262
[67,] 10064.8983 -4358.3883
[68,] -22817.9476 10064.8983
[69,] -25922.6949 -22817.9476
[70,] -13783.2455 -25922.6949
[71,] -37182.0325 -13783.2455
[72,] -15632.1088 -37182.0325
[73,] 20098.0623 -15632.1088
[74,] 63024.6706 20098.0623
[75,] -811.1244 63024.6706
[76,] 49352.3206 -811.1244
[77,] 50133.1311 49352.3206
[78,] -6268.4881 50133.1311
[79,] 33534.4557 -6268.4881
[80,] 5812.6120 33534.4557
[81,] 26669.2692 5812.6120
[82,] 47192.3874 26669.2692
[83,] 31740.5282 47192.3874
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -18503.6253 -39451.8058
2 8524.2685 -18503.6253
3 -62549.7162 8524.2685
4 -65557.7996 -62549.7162
5 -14859.3727 -65557.7996
6 -58612.3849 -14859.3727
7 -14091.5156 -58612.3849
8 -19020.4043 -14091.5156
9 -2477.9861 -19020.4043
10 5063.2729 -2477.9861
11 -21699.7031 5063.2729
12 -5203.5538 -21699.7031
13 631.4140 -5203.5538
14 -24308.1717 631.4140
15 7403.8487 -24308.1717
16 7298.9100 7403.8487
17 -30637.5795 7298.9100
18 -7466.2982 -30637.5795
19 5835.5368 -7466.2982
20 -24664.9282 5835.5368
21 6809.5951 -24664.9282
22 -771.4751 6809.5951
23 -18077.6143 -771.4751
24 26331.3345 -18077.6143
25 -102.5129 26331.3345
26 -29108.0135 -102.5129
27 5315.3497 -29108.0135
28 42086.5584 5315.3497
29 -17911.3440 42086.5584
30 17613.1034 -17911.3440
31 1908.5983 17613.1034
32 5544.6989 1908.5983
33 20049.6151 5544.6989
34 7114.4784 20049.6151
35 -7549.9464 7114.4784
36 37391.4047 -7549.9464
37 18857.2796 37391.4047
38 2210.1520 18857.2796
39 39619.4207 2210.1520
40 5033.1606 39619.4207
41 8178.7349 5033.1606
42 38944.8794 8178.7349
43 -12770.3679 38944.8794
44 27272.9745 -12770.3679
45 -1545.5381 27272.9745
46 -21936.4170 -1545.5381
47 46602.0559 -21936.4170
48 15087.1521 46602.0559
49 -3986.0075 15087.1521
50 -27524.5188 -3986.0075
51 28647.7142 -27524.5188
52 -30774.3534 28647.7142
53 4883.4041 -30774.3534
54 20147.5766 4883.4041
55 -24481.6056 20147.5766
56 27872.9946 -24481.6056
57 -23582.2603 27872.9946
58 -22879.0011 -23582.2603
59 6166.7122 -22879.0011
60 -18522.4227 6166.7122
61 -16994.6102 -18522.4227
62 7181.6129 -16994.6102
63 -17625.4927 7181.6129
64 -7438.7965 -17625.4927
65 213.0262 -7438.7965
66 -4358.3883 213.0262
67 10064.8983 -4358.3883
68 -22817.9476 10064.8983
69 -25922.6949 -22817.9476
70 -13783.2455 -25922.6949
71 -37182.0325 -13783.2455
72 -15632.1088 -37182.0325
73 20098.0623 -15632.1088
74 63024.6706 20098.0623
75 -811.1244 63024.6706
76 49352.3206 -811.1244
77 50133.1311 49352.3206
78 -6268.4881 50133.1311
79 33534.4557 -6268.4881
80 5812.6120 33534.4557
81 26669.2692 5812.6120
82 47192.3874 26669.2692
83 31740.5282 47192.3874
> 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/7s5r41292941789.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/8s5r41292941789.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/92x871292941789.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/102x871292941789.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/11ofov1292941789.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/129g511292941789.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/13npka1292941789.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/14r81g1292941789.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/15uqi41292941789.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/16fryr1292941789.tab")
+ }
>
> try(system("convert tmp/1vwte1292941789.ps tmp/1vwte1292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/2o5sh1292941789.ps tmp/2o5sh1292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/3o5sh1292941789.ps tmp/3o5sh1292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/4o5sh1292941789.ps tmp/4o5sh1292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/5hw911292941789.ps tmp/5hw911292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/6hw911292941789.ps tmp/6hw911292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/7s5r41292941789.ps tmp/7s5r41292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/8s5r41292941789.ps tmp/8s5r41292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/92x871292941789.ps tmp/92x871292941789.png",intern=TRUE))
character(0)
> try(system("convert tmp/102x871292941789.ps tmp/102x871292941789.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.796 1.697 9.128