R version 2.8.0 (2008-10-20)
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(101.3,11554.5,102,13182.1,109.2,14800.1,88.6,12150.7,94.3,14478.2,98.3,13253.9,86.4,12036.8,80.6,12653.2,104.1,14035.4,108.2,14571.4,93.4,15400.9,71.9,14283.2,94.1,14485.3,94.9,14196.3,96.4,15559.1,91.1,13767.4,84.4,14634,86.4,14381.1,88,12509.9,75.1,12122.3,109.7,13122.3,103,13908.7,82.1,13456.5,68,12441.6,96.4,12953,94.3,13057.2,90,14350.1,88,13830.2,76.1,13755.5,82.5,13574.4,81.4,12802.6,66.5,11737.3,97.2,13850.2,94.1,15081.8,80.7,13653.3,70.5,14019.1,87.8,13962,89.5,13768.7,99.6,14747.1,84.2,13858.1,75.1,13188,92,13693.1,80.8,12970,73.1,11392.8,99.8,13985.2,90,14994.7,83.1,13584.7,72.4,14257.8,78.8,13553.4,87.3,14007.3,91,16535.8,80.1,14721.4,73.6,13664.6,86.4,16405.9,74.5,13829.4,71.2,13735.6,92.4,15870.5,81.5,15962.4,85.3,15744.1,69.9,16083.7,84.2,14863.9,90.7,15533.1,100.3,17473.1,79.4,15925.5,84.8,15573.7,92.9,17495,81.6,14155.8,76,14913.9,98.7,17250.4,89.1,15879.8,88.7,17647.8,67.1,17749.9),dim=c(2,72),dimnames=list(c('textiel','Invoer'),1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('textiel','Invoer'),1:72))
> 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
textiel Invoer M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 101.3 11554.5 1 0 0 0 0 0 0 0 0 0 0 1
2 102.0 13182.1 0 1 0 0 0 0 0 0 0 0 0 2
3 109.2 14800.1 0 0 1 0 0 0 0 0 0 0 0 3
4 88.6 12150.7 0 0 0 1 0 0 0 0 0 0 0 4
5 94.3 14478.2 0 0 0 0 1 0 0 0 0 0 0 5
6 98.3 13253.9 0 0 0 0 0 1 0 0 0 0 0 6
7 86.4 12036.8 0 0 0 0 0 0 1 0 0 0 0 7
8 80.6 12653.2 0 0 0 0 0 0 0 1 0 0 0 8
9 104.1 14035.4 0 0 0 0 0 0 0 0 1 0 0 9
10 108.2 14571.4 0 0 0 0 0 0 0 0 0 1 0 10
11 93.4 15400.9 0 0 0 0 0 0 0 0 0 0 1 11
12 71.9 14283.2 0 0 0 0 0 0 0 0 0 0 0 12
13 94.1 14485.3 1 0 0 0 0 0 0 0 0 0 0 13
14 94.9 14196.3 0 1 0 0 0 0 0 0 0 0 0 14
15 96.4 15559.1 0 0 1 0 0 0 0 0 0 0 0 15
16 91.1 13767.4 0 0 0 1 0 0 0 0 0 0 0 16
17 84.4 14634.0 0 0 0 0 1 0 0 0 0 0 0 17
18 86.4 14381.1 0 0 0 0 0 1 0 0 0 0 0 18
19 88.0 12509.9 0 0 0 0 0 0 1 0 0 0 0 19
20 75.1 12122.3 0 0 0 0 0 0 0 1 0 0 0 20
21 109.7 13122.3 0 0 0 0 0 0 0 0 1 0 0 21
22 103.0 13908.7 0 0 0 0 0 0 0 0 0 1 0 22
23 82.1 13456.5 0 0 0 0 0 0 0 0 0 0 1 23
24 68.0 12441.6 0 0 0 0 0 0 0 0 0 0 0 24
25 96.4 12953.0 1 0 0 0 0 0 0 0 0 0 0 25
26 94.3 13057.2 0 1 0 0 0 0 0 0 0 0 0 26
27 90.0 14350.1 0 0 1 0 0 0 0 0 0 0 0 27
28 88.0 13830.2 0 0 0 1 0 0 0 0 0 0 0 28
29 76.1 13755.5 0 0 0 0 1 0 0 0 0 0 0 29
30 82.5 13574.4 0 0 0 0 0 1 0 0 0 0 0 30
31 81.4 12802.6 0 0 0 0 0 0 1 0 0 0 0 31
32 66.5 11737.3 0 0 0 0 0 0 0 1 0 0 0 32
33 97.2 13850.2 0 0 0 0 0 0 0 0 1 0 0 33
34 94.1 15081.8 0 0 0 0 0 0 0 0 0 1 0 34
35 80.7 13653.3 0 0 0 0 0 0 0 0 0 0 1 35
36 70.5 14019.1 0 0 0 0 0 0 0 0 0 0 0 36
37 87.8 13962.0 1 0 0 0 0 0 0 0 0 0 0 37
38 89.5 13768.7 0 1 0 0 0 0 0 0 0 0 0 38
39 99.6 14747.1 0 0 1 0 0 0 0 0 0 0 0 39
40 84.2 13858.1 0 0 0 1 0 0 0 0 0 0 0 40
41 75.1 13188.0 0 0 0 0 1 0 0 0 0 0 0 41
42 92.0 13693.1 0 0 0 0 0 1 0 0 0 0 0 42
43 80.8 12970.0 0 0 0 0 0 0 1 0 0 0 0 43
44 73.1 11392.8 0 0 0 0 0 0 0 1 0 0 0 44
45 99.8 13985.2 0 0 0 0 0 0 0 0 1 0 0 45
46 90.0 14994.7 0 0 0 0 0 0 0 0 0 1 0 46
47 83.1 13584.7 0 0 0 0 0 0 0 0 0 0 1 47
48 72.4 14257.8 0 0 0 0 0 0 0 0 0 0 0 48
49 78.8 13553.4 1 0 0 0 0 0 0 0 0 0 0 49
50 87.3 14007.3 0 1 0 0 0 0 0 0 0 0 0 50
51 91.0 16535.8 0 0 1 0 0 0 0 0 0 0 0 51
52 80.1 14721.4 0 0 0 1 0 0 0 0 0 0 0 52
53 73.6 13664.6 0 0 0 0 1 0 0 0 0 0 0 53
54 86.4 16405.9 0 0 0 0 0 1 0 0 0 0 0 54
55 74.5 13829.4 0 0 0 0 0 0 1 0 0 0 0 55
56 71.2 13735.6 0 0 0 0 0 0 0 1 0 0 0 56
57 92.4 15870.5 0 0 0 0 0 0 0 0 1 0 0 57
58 81.5 15962.4 0 0 0 0 0 0 0 0 0 1 0 58
59 85.3 15744.1 0 0 0 0 0 0 0 0 0 0 1 59
60 69.9 16083.7 0 0 0 0 0 0 0 0 0 0 0 60
61 84.2 14863.9 1 0 0 0 0 0 0 0 0 0 0 61
62 90.7 15533.1 0 1 0 0 0 0 0 0 0 0 0 62
63 100.3 17473.1 0 0 1 0 0 0 0 0 0 0 0 63
64 79.4 15925.5 0 0 0 1 0 0 0 0 0 0 0 64
65 84.8 15573.7 0 0 0 0 1 0 0 0 0 0 0 65
66 92.9 17495.0 0 0 0 0 0 1 0 0 0 0 0 66
67 81.6 14155.8 0 0 0 0 0 0 1 0 0 0 0 67
68 76.0 14913.9 0 0 0 0 0 0 0 1 0 0 0 68
69 98.7 17250.4 0 0 0 0 0 0 0 0 1 0 0 69
70 89.1 15879.8 0 0 0 0 0 0 0 0 0 1 0 70
71 88.7 17647.8 0 0 0 0 0 0 0 0 0 0 1 71
72 67.1 17749.9 0 0 0 0 0 0 0 0 0 0 0 72
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Invoer M1 M2 M3 M4
48.488975 0.002165 20.388877 22.467922 23.845293 14.904875
M5 M6 M7 M8 M9 M10
10.931230 18.283371 14.690690 7.207242 29.854559 23.281955
M11 t
15.096134 -0.251912
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-10.2221 -2.5725 -0.6192 3.2086 8.2339
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 48.4889750 8.9478306 5.419 1.21e-06 ***
Invoer 0.0021652 0.0006627 3.267 0.001827 **
M1 20.3888770 2.8065183 7.265 1.05e-09 ***
M2 22.4679221 2.7696087 8.112 3.97e-11 ***
M3 23.8452931 2.8545874 8.353 1.57e-11 ***
M4 14.9048749 2.7646242 5.391 1.34e-06 ***
M5 10.9312297 2.7548971 3.968 0.000202 ***
M6 18.2833709 2.7506489 6.647 1.15e-08 ***
M7 14.6906899 2.9299410 5.014 5.34e-06 ***
M8 7.2072419 3.0131901 2.392 0.020024 *
M9 29.8545586 2.7422629 10.887 1.21e-15 ***
M10 23.2819547 2.7510097 8.463 1.03e-11 ***
M11 15.0961336 2.7429775 5.504 8.83e-07 ***
t -0.2519124 0.0387034 -6.509 1.95e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.748 on 58 degrees of freedom
Multiple R-squared: 0.835, Adjusted R-squared: 0.798
F-statistic: 22.57 on 13 and 58 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.5003586 0.9992829 0.49964143
[2,] 0.4057187 0.8114373 0.59428134
[3,] 0.5431053 0.9137895 0.45689474
[4,] 0.4128558 0.8257116 0.58714421
[5,] 0.5856321 0.8287358 0.41436790
[6,] 0.6004509 0.7990982 0.39954910
[7,] 0.6214943 0.7570114 0.37850568
[8,] 0.5205395 0.9589210 0.47946051
[9,] 0.6458415 0.7083169 0.35415846
[10,] 0.5907680 0.8184641 0.40923204
[11,] 0.6335031 0.7329939 0.36649694
[12,] 0.6532290 0.6935419 0.34677097
[13,] 0.6482709 0.7034583 0.35172913
[14,] 0.6419482 0.7161036 0.35805181
[15,] 0.5653677 0.8692646 0.43463232
[16,] 0.5819684 0.8360632 0.41803160
[17,] 0.5030142 0.9939717 0.49698585
[18,] 0.5208940 0.9582119 0.47910597
[19,] 0.4754414 0.9508828 0.52455858
[20,] 0.5098144 0.9803713 0.49018564
[21,] 0.5158566 0.9682868 0.48414338
[22,] 0.4472588 0.8945177 0.55274116
[23,] 0.5908321 0.8183359 0.40916794
[24,] 0.6086989 0.7826023 0.39130115
[25,] 0.5280495 0.9439010 0.47195052
[26,] 0.6217194 0.7565611 0.37828057
[27,] 0.6236705 0.7526591 0.37632954
[28,] 0.5834665 0.8330669 0.41653347
[29,] 0.6131067 0.7737866 0.38689329
[30,] 0.8644551 0.2710898 0.13554488
[31,] 0.8273556 0.3452887 0.17264436
[32,] 0.9429429 0.1141143 0.05705715
[33,] 0.9185961 0.1628078 0.08140389
[34,] 0.8652824 0.2694353 0.13471763
[35,] 0.8251064 0.3497873 0.17489364
[36,] 0.8337083 0.3325834 0.16629168
[37,] 0.9457238 0.1085524 0.05427619
[38,] 0.8978603 0.2042793 0.10213967
[39,] 0.7807945 0.4384110 0.21920548
> postscript(file="/var/www/html/rcomp/tmp/14msx1229764202.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/2nf6u1229764202.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/33s381229764202.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/4r0am1229764202.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/5ptrf1229764202.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 = 72
Frequency = 1
1 2 3 4 5 6
7.65601324 3.00476665 5.57598028 -0.09515241 4.79085310 4.34150443
7 8 9 10 11 12
-1.07861160 -0.47789351 -2.36606642 7.39789126 -0.76042614 -4.49231255
13 14 15 16 17 18
-2.86686840 -3.26825224 -5.84447419 1.92728299 -2.42354001 -6.97618444
19 20 21 22 23 24
2.51997065 -1.80542929 8.23394530 6.65573162 -4.82742190 -1.38189304
25 26 27 28 29 30
5.77384823 1.62109945 -6.60377354 1.71425545 -5.79844493 -6.10655224
31 32 33 34 35 36
-1.69084122 -6.54887082 -2.81917079 -1.76134090 -3.63058907 0.72541903
37 38 39 40 41 42
-1.98791151 -1.69650701 5.15958203 0.87679413 -2.54673362 6.15938436
43 44 45 46 47 48
0.36964911 3.81999618 2.51147271 -2.64980179 1.94089344 5.13152910
49 50 51 52 53 54
-7.08025383 -1.39018042 -4.29040060 -2.06949290 -2.05572965 -2.29147908
55 56 57 58 59 60
-4.76819355 -0.12973545 -5.94767028 -10.22213790 2.48826336 1.70100025
61 62 63 64 65 66
-1.49482773 1.72907358 6.00308602 -2.35368727 8.03359511 4.87332697
67 68 69 70 71 72
4.64802662 5.14193288 0.38748948 0.57965770 4.78928031 -1.68374279
> postscript(file="/var/www/html/rcomp/tmp/6fm0v1229764202.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 7.65601324 NA
1 3.00476665 7.65601324
2 5.57598028 3.00476665
3 -0.09515241 5.57598028
4 4.79085310 -0.09515241
5 4.34150443 4.79085310
6 -1.07861160 4.34150443
7 -0.47789351 -1.07861160
8 -2.36606642 -0.47789351
9 7.39789126 -2.36606642
10 -0.76042614 7.39789126
11 -4.49231255 -0.76042614
12 -2.86686840 -4.49231255
13 -3.26825224 -2.86686840
14 -5.84447419 -3.26825224
15 1.92728299 -5.84447419
16 -2.42354001 1.92728299
17 -6.97618444 -2.42354001
18 2.51997065 -6.97618444
19 -1.80542929 2.51997065
20 8.23394530 -1.80542929
21 6.65573162 8.23394530
22 -4.82742190 6.65573162
23 -1.38189304 -4.82742190
24 5.77384823 -1.38189304
25 1.62109945 5.77384823
26 -6.60377354 1.62109945
27 1.71425545 -6.60377354
28 -5.79844493 1.71425545
29 -6.10655224 -5.79844493
30 -1.69084122 -6.10655224
31 -6.54887082 -1.69084122
32 -2.81917079 -6.54887082
33 -1.76134090 -2.81917079
34 -3.63058907 -1.76134090
35 0.72541903 -3.63058907
36 -1.98791151 0.72541903
37 -1.69650701 -1.98791151
38 5.15958203 -1.69650701
39 0.87679413 5.15958203
40 -2.54673362 0.87679413
41 6.15938436 -2.54673362
42 0.36964911 6.15938436
43 3.81999618 0.36964911
44 2.51147271 3.81999618
45 -2.64980179 2.51147271
46 1.94089344 -2.64980179
47 5.13152910 1.94089344
48 -7.08025383 5.13152910
49 -1.39018042 -7.08025383
50 -4.29040060 -1.39018042
51 -2.06949290 -4.29040060
52 -2.05572965 -2.06949290
53 -2.29147908 -2.05572965
54 -4.76819355 -2.29147908
55 -0.12973545 -4.76819355
56 -5.94767028 -0.12973545
57 -10.22213790 -5.94767028
58 2.48826336 -10.22213790
59 1.70100025 2.48826336
60 -1.49482773 1.70100025
61 1.72907358 -1.49482773
62 6.00308602 1.72907358
63 -2.35368727 6.00308602
64 8.03359511 -2.35368727
65 4.87332697 8.03359511
66 4.64802662 4.87332697
67 5.14193288 4.64802662
68 0.38748948 5.14193288
69 0.57965770 0.38748948
70 4.78928031 0.57965770
71 -1.68374279 4.78928031
72 NA -1.68374279
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3.00476665 7.65601324
[2,] 5.57598028 3.00476665
[3,] -0.09515241 5.57598028
[4,] 4.79085310 -0.09515241
[5,] 4.34150443 4.79085310
[6,] -1.07861160 4.34150443
[7,] -0.47789351 -1.07861160
[8,] -2.36606642 -0.47789351
[9,] 7.39789126 -2.36606642
[10,] -0.76042614 7.39789126
[11,] -4.49231255 -0.76042614
[12,] -2.86686840 -4.49231255
[13,] -3.26825224 -2.86686840
[14,] -5.84447419 -3.26825224
[15,] 1.92728299 -5.84447419
[16,] -2.42354001 1.92728299
[17,] -6.97618444 -2.42354001
[18,] 2.51997065 -6.97618444
[19,] -1.80542929 2.51997065
[20,] 8.23394530 -1.80542929
[21,] 6.65573162 8.23394530
[22,] -4.82742190 6.65573162
[23,] -1.38189304 -4.82742190
[24,] 5.77384823 -1.38189304
[25,] 1.62109945 5.77384823
[26,] -6.60377354 1.62109945
[27,] 1.71425545 -6.60377354
[28,] -5.79844493 1.71425545
[29,] -6.10655224 -5.79844493
[30,] -1.69084122 -6.10655224
[31,] -6.54887082 -1.69084122
[32,] -2.81917079 -6.54887082
[33,] -1.76134090 -2.81917079
[34,] -3.63058907 -1.76134090
[35,] 0.72541903 -3.63058907
[36,] -1.98791151 0.72541903
[37,] -1.69650701 -1.98791151
[38,] 5.15958203 -1.69650701
[39,] 0.87679413 5.15958203
[40,] -2.54673362 0.87679413
[41,] 6.15938436 -2.54673362
[42,] 0.36964911 6.15938436
[43,] 3.81999618 0.36964911
[44,] 2.51147271 3.81999618
[45,] -2.64980179 2.51147271
[46,] 1.94089344 -2.64980179
[47,] 5.13152910 1.94089344
[48,] -7.08025383 5.13152910
[49,] -1.39018042 -7.08025383
[50,] -4.29040060 -1.39018042
[51,] -2.06949290 -4.29040060
[52,] -2.05572965 -2.06949290
[53,] -2.29147908 -2.05572965
[54,] -4.76819355 -2.29147908
[55,] -0.12973545 -4.76819355
[56,] -5.94767028 -0.12973545
[57,] -10.22213790 -5.94767028
[58,] 2.48826336 -10.22213790
[59,] 1.70100025 2.48826336
[60,] -1.49482773 1.70100025
[61,] 1.72907358 -1.49482773
[62,] 6.00308602 1.72907358
[63,] -2.35368727 6.00308602
[64,] 8.03359511 -2.35368727
[65,] 4.87332697 8.03359511
[66,] 4.64802662 4.87332697
[67,] 5.14193288 4.64802662
[68,] 0.38748948 5.14193288
[69,] 0.57965770 0.38748948
[70,] 4.78928031 0.57965770
[71,] -1.68374279 4.78928031
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3.00476665 7.65601324
2 5.57598028 3.00476665
3 -0.09515241 5.57598028
4 4.79085310 -0.09515241
5 4.34150443 4.79085310
6 -1.07861160 4.34150443
7 -0.47789351 -1.07861160
8 -2.36606642 -0.47789351
9 7.39789126 -2.36606642
10 -0.76042614 7.39789126
11 -4.49231255 -0.76042614
12 -2.86686840 -4.49231255
13 -3.26825224 -2.86686840
14 -5.84447419 -3.26825224
15 1.92728299 -5.84447419
16 -2.42354001 1.92728299
17 -6.97618444 -2.42354001
18 2.51997065 -6.97618444
19 -1.80542929 2.51997065
20 8.23394530 -1.80542929
21 6.65573162 8.23394530
22 -4.82742190 6.65573162
23 -1.38189304 -4.82742190
24 5.77384823 -1.38189304
25 1.62109945 5.77384823
26 -6.60377354 1.62109945
27 1.71425545 -6.60377354
28 -5.79844493 1.71425545
29 -6.10655224 -5.79844493
30 -1.69084122 -6.10655224
31 -6.54887082 -1.69084122
32 -2.81917079 -6.54887082
33 -1.76134090 -2.81917079
34 -3.63058907 -1.76134090
35 0.72541903 -3.63058907
36 -1.98791151 0.72541903
37 -1.69650701 -1.98791151
38 5.15958203 -1.69650701
39 0.87679413 5.15958203
40 -2.54673362 0.87679413
41 6.15938436 -2.54673362
42 0.36964911 6.15938436
43 3.81999618 0.36964911
44 2.51147271 3.81999618
45 -2.64980179 2.51147271
46 1.94089344 -2.64980179
47 5.13152910 1.94089344
48 -7.08025383 5.13152910
49 -1.39018042 -7.08025383
50 -4.29040060 -1.39018042
51 -2.06949290 -4.29040060
52 -2.05572965 -2.06949290
53 -2.29147908 -2.05572965
54 -4.76819355 -2.29147908
55 -0.12973545 -4.76819355
56 -5.94767028 -0.12973545
57 -10.22213790 -5.94767028
58 2.48826336 -10.22213790
59 1.70100025 2.48826336
60 -1.49482773 1.70100025
61 1.72907358 -1.49482773
62 6.00308602 1.72907358
63 -2.35368727 6.00308602
64 8.03359511 -2.35368727
65 4.87332697 8.03359511
66 4.64802662 4.87332697
67 5.14193288 4.64802662
68 0.38748948 5.14193288
69 0.57965770 0.38748948
70 4.78928031 0.57965770
71 -1.68374279 4.78928031
> 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/7w5d21229764202.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/8jqqx1229764202.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/9s8gq1229764202.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/10n7701229764202.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/111h0r1229764203.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/127gbc1229764203.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/13qh2b1229764203.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/14ukz71229764203.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/15nvnl1229764203.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/16qrke1229764203.tab")
+ }
>
> system("convert tmp/14msx1229764202.ps tmp/14msx1229764202.png")
> system("convert tmp/2nf6u1229764202.ps tmp/2nf6u1229764202.png")
> system("convert tmp/33s381229764202.ps tmp/33s381229764202.png")
> system("convert tmp/4r0am1229764202.ps tmp/4r0am1229764202.png")
> system("convert tmp/5ptrf1229764202.ps tmp/5ptrf1229764202.png")
> system("convert tmp/6fm0v1229764202.ps tmp/6fm0v1229764202.png")
> system("convert tmp/7w5d21229764202.ps tmp/7w5d21229764202.png")
> system("convert tmp/8jqqx1229764202.ps tmp/8jqqx1229764202.png")
> system("convert tmp/9s8gq1229764202.ps tmp/9s8gq1229764202.png")
> system("convert tmp/10n7701229764202.ps tmp/10n7701229764202.png")
>
>
> proc.time()
user system elapsed
2.746 1.701 8.805