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(94
+ ,0
+ ,106.3
+ ,101.3
+ ,102.8
+ ,1
+ ,94
+ ,106.3
+ ,102
+ ,1
+ ,102.8
+ ,94
+ ,105.1
+ ,1
+ ,102
+ ,102.8
+ ,92.4
+ ,0
+ ,105.1
+ ,102
+ ,81.4
+ ,0
+ ,92.4
+ ,105.1
+ ,105.8
+ ,1
+ ,81.4
+ ,92.4
+ ,120.3
+ ,1
+ ,105.8
+ ,81.4
+ ,100.7
+ ,1
+ ,120.3
+ ,105.8
+ ,88.8
+ ,0
+ ,100.7
+ ,120.3
+ ,94.3
+ ,0
+ ,88.8
+ ,100.7
+ ,99.9
+ ,0
+ ,94.3
+ ,88.8
+ ,103.4
+ ,1
+ ,99.9
+ ,94.3
+ ,103.3
+ ,1
+ ,103.4
+ ,99.9
+ ,98.8
+ ,0
+ ,103.3
+ ,103.4
+ ,104.2
+ ,1
+ ,98.8
+ ,103.3
+ ,91.2
+ ,0
+ ,104.2
+ ,98.8
+ ,74.7
+ ,0
+ ,91.2
+ ,104.2
+ ,108.5
+ ,1
+ ,74.7
+ ,91.2
+ ,114.5
+ ,1
+ ,108.5
+ ,74.7
+ ,96.9
+ ,0
+ ,114.5
+ ,108.5
+ ,89.6
+ ,0
+ ,96.9
+ ,114.5
+ ,97.1
+ ,0
+ ,89.6
+ ,96.9
+ ,100.3
+ ,1
+ ,97.1
+ ,89.6
+ ,122.6
+ ,1
+ ,100.3
+ ,97.1
+ ,115.4
+ ,1
+ ,122.6
+ ,100.3
+ ,109
+ ,1
+ ,115.4
+ ,122.6
+ ,129.1
+ ,1
+ ,109
+ ,115.4
+ ,102.8
+ ,1
+ ,129.1
+ ,109
+ ,96.2
+ ,0
+ ,102.8
+ ,129.1
+ ,127.7
+ ,1
+ ,96.2
+ ,102.8
+ ,128.9
+ ,1
+ ,127.7
+ ,96.2
+ ,126.5
+ ,1
+ ,128.9
+ ,127.7
+ ,119.8
+ ,1
+ ,126.5
+ ,128.9
+ ,113.2
+ ,1
+ ,119.8
+ ,126.5
+ ,114.1
+ ,1
+ ,113.2
+ ,119.8
+ ,134.1
+ ,1
+ ,114.1
+ ,113.2
+ ,130
+ ,1
+ ,134.1
+ ,114.1
+ ,121.8
+ ,1
+ ,130
+ ,134.1
+ ,132.1
+ ,1
+ ,121.8
+ ,130
+ ,105.3
+ ,1
+ ,132.1
+ ,121.8
+ ,103
+ ,1
+ ,105.3
+ ,132.1
+ ,117.1
+ ,1
+ ,103
+ ,105.3
+ ,126.3
+ ,1
+ ,117.1
+ ,103
+ ,138.1
+ ,1
+ ,126.3
+ ,117.1
+ ,119.5
+ ,1
+ ,138.1
+ ,126.3
+ ,138
+ ,1
+ ,119.5
+ ,138.1
+ ,135.5
+ ,1
+ ,138
+ ,119.5
+ ,178.6
+ ,1
+ ,135.5
+ ,138
+ ,162.2
+ ,1
+ ,178.6
+ ,135.5
+ ,176.9
+ ,1
+ ,162.2
+ ,178.6
+ ,204.9
+ ,1
+ ,176.9
+ ,162.2
+ ,132.2
+ ,1
+ ,204.9
+ ,176.9
+ ,142.5
+ ,1
+ ,132.2
+ ,204.9
+ ,164.3
+ ,1
+ ,142.5
+ ,132.2
+ ,174.9
+ ,1
+ ,164.3
+ ,142.5
+ ,175.4
+ ,1
+ ,174.9
+ ,164.3
+ ,143
+ ,1
+ ,175.4
+ ,174.9)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('Omzet'
+ ,'Uitvoer'
+ ,'Omzet-1'
+ ,'Omzet-2')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('Omzet','Uitvoer','Omzet-1','Omzet-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
Omzet Uitvoer Omzet-1 Omzet-2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 94.0 0 106.3 101.3 1 0 0 0 0 0 0 0 0 0 0 1
2 102.8 1 94.0 106.3 0 1 0 0 0 0 0 0 0 0 0 2
3 102.0 1 102.8 94.0 0 0 1 0 0 0 0 0 0 0 0 3
4 105.1 1 102.0 102.8 0 0 0 1 0 0 0 0 0 0 0 4
5 92.4 0 105.1 102.0 0 0 0 0 1 0 0 0 0 0 0 5
6 81.4 0 92.4 105.1 0 0 0 0 0 1 0 0 0 0 0 6
7 105.8 1 81.4 92.4 0 0 0 0 0 0 1 0 0 0 0 7
8 120.3 1 105.8 81.4 0 0 0 0 0 0 0 1 0 0 0 8
9 100.7 1 120.3 105.8 0 0 0 0 0 0 0 0 1 0 0 9
10 88.8 0 100.7 120.3 0 0 0 0 0 0 0 0 0 1 0 10
11 94.3 0 88.8 100.7 0 0 0 0 0 0 0 0 0 0 1 11
12 99.9 0 94.3 88.8 0 0 0 0 0 0 0 0 0 0 0 12
13 103.4 1 99.9 94.3 1 0 0 0 0 0 0 0 0 0 0 13
14 103.3 1 103.4 99.9 0 1 0 0 0 0 0 0 0 0 0 14
15 98.8 0 103.3 103.4 0 0 1 0 0 0 0 0 0 0 0 15
16 104.2 1 98.8 103.3 0 0 0 1 0 0 0 0 0 0 0 16
17 91.2 0 104.2 98.8 0 0 0 0 1 0 0 0 0 0 0 17
18 74.7 0 91.2 104.2 0 0 0 0 0 1 0 0 0 0 0 18
19 108.5 1 74.7 91.2 0 0 0 0 0 0 1 0 0 0 0 19
20 114.5 1 108.5 74.7 0 0 0 0 0 0 0 1 0 0 0 20
21 96.9 0 114.5 108.5 0 0 0 0 0 0 0 0 1 0 0 21
22 89.6 0 96.9 114.5 0 0 0 0 0 0 0 0 0 1 0 22
23 97.1 0 89.6 96.9 0 0 0 0 0 0 0 0 0 0 1 23
24 100.3 1 97.1 89.6 0 0 0 0 0 0 0 0 0 0 0 24
25 122.6 1 100.3 97.1 1 0 0 0 0 0 0 0 0 0 0 25
26 115.4 1 122.6 100.3 0 1 0 0 0 0 0 0 0 0 0 26
27 109.0 1 115.4 122.6 0 0 1 0 0 0 0 0 0 0 0 27
28 129.1 1 109.0 115.4 0 0 0 1 0 0 0 0 0 0 0 28
29 102.8 1 129.1 109.0 0 0 0 0 1 0 0 0 0 0 0 29
30 96.2 0 102.8 129.1 0 0 0 0 0 1 0 0 0 0 0 30
31 127.7 1 96.2 102.8 0 0 0 0 0 0 1 0 0 0 0 31
32 128.9 1 127.7 96.2 0 0 0 0 0 0 0 1 0 0 0 32
33 126.5 1 128.9 127.7 0 0 0 0 0 0 0 0 1 0 0 33
34 119.8 1 126.5 128.9 0 0 0 0 0 0 0 0 0 1 0 34
35 113.2 1 119.8 126.5 0 0 0 0 0 0 0 0 0 0 1 35
36 114.1 1 113.2 119.8 0 0 0 0 0 0 0 0 0 0 0 36
37 134.1 1 114.1 113.2 1 0 0 0 0 0 0 0 0 0 0 37
38 130.0 1 134.1 114.1 0 1 0 0 0 0 0 0 0 0 0 38
39 121.8 1 130.0 134.1 0 0 1 0 0 0 0 0 0 0 0 39
40 132.1 1 121.8 130.0 0 0 0 1 0 0 0 0 0 0 0 40
41 105.3 1 132.1 121.8 0 0 0 0 1 0 0 0 0 0 0 41
42 103.0 1 105.3 132.1 0 0 0 0 0 1 0 0 0 0 0 42
43 117.1 1 103.0 105.3 0 0 0 0 0 0 1 0 0 0 0 43
44 126.3 1 117.1 103.0 0 0 0 0 0 0 0 1 0 0 0 44
45 138.1 1 126.3 117.1 0 0 0 0 0 0 0 0 1 0 0 45
46 119.5 1 138.1 126.3 0 0 0 0 0 0 0 0 0 1 0 46
47 138.0 1 119.5 138.1 0 0 0 0 0 0 0 0 0 0 1 47
48 135.5 1 138.0 119.5 0 0 0 0 0 0 0 0 0 0 0 48
49 178.6 1 135.5 138.0 1 0 0 0 0 0 0 0 0 0 0 49
50 162.2 1 178.6 135.5 0 1 0 0 0 0 0 0 0 0 0 50
51 176.9 1 162.2 178.6 0 0 1 0 0 0 0 0 0 0 0 51
52 204.9 1 176.9 162.2 0 0 0 1 0 0 0 0 0 0 0 52
53 132.2 1 204.9 176.9 0 0 0 0 1 0 0 0 0 0 0 53
54 142.5 1 132.2 204.9 0 0 0 0 0 1 0 0 0 0 0 54
55 164.3 1 142.5 132.2 0 0 0 0 0 0 1 0 0 0 0 55
56 174.9 1 164.3 142.5 0 0 0 0 0 0 0 1 0 0 0 56
57 175.4 1 174.9 164.3 0 0 0 0 0 0 0 0 1 0 0 57
58 143.0 1 175.4 174.9 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Uitvoer `Omzet-1` `Omzet-2` M1 M2
26.1377 -1.4404 0.3142 0.3613 14.8923 5.1888
M3 M4 M5 M6 M7 M8
-0.9772 13.8940 -21.3068 -22.6259 15.4496 17.2466
M9 M10 M11 t
-0.6820 -18.1301 -3.7273 0.4966
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-25.8030 -4.0305 0.2687 4.6692 26.3014
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 26.1377 10.9779 2.381 0.02188 *
Uitvoer -1.4404 4.6897 -0.307 0.76025
`Omzet-1` 0.3142 0.1429 2.198 0.03348 *
`Omzet-2` 0.3613 0.1420 2.545 0.01468 *
M1 14.8923 7.3217 2.034 0.04830 *
M2 5.1888 7.7394 0.670 0.50625
M3 -0.9772 7.7682 -0.126 0.90049
M4 13.8940 7.6701 1.811 0.07723 .
M5 -21.3068 7.7962 -2.733 0.00914 **
M6 -22.6259 8.9356 -2.532 0.01517 *
M7 15.4496 7.4629 2.070 0.04462 *
M8 17.2466 7.6963 2.241 0.03038 *
M9 -0.6820 7.5478 -0.090 0.92843
M10 -18.1301 7.7744 -2.332 0.02457 *
M11 -3.7273 8.0201 -0.465 0.64452
t 0.4966 0.1843 2.695 0.01008 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 10.73 on 42 degrees of freedom
Multiple R-squared: 0.8825, Adjusted R-squared: 0.8405
F-statistic: 21.02 on 15 and 42 DF, p-value: 8.257e-15
> 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.0389319129 0.0778638258 0.9610681
[2,] 0.0126764775 0.0253529550 0.9873235
[3,] 0.0046570207 0.0093140414 0.9953430
[4,] 0.0011355065 0.0022710130 0.9988645
[5,] 0.0003682445 0.0007364890 0.9996318
[6,] 0.0001071481 0.0002142962 0.9998929
[7,] 0.0116678349 0.0233356698 0.9883322
[8,] 0.0084749341 0.0169498683 0.9915251
[9,] 0.0045575520 0.0091151039 0.9954424
[10,] 0.0100192920 0.0200385840 0.9899807
[11,] 0.0100851157 0.0201702314 0.9899149
[12,] 0.0049498117 0.0098996233 0.9950502
[13,] 0.0049541216 0.0099082431 0.9950459
[14,] 0.0024855563 0.0049711126 0.9975144
[15,] 0.0017153640 0.0034307280 0.9982846
[16,] 0.0115881101 0.0231762202 0.9884119
[17,] 0.0089629595 0.0179259190 0.9910370
[18,] 0.0175335069 0.0350670137 0.9824665
[19,] 0.0117024051 0.0234048101 0.9882976
[20,] 0.0211017911 0.0422035823 0.9788982
[21,] 0.0115162989 0.0230325978 0.9884837
> postscript(file="/var/www/html/rcomp/tmp/1xsc31259317473.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/2il1q1259317473.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/3gpm41259317473.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/4oie21259317473.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/5na411259317473.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 6
-17.5260270 3.9792955 10.5280312 -4.6679978 15.2109190 7.9035386
7 8 9 10 11 12
3.2166244 11.7312292 -3.8085254 0.7216609 2.1429180 6.0906196
13 14 15 16 17 18
-8.1045349 -2.1206310 -3.6247538 -10.7021777 9.4909572 -4.0531852
19 20 21 22 23 24
2.4963439 1.5447749 -14.1611133 -1.1477345 0.1056194 0.8033172
25 26 27 28 29 30
3.9991791 -2.1565536 -8.6821842 0.6622584 5.0636987 -1.1534188
31 32 33 34 35 36
4.7910802 -3.8148456 -0.5411826 10.0307969 -8.4963166 -7.3257323
37 38 39 40 41 42
-0.6127225 -2.1147972 -10.5834001 -11.5934834 -3.9626103 -0.7413518
43 44 45 46 47 48
-14.8076331 -11.5002835 9.7466939 1.0666624 6.2477792 0.4317955
49 50 51 52 53 54
22.2441053 2.4126862 12.3623069 26.3014004 -25.8029645 -1.9555828
55 56 57 58
4.3035845 2.0391249 8.7641275 -10.6713857
> postscript(file="/var/www/html/rcomp/tmp/6yy5g1259317473.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 -17.5260270 NA
1 3.9792955 -17.5260270
2 10.5280312 3.9792955
3 -4.6679978 10.5280312
4 15.2109190 -4.6679978
5 7.9035386 15.2109190
6 3.2166244 7.9035386
7 11.7312292 3.2166244
8 -3.8085254 11.7312292
9 0.7216609 -3.8085254
10 2.1429180 0.7216609
11 6.0906196 2.1429180
12 -8.1045349 6.0906196
13 -2.1206310 -8.1045349
14 -3.6247538 -2.1206310
15 -10.7021777 -3.6247538
16 9.4909572 -10.7021777
17 -4.0531852 9.4909572
18 2.4963439 -4.0531852
19 1.5447749 2.4963439
20 -14.1611133 1.5447749
21 -1.1477345 -14.1611133
22 0.1056194 -1.1477345
23 0.8033172 0.1056194
24 3.9991791 0.8033172
25 -2.1565536 3.9991791
26 -8.6821842 -2.1565536
27 0.6622584 -8.6821842
28 5.0636987 0.6622584
29 -1.1534188 5.0636987
30 4.7910802 -1.1534188
31 -3.8148456 4.7910802
32 -0.5411826 -3.8148456
33 10.0307969 -0.5411826
34 -8.4963166 10.0307969
35 -7.3257323 -8.4963166
36 -0.6127225 -7.3257323
37 -2.1147972 -0.6127225
38 -10.5834001 -2.1147972
39 -11.5934834 -10.5834001
40 -3.9626103 -11.5934834
41 -0.7413518 -3.9626103
42 -14.8076331 -0.7413518
43 -11.5002835 -14.8076331
44 9.7466939 -11.5002835
45 1.0666624 9.7466939
46 6.2477792 1.0666624
47 0.4317955 6.2477792
48 22.2441053 0.4317955
49 2.4126862 22.2441053
50 12.3623069 2.4126862
51 26.3014004 12.3623069
52 -25.8029645 26.3014004
53 -1.9555828 -25.8029645
54 4.3035845 -1.9555828
55 2.0391249 4.3035845
56 8.7641275 2.0391249
57 -10.6713857 8.7641275
58 NA -10.6713857
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3.9792955 -17.5260270
[2,] 10.5280312 3.9792955
[3,] -4.6679978 10.5280312
[4,] 15.2109190 -4.6679978
[5,] 7.9035386 15.2109190
[6,] 3.2166244 7.9035386
[7,] 11.7312292 3.2166244
[8,] -3.8085254 11.7312292
[9,] 0.7216609 -3.8085254
[10,] 2.1429180 0.7216609
[11,] 6.0906196 2.1429180
[12,] -8.1045349 6.0906196
[13,] -2.1206310 -8.1045349
[14,] -3.6247538 -2.1206310
[15,] -10.7021777 -3.6247538
[16,] 9.4909572 -10.7021777
[17,] -4.0531852 9.4909572
[18,] 2.4963439 -4.0531852
[19,] 1.5447749 2.4963439
[20,] -14.1611133 1.5447749
[21,] -1.1477345 -14.1611133
[22,] 0.1056194 -1.1477345
[23,] 0.8033172 0.1056194
[24,] 3.9991791 0.8033172
[25,] -2.1565536 3.9991791
[26,] -8.6821842 -2.1565536
[27,] 0.6622584 -8.6821842
[28,] 5.0636987 0.6622584
[29,] -1.1534188 5.0636987
[30,] 4.7910802 -1.1534188
[31,] -3.8148456 4.7910802
[32,] -0.5411826 -3.8148456
[33,] 10.0307969 -0.5411826
[34,] -8.4963166 10.0307969
[35,] -7.3257323 -8.4963166
[36,] -0.6127225 -7.3257323
[37,] -2.1147972 -0.6127225
[38,] -10.5834001 -2.1147972
[39,] -11.5934834 -10.5834001
[40,] -3.9626103 -11.5934834
[41,] -0.7413518 -3.9626103
[42,] -14.8076331 -0.7413518
[43,] -11.5002835 -14.8076331
[44,] 9.7466939 -11.5002835
[45,] 1.0666624 9.7466939
[46,] 6.2477792 1.0666624
[47,] 0.4317955 6.2477792
[48,] 22.2441053 0.4317955
[49,] 2.4126862 22.2441053
[50,] 12.3623069 2.4126862
[51,] 26.3014004 12.3623069
[52,] -25.8029645 26.3014004
[53,] -1.9555828 -25.8029645
[54,] 4.3035845 -1.9555828
[55,] 2.0391249 4.3035845
[56,] 8.7641275 2.0391249
[57,] -10.6713857 8.7641275
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3.9792955 -17.5260270
2 10.5280312 3.9792955
3 -4.6679978 10.5280312
4 15.2109190 -4.6679978
5 7.9035386 15.2109190
6 3.2166244 7.9035386
7 11.7312292 3.2166244
8 -3.8085254 11.7312292
9 0.7216609 -3.8085254
10 2.1429180 0.7216609
11 6.0906196 2.1429180
12 -8.1045349 6.0906196
13 -2.1206310 -8.1045349
14 -3.6247538 -2.1206310
15 -10.7021777 -3.6247538
16 9.4909572 -10.7021777
17 -4.0531852 9.4909572
18 2.4963439 -4.0531852
19 1.5447749 2.4963439
20 -14.1611133 1.5447749
21 -1.1477345 -14.1611133
22 0.1056194 -1.1477345
23 0.8033172 0.1056194
24 3.9991791 0.8033172
25 -2.1565536 3.9991791
26 -8.6821842 -2.1565536
27 0.6622584 -8.6821842
28 5.0636987 0.6622584
29 -1.1534188 5.0636987
30 4.7910802 -1.1534188
31 -3.8148456 4.7910802
32 -0.5411826 -3.8148456
33 10.0307969 -0.5411826
34 -8.4963166 10.0307969
35 -7.3257323 -8.4963166
36 -0.6127225 -7.3257323
37 -2.1147972 -0.6127225
38 -10.5834001 -2.1147972
39 -11.5934834 -10.5834001
40 -3.9626103 -11.5934834
41 -0.7413518 -3.9626103
42 -14.8076331 -0.7413518
43 -11.5002835 -14.8076331
44 9.7466939 -11.5002835
45 1.0666624 9.7466939
46 6.2477792 1.0666624
47 0.4317955 6.2477792
48 22.2441053 0.4317955
49 2.4126862 22.2441053
50 12.3623069 2.4126862
51 26.3014004 12.3623069
52 -25.8029645 26.3014004
53 -1.9555828 -25.8029645
54 4.3035845 -1.9555828
55 2.0391249 4.3035845
56 8.7641275 2.0391249
57 -10.6713857 8.7641275
> 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/7y5ja1259317473.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/8aswk1259317473.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/9l8w31259317473.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/10d8oj1259317473.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/118zbk1259317473.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/12uscq1259317473.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/135zft1259317473.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/14uz071259317473.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/15qxej1259317473.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/16bd5v1259317473.tab")
+ }
>
> system("convert tmp/1xsc31259317473.ps tmp/1xsc31259317473.png")
> system("convert tmp/2il1q1259317473.ps tmp/2il1q1259317473.png")
> system("convert tmp/3gpm41259317473.ps tmp/3gpm41259317473.png")
> system("convert tmp/4oie21259317473.ps tmp/4oie21259317473.png")
> system("convert tmp/5na411259317473.ps tmp/5na411259317473.png")
> system("convert tmp/6yy5g1259317473.ps tmp/6yy5g1259317473.png")
> system("convert tmp/7y5ja1259317473.ps tmp/7y5ja1259317473.png")
> system("convert tmp/8aswk1259317473.ps tmp/8aswk1259317473.png")
> system("convert tmp/9l8w31259317473.ps tmp/9l8w31259317473.png")
> system("convert tmp/10d8oj1259317473.ps tmp/10d8oj1259317473.png")
>
>
> proc.time()
user system elapsed
2.324 1.519 3.531