R version 2.7.0 (2008-04-22)
Copyright (C) 2008 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(11554.5
+ ,7.5
+ ,13182.1
+ ,7.2
+ ,14800.1
+ ,6.9
+ ,12150.7
+ ,6.7
+ ,14478.2
+ ,6.4
+ ,13253.9
+ ,6.3
+ ,12036.8
+ ,6.8
+ ,12653.2
+ ,7.3
+ ,14035.4
+ ,7.1
+ ,14571.4
+ ,7.1
+ ,15400.9
+ ,6.8
+ ,14283.2
+ ,6.5
+ ,14485.3
+ ,6.3
+ ,14196.3
+ ,6.1
+ ,15559.1
+ ,6.1
+ ,13767.4
+ ,6.3
+ ,14634
+ ,6.3
+ ,14381.1
+ ,6
+ ,12509.9
+ ,6.2
+ ,12122.3
+ ,6.4
+ ,13122.3
+ ,6.8
+ ,13908.7
+ ,7.5
+ ,13456.5
+ ,7.5
+ ,12441.6
+ ,7.6
+ ,12953
+ ,7.6
+ ,13057.2
+ ,7.4
+ ,14350.1
+ ,7.3
+ ,13830.2
+ ,7.1
+ ,13755.5
+ ,6.9
+ ,13574.4
+ ,6.8
+ ,12802.6
+ ,7.5
+ ,11737.3
+ ,7.6
+ ,13850.2
+ ,7.8
+ ,15081.8
+ ,8
+ ,13653.3
+ ,8.1
+ ,14019.1
+ ,8.2
+ ,13962
+ ,8.3
+ ,13768.7
+ ,8.2
+ ,14747.1
+ ,8
+ ,13858.1
+ ,7.9
+ ,13188
+ ,7.6
+ ,13693.1
+ ,7.6
+ ,12970
+ ,8.2
+ ,11392.8
+ ,8.3
+ ,13985.2
+ ,8.4
+ ,14994.7
+ ,8.4
+ ,13584.7
+ ,8.4
+ ,14257.8
+ ,8.6
+ ,13553.4
+ ,8.9
+ ,14007.3
+ ,8.8
+ ,16535.8
+ ,8.3
+ ,14721.4
+ ,7.5
+ ,13664.6
+ ,7.2
+ ,16805.9
+ ,7.5
+ ,13829.4
+ ,8.8
+ ,13735.6
+ ,9.3
+ ,15870.5
+ ,9.3
+ ,15962.4
+ ,8.7
+ ,15744.1
+ ,8.2
+ ,16083.7
+ ,8.3
+ ,14863.9
+ ,8.5
+ ,15533.1
+ ,8.6
+ ,17473.1
+ ,8.6
+ ,15925.5
+ ,8.2
+ ,15573.7
+ ,8.1
+ ,17495
+ ,8
+ ,14155.8
+ ,8.6
+ ,14913.9
+ ,8.7
+ ,17250.4
+ ,8.8
+ ,15879.8
+ ,8.5
+ ,17647.8
+ ,8.4
+ ,17749.9
+ ,8.5
+ ,17111.8
+ ,8.7
+ ,16934.8
+ ,8.7
+ ,20280
+ ,8.6
+ ,16238.2
+ ,8.5
+ ,17896.1
+ ,8.3
+ ,18089.3
+ ,8.1
+ ,15660
+ ,8.2
+ ,16162.4
+ ,8.1
+ ,17850.1
+ ,8.1
+ ,18520.4
+ ,7.9
+ ,18524.7
+ ,7.9
+ ,16843.7
+ ,7.9)
+ ,dim=c(2
+ ,84)
+ ,dimnames=list(c('Invoer'
+ ,'Werkloosheid')
+ ,1:84))
> y <- array(NA,dim=c(2,84),dimnames=list(c('Invoer','Werkloosheid'),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 = '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
Invoer Werkloosheid M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 11554.5 7.5 1 0 0 0 0 0 0 0 0 0 0 1
2 13182.1 7.2 0 1 0 0 0 0 0 0 0 0 0 2
3 14800.1 6.9 0 0 1 0 0 0 0 0 0 0 0 3
4 12150.7 6.7 0 0 0 1 0 0 0 0 0 0 0 4
5 14478.2 6.4 0 0 0 0 1 0 0 0 0 0 0 5
6 13253.9 6.3 0 0 0 0 0 1 0 0 0 0 0 6
7 12036.8 6.8 0 0 0 0 0 0 1 0 0 0 0 7
8 12653.2 7.3 0 0 0 0 0 0 0 1 0 0 0 8
9 14035.4 7.1 0 0 0 0 0 0 0 0 1 0 0 9
10 14571.4 7.1 0 0 0 0 0 0 0 0 0 1 0 10
11 15400.9 6.8 0 0 0 0 0 0 0 0 0 0 1 11
12 14283.2 6.5 0 0 0 0 0 0 0 0 0 0 0 12
13 14485.3 6.3 1 0 0 0 0 0 0 0 0 0 0 13
14 14196.3 6.1 0 1 0 0 0 0 0 0 0 0 0 14
15 15559.1 6.1 0 0 1 0 0 0 0 0 0 0 0 15
16 13767.4 6.3 0 0 0 1 0 0 0 0 0 0 0 16
17 14634.0 6.3 0 0 0 0 1 0 0 0 0 0 0 17
18 14381.1 6.0 0 0 0 0 0 1 0 0 0 0 0 18
19 12509.9 6.2 0 0 0 0 0 0 1 0 0 0 0 19
20 12122.3 6.4 0 0 0 0 0 0 0 1 0 0 0 20
21 13122.3 6.8 0 0 0 0 0 0 0 0 1 0 0 21
22 13908.7 7.5 0 0 0 0 0 0 0 0 0 1 0 22
23 13456.5 7.5 0 0 0 0 0 0 0 0 0 0 1 23
24 12441.6 7.6 0 0 0 0 0 0 0 0 0 0 0 24
25 12953.0 7.6 1 0 0 0 0 0 0 0 0 0 0 25
26 13057.2 7.4 0 1 0 0 0 0 0 0 0 0 0 26
27 14350.1 7.3 0 0 1 0 0 0 0 0 0 0 0 27
28 13830.2 7.1 0 0 0 1 0 0 0 0 0 0 0 28
29 13755.5 6.9 0 0 0 0 1 0 0 0 0 0 0 29
30 13574.4 6.8 0 0 0 0 0 1 0 0 0 0 0 30
31 12802.6 7.5 0 0 0 0 0 0 1 0 0 0 0 31
32 11737.3 7.6 0 0 0 0 0 0 0 1 0 0 0 32
33 13850.2 7.8 0 0 0 0 0 0 0 0 1 0 0 33
34 15081.8 8.0 0 0 0 0 0 0 0 0 0 1 0 34
35 13653.3 8.1 0 0 0 0 0 0 0 0 0 0 1 35
36 14019.1 8.2 0 0 0 0 0 0 0 0 0 0 0 36
37 13962.0 8.3 1 0 0 0 0 0 0 0 0 0 0 37
38 13768.7 8.2 0 1 0 0 0 0 0 0 0 0 0 38
39 14747.1 8.0 0 0 1 0 0 0 0 0 0 0 0 39
40 13858.1 7.9 0 0 0 1 0 0 0 0 0 0 0 40
41 13188.0 7.6 0 0 0 0 1 0 0 0 0 0 0 41
42 13693.1 7.6 0 0 0 0 0 1 0 0 0 0 0 42
43 12970.0 8.2 0 0 0 0 0 0 1 0 0 0 0 43
44 11392.8 8.3 0 0 0 0 0 0 0 1 0 0 0 44
45 13985.2 8.4 0 0 0 0 0 0 0 0 1 0 0 45
46 14994.7 8.4 0 0 0 0 0 0 0 0 0 1 0 46
47 13584.7 8.4 0 0 0 0 0 0 0 0 0 0 1 47
48 14257.8 8.6 0 0 0 0 0 0 0 0 0 0 0 48
49 13553.4 8.9 1 0 0 0 0 0 0 0 0 0 0 49
50 14007.3 8.8 0 1 0 0 0 0 0 0 0 0 0 50
51 16535.8 8.3 0 0 1 0 0 0 0 0 0 0 0 51
52 14721.4 7.5 0 0 0 1 0 0 0 0 0 0 0 52
53 13664.6 7.2 0 0 0 0 1 0 0 0 0 0 0 53
54 16805.9 7.5 0 0 0 0 0 1 0 0 0 0 0 54
55 13829.4 8.8 0 0 0 0 0 0 1 0 0 0 0 55
56 13735.6 9.3 0 0 0 0 0 0 0 1 0 0 0 56
57 15870.5 9.3 0 0 0 0 0 0 0 0 1 0 0 57
58 15962.4 8.7 0 0 0 0 0 0 0 0 0 1 0 58
59 15744.1 8.2 0 0 0 0 0 0 0 0 0 0 1 59
60 16083.7 8.3 0 0 0 0 0 0 0 0 0 0 0 60
61 14863.9 8.5 1 0 0 0 0 0 0 0 0 0 0 61
62 15533.1 8.6 0 1 0 0 0 0 0 0 0 0 0 62
63 17473.1 8.6 0 0 1 0 0 0 0 0 0 0 0 63
64 15925.5 8.2 0 0 0 1 0 0 0 0 0 0 0 64
65 15573.7 8.1 0 0 0 0 1 0 0 0 0 0 0 65
66 17495.0 8.0 0 0 0 0 0 1 0 0 0 0 0 66
67 14155.8 8.6 0 0 0 0 0 0 1 0 0 0 0 67
68 14913.9 8.7 0 0 0 0 0 0 0 1 0 0 0 68
69 17250.4 8.8 0 0 0 0 0 0 0 0 1 0 0 69
70 15879.8 8.5 0 0 0 0 0 0 0 0 0 1 0 70
71 17647.8 8.4 0 0 0 0 0 0 0 0 0 0 1 71
72 17749.9 8.5 0 0 0 0 0 0 0 0 0 0 0 72
73 17111.8 8.7 1 0 0 0 0 0 0 0 0 0 0 73
74 16934.8 8.7 0 1 0 0 0 0 0 0 0 0 0 74
75 20280.0 8.6 0 0 1 0 0 0 0 0 0 0 0 75
76 16238.2 8.5 0 0 0 1 0 0 0 0 0 0 0 76
77 17896.1 8.3 0 0 0 0 1 0 0 0 0 0 0 77
78 18089.3 8.1 0 0 0 0 0 1 0 0 0 0 0 78
79 15660.0 8.2 0 0 0 0 0 0 1 0 0 0 0 79
80 16162.4 8.1 0 0 0 0 0 0 0 1 0 0 0 80
81 17850.1 8.1 0 0 0 0 0 0 0 0 1 0 0 81
82 18520.4 7.9 0 0 0 0 0 0 0 0 0 1 0 82
83 18524.7 7.9 0 0 0 0 0 0 0 0 0 0 1 83
84 16843.7 7.9 0 0 0 0 0 0 0 0 0 0 0 84
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Werkloosheid M1 M2 M3
18263.70 -865.01 -154.34 -16.70 1624.39
M4 M5 M6 M7 M8
-543.90 -408.55 38.59 -1448.32 -1530.62
M9 M10 M11 t
358.73 679.00 373.38 77.17
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2052.26 -514.43 -60.45 584.76 2043.58
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 18263.699 1459.564 12.513 < 2e-16 ***
Werkloosheid -865.008 209.803 -4.123 0.000101 ***
M1 -154.338 488.896 -0.316 0.753180
M2 -16.704 485.448 -0.034 0.972649
M3 1624.386 483.778 3.358 0.001274 **
M4 -543.895 486.971 -1.117 0.267858
M5 -408.548 494.642 -0.826 0.411641
M6 38.586 499.190 0.077 0.938608
M7 -1448.317 482.920 -2.999 0.003748 **
M8 -1530.624 483.254 -3.167 0.002280 **
M9 358.726 483.937 0.741 0.461012
M10 679.003 483.103 1.406 0.164295
M11 373.379 482.371 0.774 0.441508
t 77.165 6.812 11.329 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 902.4 on 70 degrees of freedom
Multiple R-squared: 0.7943, Adjusted R-squared: 0.7561
F-statistic: 20.79 on 13 and 70 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.5222881 0.9554238 0.4777119
[2,] 0.3793375 0.7586751 0.6206625
[3,] 0.3139608 0.6279217 0.6860392
[4,] 0.6016520 0.7966960 0.3983480
[5,] 0.6452997 0.7094006 0.3547003
[6,] 0.5496338 0.9007324 0.4503662
[7,] 0.4908873 0.9817747 0.5091127
[8,] 0.3919172 0.7838345 0.6080828
[9,] 0.4368874 0.8737749 0.5631126
[10,] 0.3599492 0.7198984 0.6400508
[11,] 0.2817668 0.5635336 0.7182332
[12,] 0.4156651 0.8313302 0.5843349
[13,] 0.3940381 0.7880763 0.6059619
[14,] 0.3225139 0.6450278 0.6774861
[15,] 0.4484374 0.8968748 0.5515626
[16,] 0.3821848 0.7643696 0.6178152
[17,] 0.3634224 0.7268449 0.6365776
[18,] 0.5076465 0.9847070 0.4923535
[19,] 0.4394477 0.8788955 0.5605523
[20,] 0.5074326 0.9851347 0.4925674
[21,] 0.6380048 0.7239904 0.3619952
[22,] 0.6393958 0.7212084 0.3606042
[23,] 0.5826107 0.8347785 0.4173893
[24,] 0.5871795 0.8256411 0.4128205
[25,] 0.5808360 0.8383280 0.4191640
[26,] 0.5734446 0.8531108 0.4265554
[27,] 0.6191286 0.7617428 0.3808714
[28,] 0.6058019 0.7883963 0.3941981
[29,] 0.5468563 0.9062875 0.4531437
[30,] 0.5254849 0.9490302 0.4745151
[31,] 0.5790524 0.8418951 0.4209476
[32,] 0.5358340 0.9283320 0.4641660
[33,] 0.4984587 0.9969173 0.5015413
[34,] 0.4506693 0.9013385 0.5493307
[35,] 0.4914353 0.9828705 0.5085647
[36,] 0.4752440 0.9504879 0.5247560
[37,] 0.5122216 0.9755568 0.4877784
[38,] 0.7268254 0.5463491 0.2731746
[39,] 0.7167285 0.5665429 0.2832715
[40,] 0.7120741 0.5758518 0.2879259
[41,] 0.7056123 0.5887755 0.2943877
[42,] 0.6411484 0.7177031 0.3588516
[43,] 0.5694076 0.8611848 0.4305924
[44,] 0.5574525 0.8850950 0.4425475
[45,] 0.4878135 0.9756270 0.5121865
[46,] 0.3922083 0.7844166 0.6077917
[47,] 0.4754250 0.9508500 0.5245750
[48,] 0.4570035 0.9140070 0.5429965
[49,] 0.4164037 0.8328074 0.5835963
[50,] 0.3557247 0.7114493 0.6442753
[51,] 0.2204927 0.4409855 0.7795073
> postscript(file="/var/www/html/rcomp/tmp/14h5y1228660029.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/2o5c41228660029.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/38okp1228660029.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/4p7vf1228660029.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/5fqor1228660029.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 = 84
Frequency = 1
1 2 3 4 5 6
-144.463981 1008.834460 649.076237 -82.209237 1773.275637 -61.824603
7 8 9 10 11 12
563.317655 1617.363031 860.046346 998.603729 1797.059312 716.070719
13 14 15 16 17 18
822.341187 145.540467 -209.915236 262.502649 916.590043 -120.111877
19 20 21 22 23 24
-408.572139 -618.029282 -1238.540928 -244.077667 -467.819564 -1100.004798
25 26 27 28 29 30
-511.432650 -795.033370 -1306.889913 91.324613 -368.889673 -1160.789913
31 32 33 34 35 36
82.654024 -891.003959 -571.617285 435.541778 -677.999280 70.515486
37 38 39 40 41 42
177.088474 -317.511406 -1230.368789 -114.753424 -1256.868549 -1276.067949
43 44 45 46 47 48
-70.424852 -1555.982835 -843.597001 -231.539618 -1413.081515 -270.765910
49 50 51 52 53 54
-638.491242 -485.891122 -108.151025 -523.441538 -2052.256663 824.246456
55 56 57 58 59 60
381.995432 725.840808 894.225803 69.678147 -352.667950 369.646816
61 62 63 64 65 66
-599.979356 -59.077557 162.666740 360.179586 -290.633860 1019.865900
67 68 69 70 71 72
-390.591003 459.151015 915.636849 -1111.908288 798.048975 1282.863741
73 74 75 76 77 78
894.937569 503.138528 2043.581985 6.397351 1278.783065 774.681985
79 80 81 82 83 84
-158.379117 262.661221 -16.153784 83.701919 316.460021 -1068.326053
> postscript(file="/var/www/html/rcomp/tmp/6kzsx1228660029.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 = 84
Frequency = 1
lag(myerror, k = 1) myerror
0 -144.463981 NA
1 1008.834460 -144.463981
2 649.076237 1008.834460
3 -82.209237 649.076237
4 1773.275637 -82.209237
5 -61.824603 1773.275637
6 563.317655 -61.824603
7 1617.363031 563.317655
8 860.046346 1617.363031
9 998.603729 860.046346
10 1797.059312 998.603729
11 716.070719 1797.059312
12 822.341187 716.070719
13 145.540467 822.341187
14 -209.915236 145.540467
15 262.502649 -209.915236
16 916.590043 262.502649
17 -120.111877 916.590043
18 -408.572139 -120.111877
19 -618.029282 -408.572139
20 -1238.540928 -618.029282
21 -244.077667 -1238.540928
22 -467.819564 -244.077667
23 -1100.004798 -467.819564
24 -511.432650 -1100.004798
25 -795.033370 -511.432650
26 -1306.889913 -795.033370
27 91.324613 -1306.889913
28 -368.889673 91.324613
29 -1160.789913 -368.889673
30 82.654024 -1160.789913
31 -891.003959 82.654024
32 -571.617285 -891.003959
33 435.541778 -571.617285
34 -677.999280 435.541778
35 70.515486 -677.999280
36 177.088474 70.515486
37 -317.511406 177.088474
38 -1230.368789 -317.511406
39 -114.753424 -1230.368789
40 -1256.868549 -114.753424
41 -1276.067949 -1256.868549
42 -70.424852 -1276.067949
43 -1555.982835 -70.424852
44 -843.597001 -1555.982835
45 -231.539618 -843.597001
46 -1413.081515 -231.539618
47 -270.765910 -1413.081515
48 -638.491242 -270.765910
49 -485.891122 -638.491242
50 -108.151025 -485.891122
51 -523.441538 -108.151025
52 -2052.256663 -523.441538
53 824.246456 -2052.256663
54 381.995432 824.246456
55 725.840808 381.995432
56 894.225803 725.840808
57 69.678147 894.225803
58 -352.667950 69.678147
59 369.646816 -352.667950
60 -599.979356 369.646816
61 -59.077557 -599.979356
62 162.666740 -59.077557
63 360.179586 162.666740
64 -290.633860 360.179586
65 1019.865900 -290.633860
66 -390.591003 1019.865900
67 459.151015 -390.591003
68 915.636849 459.151015
69 -1111.908288 915.636849
70 798.048975 -1111.908288
71 1282.863741 798.048975
72 894.937569 1282.863741
73 503.138528 894.937569
74 2043.581985 503.138528
75 6.397351 2043.581985
76 1278.783065 6.397351
77 774.681985 1278.783065
78 -158.379117 774.681985
79 262.661221 -158.379117
80 -16.153784 262.661221
81 83.701919 -16.153784
82 316.460021 83.701919
83 -1068.326053 316.460021
84 NA -1068.326053
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1008.834460 -144.463981
[2,] 649.076237 1008.834460
[3,] -82.209237 649.076237
[4,] 1773.275637 -82.209237
[5,] -61.824603 1773.275637
[6,] 563.317655 -61.824603
[7,] 1617.363031 563.317655
[8,] 860.046346 1617.363031
[9,] 998.603729 860.046346
[10,] 1797.059312 998.603729
[11,] 716.070719 1797.059312
[12,] 822.341187 716.070719
[13,] 145.540467 822.341187
[14,] -209.915236 145.540467
[15,] 262.502649 -209.915236
[16,] 916.590043 262.502649
[17,] -120.111877 916.590043
[18,] -408.572139 -120.111877
[19,] -618.029282 -408.572139
[20,] -1238.540928 -618.029282
[21,] -244.077667 -1238.540928
[22,] -467.819564 -244.077667
[23,] -1100.004798 -467.819564
[24,] -511.432650 -1100.004798
[25,] -795.033370 -511.432650
[26,] -1306.889913 -795.033370
[27,] 91.324613 -1306.889913
[28,] -368.889673 91.324613
[29,] -1160.789913 -368.889673
[30,] 82.654024 -1160.789913
[31,] -891.003959 82.654024
[32,] -571.617285 -891.003959
[33,] 435.541778 -571.617285
[34,] -677.999280 435.541778
[35,] 70.515486 -677.999280
[36,] 177.088474 70.515486
[37,] -317.511406 177.088474
[38,] -1230.368789 -317.511406
[39,] -114.753424 -1230.368789
[40,] -1256.868549 -114.753424
[41,] -1276.067949 -1256.868549
[42,] -70.424852 -1276.067949
[43,] -1555.982835 -70.424852
[44,] -843.597001 -1555.982835
[45,] -231.539618 -843.597001
[46,] -1413.081515 -231.539618
[47,] -270.765910 -1413.081515
[48,] -638.491242 -270.765910
[49,] -485.891122 -638.491242
[50,] -108.151025 -485.891122
[51,] -523.441538 -108.151025
[52,] -2052.256663 -523.441538
[53,] 824.246456 -2052.256663
[54,] 381.995432 824.246456
[55,] 725.840808 381.995432
[56,] 894.225803 725.840808
[57,] 69.678147 894.225803
[58,] -352.667950 69.678147
[59,] 369.646816 -352.667950
[60,] -599.979356 369.646816
[61,] -59.077557 -599.979356
[62,] 162.666740 -59.077557
[63,] 360.179586 162.666740
[64,] -290.633860 360.179586
[65,] 1019.865900 -290.633860
[66,] -390.591003 1019.865900
[67,] 459.151015 -390.591003
[68,] 915.636849 459.151015
[69,] -1111.908288 915.636849
[70,] 798.048975 -1111.908288
[71,] 1282.863741 798.048975
[72,] 894.937569 1282.863741
[73,] 503.138528 894.937569
[74,] 2043.581985 503.138528
[75,] 6.397351 2043.581985
[76,] 1278.783065 6.397351
[77,] 774.681985 1278.783065
[78,] -158.379117 774.681985
[79,] 262.661221 -158.379117
[80,] -16.153784 262.661221
[81,] 83.701919 -16.153784
[82,] 316.460021 83.701919
[83,] -1068.326053 316.460021
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1008.834460 -144.463981
2 649.076237 1008.834460
3 -82.209237 649.076237
4 1773.275637 -82.209237
5 -61.824603 1773.275637
6 563.317655 -61.824603
7 1617.363031 563.317655
8 860.046346 1617.363031
9 998.603729 860.046346
10 1797.059312 998.603729
11 716.070719 1797.059312
12 822.341187 716.070719
13 145.540467 822.341187
14 -209.915236 145.540467
15 262.502649 -209.915236
16 916.590043 262.502649
17 -120.111877 916.590043
18 -408.572139 -120.111877
19 -618.029282 -408.572139
20 -1238.540928 -618.029282
21 -244.077667 -1238.540928
22 -467.819564 -244.077667
23 -1100.004798 -467.819564
24 -511.432650 -1100.004798
25 -795.033370 -511.432650
26 -1306.889913 -795.033370
27 91.324613 -1306.889913
28 -368.889673 91.324613
29 -1160.789913 -368.889673
30 82.654024 -1160.789913
31 -891.003959 82.654024
32 -571.617285 -891.003959
33 435.541778 -571.617285
34 -677.999280 435.541778
35 70.515486 -677.999280
36 177.088474 70.515486
37 -317.511406 177.088474
38 -1230.368789 -317.511406
39 -114.753424 -1230.368789
40 -1256.868549 -114.753424
41 -1276.067949 -1256.868549
42 -70.424852 -1276.067949
43 -1555.982835 -70.424852
44 -843.597001 -1555.982835
45 -231.539618 -843.597001
46 -1413.081515 -231.539618
47 -270.765910 -1413.081515
48 -638.491242 -270.765910
49 -485.891122 -638.491242
50 -108.151025 -485.891122
51 -523.441538 -108.151025
52 -2052.256663 -523.441538
53 824.246456 -2052.256663
54 381.995432 824.246456
55 725.840808 381.995432
56 894.225803 725.840808
57 69.678147 894.225803
58 -352.667950 69.678147
59 369.646816 -352.667950
60 -599.979356 369.646816
61 -59.077557 -599.979356
62 162.666740 -59.077557
63 360.179586 162.666740
64 -290.633860 360.179586
65 1019.865900 -290.633860
66 -390.591003 1019.865900
67 459.151015 -390.591003
68 915.636849 459.151015
69 -1111.908288 915.636849
70 798.048975 -1111.908288
71 1282.863741 798.048975
72 894.937569 1282.863741
73 503.138528 894.937569
74 2043.581985 503.138528
75 6.397351 2043.581985
76 1278.783065 6.397351
77 774.681985 1278.783065
78 -158.379117 774.681985
79 262.661221 -158.379117
80 -16.153784 262.661221
81 83.701919 -16.153784
82 316.460021 83.701919
83 -1068.326053 316.460021
> 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/7m5ru1228660029.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/82ixm1228660029.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/9l1z61228660029.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/104uv71228660029.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/11r7mn1228660029.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/122k661228660029.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/13co6m1228660029.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/14g1741228660030.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/15j94i1228660030.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/167mkw1228660030.tab")
+ }
>
> system("convert tmp/14h5y1228660029.ps tmp/14h5y1228660029.png")
> system("convert tmp/2o5c41228660029.ps tmp/2o5c41228660029.png")
> system("convert tmp/38okp1228660029.ps tmp/38okp1228660029.png")
> system("convert tmp/4p7vf1228660029.ps tmp/4p7vf1228660029.png")
> system("convert tmp/5fqor1228660029.ps tmp/5fqor1228660029.png")
> system("convert tmp/6kzsx1228660029.ps tmp/6kzsx1228660029.png")
> system("convert tmp/7m5ru1228660029.ps tmp/7m5ru1228660029.png")
> system("convert tmp/82ixm1228660029.ps tmp/82ixm1228660029.png")
> system("convert tmp/9l1z61228660029.ps tmp/9l1z61228660029.png")
> system("convert tmp/104uv71228660029.ps tmp/104uv71228660029.png")
>
>
> proc.time()
user system elapsed
5.532 2.763 5.944