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.7905
+ ,0.313
+ ,0.7744
+ ,0.779
+ ,0.7775
+ ,0.7461
+ ,0.7719
+ ,0.364
+ ,0.7905
+ ,0.7744
+ ,0.779
+ ,0.7775
+ ,0.7811
+ ,0.363
+ ,0.7719
+ ,0.7905
+ ,0.7744
+ ,0.779
+ ,0.7557
+ ,-0.155
+ ,0.7811
+ ,0.7719
+ ,0.7905
+ ,0.7744
+ ,0.7637
+ ,0.052
+ ,0.7557
+ ,0.7811
+ ,0.7719
+ ,0.7905
+ ,0.7595
+ ,0.568
+ ,0.7637
+ ,0.7557
+ ,0.7811
+ ,0.7719
+ ,0.7471
+ ,0.668
+ ,0.7595
+ ,0.7637
+ ,0.7557
+ ,0.7811
+ ,0.7615
+ ,1.378
+ ,0.7471
+ ,0.7595
+ ,0.7637
+ ,0.7557
+ ,0.7487
+ ,0.252
+ ,0.7615
+ ,0.7471
+ ,0.7595
+ ,0.7637
+ ,0.7389
+ ,-0.402
+ ,0.7487
+ ,0.7615
+ ,0.7471
+ ,0.7595
+ ,0.7337
+ ,-0.05
+ ,0.7389
+ ,0.7487
+ ,0.7615
+ ,0.7471
+ ,0.751
+ ,0.555
+ ,0.7337
+ ,0.7389
+ ,0.7487
+ ,0.7615
+ ,0.7382
+ ,0.05
+ ,0.751
+ ,0.7337
+ ,0.7389
+ ,0.7487
+ ,0.7159
+ ,0.15
+ ,0.7382
+ ,0.751
+ ,0.7337
+ ,0.7389
+ ,0.7542
+ ,0.45
+ ,0.7159
+ ,0.7382
+ ,0.751
+ ,0.7337
+ ,0.7636
+ ,0.299
+ ,0.7542
+ ,0.7159
+ ,0.7382
+ ,0.751
+ ,0.7433
+ ,0.199
+ ,0.7636
+ ,0.7542
+ ,0.7159
+ ,0.7382
+ ,0.7658
+ ,0.496
+ ,0.7433
+ ,0.7636
+ ,0.7542
+ ,0.7159
+ ,0.7627
+ ,0.444
+ ,0.7658
+ ,0.7433
+ ,0.7636
+ ,0.7542
+ ,0.748
+ ,-0.393
+ ,0.7627
+ ,0.7658
+ ,0.7433
+ ,0.7636
+ ,0.7692
+ ,-0.444
+ ,0.748
+ ,0.7627
+ ,0.7658
+ ,0.7433
+ ,0.785
+ ,0.198
+ ,0.7692
+ ,0.748
+ ,0.7627
+ ,0.7658
+ ,0.7913
+ ,0.494
+ ,0.785
+ ,0.7692
+ ,0.748
+ ,0.7627
+ ,0.772
+ ,0.133
+ ,0.7913
+ ,0.785
+ ,0.7692
+ ,0.748
+ ,0.788
+ ,0.388
+ ,0.772
+ ,0.7913
+ ,0.785
+ ,0.7692
+ ,0.807
+ ,0.484
+ ,0.788
+ ,0.772
+ ,0.7913
+ ,0.785
+ ,0.8268
+ ,0.278
+ ,0.807
+ ,0.788
+ ,0.772
+ ,0.7913
+ ,0.8244
+ ,0.369
+ ,0.8268
+ ,0.807
+ ,0.788
+ ,0.772
+ ,0.8487
+ ,0.165
+ ,0.8244
+ ,0.8268
+ ,0.807
+ ,0.788
+ ,0.8572
+ ,0.155
+ ,0.8487
+ ,0.8244
+ ,0.8268
+ ,0.807
+ ,0.8214
+ ,0.087
+ ,0.8572
+ ,0.8487
+ ,0.8244
+ ,0.8268
+ ,0.8827
+ ,0.414
+ ,0.8214
+ ,0.8572
+ ,0.8487
+ ,0.8244
+ ,0.9216
+ ,0.36
+ ,0.8827
+ ,0.8214
+ ,0.8572
+ ,0.8487
+ ,0.8865
+ ,0.975
+ ,0.9216
+ ,0.8827
+ ,0.8214
+ ,0.8572
+ ,0.8816
+ ,0.27
+ ,0.8865
+ ,0.9216
+ ,0.8827
+ ,0.8214
+ ,0.8884
+ ,0.359
+ ,0.8816
+ ,0.8865
+ ,0.9216
+ ,0.8827
+ ,0.9466
+ ,0.169
+ ,0.8884
+ ,0.8816
+ ,0.8865
+ ,0.9216
+ ,0.918
+ ,0.381
+ ,0.9466
+ ,0.8884
+ ,0.8816
+ ,0.8865
+ ,0.9337
+ ,0.154
+ ,0.918
+ ,0.9466
+ ,0.8884
+ ,0.8816
+ ,0.9559
+ ,0.486
+ ,0.9337
+ ,0.918
+ ,0.9466
+ ,0.8884
+ ,0.9626
+ ,0.925
+ ,0.9559
+ ,0.9337
+ ,0.918
+ ,0.9466
+ ,0.9434
+ ,0.728
+ ,0.9626
+ ,0.9559
+ ,0.9337
+ ,0.918
+ ,0.8639
+ ,-0.014
+ ,0.9434
+ ,0.9626
+ ,0.9559
+ ,0.9337
+ ,0.7996
+ ,0.046
+ ,0.8639
+ ,0.9434
+ ,0.9626
+ ,0.9559
+ ,0.668
+ ,-0.819
+ ,0.7996
+ ,0.8639
+ ,0.9434
+ ,0.9626
+ ,0.6572
+ ,-1.674
+ ,0.668
+ ,0.7996
+ ,0.8639
+ ,0.9434
+ ,0.6928
+ ,-0.788
+ ,0.6572
+ ,0.668
+ ,0.7996
+ ,0.8639
+ ,0.6438
+ ,0.279
+ ,0.6928
+ ,0.6572
+ ,0.668
+ ,0.7996
+ ,0.6454
+ ,0.396
+ ,0.6438
+ ,0.6928
+ ,0.6572
+ ,0.668
+ ,0.6873
+ ,-0.141
+ ,0.6454
+ ,0.6438
+ ,0.6928
+ ,0.6572
+ ,0.7265
+ ,-0.019
+ ,0.6873
+ ,0.6454
+ ,0.6438
+ ,0.6928
+ ,0.7912
+ ,0.099
+ ,0.7265
+ ,0.6873
+ ,0.6454
+ ,0.6438
+ ,0.8114
+ ,0.742
+ ,0.7912
+ ,0.7265
+ ,0.6873
+ ,0.6454
+ ,0.8281
+ ,0.005
+ ,0.8114
+ ,0.7912
+ ,0.7265
+ ,0.6873
+ ,0.8393
+ ,0.448
+ ,0.8281
+ ,0.8114
+ ,0.7912
+ ,0.7265)
+ ,dim=c(6
+ ,55)
+ ,dimnames=list(c('USDOLLAR'
+ ,'Amerikaanse_inflatie'
+ ,'Y[t-1]'
+ ,'Y[t-2]'
+ ,'Y[t-3]'
+ ,'Y[t-4]')
+ ,1:55))
> y <- array(NA,dim=c(6,55),dimnames=list(c('USDOLLAR','Amerikaanse_inflatie','Y[t-1]','Y[t-2]','Y[t-3]','Y[t-4]'),1:55))
> 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 = '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
USDOLLAR Amerikaanse_inflatie Y[t-1] Y[t-2] Y[t-3] Y[t-4] t
1 0.7905 0.313 0.7744 0.7790 0.7775 0.7461 1
2 0.7719 0.364 0.7905 0.7744 0.7790 0.7775 2
3 0.7811 0.363 0.7719 0.7905 0.7744 0.7790 3
4 0.7557 -0.155 0.7811 0.7719 0.7905 0.7744 4
5 0.7637 0.052 0.7557 0.7811 0.7719 0.7905 5
6 0.7595 0.568 0.7637 0.7557 0.7811 0.7719 6
7 0.7471 0.668 0.7595 0.7637 0.7557 0.7811 7
8 0.7615 1.378 0.7471 0.7595 0.7637 0.7557 8
9 0.7487 0.252 0.7615 0.7471 0.7595 0.7637 9
10 0.7389 -0.402 0.7487 0.7615 0.7471 0.7595 10
11 0.7337 -0.050 0.7389 0.7487 0.7615 0.7471 11
12 0.7510 0.555 0.7337 0.7389 0.7487 0.7615 12
13 0.7382 0.050 0.7510 0.7337 0.7389 0.7487 13
14 0.7159 0.150 0.7382 0.7510 0.7337 0.7389 14
15 0.7542 0.450 0.7159 0.7382 0.7510 0.7337 15
16 0.7636 0.299 0.7542 0.7159 0.7382 0.7510 16
17 0.7433 0.199 0.7636 0.7542 0.7159 0.7382 17
18 0.7658 0.496 0.7433 0.7636 0.7542 0.7159 18
19 0.7627 0.444 0.7658 0.7433 0.7636 0.7542 19
20 0.7480 -0.393 0.7627 0.7658 0.7433 0.7636 20
21 0.7692 -0.444 0.7480 0.7627 0.7658 0.7433 21
22 0.7850 0.198 0.7692 0.7480 0.7627 0.7658 22
23 0.7913 0.494 0.7850 0.7692 0.7480 0.7627 23
24 0.7720 0.133 0.7913 0.7850 0.7692 0.7480 24
25 0.7880 0.388 0.7720 0.7913 0.7850 0.7692 25
26 0.8070 0.484 0.7880 0.7720 0.7913 0.7850 26
27 0.8268 0.278 0.8070 0.7880 0.7720 0.7913 27
28 0.8244 0.369 0.8268 0.8070 0.7880 0.7720 28
29 0.8487 0.165 0.8244 0.8268 0.8070 0.7880 29
30 0.8572 0.155 0.8487 0.8244 0.8268 0.8070 30
31 0.8214 0.087 0.8572 0.8487 0.8244 0.8268 31
32 0.8827 0.414 0.8214 0.8572 0.8487 0.8244 32
33 0.9216 0.360 0.8827 0.8214 0.8572 0.8487 33
34 0.8865 0.975 0.9216 0.8827 0.8214 0.8572 34
35 0.8816 0.270 0.8865 0.9216 0.8827 0.8214 35
36 0.8884 0.359 0.8816 0.8865 0.9216 0.8827 36
37 0.9466 0.169 0.8884 0.8816 0.8865 0.9216 37
38 0.9180 0.381 0.9466 0.8884 0.8816 0.8865 38
39 0.9337 0.154 0.9180 0.9466 0.8884 0.8816 39
40 0.9559 0.486 0.9337 0.9180 0.9466 0.8884 40
41 0.9626 0.925 0.9559 0.9337 0.9180 0.9466 41
42 0.9434 0.728 0.9626 0.9559 0.9337 0.9180 42
43 0.8639 -0.014 0.9434 0.9626 0.9559 0.9337 43
44 0.7996 0.046 0.8639 0.9434 0.9626 0.9559 44
45 0.6680 -0.819 0.7996 0.8639 0.9434 0.9626 45
46 0.6572 -1.674 0.6680 0.7996 0.8639 0.9434 46
47 0.6928 -0.788 0.6572 0.6680 0.7996 0.8639 47
48 0.6438 0.279 0.6928 0.6572 0.6680 0.7996 48
49 0.6454 0.396 0.6438 0.6928 0.6572 0.6680 49
50 0.6873 -0.141 0.6454 0.6438 0.6928 0.6572 50
51 0.7265 -0.019 0.6873 0.6454 0.6438 0.6928 51
52 0.7912 0.099 0.7265 0.6873 0.6454 0.6438 52
53 0.8114 0.742 0.7912 0.7265 0.6873 0.6454 53
54 0.8281 0.005 0.8114 0.7912 0.7265 0.6873 54
55 0.8393 0.448 0.8281 0.8114 0.7912 0.7265 55
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Amerikaanse_inflatie `Y[t-1]`
0.1395278 0.0131670 1.0499153
`Y[t-2]` `Y[t-3]` `Y[t-4]`
-0.2397233 0.2884895 -0.2879608
t
0.0003137
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.1022462 -0.0178959 -0.0004023 0.0188252 0.0814738
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1395278 0.0472515 2.953 0.00486 **
Amerikaanse_inflatie 0.0131670 0.0124823 1.055 0.29677
`Y[t-1]` 1.0499153 0.1578148 6.653 2.51e-08 ***
`Y[t-2]` -0.2397233 0.2087274 -1.148 0.25645
`Y[t-3]` 0.2884895 0.2083110 1.385 0.17249
`Y[t-4]` -0.2879608 0.1369523 -2.103 0.04077 *
t 0.0003137 0.0002816 1.114 0.27073
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.03098 on 48 degrees of freedom
Multiple R-squared: 0.8667, Adjusted R-squared: 0.85
F-statistic: 52 on 6 and 48 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,] 1.487208e-02 2.974416e-02 0.9851279
[2,] 3.436545e-03 6.873090e-03 0.9965635
[3,] 2.746460e-03 5.492919e-03 0.9972535
[4,] 9.297725e-04 1.859545e-03 0.9990702
[5,] 3.896660e-04 7.793321e-04 0.9996103
[6,] 6.866724e-04 1.373345e-03 0.9993133
[7,] 5.639740e-03 1.127948e-02 0.9943603
[8,] 2.910149e-03 5.820298e-03 0.9970899
[9,] 1.303108e-03 2.606217e-03 0.9986969
[10,] 5.267287e-04 1.053457e-03 0.9994733
[11,] 2.068966e-04 4.137933e-04 0.9997931
[12,] 1.036977e-04 2.073953e-04 0.9998963
[13,] 5.700479e-05 1.140096e-04 0.9999430
[14,] 2.183517e-05 4.367034e-05 0.9999782
[15,] 3.442059e-05 6.884119e-05 0.9999656
[16,] 1.231353e-05 2.462707e-05 0.9999877
[17,] 4.428637e-06 8.857274e-06 0.9999956
[18,] 4.263163e-06 8.526325e-06 0.9999957
[19,] 1.885958e-06 3.771916e-06 0.9999981
[20,] 7.424480e-07 1.484896e-06 0.9999993
[21,] 2.679963e-07 5.359926e-07 0.9999997
[22,] 4.921549e-06 9.843098e-06 0.9999951
[23,] 4.800423e-06 9.600846e-06 0.9999952
[24,] 4.727420e-06 9.454839e-06 0.9999953
[25,] 4.495251e-06 8.990502e-06 0.9999955
[26,] 6.402477e-06 1.280495e-05 0.9999936
[27,] 1.467470e-05 2.934941e-05 0.9999853
[28,] 6.325555e-05 1.265111e-04 0.9999367
[29,] 9.133703e-05 1.826741e-04 0.9999087
[30,] 4.173581e-05 8.347163e-05 0.9999583
[31,] 1.774118e-05 3.548235e-05 0.9999823
[32,] 7.573181e-05 1.514636e-04 0.9999243
[33,] 7.961522e-04 1.592304e-03 0.9992038
[34,] 1.199612e-02 2.399224e-02 0.9880039
[35,] 5.572707e-01 8.854586e-01 0.4427293
[36,] 6.036682e-01 7.926636e-01 0.3963318
> postscript(file="/var/www/html/rcomp/tmp/1sfrw1260706615.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/214cq1260706615.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/3lc7u1260706615.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/4gu1m1260706615.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/5grvz1260706615.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 = 55
Frequency = 1
1 2 3 4 5
1.077431e-02 -1.820805e-02 1.583837e-02 -2.314221e-02 2.069388e-02
6 7 8 9 10
-1.311246e-02 -1.083857e-02 -3.710852e-03 -1.657454e-02 1.181728e-03
11 12 13 14 15
-9.471014e-03 1.049882e-02 -1.623436e-02 -2.390051e-02 2.399207e-02
16 17 18 19 20
-1.816625e-03 -1.905402e-02 5.317679e-03 -1.758373e-02 -4.364988e-03
21 22 23 24 25
1.954681e-02 8.171193e-03 2.101642e-03 -2.593462e-02 9.714341e-03
26 27 28 29 30
8.443591e-03 2.191146e-02 -8.407501e-03 2.465725e-02 6.646091e-03
31 32 33 34 35
-2.527727e-02 6.332663e-02 3.422732e-02 -2.265517e-02 -4.022856e-04
36 37 38 39 40
8.072197e-03 8.147380e-02 -1.840009e-02 4.058184e-02 1.992498e-02
41 42 43 44 45
2.599662e-02 -5.400736e-03 -5.556350e-02 -3.764180e-02 -1.022462e-01
46 47 48 49 50
3.805860e-02 3.712743e-02 -4.675213e-02 -2.180634e-02 4.411891e-05
51 52 53 54 55
1.810353e-02 3.525218e-02 -2.348725e-02 -2.338308e-03 -1.735337e-02
> postscript(file="/var/www/html/rcomp/tmp/6pr4u1260706615.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 = 55
Frequency = 1
lag(myerror, k = 1) myerror
0 1.077431e-02 NA
1 -1.820805e-02 1.077431e-02
2 1.583837e-02 -1.820805e-02
3 -2.314221e-02 1.583837e-02
4 2.069388e-02 -2.314221e-02
5 -1.311246e-02 2.069388e-02
6 -1.083857e-02 -1.311246e-02
7 -3.710852e-03 -1.083857e-02
8 -1.657454e-02 -3.710852e-03
9 1.181728e-03 -1.657454e-02
10 -9.471014e-03 1.181728e-03
11 1.049882e-02 -9.471014e-03
12 -1.623436e-02 1.049882e-02
13 -2.390051e-02 -1.623436e-02
14 2.399207e-02 -2.390051e-02
15 -1.816625e-03 2.399207e-02
16 -1.905402e-02 -1.816625e-03
17 5.317679e-03 -1.905402e-02
18 -1.758373e-02 5.317679e-03
19 -4.364988e-03 -1.758373e-02
20 1.954681e-02 -4.364988e-03
21 8.171193e-03 1.954681e-02
22 2.101642e-03 8.171193e-03
23 -2.593462e-02 2.101642e-03
24 9.714341e-03 -2.593462e-02
25 8.443591e-03 9.714341e-03
26 2.191146e-02 8.443591e-03
27 -8.407501e-03 2.191146e-02
28 2.465725e-02 -8.407501e-03
29 6.646091e-03 2.465725e-02
30 -2.527727e-02 6.646091e-03
31 6.332663e-02 -2.527727e-02
32 3.422732e-02 6.332663e-02
33 -2.265517e-02 3.422732e-02
34 -4.022856e-04 -2.265517e-02
35 8.072197e-03 -4.022856e-04
36 8.147380e-02 8.072197e-03
37 -1.840009e-02 8.147380e-02
38 4.058184e-02 -1.840009e-02
39 1.992498e-02 4.058184e-02
40 2.599662e-02 1.992498e-02
41 -5.400736e-03 2.599662e-02
42 -5.556350e-02 -5.400736e-03
43 -3.764180e-02 -5.556350e-02
44 -1.022462e-01 -3.764180e-02
45 3.805860e-02 -1.022462e-01
46 3.712743e-02 3.805860e-02
47 -4.675213e-02 3.712743e-02
48 -2.180634e-02 -4.675213e-02
49 4.411891e-05 -2.180634e-02
50 1.810353e-02 4.411891e-05
51 3.525218e-02 1.810353e-02
52 -2.348725e-02 3.525218e-02
53 -2.338308e-03 -2.348725e-02
54 -1.735337e-02 -2.338308e-03
55 NA -1.735337e-02
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.820805e-02 1.077431e-02
[2,] 1.583837e-02 -1.820805e-02
[3,] -2.314221e-02 1.583837e-02
[4,] 2.069388e-02 -2.314221e-02
[5,] -1.311246e-02 2.069388e-02
[6,] -1.083857e-02 -1.311246e-02
[7,] -3.710852e-03 -1.083857e-02
[8,] -1.657454e-02 -3.710852e-03
[9,] 1.181728e-03 -1.657454e-02
[10,] -9.471014e-03 1.181728e-03
[11,] 1.049882e-02 -9.471014e-03
[12,] -1.623436e-02 1.049882e-02
[13,] -2.390051e-02 -1.623436e-02
[14,] 2.399207e-02 -2.390051e-02
[15,] -1.816625e-03 2.399207e-02
[16,] -1.905402e-02 -1.816625e-03
[17,] 5.317679e-03 -1.905402e-02
[18,] -1.758373e-02 5.317679e-03
[19,] -4.364988e-03 -1.758373e-02
[20,] 1.954681e-02 -4.364988e-03
[21,] 8.171193e-03 1.954681e-02
[22,] 2.101642e-03 8.171193e-03
[23,] -2.593462e-02 2.101642e-03
[24,] 9.714341e-03 -2.593462e-02
[25,] 8.443591e-03 9.714341e-03
[26,] 2.191146e-02 8.443591e-03
[27,] -8.407501e-03 2.191146e-02
[28,] 2.465725e-02 -8.407501e-03
[29,] 6.646091e-03 2.465725e-02
[30,] -2.527727e-02 6.646091e-03
[31,] 6.332663e-02 -2.527727e-02
[32,] 3.422732e-02 6.332663e-02
[33,] -2.265517e-02 3.422732e-02
[34,] -4.022856e-04 -2.265517e-02
[35,] 8.072197e-03 -4.022856e-04
[36,] 8.147380e-02 8.072197e-03
[37,] -1.840009e-02 8.147380e-02
[38,] 4.058184e-02 -1.840009e-02
[39,] 1.992498e-02 4.058184e-02
[40,] 2.599662e-02 1.992498e-02
[41,] -5.400736e-03 2.599662e-02
[42,] -5.556350e-02 -5.400736e-03
[43,] -3.764180e-02 -5.556350e-02
[44,] -1.022462e-01 -3.764180e-02
[45,] 3.805860e-02 -1.022462e-01
[46,] 3.712743e-02 3.805860e-02
[47,] -4.675213e-02 3.712743e-02
[48,] -2.180634e-02 -4.675213e-02
[49,] 4.411891e-05 -2.180634e-02
[50,] 1.810353e-02 4.411891e-05
[51,] 3.525218e-02 1.810353e-02
[52,] -2.348725e-02 3.525218e-02
[53,] -2.338308e-03 -2.348725e-02
[54,] -1.735337e-02 -2.338308e-03
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.820805e-02 1.077431e-02
2 1.583837e-02 -1.820805e-02
3 -2.314221e-02 1.583837e-02
4 2.069388e-02 -2.314221e-02
5 -1.311246e-02 2.069388e-02
6 -1.083857e-02 -1.311246e-02
7 -3.710852e-03 -1.083857e-02
8 -1.657454e-02 -3.710852e-03
9 1.181728e-03 -1.657454e-02
10 -9.471014e-03 1.181728e-03
11 1.049882e-02 -9.471014e-03
12 -1.623436e-02 1.049882e-02
13 -2.390051e-02 -1.623436e-02
14 2.399207e-02 -2.390051e-02
15 -1.816625e-03 2.399207e-02
16 -1.905402e-02 -1.816625e-03
17 5.317679e-03 -1.905402e-02
18 -1.758373e-02 5.317679e-03
19 -4.364988e-03 -1.758373e-02
20 1.954681e-02 -4.364988e-03
21 8.171193e-03 1.954681e-02
22 2.101642e-03 8.171193e-03
23 -2.593462e-02 2.101642e-03
24 9.714341e-03 -2.593462e-02
25 8.443591e-03 9.714341e-03
26 2.191146e-02 8.443591e-03
27 -8.407501e-03 2.191146e-02
28 2.465725e-02 -8.407501e-03
29 6.646091e-03 2.465725e-02
30 -2.527727e-02 6.646091e-03
31 6.332663e-02 -2.527727e-02
32 3.422732e-02 6.332663e-02
33 -2.265517e-02 3.422732e-02
34 -4.022856e-04 -2.265517e-02
35 8.072197e-03 -4.022856e-04
36 8.147380e-02 8.072197e-03
37 -1.840009e-02 8.147380e-02
38 4.058184e-02 -1.840009e-02
39 1.992498e-02 4.058184e-02
40 2.599662e-02 1.992498e-02
41 -5.400736e-03 2.599662e-02
42 -5.556350e-02 -5.400736e-03
43 -3.764180e-02 -5.556350e-02
44 -1.022462e-01 -3.764180e-02
45 3.805860e-02 -1.022462e-01
46 3.712743e-02 3.805860e-02
47 -4.675213e-02 3.712743e-02
48 -2.180634e-02 -4.675213e-02
49 4.411891e-05 -2.180634e-02
50 1.810353e-02 4.411891e-05
51 3.525218e-02 1.810353e-02
52 -2.348725e-02 3.525218e-02
53 -2.338308e-03 -2.348725e-02
54 -1.735337e-02 -2.338308e-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/7m7h01260706615.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/8knbg1260706615.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/97gee1260706615.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/10bt0q1260706615.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/1196741260706615.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/12lkw41260706615.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/1328ve1260706615.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/14yw9a1260706615.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/15w04t1260706615.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/16ys6r1260706615.tab")
+ }
>
> try(system("convert tmp/1sfrw1260706615.ps tmp/1sfrw1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/214cq1260706615.ps tmp/214cq1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/3lc7u1260706615.ps tmp/3lc7u1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/4gu1m1260706615.ps tmp/4gu1m1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/5grvz1260706615.ps tmp/5grvz1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/6pr4u1260706615.ps tmp/6pr4u1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/7m7h01260706615.ps tmp/7m7h01260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/8knbg1260706615.ps tmp/8knbg1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/97gee1260706615.ps tmp/97gee1260706615.png",intern=TRUE))
character(0)
> try(system("convert tmp/10bt0q1260706615.ps tmp/10bt0q1260706615.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.375 1.530 2.810