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(6.70
+ ,2.04
+ ,6.40
+ ,2.16
+ ,6.30
+ ,2.75
+ ,6.80
+ ,2.79
+ ,7.30
+ ,2.88
+ ,7.10
+ ,3.36
+ ,7.00
+ ,2.97
+ ,6.80
+ ,3.10
+ ,6.60
+ ,2.49
+ ,6.30
+ ,2.20
+ ,6.10
+ ,2.25
+ ,6.10
+ ,2.09
+ ,6.30
+ ,2.79
+ ,6.30
+ ,3.14
+ ,6.00
+ ,2.93
+ ,6.20
+ ,2.65
+ ,6.40
+ ,2.67
+ ,6.80
+ ,2.26
+ ,7.50
+ ,2.35
+ ,7.50
+ ,2.13
+ ,7.60
+ ,2.18
+ ,7.60
+ ,2.90
+ ,7.40
+ ,2.63
+ ,7.30
+ ,2.67
+ ,7.10
+ ,1.81
+ ,6.90
+ ,1.33
+ ,6.80
+ ,0.88
+ ,7.50
+ ,1.28
+ ,7.60
+ ,1.26
+ ,7.80
+ ,1.26
+ ,8.00
+ ,1.29
+ ,8.10
+ ,1.10
+ ,8.20
+ ,1.37
+ ,8.30
+ ,1.21
+ ,8.20
+ ,1.74
+ ,8.00
+ ,1.76
+ ,7.90
+ ,1.48
+ ,7.60
+ ,1.04
+ ,7.60
+ ,1.62
+ ,8.30
+ ,1.49
+ ,8.40
+ ,1.79
+ ,8.40
+ ,1.80
+ ,8.40
+ ,1.58
+ ,8.40
+ ,1.86
+ ,8.60
+ ,1.74
+ ,8.90
+ ,1.59
+ ,8.80
+ ,1.26
+ ,8.30
+ ,1.13
+ ,7.50
+ ,1.92
+ ,7.20
+ ,2.61
+ ,7.40
+ ,2.26
+ ,8.80
+ ,2.41
+ ,9.30
+ ,2.26
+ ,9.30
+ ,2.03
+ ,8.70
+ ,2.86
+ ,8.20
+ ,2.55
+ ,8.30
+ ,2.27
+ ,8.50
+ ,2.26
+ ,8.60
+ ,2.57
+ ,8.50
+ ,3.07
+ ,8.20
+ ,2.76
+ ,8.10
+ ,2.51
+ ,7.90
+ ,2.87
+ ,8.60
+ ,3.14
+ ,8.70
+ ,3.11
+ ,8.70
+ ,3.16
+ ,8.50
+ ,2.47
+ ,8.40
+ ,2.57
+ ,8.50
+ ,2.89
+ ,8.70
+ ,2.63
+ ,8.70
+ ,2.38
+ ,8.60
+ ,1.69
+ ,8.50
+ ,1.96
+ ,8.30
+ ,2.19
+ ,8.00
+ ,1.87
+ ,8.20
+ ,1.60
+ ,8.10
+ ,1.63
+ ,8.10
+ ,1.22
+ ,8.00
+ ,1.21
+ ,7.90
+ ,1.49
+ ,7.90
+ ,1.64
+ ,8.00
+ ,1.66
+ ,8.00
+ ,1.77
+ ,7.90
+ ,1.82
+ ,8.00
+ ,1.78
+ ,7.70
+ ,1.28
+ ,7.20
+ ,1.29
+ ,7.50
+ ,1.37
+ ,7.30
+ ,1.12
+ ,7.00
+ ,1.51
+ ,7.00
+ ,2.24
+ ,7.00
+ ,2.94
+ ,7.20
+ ,3.09
+ ,7.30
+ ,3.46
+ ,7.10
+ ,3.64
+ ,6.80
+ ,4.39
+ ,6.40
+ ,4.15
+ ,6.10
+ ,5.21
+ ,6.50
+ ,5.80
+ ,7.70
+ ,5.91
+ ,7.90
+ ,5.39
+ ,7.50
+ ,5.46
+ ,6.90
+ ,4.72
+ ,6.60
+ ,3.14
+ ,6.90
+ ,2.63
+ ,7.70
+ ,2.32
+ ,8.00
+ ,1.93
+ ,8.00
+ ,0.62)
+ ,dim=c(2
+ ,108)
+ ,dimnames=list(c('Y'
+ ,'X')
+ ,1:108))
> y <- array(NA,dim=c(2,108),dimnames=list(c('Y','X'),1:108))
> 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 6.7 2.04
2 6.4 2.16
3 6.3 2.75
4 6.8 2.79
5 7.3 2.88
6 7.1 3.36
7 7.0 2.97
8 6.8 3.10
9 6.6 2.49
10 6.3 2.20
11 6.1 2.25
12 6.1 2.09
13 6.3 2.79
14 6.3 3.14
15 6.0 2.93
16 6.2 2.65
17 6.4 2.67
18 6.8 2.26
19 7.5 2.35
20 7.5 2.13
21 7.6 2.18
22 7.6 2.90
23 7.4 2.63
24 7.3 2.67
25 7.1 1.81
26 6.9 1.33
27 6.8 0.88
28 7.5 1.28
29 7.6 1.26
30 7.8 1.26
31 8.0 1.29
32 8.1 1.10
33 8.2 1.37
34 8.3 1.21
35 8.2 1.74
36 8.0 1.76
37 7.9 1.48
38 7.6 1.04
39 7.6 1.62
40 8.3 1.49
41 8.4 1.79
42 8.4 1.80
43 8.4 1.58
44 8.4 1.86
45 8.6 1.74
46 8.9 1.59
47 8.8 1.26
48 8.3 1.13
49 7.5 1.92
50 7.2 2.61
51 7.4 2.26
52 8.8 2.41
53 9.3 2.26
54 9.3 2.03
55 8.7 2.86
56 8.2 2.55
57 8.3 2.27
58 8.5 2.26
59 8.6 2.57
60 8.5 3.07
61 8.2 2.76
62 8.1 2.51
63 7.9 2.87
64 8.6 3.14
65 8.7 3.11
66 8.7 3.16
67 8.5 2.47
68 8.4 2.57
69 8.5 2.89
70 8.7 2.63
71 8.7 2.38
72 8.6 1.69
73 8.5 1.96
74 8.3 2.19
75 8.0 1.87
76 8.2 1.60
77 8.1 1.63
78 8.1 1.22
79 8.0 1.21
80 7.9 1.49
81 7.9 1.64
82 8.0 1.66
83 8.0 1.77
84 7.9 1.82
85 8.0 1.78
86 7.7 1.28
87 7.2 1.29
88 7.5 1.37
89 7.3 1.12
90 7.0 1.51
91 7.0 2.24
92 7.0 2.94
93 7.2 3.09
94 7.3 3.46
95 7.1 3.64
96 6.8 4.39
97 6.4 4.15
98 6.1 5.21
99 6.5 5.80
100 7.7 5.91
101 7.9 5.39
102 7.5 5.46
103 6.9 4.72
104 6.6 3.14
105 6.9 2.63
106 7.7 2.32
107 8.0 1.93
108 8.0 0.62
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X
8.1972 -0.2313
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.61374 -0.51192 0.04633 0.61126 1.62559
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.19716 0.18384 44.588 < 2e-16 ***
X -0.23130 0.07163 -3.229 0.00165 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.769 on 106 degrees of freedom
Multiple R-squared: 0.08956, Adjusted R-squared: 0.08098
F-statistic: 10.43 on 1 and 106 DF, p-value: 0.001653
> 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.173958539 0.3479170774 0.8260414613
[2,] 0.074991307 0.1499826150 0.9250086925
[3,] 0.030522568 0.0610451365 0.9694774318
[4,] 0.012972122 0.0259442446 0.9870278777
[5,] 0.004990430 0.0099808605 0.9950095697
[6,] 0.002544643 0.0050892864 0.9974553568
[7,] 0.002441792 0.0048835838 0.9975582081
[8,] 0.001511379 0.0030227571 0.9984886214
[9,] 0.001801363 0.0036027261 0.9981986370
[10,] 0.003504685 0.0070093699 0.9964953150
[11,] 0.009857567 0.0197151346 0.9901424327
[12,] 0.009165825 0.0183316503 0.9908341749
[13,] 0.006501598 0.0130031961 0.9934984019
[14,] 0.006762084 0.0135241687 0.9932379157
[15,] 0.034668202 0.0693364035 0.9653317982
[16,] 0.080206696 0.1604133922 0.9197933039
[17,] 0.136213068 0.2724261367 0.8637869317
[18,] 0.186545734 0.3730914687 0.8134542657
[19,] 0.194163944 0.3883278885 0.8058360558
[20,] 0.185042361 0.3700847215 0.8149576393
[21,] 0.168810397 0.3376207944 0.8311896028
[22,] 0.157279822 0.3145596439 0.8427201780
[23,] 0.161348129 0.3226962575 0.8386518713
[24,] 0.170546480 0.3410929597 0.8294535202
[25,] 0.175516556 0.3510331126 0.8244834437
[26,] 0.188373212 0.3767464241 0.8116267880
[27,] 0.213494773 0.4269895470 0.7865052265
[28,] 0.226223565 0.4524471306 0.7737764347
[29,] 0.255692524 0.5113850471 0.7443074765
[30,] 0.274747886 0.5494957727 0.7252521136
[31,] 0.309535338 0.6190706759 0.6904646620
[32,] 0.305604554 0.6112091080 0.6943954460
[33,] 0.274173855 0.5483477095 0.7258261452
[34,] 0.244863326 0.4897266523 0.7551366739
[35,] 0.214379306 0.4287586119 0.7856206940
[36,] 0.222194569 0.4443891376 0.7778054312
[37,] 0.265651703 0.5313034062 0.7343482969
[38,] 0.303319065 0.6066381307 0.6966809346
[39,] 0.312747660 0.6254953201 0.6872523399
[40,] 0.343376100 0.6867522006 0.6566238997
[41,] 0.393037425 0.7860748495 0.6069625752
[42,] 0.485763953 0.9715279067 0.5142360467
[43,] 0.505595558 0.9888088847 0.4944044424
[44,] 0.454748676 0.9094973525 0.5452513238
[45,] 0.414136030 0.8282720591 0.5858639704
[46,] 0.388640498 0.7772809954 0.6113595023
[47,] 0.355061001 0.7101220012 0.6449389994
[48,] 0.520665538 0.9586689244 0.4793344622
[49,] 0.778543336 0.4429133283 0.2214566641
[50,] 0.907331605 0.1853367903 0.0926683951
[51,] 0.951862211 0.0962755776 0.0481377888
[52,] 0.950247064 0.0995058720 0.0497529360
[53,] 0.947157127 0.1056857452 0.0528428726
[54,] 0.951391314 0.0972173712 0.0486086856
[55,] 0.963891643 0.0722167146 0.0361083573
[56,] 0.975274787 0.0494504267 0.0247252134
[57,] 0.973641820 0.0527163607 0.0263581803
[58,] 0.968107864 0.0637842713 0.0318921357
[59,] 0.960006205 0.0799875903 0.0399937952
[60,] 0.974297308 0.0514053844 0.0257026922
[61,] 0.986059906 0.0278801886 0.0139400943
[62,] 0.993155259 0.0136894820 0.0068447410
[63,] 0.994204220 0.0115915595 0.0057957797
[64,] 0.994675447 0.0106491051 0.0053245526
[65,] 0.996392095 0.0072158108 0.0036079054
[66,] 0.998337045 0.0033259092 0.0016629546
[67,] 0.999268492 0.0014630167 0.0007315084
[68,] 0.999494682 0.0010106355 0.0005053178
[69,] 0.999656606 0.0006867880 0.0003433940
[70,] 0.999701881 0.0005962384 0.0002981192
[71,] 0.999553393 0.0008932150 0.0004466075
[72,] 0.999463255 0.0010734895 0.0005367448
[73,] 0.999288527 0.0014229454 0.0007114727
[74,] 0.998998732 0.0020025362 0.0010012681
[75,] 0.998487617 0.0030247661 0.0015123830
[76,] 0.997679369 0.0046412623 0.0023206312
[77,] 0.996610982 0.0067780361 0.0033890181
[78,] 0.995723289 0.0085534227 0.0042767114
[79,] 0.994966840 0.0100663196 0.0050331598
[80,] 0.993636296 0.0127274080 0.0063637040
[81,] 0.993383866 0.0132322676 0.0066161338
[82,] 0.990155584 0.0196888316 0.0098444158
[83,] 0.985019131 0.0299617383 0.0149808692
[84,] 0.976378979 0.0472420420 0.0236210210
[85,] 0.963982207 0.0720355860 0.0360177930
[86,] 0.953765471 0.0924690574 0.0462345287
[87,] 0.938176761 0.1236464778 0.0618232389
[88,] 0.914049256 0.1719014877 0.0859507439
[89,] 0.873986330 0.2520273404 0.1260136702
[90,] 0.820047393 0.3599052147 0.1799526074
[91,] 0.752667982 0.4946640352 0.2473320176
[92,] 0.684523704 0.6309525918 0.3154762959
[93,] 0.697659617 0.6046807656 0.3023403828
[94,] 0.796224620 0.4075507594 0.2037753797
[95,] 0.815476862 0.3690462766 0.1845231383
[96,] 0.759599408 0.4808011844 0.2404005922
[97,] 0.792512838 0.4149743234 0.2074871617
[98,] 0.851458114 0.2970837720 0.1485418860
[99,] 0.820319292 0.3593614166 0.1796807083
> postscript(file="/var/www/html/rcomp/tmp/1kfiu1258483701.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/2m0kj1258483701.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/3yopu1258483701.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/4fg601258483701.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/5i1v61258483701.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 = 108
Frequency = 1
1 2 3 4 5 6
-1.02530094 -1.29754443 -1.26107491 -0.75182274 -0.23100536 -0.31997931
7 8 9 10 11 12
-0.51018797 -0.68011842 -1.02121402 -1.38829226 -1.57672705 -1.61373573
13 14 15 16 17 18
-1.25182274 -1.17086625 -1.51944014 -1.38420534 -1.17957925 -0.87441400
19 20 21 22 23 24
-0.15359662 -0.20448356 -0.09291834 0.07362073 -0.18883142 -0.27957925
25 26 27 28 29 30
-0.67850092 -0.98952697 -1.19361389 -0.40109218 -0.30571827 -0.10571827
31 32 33 34 35 36
0.10122086 0.15727305 0.31972520 0.38271652 0.40530778 0.20993386
37 38 39 40 41 42
0.04516867 -0.35660521 -0.22244873 0.44748171 0.61687299 0.61918604
43 44 45 46 47 48
0.56829910 0.63306429 0.80530778 1.07061214 0.89428173 0.36421218
49 50 51 52 53 54
-0.25305745 -0.39345751 -0.27441400 1.16028164 1.62558600 1.57238602
55 56 57 58 59 60
1.16436856 0.59266423 0.62789904 0.82558600 0.99729032 1.01294245
61 62 63 64 65 66
0.64123813 0.48341206 0.36668160 1.12913375 1.22219462 1.23375984
67 68 69 70 71 72
0.87415989 0.79729032 0.97130769 1.11116858 1.05334251 0.79374257
73 74 75 76 77 78
0.75619472 0.60939470 0.23537733 0.37292518 0.27986431 0.18502956
79 80 81 82 83 84
0.08271652 0.04748171 0.08217735 0.18680344 0.21224691 0.12381212
85 86 87 88 89 90
0.21455995 -0.20109218 -0.69877914 -0.38027480 -0.63810087 -0.84789220
91 92 93 94 95 96
-0.67904009 -0.51712710 -0.28243146 -0.09684888 -0.25521411 -0.38173592
97 98 99 100 101 102
-0.83724894 -0.89206642 -0.35559690 0.86984657 0.94956835 0.56575965
103 104 105 106 107 108
-0.20540551 -0.87086625 -0.68883142 0.03946425 0.24925559 -0.05375300
> postscript(file="/var/www/html/rcomp/tmp/6w4iq1258483701.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 = 108
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.02530094 NA
1 -1.29754443 -1.02530094
2 -1.26107491 -1.29754443
3 -0.75182274 -1.26107491
4 -0.23100536 -0.75182274
5 -0.31997931 -0.23100536
6 -0.51018797 -0.31997931
7 -0.68011842 -0.51018797
8 -1.02121402 -0.68011842
9 -1.38829226 -1.02121402
10 -1.57672705 -1.38829226
11 -1.61373573 -1.57672705
12 -1.25182274 -1.61373573
13 -1.17086625 -1.25182274
14 -1.51944014 -1.17086625
15 -1.38420534 -1.51944014
16 -1.17957925 -1.38420534
17 -0.87441400 -1.17957925
18 -0.15359662 -0.87441400
19 -0.20448356 -0.15359662
20 -0.09291834 -0.20448356
21 0.07362073 -0.09291834
22 -0.18883142 0.07362073
23 -0.27957925 -0.18883142
24 -0.67850092 -0.27957925
25 -0.98952697 -0.67850092
26 -1.19361389 -0.98952697
27 -0.40109218 -1.19361389
28 -0.30571827 -0.40109218
29 -0.10571827 -0.30571827
30 0.10122086 -0.10571827
31 0.15727305 0.10122086
32 0.31972520 0.15727305
33 0.38271652 0.31972520
34 0.40530778 0.38271652
35 0.20993386 0.40530778
36 0.04516867 0.20993386
37 -0.35660521 0.04516867
38 -0.22244873 -0.35660521
39 0.44748171 -0.22244873
40 0.61687299 0.44748171
41 0.61918604 0.61687299
42 0.56829910 0.61918604
43 0.63306429 0.56829910
44 0.80530778 0.63306429
45 1.07061214 0.80530778
46 0.89428173 1.07061214
47 0.36421218 0.89428173
48 -0.25305745 0.36421218
49 -0.39345751 -0.25305745
50 -0.27441400 -0.39345751
51 1.16028164 -0.27441400
52 1.62558600 1.16028164
53 1.57238602 1.62558600
54 1.16436856 1.57238602
55 0.59266423 1.16436856
56 0.62789904 0.59266423
57 0.82558600 0.62789904
58 0.99729032 0.82558600
59 1.01294245 0.99729032
60 0.64123813 1.01294245
61 0.48341206 0.64123813
62 0.36668160 0.48341206
63 1.12913375 0.36668160
64 1.22219462 1.12913375
65 1.23375984 1.22219462
66 0.87415989 1.23375984
67 0.79729032 0.87415989
68 0.97130769 0.79729032
69 1.11116858 0.97130769
70 1.05334251 1.11116858
71 0.79374257 1.05334251
72 0.75619472 0.79374257
73 0.60939470 0.75619472
74 0.23537733 0.60939470
75 0.37292518 0.23537733
76 0.27986431 0.37292518
77 0.18502956 0.27986431
78 0.08271652 0.18502956
79 0.04748171 0.08271652
80 0.08217735 0.04748171
81 0.18680344 0.08217735
82 0.21224691 0.18680344
83 0.12381212 0.21224691
84 0.21455995 0.12381212
85 -0.20109218 0.21455995
86 -0.69877914 -0.20109218
87 -0.38027480 -0.69877914
88 -0.63810087 -0.38027480
89 -0.84789220 -0.63810087
90 -0.67904009 -0.84789220
91 -0.51712710 -0.67904009
92 -0.28243146 -0.51712710
93 -0.09684888 -0.28243146
94 -0.25521411 -0.09684888
95 -0.38173592 -0.25521411
96 -0.83724894 -0.38173592
97 -0.89206642 -0.83724894
98 -0.35559690 -0.89206642
99 0.86984657 -0.35559690
100 0.94956835 0.86984657
101 0.56575965 0.94956835
102 -0.20540551 0.56575965
103 -0.87086625 -0.20540551
104 -0.68883142 -0.87086625
105 0.03946425 -0.68883142
106 0.24925559 0.03946425
107 -0.05375300 0.24925559
108 NA -0.05375300
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.29754443 -1.02530094
[2,] -1.26107491 -1.29754443
[3,] -0.75182274 -1.26107491
[4,] -0.23100536 -0.75182274
[5,] -0.31997931 -0.23100536
[6,] -0.51018797 -0.31997931
[7,] -0.68011842 -0.51018797
[8,] -1.02121402 -0.68011842
[9,] -1.38829226 -1.02121402
[10,] -1.57672705 -1.38829226
[11,] -1.61373573 -1.57672705
[12,] -1.25182274 -1.61373573
[13,] -1.17086625 -1.25182274
[14,] -1.51944014 -1.17086625
[15,] -1.38420534 -1.51944014
[16,] -1.17957925 -1.38420534
[17,] -0.87441400 -1.17957925
[18,] -0.15359662 -0.87441400
[19,] -0.20448356 -0.15359662
[20,] -0.09291834 -0.20448356
[21,] 0.07362073 -0.09291834
[22,] -0.18883142 0.07362073
[23,] -0.27957925 -0.18883142
[24,] -0.67850092 -0.27957925
[25,] -0.98952697 -0.67850092
[26,] -1.19361389 -0.98952697
[27,] -0.40109218 -1.19361389
[28,] -0.30571827 -0.40109218
[29,] -0.10571827 -0.30571827
[30,] 0.10122086 -0.10571827
[31,] 0.15727305 0.10122086
[32,] 0.31972520 0.15727305
[33,] 0.38271652 0.31972520
[34,] 0.40530778 0.38271652
[35,] 0.20993386 0.40530778
[36,] 0.04516867 0.20993386
[37,] -0.35660521 0.04516867
[38,] -0.22244873 -0.35660521
[39,] 0.44748171 -0.22244873
[40,] 0.61687299 0.44748171
[41,] 0.61918604 0.61687299
[42,] 0.56829910 0.61918604
[43,] 0.63306429 0.56829910
[44,] 0.80530778 0.63306429
[45,] 1.07061214 0.80530778
[46,] 0.89428173 1.07061214
[47,] 0.36421218 0.89428173
[48,] -0.25305745 0.36421218
[49,] -0.39345751 -0.25305745
[50,] -0.27441400 -0.39345751
[51,] 1.16028164 -0.27441400
[52,] 1.62558600 1.16028164
[53,] 1.57238602 1.62558600
[54,] 1.16436856 1.57238602
[55,] 0.59266423 1.16436856
[56,] 0.62789904 0.59266423
[57,] 0.82558600 0.62789904
[58,] 0.99729032 0.82558600
[59,] 1.01294245 0.99729032
[60,] 0.64123813 1.01294245
[61,] 0.48341206 0.64123813
[62,] 0.36668160 0.48341206
[63,] 1.12913375 0.36668160
[64,] 1.22219462 1.12913375
[65,] 1.23375984 1.22219462
[66,] 0.87415989 1.23375984
[67,] 0.79729032 0.87415989
[68,] 0.97130769 0.79729032
[69,] 1.11116858 0.97130769
[70,] 1.05334251 1.11116858
[71,] 0.79374257 1.05334251
[72,] 0.75619472 0.79374257
[73,] 0.60939470 0.75619472
[74,] 0.23537733 0.60939470
[75,] 0.37292518 0.23537733
[76,] 0.27986431 0.37292518
[77,] 0.18502956 0.27986431
[78,] 0.08271652 0.18502956
[79,] 0.04748171 0.08271652
[80,] 0.08217735 0.04748171
[81,] 0.18680344 0.08217735
[82,] 0.21224691 0.18680344
[83,] 0.12381212 0.21224691
[84,] 0.21455995 0.12381212
[85,] -0.20109218 0.21455995
[86,] -0.69877914 -0.20109218
[87,] -0.38027480 -0.69877914
[88,] -0.63810087 -0.38027480
[89,] -0.84789220 -0.63810087
[90,] -0.67904009 -0.84789220
[91,] -0.51712710 -0.67904009
[92,] -0.28243146 -0.51712710
[93,] -0.09684888 -0.28243146
[94,] -0.25521411 -0.09684888
[95,] -0.38173592 -0.25521411
[96,] -0.83724894 -0.38173592
[97,] -0.89206642 -0.83724894
[98,] -0.35559690 -0.89206642
[99,] 0.86984657 -0.35559690
[100,] 0.94956835 0.86984657
[101,] 0.56575965 0.94956835
[102,] -0.20540551 0.56575965
[103,] -0.87086625 -0.20540551
[104,] -0.68883142 -0.87086625
[105,] 0.03946425 -0.68883142
[106,] 0.24925559 0.03946425
[107,] -0.05375300 0.24925559
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.29754443 -1.02530094
2 -1.26107491 -1.29754443
3 -0.75182274 -1.26107491
4 -0.23100536 -0.75182274
5 -0.31997931 -0.23100536
6 -0.51018797 -0.31997931
7 -0.68011842 -0.51018797
8 -1.02121402 -0.68011842
9 -1.38829226 -1.02121402
10 -1.57672705 -1.38829226
11 -1.61373573 -1.57672705
12 -1.25182274 -1.61373573
13 -1.17086625 -1.25182274
14 -1.51944014 -1.17086625
15 -1.38420534 -1.51944014
16 -1.17957925 -1.38420534
17 -0.87441400 -1.17957925
18 -0.15359662 -0.87441400
19 -0.20448356 -0.15359662
20 -0.09291834 -0.20448356
21 0.07362073 -0.09291834
22 -0.18883142 0.07362073
23 -0.27957925 -0.18883142
24 -0.67850092 -0.27957925
25 -0.98952697 -0.67850092
26 -1.19361389 -0.98952697
27 -0.40109218 -1.19361389
28 -0.30571827 -0.40109218
29 -0.10571827 -0.30571827
30 0.10122086 -0.10571827
31 0.15727305 0.10122086
32 0.31972520 0.15727305
33 0.38271652 0.31972520
34 0.40530778 0.38271652
35 0.20993386 0.40530778
36 0.04516867 0.20993386
37 -0.35660521 0.04516867
38 -0.22244873 -0.35660521
39 0.44748171 -0.22244873
40 0.61687299 0.44748171
41 0.61918604 0.61687299
42 0.56829910 0.61918604
43 0.63306429 0.56829910
44 0.80530778 0.63306429
45 1.07061214 0.80530778
46 0.89428173 1.07061214
47 0.36421218 0.89428173
48 -0.25305745 0.36421218
49 -0.39345751 -0.25305745
50 -0.27441400 -0.39345751
51 1.16028164 -0.27441400
52 1.62558600 1.16028164
53 1.57238602 1.62558600
54 1.16436856 1.57238602
55 0.59266423 1.16436856
56 0.62789904 0.59266423
57 0.82558600 0.62789904
58 0.99729032 0.82558600
59 1.01294245 0.99729032
60 0.64123813 1.01294245
61 0.48341206 0.64123813
62 0.36668160 0.48341206
63 1.12913375 0.36668160
64 1.22219462 1.12913375
65 1.23375984 1.22219462
66 0.87415989 1.23375984
67 0.79729032 0.87415989
68 0.97130769 0.79729032
69 1.11116858 0.97130769
70 1.05334251 1.11116858
71 0.79374257 1.05334251
72 0.75619472 0.79374257
73 0.60939470 0.75619472
74 0.23537733 0.60939470
75 0.37292518 0.23537733
76 0.27986431 0.37292518
77 0.18502956 0.27986431
78 0.08271652 0.18502956
79 0.04748171 0.08271652
80 0.08217735 0.04748171
81 0.18680344 0.08217735
82 0.21224691 0.18680344
83 0.12381212 0.21224691
84 0.21455995 0.12381212
85 -0.20109218 0.21455995
86 -0.69877914 -0.20109218
87 -0.38027480 -0.69877914
88 -0.63810087 -0.38027480
89 -0.84789220 -0.63810087
90 -0.67904009 -0.84789220
91 -0.51712710 -0.67904009
92 -0.28243146 -0.51712710
93 -0.09684888 -0.28243146
94 -0.25521411 -0.09684888
95 -0.38173592 -0.25521411
96 -0.83724894 -0.38173592
97 -0.89206642 -0.83724894
98 -0.35559690 -0.89206642
99 0.86984657 -0.35559690
100 0.94956835 0.86984657
101 0.56575965 0.94956835
102 -0.20540551 0.56575965
103 -0.87086625 -0.20540551
104 -0.68883142 -0.87086625
105 0.03946425 -0.68883142
106 0.24925559 0.03946425
107 -0.05375300 0.24925559
> 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/7uj651258483701.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/8a4eo1258483701.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/9n5ma1258483701.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/10cin61258483701.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/11h4tx1258483701.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/12ezzk1258483701.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/13pdxr1258483701.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/14ibf61258483701.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/159oji1258483701.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/16vnyg1258483701.tab")
+ }
>
> system("convert tmp/1kfiu1258483701.ps tmp/1kfiu1258483701.png")
> system("convert tmp/2m0kj1258483701.ps tmp/2m0kj1258483701.png")
> system("convert tmp/3yopu1258483701.ps tmp/3yopu1258483701.png")
> system("convert tmp/4fg601258483701.ps tmp/4fg601258483701.png")
> system("convert tmp/5i1v61258483701.ps tmp/5i1v61258483701.png")
> system("convert tmp/6w4iq1258483701.ps tmp/6w4iq1258483701.png")
> system("convert tmp/7uj651258483701.ps tmp/7uj651258483701.png")
> system("convert tmp/8a4eo1258483701.ps tmp/8a4eo1258483701.png")
> system("convert tmp/9n5ma1258483701.ps tmp/9n5ma1258483701.png")
> system("convert tmp/10cin61258483701.ps tmp/10cin61258483701.png")
>
>
> proc.time()
user system elapsed
2.995 1.631 3.475