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(0.62915
+ ,1.5355
+ ,0.634
+ ,0.6348
+ ,0.62168
+ ,1.5287
+ ,0.62915
+ ,0.634
+ ,0.61328
+ ,1.5334
+ ,0.62168
+ ,0.62915
+ ,0.6089
+ ,1.5225
+ ,0.61328
+ ,0.62168
+ ,0.60857
+ ,1.5135
+ ,0.6089
+ ,0.61328
+ ,0.62672
+ ,1.5144
+ ,0.60857
+ ,0.6089
+ ,0.62291
+ ,1.4913
+ ,0.62672
+ ,0.60857
+ ,0.62393
+ ,1.4793
+ ,0.62291
+ ,0.62672
+ ,0.61838
+ ,1.4663
+ ,0.62393
+ ,0.62291
+ ,0.62012
+ ,1.4749
+ ,0.61838
+ ,0.62393
+ ,0.61659
+ ,1.4745
+ ,0.62012
+ ,0.61838
+ ,0.6116
+ ,1.4775
+ ,0.61659
+ ,0.62012
+ ,0.61573
+ ,1.4678
+ ,0.6116
+ ,0.61659
+ ,0.61407
+ ,1.4658
+ ,0.61573
+ ,0.6116
+ ,0.62823
+ ,1.4572
+ ,0.61407
+ ,0.61573
+ ,0.64405
+ ,1.4721
+ ,0.62823
+ ,0.61407
+ ,0.6387
+ ,1.4624
+ ,0.64405
+ ,0.62823
+ ,0.63633
+ ,1.4636
+ ,0.6387
+ ,0.64405
+ ,0.63059
+ ,1.4649
+ ,0.63633
+ ,0.6387
+ ,0.62994
+ ,1.465
+ ,0.63059
+ ,0.63633
+ ,0.63709
+ ,1.4673
+ ,0.62994
+ ,0.63059
+ ,0.64217
+ ,1.4679
+ ,0.63709
+ ,0.62994
+ ,0.65711
+ ,1.4621
+ ,0.64217
+ ,0.63709
+ ,0.66977
+ ,1.4674
+ ,0.65711
+ ,0.64217
+ ,0.68255
+ ,1.4695
+ ,0.66977
+ ,0.65711
+ ,0.68902
+ ,1.4964
+ ,0.68255
+ ,0.66977
+ ,0.71322
+ ,1.5155
+ ,0.68902
+ ,0.68255
+ ,0.70224
+ ,1.5411
+ ,0.71322
+ ,0.68902
+ ,0.70045
+ ,1.5476
+ ,0.70224
+ ,0.71322
+ ,0.69919
+ ,1.54
+ ,0.70045
+ ,0.70224
+ ,0.69693
+ ,1.5474
+ ,0.69919
+ ,0.70045
+ ,0.69763
+ ,1.5485
+ ,0.69693
+ ,0.69919
+ ,0.69278
+ ,1.559
+ ,0.69763
+ ,0.69693
+ ,0.70196
+ ,1.5544
+ ,0.69278
+ ,0.69763
+ ,0.69215
+ ,1.5657
+ ,0.70196
+ ,0.69278
+ ,0.6769
+ ,1.5734
+ ,0.69215
+ ,0.70196
+ ,0.67124
+ ,1.567
+ ,0.6769
+ ,0.69215
+ ,0.66532
+ ,1.5547
+ ,0.67124
+ ,0.6769
+ ,0.67157
+ ,1.54
+ ,0.66532
+ ,0.67124
+ ,0.66428
+ ,1.5192
+ ,0.67157
+ ,0.66532
+ ,0.66576
+ ,1.527
+ ,0.66428
+ ,0.67157
+ ,0.66942
+ ,1.5387
+ ,0.66576
+ ,0.66428
+ ,0.6813
+ ,1.5431
+ ,0.66942
+ ,0.66576
+ ,0.69144
+ ,1.5426
+ ,0.6813
+ ,0.66942
+ ,0.69862
+ ,1.5216
+ ,0.69144
+ ,0.6813
+ ,0.695
+ ,1.5364
+ ,0.69862
+ ,0.69144
+ ,0.69867
+ ,1.5469
+ ,0.695
+ ,0.69862
+ ,0.68968
+ ,1.5501
+ ,0.69867
+ ,0.695
+ ,0.69233
+ ,1.5494
+ ,0.68968
+ ,0.69867
+ ,0.68293
+ ,1.5475
+ ,0.69233
+ ,0.68968
+ ,0.68399
+ ,1.5448
+ ,0.68293
+ ,0.69233
+ ,0.66895
+ ,1.5391
+ ,0.68399
+ ,0.68293
+ ,0.68756
+ ,1.5578
+ ,0.66895
+ ,0.68399
+ ,0.68527
+ ,1.5528
+ ,0.68756
+ ,0.66895
+ ,0.6776
+ ,1.5496
+ ,0.68527
+ ,0.68756
+ ,0.68137
+ ,1.549
+ ,0.6776
+ ,0.68527
+ ,0.67933
+ ,1.5449
+ ,0.68137
+ ,0.6776
+ ,0.67922
+ ,1.5479
+ ,0.67933
+ ,0.68137)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('britse_pond'
+ ,'Zwitserse_frank'
+ ,'Britse_pond_-1'
+ ,'Britse_pond_-2')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('britse_pond','Zwitserse_frank','Britse_pond_-1','Britse_pond_-2'),1:58))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
britse_pond Zwitserse_frank Britse_pond_-1 Britse_pond_-2 M1 M2 M3 M4 M5 M6
1 0.62915 1.5355 0.63400 0.63480 1 0 0 0 0 0
2 0.62168 1.5287 0.62915 0.63400 0 1 0 0 0 0
3 0.61328 1.5334 0.62168 0.62915 0 0 1 0 0 0
4 0.60890 1.5225 0.61328 0.62168 0 0 0 1 0 0
5 0.60857 1.5135 0.60890 0.61328 0 0 0 0 1 0
6 0.62672 1.5144 0.60857 0.60890 0 0 0 0 0 1
7 0.62291 1.4913 0.62672 0.60857 0 0 0 0 0 0
8 0.62393 1.4793 0.62291 0.62672 0 0 0 0 0 0
9 0.61838 1.4663 0.62393 0.62291 0 0 0 0 0 0
10 0.62012 1.4749 0.61838 0.62393 0 0 0 0 0 0
11 0.61659 1.4745 0.62012 0.61838 0 0 0 0 0 0
12 0.61160 1.4775 0.61659 0.62012 0 0 0 0 0 0
13 0.61573 1.4678 0.61160 0.61659 1 0 0 0 0 0
14 0.61407 1.4658 0.61573 0.61160 0 1 0 0 0 0
15 0.62823 1.4572 0.61407 0.61573 0 0 1 0 0 0
16 0.64405 1.4721 0.62823 0.61407 0 0 0 1 0 0
17 0.63870 1.4624 0.64405 0.62823 0 0 0 0 1 0
18 0.63633 1.4636 0.63870 0.64405 0 0 0 0 0 1
19 0.63059 1.4649 0.63633 0.63870 0 0 0 0 0 0
20 0.62994 1.4650 0.63059 0.63633 0 0 0 0 0 0
21 0.63709 1.4673 0.62994 0.63059 0 0 0 0 0 0
22 0.64217 1.4679 0.63709 0.62994 0 0 0 0 0 0
23 0.65711 1.4621 0.64217 0.63709 0 0 0 0 0 0
24 0.66977 1.4674 0.65711 0.64217 0 0 0 0 0 0
25 0.68255 1.4695 0.66977 0.65711 1 0 0 0 0 0
26 0.68902 1.4964 0.68255 0.66977 0 1 0 0 0 0
27 0.71322 1.5155 0.68902 0.68255 0 0 1 0 0 0
28 0.70224 1.5411 0.71322 0.68902 0 0 0 1 0 0
29 0.70045 1.5476 0.70224 0.71322 0 0 0 0 1 0
30 0.69919 1.5400 0.70045 0.70224 0 0 0 0 0 1
31 0.69693 1.5474 0.69919 0.70045 0 0 0 0 0 0
32 0.69763 1.5485 0.69693 0.69919 0 0 0 0 0 0
33 0.69278 1.5590 0.69763 0.69693 0 0 0 0 0 0
34 0.70196 1.5544 0.69278 0.69763 0 0 0 0 0 0
35 0.69215 1.5657 0.70196 0.69278 0 0 0 0 0 0
36 0.67690 1.5734 0.69215 0.70196 0 0 0 0 0 0
37 0.67124 1.5670 0.67690 0.69215 1 0 0 0 0 0
38 0.66532 1.5547 0.67124 0.67690 0 1 0 0 0 0
39 0.67157 1.5400 0.66532 0.67124 0 0 1 0 0 0
40 0.66428 1.5192 0.67157 0.66532 0 0 0 1 0 0
41 0.66576 1.5270 0.66428 0.67157 0 0 0 0 1 0
42 0.66942 1.5387 0.66576 0.66428 0 0 0 0 0 1
43 0.68130 1.5431 0.66942 0.66576 0 0 0 0 0 0
44 0.69144 1.5426 0.68130 0.66942 0 0 0 0 0 0
45 0.69862 1.5216 0.69144 0.68130 0 0 0 0 0 0
46 0.69500 1.5364 0.69862 0.69144 0 0 0 0 0 0
47 0.69867 1.5469 0.69500 0.69862 0 0 0 0 0 0
48 0.68968 1.5501 0.69867 0.69500 0 0 0 0 0 0
49 0.69233 1.5494 0.68968 0.69867 1 0 0 0 0 0
50 0.68293 1.5475 0.69233 0.68968 0 1 0 0 0 0
51 0.68399 1.5448 0.68293 0.69233 0 0 1 0 0 0
52 0.66895 1.5391 0.68399 0.68293 0 0 0 1 0 0
53 0.68756 1.5578 0.66895 0.68399 0 0 0 0 1 0
54 0.68527 1.5528 0.68756 0.66895 0 0 0 0 0 1
55 0.67760 1.5496 0.68527 0.68756 0 0 0 0 0 0
56 0.68137 1.5490 0.67760 0.68527 0 0 0 0 0 0
57 0.67933 1.5449 0.68137 0.67760 0 0 0 0 0 0
58 0.67922 1.5479 0.67933 0.68137 0 0 0 0 0 0
M7 M8 M9 M10 M11 t
1 0 0 0 0 0 1
2 0 0 0 0 0 2
3 0 0 0 0 0 3
4 0 0 0 0 0 4
5 0 0 0 0 0 5
6 0 0 0 0 0 6
7 1 0 0 0 0 7
8 0 1 0 0 0 8
9 0 0 1 0 0 9
10 0 0 0 1 0 10
11 0 0 0 0 1 11
12 0 0 0 0 0 12
13 0 0 0 0 0 13
14 0 0 0 0 0 14
15 0 0 0 0 0 15
16 0 0 0 0 0 16
17 0 0 0 0 0 17
18 0 0 0 0 0 18
19 1 0 0 0 0 19
20 0 1 0 0 0 20
21 0 0 1 0 0 21
22 0 0 0 1 0 22
23 0 0 0 0 1 23
24 0 0 0 0 0 24
25 0 0 0 0 0 25
26 0 0 0 0 0 26
27 0 0 0 0 0 27
28 0 0 0 0 0 28
29 0 0 0 0 0 29
30 0 0 0 0 0 30
31 1 0 0 0 0 31
32 0 1 0 0 0 32
33 0 0 1 0 0 33
34 0 0 0 1 0 34
35 0 0 0 0 1 35
36 0 0 0 0 0 36
37 0 0 0 0 0 37
38 0 0 0 0 0 38
39 0 0 0 0 0 39
40 0 0 0 0 0 40
41 0 0 0 0 0 41
42 0 0 0 0 0 42
43 1 0 0 0 0 43
44 0 1 0 0 0 44
45 0 0 1 0 0 45
46 0 0 0 1 0 46
47 0 0 0 0 1 47
48 0 0 0 0 0 48
49 0 0 0 0 0 49
50 0 0 0 0 0 50
51 0 0 0 0 0 51
52 0 0 0 0 0 52
53 0 0 0 0 0 53
54 0 0 0 0 0 54
55 1 0 0 0 0 55
56 0 1 0 0 0 56
57 0 0 1 0 0 57
58 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Zwitserse_frank `Britse_pond_-1` `Britse_pond_-2`
0.1360396 -0.0837778 1.1293382 -0.1557472
M1 M2 M3 M4
0.0072209 0.0009616 0.0125782 -0.0008654
M5 M6 M7 M8
0.0078554 0.0073783 0.0022978 0.0071625
M9 M10 M11 t
0.0033529 0.0060784 0.0048897 0.0001435
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.014622 -0.005424 -0.001284 0.004121 0.017629
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1360396 0.0634359 2.145 0.0378 *
Zwitserse_frank -0.0837778 0.0541726 -1.546 0.1295
`Britse_pond_-1` 1.1293382 0.1495490 7.552 2.39e-09 ***
`Britse_pond_-2` -0.1557472 0.1691657 -0.921 0.3625
M1 0.0072209 0.0057270 1.261 0.2143
M2 0.0009616 0.0057052 0.169 0.8670
M3 0.0125782 0.0057292 2.195 0.0337 *
M4 -0.0008654 0.0058053 -0.149 0.8822
M5 0.0078554 0.0057377 1.369 0.1783
M6 0.0073783 0.0057250 1.289 0.2045
M7 0.0022978 0.0057029 0.403 0.6891
M8 0.0071625 0.0056997 1.257 0.2158
M9 0.0033529 0.0056978 0.588 0.5594
M10 0.0060784 0.0056953 1.067 0.2919
M11 0.0048897 0.0059866 0.817 0.4187
t 0.0001435 0.0001125 1.275 0.2092
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008458 on 42 degrees of freedom
Multiple R-squared: 0.9484, Adjusted R-squared: 0.93
F-statistic: 51.45 on 15 and 42 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.7363963 0.5272075 0.2636037
[2,] 0.6894964 0.6210073 0.3105036
[3,] 0.5902864 0.8194272 0.4097136
[4,] 0.5692521 0.8614957 0.4307479
[5,] 0.6981870 0.6036260 0.3018130
[6,] 0.6780579 0.6438843 0.3219421
[7,] 0.6179433 0.7641134 0.3820567
[8,] 0.5063493 0.9873015 0.4936507
[9,] 0.6295368 0.7409263 0.3704632
[10,] 0.8731242 0.2537516 0.1268758
[11,] 0.8208529 0.3582941 0.1791471
[12,] 0.7741824 0.4516353 0.2258176
[13,] 0.6778666 0.6442668 0.3221334
[14,] 0.5849395 0.8301210 0.4150605
[15,] 0.5115272 0.9769457 0.4884728
[16,] 0.5574295 0.8851410 0.4425705
[17,] 0.6043495 0.7913011 0.3956505
[18,] 0.5312363 0.9375274 0.4687637
[19,] 0.5736117 0.8527765 0.4263883
[20,] 0.5441851 0.9116298 0.4558149
[21,] 0.4514434 0.9028869 0.5485566
> postscript(file="/var/www/html/rcomp/tmp/1gliw1258733128.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/272v61258733128.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/319ju1258733128.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/4gjxa1258733128.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/5b77x1258733128.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 = 58
Frequency = 1
1 2 3 4 5
-2.745130e-03 6.836944e-04 -1.140191e-02 4.928135e-03 -1.381911e-03
6 7 8 9 10
1.686758e-02 -4.489469e-03 -2.353380e-03 -7.071665e-03 -1.053540e-03
11 12 13 14 15
-6.401210e-03 -2.136081e-03 -1.097430e-03 -2.250510e-03 1.946797e-03
16 17 18 19 20
1.606533e-02 -1.462234e-02 -8.052340e-03 -6.903040e-03 -6.439550e-03
21 22 23 24 25
4.409369e-03 -1.505422e-03 9.370508e-03 1.113965e-02 4.760706e-03
26 27 28 29 30
7.138969e-03 1.586262e-02 -5.994759e-03 6.474306e-05 -1.186976e-03
31 32 33 34 35
3.254263e-03 1.394314e-03 -5.239553e-05 1.145949e-02 -7.481236e-03
36 37 38 39 40
-4.831348e-03 -2.697313e-03 4.849501e-04 -4.525716e-04 -4.165326e-03
41 42 43 44 45
-1.689833e-03 4.771311e-04 1.375999e-02 6.003426e-03 5.489028e-03
46 47 48 49 50
-6.289485e-03 4.511939e-03 -4.172217e-03 1.779167e-03 -6.057103e-03
51 52 53 54 55
-5.954934e-03 -1.083338e-02 1.762934e-02 -8.105394e-03 -5.621739e-03
56 57 58
1.395190e-03 -2.774337e-03 -2.611040e-03
> postscript(file="/var/www/html/rcomp/tmp/6cskm1258733128.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 -2.745130e-03 NA
1 6.836944e-04 -2.745130e-03
2 -1.140191e-02 6.836944e-04
3 4.928135e-03 -1.140191e-02
4 -1.381911e-03 4.928135e-03
5 1.686758e-02 -1.381911e-03
6 -4.489469e-03 1.686758e-02
7 -2.353380e-03 -4.489469e-03
8 -7.071665e-03 -2.353380e-03
9 -1.053540e-03 -7.071665e-03
10 -6.401210e-03 -1.053540e-03
11 -2.136081e-03 -6.401210e-03
12 -1.097430e-03 -2.136081e-03
13 -2.250510e-03 -1.097430e-03
14 1.946797e-03 -2.250510e-03
15 1.606533e-02 1.946797e-03
16 -1.462234e-02 1.606533e-02
17 -8.052340e-03 -1.462234e-02
18 -6.903040e-03 -8.052340e-03
19 -6.439550e-03 -6.903040e-03
20 4.409369e-03 -6.439550e-03
21 -1.505422e-03 4.409369e-03
22 9.370508e-03 -1.505422e-03
23 1.113965e-02 9.370508e-03
24 4.760706e-03 1.113965e-02
25 7.138969e-03 4.760706e-03
26 1.586262e-02 7.138969e-03
27 -5.994759e-03 1.586262e-02
28 6.474306e-05 -5.994759e-03
29 -1.186976e-03 6.474306e-05
30 3.254263e-03 -1.186976e-03
31 1.394314e-03 3.254263e-03
32 -5.239553e-05 1.394314e-03
33 1.145949e-02 -5.239553e-05
34 -7.481236e-03 1.145949e-02
35 -4.831348e-03 -7.481236e-03
36 -2.697313e-03 -4.831348e-03
37 4.849501e-04 -2.697313e-03
38 -4.525716e-04 4.849501e-04
39 -4.165326e-03 -4.525716e-04
40 -1.689833e-03 -4.165326e-03
41 4.771311e-04 -1.689833e-03
42 1.375999e-02 4.771311e-04
43 6.003426e-03 1.375999e-02
44 5.489028e-03 6.003426e-03
45 -6.289485e-03 5.489028e-03
46 4.511939e-03 -6.289485e-03
47 -4.172217e-03 4.511939e-03
48 1.779167e-03 -4.172217e-03
49 -6.057103e-03 1.779167e-03
50 -5.954934e-03 -6.057103e-03
51 -1.083338e-02 -5.954934e-03
52 1.762934e-02 -1.083338e-02
53 -8.105394e-03 1.762934e-02
54 -5.621739e-03 -8.105394e-03
55 1.395190e-03 -5.621739e-03
56 -2.774337e-03 1.395190e-03
57 -2.611040e-03 -2.774337e-03
58 NA -2.611040e-03
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 6.836944e-04 -2.745130e-03
[2,] -1.140191e-02 6.836944e-04
[3,] 4.928135e-03 -1.140191e-02
[4,] -1.381911e-03 4.928135e-03
[5,] 1.686758e-02 -1.381911e-03
[6,] -4.489469e-03 1.686758e-02
[7,] -2.353380e-03 -4.489469e-03
[8,] -7.071665e-03 -2.353380e-03
[9,] -1.053540e-03 -7.071665e-03
[10,] -6.401210e-03 -1.053540e-03
[11,] -2.136081e-03 -6.401210e-03
[12,] -1.097430e-03 -2.136081e-03
[13,] -2.250510e-03 -1.097430e-03
[14,] 1.946797e-03 -2.250510e-03
[15,] 1.606533e-02 1.946797e-03
[16,] -1.462234e-02 1.606533e-02
[17,] -8.052340e-03 -1.462234e-02
[18,] -6.903040e-03 -8.052340e-03
[19,] -6.439550e-03 -6.903040e-03
[20,] 4.409369e-03 -6.439550e-03
[21,] -1.505422e-03 4.409369e-03
[22,] 9.370508e-03 -1.505422e-03
[23,] 1.113965e-02 9.370508e-03
[24,] 4.760706e-03 1.113965e-02
[25,] 7.138969e-03 4.760706e-03
[26,] 1.586262e-02 7.138969e-03
[27,] -5.994759e-03 1.586262e-02
[28,] 6.474306e-05 -5.994759e-03
[29,] -1.186976e-03 6.474306e-05
[30,] 3.254263e-03 -1.186976e-03
[31,] 1.394314e-03 3.254263e-03
[32,] -5.239553e-05 1.394314e-03
[33,] 1.145949e-02 -5.239553e-05
[34,] -7.481236e-03 1.145949e-02
[35,] -4.831348e-03 -7.481236e-03
[36,] -2.697313e-03 -4.831348e-03
[37,] 4.849501e-04 -2.697313e-03
[38,] -4.525716e-04 4.849501e-04
[39,] -4.165326e-03 -4.525716e-04
[40,] -1.689833e-03 -4.165326e-03
[41,] 4.771311e-04 -1.689833e-03
[42,] 1.375999e-02 4.771311e-04
[43,] 6.003426e-03 1.375999e-02
[44,] 5.489028e-03 6.003426e-03
[45,] -6.289485e-03 5.489028e-03
[46,] 4.511939e-03 -6.289485e-03
[47,] -4.172217e-03 4.511939e-03
[48,] 1.779167e-03 -4.172217e-03
[49,] -6.057103e-03 1.779167e-03
[50,] -5.954934e-03 -6.057103e-03
[51,] -1.083338e-02 -5.954934e-03
[52,] 1.762934e-02 -1.083338e-02
[53,] -8.105394e-03 1.762934e-02
[54,] -5.621739e-03 -8.105394e-03
[55,] 1.395190e-03 -5.621739e-03
[56,] -2.774337e-03 1.395190e-03
[57,] -2.611040e-03 -2.774337e-03
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 6.836944e-04 -2.745130e-03
2 -1.140191e-02 6.836944e-04
3 4.928135e-03 -1.140191e-02
4 -1.381911e-03 4.928135e-03
5 1.686758e-02 -1.381911e-03
6 -4.489469e-03 1.686758e-02
7 -2.353380e-03 -4.489469e-03
8 -7.071665e-03 -2.353380e-03
9 -1.053540e-03 -7.071665e-03
10 -6.401210e-03 -1.053540e-03
11 -2.136081e-03 -6.401210e-03
12 -1.097430e-03 -2.136081e-03
13 -2.250510e-03 -1.097430e-03
14 1.946797e-03 -2.250510e-03
15 1.606533e-02 1.946797e-03
16 -1.462234e-02 1.606533e-02
17 -8.052340e-03 -1.462234e-02
18 -6.903040e-03 -8.052340e-03
19 -6.439550e-03 -6.903040e-03
20 4.409369e-03 -6.439550e-03
21 -1.505422e-03 4.409369e-03
22 9.370508e-03 -1.505422e-03
23 1.113965e-02 9.370508e-03
24 4.760706e-03 1.113965e-02
25 7.138969e-03 4.760706e-03
26 1.586262e-02 7.138969e-03
27 -5.994759e-03 1.586262e-02
28 6.474306e-05 -5.994759e-03
29 -1.186976e-03 6.474306e-05
30 3.254263e-03 -1.186976e-03
31 1.394314e-03 3.254263e-03
32 -5.239553e-05 1.394314e-03
33 1.145949e-02 -5.239553e-05
34 -7.481236e-03 1.145949e-02
35 -4.831348e-03 -7.481236e-03
36 -2.697313e-03 -4.831348e-03
37 4.849501e-04 -2.697313e-03
38 -4.525716e-04 4.849501e-04
39 -4.165326e-03 -4.525716e-04
40 -1.689833e-03 -4.165326e-03
41 4.771311e-04 -1.689833e-03
42 1.375999e-02 4.771311e-04
43 6.003426e-03 1.375999e-02
44 5.489028e-03 6.003426e-03
45 -6.289485e-03 5.489028e-03
46 4.511939e-03 -6.289485e-03
47 -4.172217e-03 4.511939e-03
48 1.779167e-03 -4.172217e-03
49 -6.057103e-03 1.779167e-03
50 -5.954934e-03 -6.057103e-03
51 -1.083338e-02 -5.954934e-03
52 1.762934e-02 -1.083338e-02
53 -8.105394e-03 1.762934e-02
54 -5.621739e-03 -8.105394e-03
55 1.395190e-03 -5.621739e-03
56 -2.774337e-03 1.395190e-03
57 -2.611040e-03 -2.774337e-03
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7hqcb1258733128.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/8tci61258733128.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/9wp0w1258733128.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/10lojn1258733128.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/11tpjw1258733128.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/128xnh1258733128.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/13dzrw1258733128.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/145z9q1258733128.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/15l88x1258733128.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/16u6sk1258733128.tab")
+ }
>
> system("convert tmp/1gliw1258733128.ps tmp/1gliw1258733128.png")
> system("convert tmp/272v61258733128.ps tmp/272v61258733128.png")
> system("convert tmp/319ju1258733128.ps tmp/319ju1258733128.png")
> system("convert tmp/4gjxa1258733128.ps tmp/4gjxa1258733128.png")
> system("convert tmp/5b77x1258733128.ps tmp/5b77x1258733128.png")
> system("convert tmp/6cskm1258733128.ps tmp/6cskm1258733128.png")
> system("convert tmp/7hqcb1258733128.ps tmp/7hqcb1258733128.png")
> system("convert tmp/8tci61258733128.ps tmp/8tci61258733128.png")
> system("convert tmp/9wp0w1258733128.ps tmp/9wp0w1258733128.png")
> system("convert tmp/10lojn1258733128.ps tmp/10lojn1258733128.png")
>
>
> proc.time()
user system elapsed
2.402 1.567 2.807