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])
+ }
+ }
> par20 = ''
> par19 = ''
> par18 = ''
> par17 = ''
> par16 = ''
> par15 = ''
> par14 = ''
> par13 = ''
> par12 = ''
> par11 = ''
> par10 = ''
> par9 = ''
> par8 = ''
> par7 = ''
> par6 = ''
> par5 = ''
> par4 = ''
> par3 = 'Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '1'
> ylab = ''
> xlab = ''
> main = ''
> #'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 t
1 102.0 1 102.8 94.0 106.3 101.3 1
2 105.1 1 102.0 102.8 94.0 106.3 2
3 92.4 0 105.1 102.0 102.8 94.0 3
4 81.4 0 92.4 105.1 102.0 102.8 4
5 105.8 1 81.4 92.4 105.1 102.0 5
6 120.3 1 105.8 81.4 92.4 105.1 6
7 100.7 1 120.3 105.8 81.4 92.4 7
8 88.8 0 100.7 120.3 105.8 81.4 8
9 94.3 0 88.8 100.7 120.3 105.8 9
10 99.9 0 94.3 88.8 100.7 120.3 10
11 103.4 1 99.9 94.3 88.8 100.7 11
12 103.3 1 103.4 99.9 94.3 88.8 12
13 98.8 0 103.3 103.4 99.9 94.3 13
14 104.2 1 98.8 103.3 103.4 99.9 14
15 91.2 0 104.2 98.8 103.3 103.4 15
16 74.7 0 91.2 104.2 98.8 103.3 16
17 108.5 1 74.7 91.2 104.2 98.8 17
18 114.5 1 108.5 74.7 91.2 104.2 18
19 96.9 0 114.5 108.5 74.7 91.2 19
20 89.6 0 96.9 114.5 108.5 74.7 20
21 97.1 0 89.6 96.9 114.5 108.5 21
22 100.3 1 97.1 89.6 96.9 114.5 22
23 122.6 1 100.3 97.1 89.6 96.9 23
24 115.4 1 122.6 100.3 97.1 89.6 24
25 109.0 1 115.4 122.6 100.3 97.1 25
26 129.1 1 109.0 115.4 122.6 100.3 26
27 102.8 1 129.1 109.0 115.4 122.6 27
28 96.2 0 102.8 129.1 109.0 115.4 28
29 127.7 1 96.2 102.8 129.1 109.0 29
30 128.9 1 127.7 96.2 102.8 129.1 30
31 126.5 1 128.9 127.7 96.2 102.8 31
32 119.8 1 126.5 128.9 127.7 96.2 32
33 113.2 1 119.8 126.5 128.9 127.7 33
34 114.1 1 113.2 119.8 126.5 128.9 34
35 134.1 1 114.1 113.2 119.8 126.5 35
36 130.0 1 134.1 114.1 113.2 119.8 36
37 121.8 1 130.0 134.1 114.1 113.2 37
38 132.1 1 121.8 130.0 134.1 114.1 38
39 105.3 1 132.1 121.8 130.0 134.1 39
40 103.0 1 105.3 132.1 121.8 130.0 40
41 117.1 1 103.0 105.3 132.1 121.8 41
42 126.3 1 117.1 103.0 105.3 132.1 42
43 138.1 1 126.3 117.1 103.0 105.3 43
44 119.5 1 138.1 126.3 117.1 103.0 44
45 138.0 1 119.5 138.1 126.3 117.1 45
46 135.5 1 138.0 119.5 138.1 126.3 46
47 178.6 1 135.5 138.0 119.5 138.1 47
48 162.2 1 178.6 135.5 138.0 119.5 48
49 176.9 1 162.2 178.6 135.5 138.0 49
50 204.9 1 176.9 162.2 178.6 135.5 50
51 132.2 1 204.9 176.9 162.2 178.6 51
52 142.5 1 132.2 204.9 176.9 162.2 52
53 164.3 1 142.5 132.2 204.9 176.9 53
54 174.9 1 164.3 142.5 132.2 204.9 54
55 175.4 1 174.9 164.3 142.5 132.2 55
56 143.0 1 175.4 174.9 164.3 142.5 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`
35.44780 14.54732 0.36344 -0.06806 0.17636 0.02386
t
0.51223
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-39.21405 -7.41405 0.03039 6.60686 41.30990
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.44780 16.07486 2.205 0.0322 *
Uitvoer 14.54732 5.84484 2.489 0.0163 *
`Omzet-1` 0.36344 0.13811 2.631 0.0113 *
`Omzet-2` -0.06806 0.15160 -0.449 0.6554
`Omzet-3` 0.17636 0.14702 1.200 0.2361
`Omzet-4` 0.02386 0.13731 0.174 0.8628
t 0.51223 0.26120 1.961 0.0556 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 15.18 on 49 degrees of freedom
Multiple R-squared: 0.7191, Adjusted R-squared: 0.6847
F-statistic: 20.91 on 6 and 49 DF, p-value: 5.558e-12
> 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,] 7.526375e-02 1.505275e-01 0.9247363
[2,] 4.013895e-02 8.027790e-02 0.9598611
[3,] 1.514074e-02 3.028148e-02 0.9848593
[4,] 5.874311e-03 1.174862e-02 0.9941257
[5,] 1.754101e-03 3.508201e-03 0.9982459
[6,] 1.015023e-03 2.030045e-03 0.9989850
[7,] 2.251181e-03 4.502363e-03 0.9977488
[8,] 1.015078e-03 2.030157e-03 0.9989849
[9,] 4.825804e-04 9.651608e-04 0.9995174
[10,] 3.721080e-04 7.442160e-04 0.9996279
[11,] 1.249267e-04 2.498535e-04 0.9998751
[12,] 4.831466e-05 9.662933e-05 0.9999517
[13,] 2.187361e-05 4.374722e-05 0.9999781
[14,] 1.014184e-04 2.028369e-04 0.9998986
[15,] 3.735329e-05 7.470659e-05 0.9999626
[16,] 1.826940e-05 3.653879e-05 0.9999817
[17,] 4.386370e-05 8.772740e-05 0.9999561
[18,] 7.100129e-05 1.420026e-04 0.9999290
[19,] 3.885640e-05 7.771281e-05 0.9999611
[20,] 3.427174e-05 6.854349e-05 0.9999657
[21,] 2.616998e-05 5.233996e-05 0.9999738
[22,] 2.460527e-05 4.921054e-05 0.9999754
[23,] 9.624196e-06 1.924839e-05 0.9999904
[24,] 4.086654e-06 8.173307e-06 0.9999959
[25,] 1.502113e-06 3.004227e-06 0.9999985
[26,] 2.457317e-06 4.914634e-06 0.9999975
[27,] 1.147023e-06 2.294047e-06 0.9999989
[28,] 3.860585e-07 7.721171e-07 0.9999996
[29,] 2.626157e-07 5.252314e-07 0.9999997
[30,] 8.003940e-07 1.600788e-06 0.9999992
[31,] 6.763205e-07 1.352641e-06 0.9999993
[32,] 3.306508e-07 6.613015e-07 0.9999997
[33,] 1.195581e-07 2.391163e-07 0.9999999
[34,] 5.603589e-08 1.120718e-07 0.9999999
[35,] 1.756032e-07 3.512065e-07 0.9999998
[36,] 3.011240e-07 6.022479e-07 0.9999997
[37,] 9.552324e-06 1.910465e-05 0.9999904
> postscript(file="/var/www/html/rcomp/tmp/1t1641258567180.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/2mz5l1258567180.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/3pdnc1258567180.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/4abp61258567180.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/5mway1258567180.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
-0.6349374 4.8924881 3.7879613 -2.9665026 8.9797073 15.5167452
7 8 9 10 11 12
-5.9615796 0.2430203 5.0822223 10.4718572 -0.1822440 -2.3714123
13 14 15 16 17 18
6.3193884 -2.4623885 -3.7620168 -14.8860147 8.1213274 2.3657413
19 20 21 22 23 24
2.1408965 -4.4338121 2.1445019 -9.9768848 12.8657287 -3.8818831
25 26 27 28 29 30
-7.4028617 10.0116257 -23.8035600 -4.1415017 9.5153869 2.4644089
31 32 33 34 35 36
3.0515438 -8.6046879 -14.4084584 -11.6833971 8.2669440 -2.2289236
37 38 39 40 41 42
-8.0910500 0.8491295 -30.5187332 -21.3458144 -10.3671208 -2.4796192
43 44 45 46 47 48
7.4692911 -17.7371385 5.8547536 -7.4476198 40.3066976 4.7412709
49 50 51 52 53 54
27.8224375 41.3098978 -39.2140524 -3.2998691 4.0074203 19.0267473
55 56
16.5639317 -19.8989888
> postscript(file="/var/www/html/rcomp/tmp/672j81258567180.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 -0.6349374 NA
1 4.8924881 -0.6349374
2 3.7879613 4.8924881
3 -2.9665026 3.7879613
4 8.9797073 -2.9665026
5 15.5167452 8.9797073
6 -5.9615796 15.5167452
7 0.2430203 -5.9615796
8 5.0822223 0.2430203
9 10.4718572 5.0822223
10 -0.1822440 10.4718572
11 -2.3714123 -0.1822440
12 6.3193884 -2.3714123
13 -2.4623885 6.3193884
14 -3.7620168 -2.4623885
15 -14.8860147 -3.7620168
16 8.1213274 -14.8860147
17 2.3657413 8.1213274
18 2.1408965 2.3657413
19 -4.4338121 2.1408965
20 2.1445019 -4.4338121
21 -9.9768848 2.1445019
22 12.8657287 -9.9768848
23 -3.8818831 12.8657287
24 -7.4028617 -3.8818831
25 10.0116257 -7.4028617
26 -23.8035600 10.0116257
27 -4.1415017 -23.8035600
28 9.5153869 -4.1415017
29 2.4644089 9.5153869
30 3.0515438 2.4644089
31 -8.6046879 3.0515438
32 -14.4084584 -8.6046879
33 -11.6833971 -14.4084584
34 8.2669440 -11.6833971
35 -2.2289236 8.2669440
36 -8.0910500 -2.2289236
37 0.8491295 -8.0910500
38 -30.5187332 0.8491295
39 -21.3458144 -30.5187332
40 -10.3671208 -21.3458144
41 -2.4796192 -10.3671208
42 7.4692911 -2.4796192
43 -17.7371385 7.4692911
44 5.8547536 -17.7371385
45 -7.4476198 5.8547536
46 40.3066976 -7.4476198
47 4.7412709 40.3066976
48 27.8224375 4.7412709
49 41.3098978 27.8224375
50 -39.2140524 41.3098978
51 -3.2998691 -39.2140524
52 4.0074203 -3.2998691
53 19.0267473 4.0074203
54 16.5639317 19.0267473
55 -19.8989888 16.5639317
56 NA -19.8989888
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 4.8924881 -0.6349374
[2,] 3.7879613 4.8924881
[3,] -2.9665026 3.7879613
[4,] 8.9797073 -2.9665026
[5,] 15.5167452 8.9797073
[6,] -5.9615796 15.5167452
[7,] 0.2430203 -5.9615796
[8,] 5.0822223 0.2430203
[9,] 10.4718572 5.0822223
[10,] -0.1822440 10.4718572
[11,] -2.3714123 -0.1822440
[12,] 6.3193884 -2.3714123
[13,] -2.4623885 6.3193884
[14,] -3.7620168 -2.4623885
[15,] -14.8860147 -3.7620168
[16,] 8.1213274 -14.8860147
[17,] 2.3657413 8.1213274
[18,] 2.1408965 2.3657413
[19,] -4.4338121 2.1408965
[20,] 2.1445019 -4.4338121
[21,] -9.9768848 2.1445019
[22,] 12.8657287 -9.9768848
[23,] -3.8818831 12.8657287
[24,] -7.4028617 -3.8818831
[25,] 10.0116257 -7.4028617
[26,] -23.8035600 10.0116257
[27,] -4.1415017 -23.8035600
[28,] 9.5153869 -4.1415017
[29,] 2.4644089 9.5153869
[30,] 3.0515438 2.4644089
[31,] -8.6046879 3.0515438
[32,] -14.4084584 -8.6046879
[33,] -11.6833971 -14.4084584
[34,] 8.2669440 -11.6833971
[35,] -2.2289236 8.2669440
[36,] -8.0910500 -2.2289236
[37,] 0.8491295 -8.0910500
[38,] -30.5187332 0.8491295
[39,] -21.3458144 -30.5187332
[40,] -10.3671208 -21.3458144
[41,] -2.4796192 -10.3671208
[42,] 7.4692911 -2.4796192
[43,] -17.7371385 7.4692911
[44,] 5.8547536 -17.7371385
[45,] -7.4476198 5.8547536
[46,] 40.3066976 -7.4476198
[47,] 4.7412709 40.3066976
[48,] 27.8224375 4.7412709
[49,] 41.3098978 27.8224375
[50,] -39.2140524 41.3098978
[51,] -3.2998691 -39.2140524
[52,] 4.0074203 -3.2998691
[53,] 19.0267473 4.0074203
[54,] 16.5639317 19.0267473
[55,] -19.8989888 16.5639317
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 4.8924881 -0.6349374
2 3.7879613 4.8924881
3 -2.9665026 3.7879613
4 8.9797073 -2.9665026
5 15.5167452 8.9797073
6 -5.9615796 15.5167452
7 0.2430203 -5.9615796
8 5.0822223 0.2430203
9 10.4718572 5.0822223
10 -0.1822440 10.4718572
11 -2.3714123 -0.1822440
12 6.3193884 -2.3714123
13 -2.4623885 6.3193884
14 -3.7620168 -2.4623885
15 -14.8860147 -3.7620168
16 8.1213274 -14.8860147
17 2.3657413 8.1213274
18 2.1408965 2.3657413
19 -4.4338121 2.1408965
20 2.1445019 -4.4338121
21 -9.9768848 2.1445019
22 12.8657287 -9.9768848
23 -3.8818831 12.8657287
24 -7.4028617 -3.8818831
25 10.0116257 -7.4028617
26 -23.8035600 10.0116257
27 -4.1415017 -23.8035600
28 9.5153869 -4.1415017
29 2.4644089 9.5153869
30 3.0515438 2.4644089
31 -8.6046879 3.0515438
32 -14.4084584 -8.6046879
33 -11.6833971 -14.4084584
34 8.2669440 -11.6833971
35 -2.2289236 8.2669440
36 -8.0910500 -2.2289236
37 0.8491295 -8.0910500
38 -30.5187332 0.8491295
39 -21.3458144 -30.5187332
40 -10.3671208 -21.3458144
41 -2.4796192 -10.3671208
42 7.4692911 -2.4796192
43 -17.7371385 7.4692911
44 5.8547536 -17.7371385
45 -7.4476198 5.8547536
46 40.3066976 -7.4476198
47 4.7412709 40.3066976
48 27.8224375 4.7412709
49 41.3098978 27.8224375
50 -39.2140524 41.3098978
51 -3.2998691 -39.2140524
52 4.0074203 -3.2998691
53 19.0267473 4.0074203
54 16.5639317 19.0267473
55 -19.8989888 16.5639317
> 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/755ny1258567180.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/8vf2f1258567180.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/98n0n1258567180.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/10q9hu1258567180.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/117dwk1258567180.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/12cbof1258567180.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/138p3m1258567180.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/1409h21258567180.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/15ksyi1258567180.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/16lm8i1258567180.tab")
+ }
>
> system("convert tmp/1t1641258567180.ps tmp/1t1641258567180.png")
> system("convert tmp/2mz5l1258567180.ps tmp/2mz5l1258567180.png")
> system("convert tmp/3pdnc1258567180.ps tmp/3pdnc1258567180.png")
> system("convert tmp/4abp61258567180.ps tmp/4abp61258567180.png")
> system("convert tmp/5mway1258567180.ps tmp/5mway1258567180.png")
> system("convert tmp/672j81258567180.ps tmp/672j81258567180.png")
> system("convert tmp/755ny1258567180.ps tmp/755ny1258567180.png")
> system("convert tmp/8vf2f1258567180.ps tmp/8vf2f1258567180.png")
> system("convert tmp/98n0n1258567180.ps tmp/98n0n1258567180.png")
> system("convert tmp/10q9hu1258567180.ps tmp/10q9hu1258567180.png")
>
>
> proc.time()
user system elapsed
2.472 1.595 6.073