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(102
+ ,1
+ ,102.8
+ ,94
+ ,106.3
+ ,101.3
+ ,105.1
+ ,1
+ ,102
+ ,102.8
+ ,94
+ ,106.3
+ ,92.4
+ ,0
+ ,105.1
+ ,102
+ ,102.8
+ ,94
+ ,81.4
+ ,0
+ ,92.4
+ ,105.1
+ ,102
+ ,102.8
+ ,105.8
+ ,1
+ ,81.4
+ ,92.4
+ ,105.1
+ ,102
+ ,120.3
+ ,1
+ ,105.8
+ ,81.4
+ ,92.4
+ ,105.1
+ ,100.7
+ ,1
+ ,120.3
+ ,105.8
+ ,81.4
+ ,92.4
+ ,88.8
+ ,0
+ ,100.7
+ ,120.3
+ ,105.8
+ ,81.4
+ ,94.3
+ ,0
+ ,88.8
+ ,100.7
+ ,120.3
+ ,105.8
+ ,99.9
+ ,0
+ ,94.3
+ ,88.8
+ ,100.7
+ ,120.3
+ ,103.4
+ ,1
+ ,99.9
+ ,94.3
+ ,88.8
+ ,100.7
+ ,103.3
+ ,1
+ ,103.4
+ ,99.9
+ ,94.3
+ ,88.8
+ ,98.8
+ ,0
+ ,103.3
+ ,103.4
+ ,99.9
+ ,94.3
+ ,104.2
+ ,1
+ ,98.8
+ ,103.3
+ ,103.4
+ ,99.9
+ ,91.2
+ ,0
+ ,104.2
+ ,98.8
+ ,103.3
+ ,103.4
+ ,74.7
+ ,0
+ ,91.2
+ ,104.2
+ ,98.8
+ ,103.3
+ ,108.5
+ ,1
+ ,74.7
+ ,91.2
+ ,104.2
+ ,98.8
+ ,114.5
+ ,1
+ ,108.5
+ ,74.7
+ ,91.2
+ ,104.2
+ ,96.9
+ ,0
+ ,114.5
+ ,108.5
+ ,74.7
+ ,91.2
+ ,89.6
+ ,0
+ ,96.9
+ ,114.5
+ ,108.5
+ ,74.7
+ ,97.1
+ ,0
+ ,89.6
+ ,96.9
+ ,114.5
+ ,108.5
+ ,100.3
+ ,1
+ ,97.1
+ ,89.6
+ ,96.9
+ ,114.5
+ ,122.6
+ ,1
+ ,100.3
+ ,97.1
+ ,89.6
+ ,96.9
+ ,115.4
+ ,1
+ ,122.6
+ ,100.3
+ ,97.1
+ ,89.6
+ ,109
+ ,1
+ ,115.4
+ ,122.6
+ ,100.3
+ ,97.1
+ ,129.1
+ ,1
+ ,109
+ ,115.4
+ ,122.6
+ ,100.3
+ ,102.8
+ ,1
+ ,129.1
+ ,109
+ ,115.4
+ ,122.6
+ ,96.2
+ ,0
+ ,102.8
+ ,129.1
+ ,109
+ ,115.4
+ ,127.7
+ ,1
+ ,96.2
+ ,102.8
+ ,129.1
+ ,109
+ ,128.9
+ ,1
+ ,127.7
+ ,96.2
+ ,102.8
+ ,129.1
+ ,126.5
+ ,1
+ ,128.9
+ ,127.7
+ ,96.2
+ ,102.8
+ ,119.8
+ ,1
+ ,126.5
+ ,128.9
+ ,127.7
+ ,96.2
+ ,113.2
+ ,1
+ ,119.8
+ ,126.5
+ ,128.9
+ ,127.7
+ ,114.1
+ ,1
+ ,113.2
+ ,119.8
+ ,126.5
+ ,128.9
+ ,134.1
+ ,1
+ ,114.1
+ ,113.2
+ ,119.8
+ ,126.5
+ ,130
+ ,1
+ ,134.1
+ ,114.1
+ ,113.2
+ ,119.8
+ ,121.8
+ ,1
+ ,130
+ ,134.1
+ ,114.1
+ ,113.2
+ ,132.1
+ ,1
+ ,121.8
+ ,130
+ ,134.1
+ ,114.1
+ ,105.3
+ ,1
+ ,132.1
+ ,121.8
+ ,130
+ ,134.1
+ ,103
+ ,1
+ ,105.3
+ ,132.1
+ ,121.8
+ ,130
+ ,117.1
+ ,1
+ ,103
+ ,105.3
+ ,132.1
+ ,121.8
+ ,126.3
+ ,1
+ ,117.1
+ ,103
+ ,105.3
+ ,132.1
+ ,138.1
+ ,1
+ ,126.3
+ ,117.1
+ ,103
+ ,105.3
+ ,119.5
+ ,1
+ ,138.1
+ ,126.3
+ ,117.1
+ ,103
+ ,138
+ ,1
+ ,119.5
+ ,138.1
+ ,126.3
+ ,117.1
+ ,135.5
+ ,1
+ ,138
+ ,119.5
+ ,138.1
+ ,126.3
+ ,178.6
+ ,1
+ ,135.5
+ ,138
+ ,119.5
+ ,138.1
+ ,162.2
+ ,1
+ ,178.6
+ ,135.5
+ ,138
+ ,119.5
+ ,176.9
+ ,1
+ ,162.2
+ ,178.6
+ ,135.5
+ ,138
+ ,204.9
+ ,1
+ ,176.9
+ ,162.2
+ ,178.6
+ ,135.5
+ ,132.2
+ ,1
+ ,204.9
+ ,176.9
+ ,162.2
+ ,178.6
+ ,142.5
+ ,1
+ ,132.2
+ ,204.9
+ ,176.9
+ ,162.2
+ ,164.3
+ ,1
+ ,142.5
+ ,132.2
+ ,204.9
+ ,176.9
+ ,174.9
+ ,1
+ ,164.3
+ ,142.5
+ ,132.2
+ ,204.9
+ ,175.4
+ ,1
+ ,174.9
+ ,164.3
+ ,142.5
+ ,132.2
+ ,143
+ ,1
+ ,175.4
+ ,174.9
+ ,164.3
+ ,142.5)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Omzet'
+ ,'Uitvoer'
+ ,'Omzet-1'
+ ,'Omzet-2'
+ ,'Omzet-3'
+ ,'Omzet-4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Omzet','Uitvoer','Omzet-1','Omzet-2','Omzet-3','Omzet-4'),1:56))
> 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 Omzet-3 Omzet-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10
1 102.0 1 102.8 94.0 106.3 101.3 1 0 0 0 0 0 0 0 0 0
2 105.1 1 102.0 102.8 94.0 106.3 0 1 0 0 0 0 0 0 0 0
3 92.4 0 105.1 102.0 102.8 94.0 0 0 1 0 0 0 0 0 0 0
4 81.4 0 92.4 105.1 102.0 102.8 0 0 0 1 0 0 0 0 0 0
5 105.8 1 81.4 92.4 105.1 102.0 0 0 0 0 1 0 0 0 0 0
6 120.3 1 105.8 81.4 92.4 105.1 0 0 0 0 0 1 0 0 0 0
7 100.7 1 120.3 105.8 81.4 92.4 0 0 0 0 0 0 1 0 0 0
8 88.8 0 100.7 120.3 105.8 81.4 0 0 0 0 0 0 0 1 0 0
9 94.3 0 88.8 100.7 120.3 105.8 0 0 0 0 0 0 0 0 1 0
10 99.9 0 94.3 88.8 100.7 120.3 0 0 0 0 0 0 0 0 0 1
11 103.4 1 99.9 94.3 88.8 100.7 0 0 0 0 0 0 0 0 0 0
12 103.3 1 103.4 99.9 94.3 88.8 0 0 0 0 0 0 0 0 0 0
13 98.8 0 103.3 103.4 99.9 94.3 1 0 0 0 0 0 0 0 0 0
14 104.2 1 98.8 103.3 103.4 99.9 0 1 0 0 0 0 0 0 0 0
15 91.2 0 104.2 98.8 103.3 103.4 0 0 1 0 0 0 0 0 0 0
16 74.7 0 91.2 104.2 98.8 103.3 0 0 0 1 0 0 0 0 0 0
17 108.5 1 74.7 91.2 104.2 98.8 0 0 0 0 1 0 0 0 0 0
18 114.5 1 108.5 74.7 91.2 104.2 0 0 0 0 0 1 0 0 0 0
19 96.9 0 114.5 108.5 74.7 91.2 0 0 0 0 0 0 1 0 0 0
20 89.6 0 96.9 114.5 108.5 74.7 0 0 0 0 0 0 0 1 0 0
21 97.1 0 89.6 96.9 114.5 108.5 0 0 0 0 0 0 0 0 1 0
22 100.3 1 97.1 89.6 96.9 114.5 0 0 0 0 0 0 0 0 0 1
23 122.6 1 100.3 97.1 89.6 96.9 0 0 0 0 0 0 0 0 0 0
24 115.4 1 122.6 100.3 97.1 89.6 0 0 0 0 0 0 0 0 0 0
25 109.0 1 115.4 122.6 100.3 97.1 1 0 0 0 0 0 0 0 0 0
26 129.1 1 109.0 115.4 122.6 100.3 0 1 0 0 0 0 0 0 0 0
27 102.8 1 129.1 109.0 115.4 122.6 0 0 1 0 0 0 0 0 0 0
28 96.2 0 102.8 129.1 109.0 115.4 0 0 0 1 0 0 0 0 0 0
29 127.7 1 96.2 102.8 129.1 109.0 0 0 0 0 1 0 0 0 0 0
30 128.9 1 127.7 96.2 102.8 129.1 0 0 0 0 0 1 0 0 0 0
31 126.5 1 128.9 127.7 96.2 102.8 0 0 0 0 0 0 1 0 0 0
32 119.8 1 126.5 128.9 127.7 96.2 0 0 0 0 0 0 0 1 0 0
33 113.2 1 119.8 126.5 128.9 127.7 0 0 0 0 0 0 0 0 1 0
34 114.1 1 113.2 119.8 126.5 128.9 0 0 0 0 0 0 0 0 0 1
35 134.1 1 114.1 113.2 119.8 126.5 0 0 0 0 0 0 0 0 0 0
36 130.0 1 134.1 114.1 113.2 119.8 0 0 0 0 0 0 0 0 0 0
37 121.8 1 130.0 134.1 114.1 113.2 1 0 0 0 0 0 0 0 0 0
38 132.1 1 121.8 130.0 134.1 114.1 0 1 0 0 0 0 0 0 0 0
39 105.3 1 132.1 121.8 130.0 134.1 0 0 1 0 0 0 0 0 0 0
40 103.0 1 105.3 132.1 121.8 130.0 0 0 0 1 0 0 0 0 0 0
41 117.1 1 103.0 105.3 132.1 121.8 0 0 0 0 1 0 0 0 0 0
42 126.3 1 117.1 103.0 105.3 132.1 0 0 0 0 0 1 0 0 0 0
43 138.1 1 126.3 117.1 103.0 105.3 0 0 0 0 0 0 1 0 0 0
44 119.5 1 138.1 126.3 117.1 103.0 0 0 0 0 0 0 0 1 0 0
45 138.0 1 119.5 138.1 126.3 117.1 0 0 0 0 0 0 0 0 1 0
46 135.5 1 138.0 119.5 138.1 126.3 0 0 0 0 0 0 0 0 0 1
47 178.6 1 135.5 138.0 119.5 138.1 0 0 0 0 0 0 0 0 0 0
48 162.2 1 178.6 135.5 138.0 119.5 0 0 0 0 0 0 0 0 0 0
49 176.9 1 162.2 178.6 135.5 138.0 1 0 0 0 0 0 0 0 0 0
50 204.9 1 176.9 162.2 178.6 135.5 0 1 0 0 0 0 0 0 0 0
51 132.2 1 204.9 176.9 162.2 178.6 0 0 1 0 0 0 0 0 0 0
52 142.5 1 132.2 204.9 176.9 162.2 0 0 0 1 0 0 0 0 0 0
53 164.3 1 142.5 132.2 204.9 176.9 0 0 0 0 1 0 0 0 0 0
54 174.9 1 164.3 142.5 132.2 204.9 0 0 0 0 0 1 0 0 0 0
55 175.4 1 174.9 164.3 142.5 132.2 0 0 0 0 0 0 1 0 0 0
56 143.0 1 175.4 174.9 164.3 142.5 0 0 0 0 0 0 0 1 0 0
M11 t
1 0 1
2 0 2
3 0 3
4 0 4
5 0 5
6 0 6
7 0 7
8 0 8
9 0 9
10 0 10
11 1 11
12 0 12
13 0 13
14 0 14
15 0 15
16 0 16
17 0 17
18 0 18
19 0 19
20 0 20
21 0 21
22 0 22
23 1 23
24 0 24
25 0 25
26 0 26
27 0 27
28 0 28
29 0 29
30 0 30
31 0 31
32 0 32
33 0 33
34 0 34
35 1 35
36 0 36
37 0 37
38 0 38
39 0 39
40 0 40
41 0 41
42 0 42
43 0 43
44 0 44
45 0 45
46 0 46
47 1 47
48 0 48
49 0 49
50 0 50
51 0 51
52 0 52
53 0 53
54 0 54
55 0 55
56 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Uitvoer `Omzet-1` `Omzet-2` `Omzet-3` `Omzet-4`
24.2720 -3.3170 0.3471 0.3557 0.3076 -0.2367
M1 M2 M3 M4 M5 M6
-4.9192 6.3448 -25.1186 -26.1791 8.8018 22.3701
M7 M8 M9 M10 M11 t
-1.4910 -27.9111 -9.4620 -1.4268 20.2096 0.3565
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-23.4996 -5.7349 -0.5422 5.6123 20.4769
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 24.2720 12.6833 1.914 0.06321 .
Uitvoer -3.3170 4.6007 -0.721 0.47533
`Omzet-1` 0.3471 0.1600 2.169 0.03639 *
`Omzet-2` 0.3557 0.1558 2.283 0.02810 *
`Omzet-3` 0.3076 0.1521 2.023 0.05016 .
`Omzet-4` -0.2367 0.1487 -1.592 0.11972
M1 -4.9192 7.6321 -0.645 0.52310
M2 6.3448 7.9171 0.801 0.42788
M3 -25.1186 7.6188 -3.297 0.00213 **
M4 -26.1791 10.4522 -2.505 0.01666 *
M5 8.8018 10.6750 0.825 0.41478
M6 22.3701 8.9736 2.493 0.01715 *
M7 -1.4910 7.4008 -0.201 0.84141
M8 -27.9111 8.1888 -3.408 0.00156 **
M9 -9.4620 9.4978 -0.996 0.32544
M10 -1.4268 8.9160 -0.160 0.87371
M11 20.2096 8.2318 2.455 0.01878 *
t 0.3565 0.1899 1.877 0.06821 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 10.02 on 38 degrees of freedom
Multiple R-squared: 0.9051, Adjusted R-squared: 0.8627
F-statistic: 21.33 on 17 and 38 DF, p-value: 2.207e-14
> 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.0291724116 0.0583448233 0.9708276
[2,] 0.0068067963 0.0136135926 0.9931932
[3,] 0.0701598337 0.1403196674 0.9298402
[4,] 0.0310909517 0.0621819034 0.9689090
[5,] 0.0144778158 0.0289556316 0.9855222
[6,] 0.0055678600 0.0111357200 0.9944321
[7,] 0.0038001947 0.0076003894 0.9961998
[8,] 0.0014681392 0.0029362785 0.9985319
[9,] 0.0007654811 0.0015309622 0.9992345
[10,] 0.0002466886 0.0004933772 0.9997533
[11,] 0.0001249093 0.0002498187 0.9998751
[12,] 0.0006933479 0.0013866958 0.9993067
[13,] 0.0003038667 0.0006077335 0.9996961
[14,] 0.0021164088 0.0042328175 0.9978836
[15,] 0.0006208108 0.0012416216 0.9993792
> postscript(file="/var/www/html/rcomp/tmp/1wc4a1259316971.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/2jjps1259316971.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/3yu4k1259316971.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/42hmg1259316971.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/59d6i1259316971.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 = 56
Frequency = 1
1 2 3 4 5 6
7.7595968 1.3538997 10.0340136 5.3725984 4.9448867 5.6034642
7 8 9 10 11 12
-3.8258639 -1.4428086 -2.3321993 6.6608480 -13.3929157 -1.3549655
13 14 15 16 17 18
-6.2406797 -7.2979521 8.0770327 -3.7663611 5.6386312 -2.8728617
19 20 21 22 23 24
-12.3911633 -3.9553410 -0.3133925 4.6393532 -0.7515338 -1.0125526
25 26 27 28 29 30
-7.4920385 -0.3329210 7.2655690 0.2974528 3.7247078 -4.7392984
31 32 33 34 35 36
0.5505615 9.0678767 -6.0726715 -7.8679198 -6.3324685 2.6026753
37 38 39 40 41 42
-8.5641516 -11.5196116 -1.8770123 3.7186666 -12.2970620 -10.4159848
43 44 45 46 47 48
11.0447725 6.2578336 8.7182633 -3.4322814 20.4769180 -0.2351572
49 50 51 52 53 54
14.5372730 17.7965849 -23.4996030 -5.6223567 -2.0111638 12.4246807
55 56
4.6216931 -9.9275608
> postscript(file="/var/www/html/rcomp/tmp/6pviw1259316971.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 7.7595968 NA
1 1.3538997 7.7595968
2 10.0340136 1.3538997
3 5.3725984 10.0340136
4 4.9448867 5.3725984
5 5.6034642 4.9448867
6 -3.8258639 5.6034642
7 -1.4428086 -3.8258639
8 -2.3321993 -1.4428086
9 6.6608480 -2.3321993
10 -13.3929157 6.6608480
11 -1.3549655 -13.3929157
12 -6.2406797 -1.3549655
13 -7.2979521 -6.2406797
14 8.0770327 -7.2979521
15 -3.7663611 8.0770327
16 5.6386312 -3.7663611
17 -2.8728617 5.6386312
18 -12.3911633 -2.8728617
19 -3.9553410 -12.3911633
20 -0.3133925 -3.9553410
21 4.6393532 -0.3133925
22 -0.7515338 4.6393532
23 -1.0125526 -0.7515338
24 -7.4920385 -1.0125526
25 -0.3329210 -7.4920385
26 7.2655690 -0.3329210
27 0.2974528 7.2655690
28 3.7247078 0.2974528
29 -4.7392984 3.7247078
30 0.5505615 -4.7392984
31 9.0678767 0.5505615
32 -6.0726715 9.0678767
33 -7.8679198 -6.0726715
34 -6.3324685 -7.8679198
35 2.6026753 -6.3324685
36 -8.5641516 2.6026753
37 -11.5196116 -8.5641516
38 -1.8770123 -11.5196116
39 3.7186666 -1.8770123
40 -12.2970620 3.7186666
41 -10.4159848 -12.2970620
42 11.0447725 -10.4159848
43 6.2578336 11.0447725
44 8.7182633 6.2578336
45 -3.4322814 8.7182633
46 20.4769180 -3.4322814
47 -0.2351572 20.4769180
48 14.5372730 -0.2351572
49 17.7965849 14.5372730
50 -23.4996030 17.7965849
51 -5.6223567 -23.4996030
52 -2.0111638 -5.6223567
53 12.4246807 -2.0111638
54 4.6216931 12.4246807
55 -9.9275608 4.6216931
56 NA -9.9275608
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.3538997 7.7595968
[2,] 10.0340136 1.3538997
[3,] 5.3725984 10.0340136
[4,] 4.9448867 5.3725984
[5,] 5.6034642 4.9448867
[6,] -3.8258639 5.6034642
[7,] -1.4428086 -3.8258639
[8,] -2.3321993 -1.4428086
[9,] 6.6608480 -2.3321993
[10,] -13.3929157 6.6608480
[11,] -1.3549655 -13.3929157
[12,] -6.2406797 -1.3549655
[13,] -7.2979521 -6.2406797
[14,] 8.0770327 -7.2979521
[15,] -3.7663611 8.0770327
[16,] 5.6386312 -3.7663611
[17,] -2.8728617 5.6386312
[18,] -12.3911633 -2.8728617
[19,] -3.9553410 -12.3911633
[20,] -0.3133925 -3.9553410
[21,] 4.6393532 -0.3133925
[22,] -0.7515338 4.6393532
[23,] -1.0125526 -0.7515338
[24,] -7.4920385 -1.0125526
[25,] -0.3329210 -7.4920385
[26,] 7.2655690 -0.3329210
[27,] 0.2974528 7.2655690
[28,] 3.7247078 0.2974528
[29,] -4.7392984 3.7247078
[30,] 0.5505615 -4.7392984
[31,] 9.0678767 0.5505615
[32,] -6.0726715 9.0678767
[33,] -7.8679198 -6.0726715
[34,] -6.3324685 -7.8679198
[35,] 2.6026753 -6.3324685
[36,] -8.5641516 2.6026753
[37,] -11.5196116 -8.5641516
[38,] -1.8770123 -11.5196116
[39,] 3.7186666 -1.8770123
[40,] -12.2970620 3.7186666
[41,] -10.4159848 -12.2970620
[42,] 11.0447725 -10.4159848
[43,] 6.2578336 11.0447725
[44,] 8.7182633 6.2578336
[45,] -3.4322814 8.7182633
[46,] 20.4769180 -3.4322814
[47,] -0.2351572 20.4769180
[48,] 14.5372730 -0.2351572
[49,] 17.7965849 14.5372730
[50,] -23.4996030 17.7965849
[51,] -5.6223567 -23.4996030
[52,] -2.0111638 -5.6223567
[53,] 12.4246807 -2.0111638
[54,] 4.6216931 12.4246807
[55,] -9.9275608 4.6216931
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.3538997 7.7595968
2 10.0340136 1.3538997
3 5.3725984 10.0340136
4 4.9448867 5.3725984
5 5.6034642 4.9448867
6 -3.8258639 5.6034642
7 -1.4428086 -3.8258639
8 -2.3321993 -1.4428086
9 6.6608480 -2.3321993
10 -13.3929157 6.6608480
11 -1.3549655 -13.3929157
12 -6.2406797 -1.3549655
13 -7.2979521 -6.2406797
14 8.0770327 -7.2979521
15 -3.7663611 8.0770327
16 5.6386312 -3.7663611
17 -2.8728617 5.6386312
18 -12.3911633 -2.8728617
19 -3.9553410 -12.3911633
20 -0.3133925 -3.9553410
21 4.6393532 -0.3133925
22 -0.7515338 4.6393532
23 -1.0125526 -0.7515338
24 -7.4920385 -1.0125526
25 -0.3329210 -7.4920385
26 7.2655690 -0.3329210
27 0.2974528 7.2655690
28 3.7247078 0.2974528
29 -4.7392984 3.7247078
30 0.5505615 -4.7392984
31 9.0678767 0.5505615
32 -6.0726715 9.0678767
33 -7.8679198 -6.0726715
34 -6.3324685 -7.8679198
35 2.6026753 -6.3324685
36 -8.5641516 2.6026753
37 -11.5196116 -8.5641516
38 -1.8770123 -11.5196116
39 3.7186666 -1.8770123
40 -12.2970620 3.7186666
41 -10.4159848 -12.2970620
42 11.0447725 -10.4159848
43 6.2578336 11.0447725
44 8.7182633 6.2578336
45 -3.4322814 8.7182633
46 20.4769180 -3.4322814
47 -0.2351572 20.4769180
48 14.5372730 -0.2351572
49 17.7965849 14.5372730
50 -23.4996030 17.7965849
51 -5.6223567 -23.4996030
52 -2.0111638 -5.6223567
53 12.4246807 -2.0111638
54 4.6216931 12.4246807
55 -9.9275608 4.6216931
> 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/7q01e1259316971.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/8bleg1259316971.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/9mchw1259316971.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/10xhj81259316971.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/113cg61259316971.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/122zxu1259316971.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/13k8jp1259316971.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/14tale1259316971.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/15jjnb1259316971.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/166szg1259316971.tab")
+ }
>
> system("convert tmp/1wc4a1259316971.ps tmp/1wc4a1259316971.png")
> system("convert tmp/2jjps1259316971.ps tmp/2jjps1259316971.png")
> system("convert tmp/3yu4k1259316971.ps tmp/3yu4k1259316971.png")
> system("convert tmp/42hmg1259316971.ps tmp/42hmg1259316971.png")
> system("convert tmp/59d6i1259316971.ps tmp/59d6i1259316971.png")
> system("convert tmp/6pviw1259316971.ps tmp/6pviw1259316971.png")
> system("convert tmp/7q01e1259316971.ps tmp/7q01e1259316971.png")
> system("convert tmp/8bleg1259316971.ps tmp/8bleg1259316971.png")
> system("convert tmp/9mchw1259316971.ps tmp/9mchw1259316971.png")
> system("convert tmp/10xhj81259316971.ps tmp/10xhj81259316971.png")
>
>
> proc.time()
user system elapsed
2.303 1.556 3.105