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(101.8612953
+ ,1
+ ,118.1540031
+ ,105.5073942
+ ,95.84395716
+ ,100
+ ,109.8419174
+ ,1
+ ,101.8612953
+ ,118.1540031
+ ,105.5073942
+ ,95.84395716
+ ,105.6348802
+ ,1
+ ,109.8419174
+ ,101.8612953
+ ,118.1540031
+ ,105.5073942
+ ,112.927078
+ ,1
+ ,105.6348802
+ ,109.8419174
+ ,101.8612953
+ ,118.1540031
+ ,133.0698623
+ ,1
+ ,112.927078
+ ,105.6348802
+ ,109.8419174
+ ,101.8612953
+ ,125.6756757
+ ,1
+ ,133.0698623
+ ,112.927078
+ ,105.6348802
+ ,109.8419174
+ ,146.736359
+ ,1
+ ,125.6756757
+ ,133.0698623
+ ,112.927078
+ ,105.6348802
+ ,142.5803162
+ ,1
+ ,146.736359
+ ,125.6756757
+ ,133.0698623
+ ,112.927078
+ ,106.1448241
+ ,1
+ ,142.5803162
+ ,146.736359
+ ,125.6756757
+ ,133.0698623
+ ,126.5170831
+ ,1
+ ,106.1448241
+ ,142.5803162
+ ,146.736359
+ ,125.6756757
+ ,132.7893932
+ ,1
+ ,126.5170831
+ ,106.1448241
+ ,142.5803162
+ ,146.736359
+ ,121.2391637
+ ,1
+ ,132.7893932
+ ,126.5170831
+ ,106.1448241
+ ,142.5803162
+ ,114.5079041
+ ,1
+ ,121.2391637
+ ,132.7893932
+ ,126.5170831
+ ,106.1448241
+ ,146.1499235
+ ,1
+ ,114.5079041
+ ,121.2391637
+ ,132.7893932
+ ,126.5170831
+ ,146.1244263
+ ,1
+ ,146.1499235
+ ,114.5079041
+ ,121.2391637
+ ,132.7893932
+ ,128.5058644
+ ,1
+ ,146.1244263
+ ,146.1499235
+ ,114.5079041
+ ,121.2391637
+ ,155.5838858
+ ,1
+ ,128.5058644
+ ,146.1244263
+ ,146.1499235
+ ,114.5079041
+ ,125.0382458
+ ,1
+ ,155.5838858
+ ,128.5058644
+ ,146.1244263
+ ,146.1499235
+ ,136.8944416
+ ,1
+ ,125.0382458
+ ,155.5838858
+ ,128.5058644
+ ,146.1244263
+ ,142.2233554
+ ,1
+ ,136.8944416
+ ,125.0382458
+ ,155.5838858
+ ,128.5058644
+ ,117.7715451
+ ,1
+ ,142.2233554
+ ,136.8944416
+ ,125.0382458
+ ,155.5838858
+ ,120.627231
+ ,1
+ ,117.7715451
+ ,142.2233554
+ ,136.8944416
+ ,125.0382458
+ ,127.7664457
+ ,1
+ ,120.627231
+ ,117.7715451
+ ,142.2233554
+ ,136.8944416
+ ,135.1096379
+ ,1
+ ,127.7664457
+ ,120.627231
+ ,117.7715451
+ ,142.2233554
+ ,105.7113717
+ ,1
+ ,135.1096379
+ ,127.7664457
+ ,120.627231
+ ,117.7715451
+ ,117.9245283
+ ,1
+ ,105.7113717
+ ,135.1096379
+ ,127.7664457
+ ,120.627231
+ ,120.754717
+ ,1
+ ,117.9245283
+ ,105.7113717
+ ,135.1096379
+ ,127.7664457
+ ,107.572667
+ ,1
+ ,120.754717
+ ,117.9245283
+ ,105.7113717
+ ,135.1096379
+ ,130.4436512
+ ,1
+ ,107.572667
+ ,120.754717
+ ,117.9245283
+ ,105.7113717
+ ,107.2157063
+ ,1
+ ,130.4436512
+ ,107.572667
+ ,120.754717
+ ,117.9245283
+ ,105.0739419
+ ,1
+ ,107.2157063
+ ,130.4436512
+ ,107.572667
+ ,120.754717
+ ,130.1121877
+ ,1
+ ,105.0739419
+ ,107.2157063
+ ,130.4436512
+ ,107.572667
+ ,109.6379398
+ ,1
+ ,130.1121877
+ ,105.0739419
+ ,107.2157063
+ ,130.4436512
+ ,116.7261601
+ ,1
+ ,109.6379398
+ ,130.1121877
+ ,105.0739419
+ ,107.2157063
+ ,97.11881693
+ ,0
+ ,116.7261601
+ ,109.6379398
+ ,130.1121877
+ ,105.0739419
+ ,140.8975013
+ ,1
+ ,97.11881693
+ ,116.7261601
+ ,109.6379398
+ ,130.1121877
+ ,108.2865885
+ ,1
+ ,140.8975013
+ ,97.11881693
+ ,116.7261601
+ ,109.6379398
+ ,97.65425803
+ ,0
+ ,108.2865885
+ ,140.8975013
+ ,97.11881693
+ ,116.7261601
+ ,112.0346762
+ ,1
+ ,97.65425803
+ ,108.2865885
+ ,140.8975013
+ ,97.11881693
+ ,123.0494646
+ ,1
+ ,112.0346762
+ ,97.65425803
+ ,108.2865885
+ ,140.8975013
+ ,112.4171341
+ ,1
+ ,123.0494646
+ ,112.0346762
+ ,97.65425803
+ ,108.2865885
+ ,116.4966854
+ ,1
+ ,112.4171341
+ ,123.0494646
+ ,112.0346762
+ ,97.65425803
+ ,104.6914839
+ ,1
+ ,116.4966854
+ ,112.4171341
+ ,123.0494646
+ ,112.0346762
+ ,122.2335543
+ ,1
+ ,104.6914839
+ ,116.4966854
+ ,112.4171341
+ ,123.0494646
+ ,99.79602244
+ ,0
+ ,122.2335543
+ ,104.6914839
+ ,116.4966854
+ ,112.4171341
+ ,96.71086181
+ ,0
+ ,99.79602244
+ ,122.2335543
+ ,104.6914839
+ ,116.4966854
+ ,112.3151453
+ ,1
+ ,96.71086181
+ ,99.79602244
+ ,122.2335543
+ ,104.6914839
+ ,102.5497195
+ ,1
+ ,112.3151453
+ ,96.71086181
+ ,99.79602244
+ ,122.2335543
+ ,104.5385008
+ ,1
+ ,102.5497195
+ ,112.3151453
+ ,96.71086181
+ ,99.79602244
+ ,122.0805711
+ ,1
+ ,104.5385008
+ ,102.5497195
+ ,112.3151453
+ ,96.71086181
+ ,80.64762876
+ ,0
+ ,122.0805711
+ ,104.5385008
+ ,102.5497195
+ ,112.3151453
+ ,91.40744518
+ ,0
+ ,80.64762876
+ ,122.0805711
+ ,104.5385008
+ ,102.5497195
+ ,99.51555329
+ ,0
+ ,91.40744518
+ ,80.64762876
+ ,122.0805711
+ ,104.5385008
+ ,106.527282
+ ,1
+ ,99.51555329
+ ,91.40744518
+ ,80.64762876
+ ,122.0805711
+ ,98.49566548
+ ,0
+ ,106.527282
+ ,99.51555329
+ ,91.40744518
+ ,80.64762876
+ ,106.7567568
+ ,1
+ ,98.49566548
+ ,106.527282
+ ,99.51555329
+ ,91.40744518)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),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
Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8
1 101.86130 1 118.15400 105.50739 95.84396 100.00000 1 0 0 0 0 0 0 0
2 109.84192 1 101.86130 118.15400 105.50739 95.84396 0 1 0 0 0 0 0 0
3 105.63488 1 109.84192 101.86130 118.15400 105.50739 0 0 1 0 0 0 0 0
4 112.92708 1 105.63488 109.84192 101.86130 118.15400 0 0 0 1 0 0 0 0
5 133.06986 1 112.92708 105.63488 109.84192 101.86130 0 0 0 0 1 0 0 0
6 125.67568 1 133.06986 112.92708 105.63488 109.84192 0 0 0 0 0 1 0 0
7 146.73636 1 125.67568 133.06986 112.92708 105.63488 0 0 0 0 0 0 1 0
8 142.58032 1 146.73636 125.67568 133.06986 112.92708 0 0 0 0 0 0 0 1
9 106.14482 1 142.58032 146.73636 125.67568 133.06986 0 0 0 0 0 0 0 0
10 126.51708 1 106.14482 142.58032 146.73636 125.67568 0 0 0 0 0 0 0 0
11 132.78939 1 126.51708 106.14482 142.58032 146.73636 0 0 0 0 0 0 0 0
12 121.23916 1 132.78939 126.51708 106.14482 142.58032 0 0 0 0 0 0 0 0
13 114.50790 1 121.23916 132.78939 126.51708 106.14482 1 0 0 0 0 0 0 0
14 146.14992 1 114.50790 121.23916 132.78939 126.51708 0 1 0 0 0 0 0 0
15 146.12443 1 146.14992 114.50790 121.23916 132.78939 0 0 1 0 0 0 0 0
16 128.50586 1 146.12443 146.14992 114.50790 121.23916 0 0 0 1 0 0 0 0
17 155.58389 1 128.50586 146.12443 146.14992 114.50790 0 0 0 0 1 0 0 0
18 125.03825 1 155.58389 128.50586 146.12443 146.14992 0 0 0 0 0 1 0 0
19 136.89444 1 125.03825 155.58389 128.50586 146.12443 0 0 0 0 0 0 1 0
20 142.22336 1 136.89444 125.03825 155.58389 128.50586 0 0 0 0 0 0 0 1
21 117.77155 1 142.22336 136.89444 125.03825 155.58389 0 0 0 0 0 0 0 0
22 120.62723 1 117.77155 142.22336 136.89444 125.03825 0 0 0 0 0 0 0 0
23 127.76645 1 120.62723 117.77155 142.22336 136.89444 0 0 0 0 0 0 0 0
24 135.10964 1 127.76645 120.62723 117.77155 142.22336 0 0 0 0 0 0 0 0
25 105.71137 1 135.10964 127.76645 120.62723 117.77155 1 0 0 0 0 0 0 0
26 117.92453 1 105.71137 135.10964 127.76645 120.62723 0 1 0 0 0 0 0 0
27 120.75472 1 117.92453 105.71137 135.10964 127.76645 0 0 1 0 0 0 0 0
28 107.57267 1 120.75472 117.92453 105.71137 135.10964 0 0 0 1 0 0 0 0
29 130.44365 1 107.57267 120.75472 117.92453 105.71137 0 0 0 0 1 0 0 0
30 107.21571 1 130.44365 107.57267 120.75472 117.92453 0 0 0 0 0 1 0 0
31 105.07394 1 107.21571 130.44365 107.57267 120.75472 0 0 0 0 0 0 1 0
32 130.11219 1 105.07394 107.21571 130.44365 107.57267 0 0 0 0 0 0 0 1
33 109.63794 1 130.11219 105.07394 107.21571 130.44365 0 0 0 0 0 0 0 0
34 116.72616 1 109.63794 130.11219 105.07394 107.21571 0 0 0 0 0 0 0 0
35 97.11882 0 116.72616 109.63794 130.11219 105.07394 0 0 0 0 0 0 0 0
36 140.89750 1 97.11882 116.72616 109.63794 130.11219 0 0 0 0 0 0 0 0
37 108.28659 1 140.89750 97.11882 116.72616 109.63794 1 0 0 0 0 0 0 0
38 97.65426 0 108.28659 140.89750 97.11882 116.72616 0 1 0 0 0 0 0 0
39 112.03468 1 97.65426 108.28659 140.89750 97.11882 0 0 1 0 0 0 0 0
40 123.04946 1 112.03468 97.65426 108.28659 140.89750 0 0 0 1 0 0 0 0
41 112.41713 1 123.04946 112.03468 97.65426 108.28659 0 0 0 0 1 0 0 0
42 116.49669 1 112.41713 123.04946 112.03468 97.65426 0 0 0 0 0 1 0 0
43 104.69148 1 116.49669 112.41713 123.04946 112.03468 0 0 0 0 0 0 1 0
44 122.23355 1 104.69148 116.49669 112.41713 123.04946 0 0 0 0 0 0 0 1
45 99.79602 0 122.23355 104.69148 116.49669 112.41713 0 0 0 0 0 0 0 0
46 96.71086 0 99.79602 122.23355 104.69148 116.49669 0 0 0 0 0 0 0 0
47 112.31515 1 96.71086 99.79602 122.23355 104.69148 0 0 0 0 0 0 0 0
48 102.54972 1 112.31515 96.71086 99.79602 122.23355 0 0 0 0 0 0 0 0
49 104.53850 1 102.54972 112.31515 96.71086 99.79602 1 0 0 0 0 0 0 0
50 122.08057 1 104.53850 102.54972 112.31515 96.71086 0 1 0 0 0 0 0 0
51 80.64763 0 122.08057 104.53850 102.54972 112.31515 0 0 1 0 0 0 0 0
52 91.40745 0 80.64763 122.08057 104.53850 102.54972 0 0 0 1 0 0 0 0
53 99.51555 0 91.40745 80.64763 122.08057 104.53850 0 0 0 0 1 0 0 0
54 106.52728 1 99.51555 91.40745 80.64763 122.08057 0 0 0 0 0 1 0 0
55 98.49567 0 106.52728 99.51555 91.40745 80.64763 0 0 0 0 0 0 1 0
56 106.75676 1 98.49567 106.52728 99.51555 91.40745 0 0 0 0 0 0 0 1
M9 M10 M11 t
1 0 0 0 1
2 0 0 0 2
3 0 0 0 3
4 0 0 0 4
5 0 0 0 5
6 0 0 0 6
7 0 0 0 7
8 0 0 0 8
9 1 0 0 9
10 0 1 0 10
11 0 0 1 11
12 0 0 0 12
13 0 0 0 13
14 0 0 0 14
15 0 0 0 15
16 0 0 0 16
17 0 0 0 17
18 0 0 0 18
19 0 0 0 19
20 0 0 0 20
21 1 0 0 21
22 0 1 0 22
23 0 0 1 23
24 0 0 0 24
25 0 0 0 25
26 0 0 0 26
27 0 0 0 27
28 0 0 0 28
29 0 0 0 29
30 0 0 0 30
31 0 0 0 31
32 0 0 0 32
33 1 0 0 33
34 0 1 0 34
35 0 0 1 35
36 0 0 0 36
37 0 0 0 37
38 0 0 0 38
39 0 0 0 39
40 0 0 0 40
41 0 0 0 41
42 0 0 0 42
43 0 0 0 43
44 0 0 0 44
45 1 0 0 45
46 0 1 0 46
47 0 0 1 47
48 0 0 0 48
49 0 0 0 49
50 0 0 0 50
51 0 0 0 51
52 0 0 0 52
53 0 0 0 53
54 0 0 0 54
55 0 0 0 55
56 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
53.86969 15.84888 0.13333 0.05322 0.27375 0.06706
M1 M2 M3 M4 M5 M6
-18.60359 -3.10158 -11.88095 -7.94283 3.99152 -10.03267
M7 M8 M9 M10 M11 t
-3.40836 0.56426 -18.56362 -9.04511 -9.35771 -0.17420
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-16.8410 -6.2120 0.6958 4.3747 23.2258
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 53.86969 22.79446 2.363 0.02333 *
X 15.84888 5.16298 3.070 0.00394 **
Y1 0.13333 0.14283 0.934 0.35645
Y2 0.05322 0.13386 0.398 0.69316
Y3 0.27375 0.13152 2.081 0.04419 *
Y4 0.06706 0.14149 0.474 0.63824
M1 -18.60359 8.43598 -2.205 0.03356 *
M2 -3.10158 8.17022 -0.380 0.70634
M3 -11.88095 8.30370 -1.431 0.16066
M4 -7.94283 7.44767 -1.066 0.29293
M5 3.99152 8.38027 0.476 0.63659
M6 -10.03267 7.86743 -1.275 0.20997
M7 -3.40836 8.05691 -0.423 0.67465
M8 0.56426 8.45863 0.067 0.94716
M9 -18.56362 8.11640 -2.287 0.02784 *
M10 -9.04511 8.74749 -1.034 0.30766
M11 -9.35771 8.86345 -1.056 0.29774
t -0.17420 0.12607 -1.382 0.17513
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 10.79 on 38 degrees of freedom
Multiple R-squared: 0.6877, Adjusted R-squared: 0.548
F-statistic: 4.922 on 17 and 38 DF, p-value: 2.203e-05
> 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.9282396 0.1435208 0.07176040
[2,] 0.9287679 0.1424642 0.07123211
[3,] 0.8783400 0.2433200 0.12165998
[4,] 0.8277706 0.3444587 0.17222936
[5,] 0.8110510 0.3778979 0.18894897
[6,] 0.7521901 0.4956199 0.24780994
[7,] 0.6582207 0.6835585 0.34177927
[8,] 0.5943333 0.8113334 0.40566670
[9,] 0.4883797 0.9767595 0.51162026
[10,] 0.4464015 0.8928030 0.55359849
[11,] 0.4712414 0.9424828 0.52875858
[12,] 0.4547992 0.9095985 0.54520075
[13,] 0.4392642 0.8785284 0.56073579
[14,] 0.3482948 0.6965896 0.65170519
[15,] 0.2327394 0.4654789 0.76726057
> postscript(file="/var/www/html/rcomp/tmp/1jk8s1258720123.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/230pw1258720123.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/3y0w41258720123.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/4n0fk1258720123.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/5ourk1258720123.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
-3.3910180 -11.6055995 -11.1659676 -3.8895441 2.6526494 6.9995869
7 8 9 10 11 12
19.8098984 3.4379428 -13.5888715 -2.7512047 2.9562228 -9.4453224
13 14 15 16 17 18
0.6738984 15.4171495 23.2258423 2.7798933 12.2377471 -8.8970315
19 20 21 22 23 24
3.9652550 -0.6903327 -0.6356849 -5.3449817 0.9478218 4.3398543
25 26 27 28 29 30
-6.7816678 -8.5133002 0.7177965 -9.7003388 1.6455612 -11.3255647
31 32 33 34 35 36
-14.6189724 2.7658027 3.1941072 4.4791994 -5.3583332 19.5506313
37 38 39 40 41 42
0.3566614 -2.8444982 -2.8755187 9.0151889 -10.5138370 5.3719022
43 44 45 46 47 48
-16.8410487 0.4313629 11.0304491 3.6169869 1.4542885 -14.4451633
49 50 51 52 53 54
9.1421260 7.5462484 -9.9021525 1.7948007 -6.0221207 7.8511071
55 56
7.6848678 -5.9447757
> postscript(file="/var/www/html/rcomp/tmp/6f8ey1258720123.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 -3.3910180 NA
1 -11.6055995 -3.3910180
2 -11.1659676 -11.6055995
3 -3.8895441 -11.1659676
4 2.6526494 -3.8895441
5 6.9995869 2.6526494
6 19.8098984 6.9995869
7 3.4379428 19.8098984
8 -13.5888715 3.4379428
9 -2.7512047 -13.5888715
10 2.9562228 -2.7512047
11 -9.4453224 2.9562228
12 0.6738984 -9.4453224
13 15.4171495 0.6738984
14 23.2258423 15.4171495
15 2.7798933 23.2258423
16 12.2377471 2.7798933
17 -8.8970315 12.2377471
18 3.9652550 -8.8970315
19 -0.6903327 3.9652550
20 -0.6356849 -0.6903327
21 -5.3449817 -0.6356849
22 0.9478218 -5.3449817
23 4.3398543 0.9478218
24 -6.7816678 4.3398543
25 -8.5133002 -6.7816678
26 0.7177965 -8.5133002
27 -9.7003388 0.7177965
28 1.6455612 -9.7003388
29 -11.3255647 1.6455612
30 -14.6189724 -11.3255647
31 2.7658027 -14.6189724
32 3.1941072 2.7658027
33 4.4791994 3.1941072
34 -5.3583332 4.4791994
35 19.5506313 -5.3583332
36 0.3566614 19.5506313
37 -2.8444982 0.3566614
38 -2.8755187 -2.8444982
39 9.0151889 -2.8755187
40 -10.5138370 9.0151889
41 5.3719022 -10.5138370
42 -16.8410487 5.3719022
43 0.4313629 -16.8410487
44 11.0304491 0.4313629
45 3.6169869 11.0304491
46 1.4542885 3.6169869
47 -14.4451633 1.4542885
48 9.1421260 -14.4451633
49 7.5462484 9.1421260
50 -9.9021525 7.5462484
51 1.7948007 -9.9021525
52 -6.0221207 1.7948007
53 7.8511071 -6.0221207
54 7.6848678 7.8511071
55 -5.9447757 7.6848678
56 NA -5.9447757
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -11.6055995 -3.3910180
[2,] -11.1659676 -11.6055995
[3,] -3.8895441 -11.1659676
[4,] 2.6526494 -3.8895441
[5,] 6.9995869 2.6526494
[6,] 19.8098984 6.9995869
[7,] 3.4379428 19.8098984
[8,] -13.5888715 3.4379428
[9,] -2.7512047 -13.5888715
[10,] 2.9562228 -2.7512047
[11,] -9.4453224 2.9562228
[12,] 0.6738984 -9.4453224
[13,] 15.4171495 0.6738984
[14,] 23.2258423 15.4171495
[15,] 2.7798933 23.2258423
[16,] 12.2377471 2.7798933
[17,] -8.8970315 12.2377471
[18,] 3.9652550 -8.8970315
[19,] -0.6903327 3.9652550
[20,] -0.6356849 -0.6903327
[21,] -5.3449817 -0.6356849
[22,] 0.9478218 -5.3449817
[23,] 4.3398543 0.9478218
[24,] -6.7816678 4.3398543
[25,] -8.5133002 -6.7816678
[26,] 0.7177965 -8.5133002
[27,] -9.7003388 0.7177965
[28,] 1.6455612 -9.7003388
[29,] -11.3255647 1.6455612
[30,] -14.6189724 -11.3255647
[31,] 2.7658027 -14.6189724
[32,] 3.1941072 2.7658027
[33,] 4.4791994 3.1941072
[34,] -5.3583332 4.4791994
[35,] 19.5506313 -5.3583332
[36,] 0.3566614 19.5506313
[37,] -2.8444982 0.3566614
[38,] -2.8755187 -2.8444982
[39,] 9.0151889 -2.8755187
[40,] -10.5138370 9.0151889
[41,] 5.3719022 -10.5138370
[42,] -16.8410487 5.3719022
[43,] 0.4313629 -16.8410487
[44,] 11.0304491 0.4313629
[45,] 3.6169869 11.0304491
[46,] 1.4542885 3.6169869
[47,] -14.4451633 1.4542885
[48,] 9.1421260 -14.4451633
[49,] 7.5462484 9.1421260
[50,] -9.9021525 7.5462484
[51,] 1.7948007 -9.9021525
[52,] -6.0221207 1.7948007
[53,] 7.8511071 -6.0221207
[54,] 7.6848678 7.8511071
[55,] -5.9447757 7.6848678
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -11.6055995 -3.3910180
2 -11.1659676 -11.6055995
3 -3.8895441 -11.1659676
4 2.6526494 -3.8895441
5 6.9995869 2.6526494
6 19.8098984 6.9995869
7 3.4379428 19.8098984
8 -13.5888715 3.4379428
9 -2.7512047 -13.5888715
10 2.9562228 -2.7512047
11 -9.4453224 2.9562228
12 0.6738984 -9.4453224
13 15.4171495 0.6738984
14 23.2258423 15.4171495
15 2.7798933 23.2258423
16 12.2377471 2.7798933
17 -8.8970315 12.2377471
18 3.9652550 -8.8970315
19 -0.6903327 3.9652550
20 -0.6356849 -0.6903327
21 -5.3449817 -0.6356849
22 0.9478218 -5.3449817
23 4.3398543 0.9478218
24 -6.7816678 4.3398543
25 -8.5133002 -6.7816678
26 0.7177965 -8.5133002
27 -9.7003388 0.7177965
28 1.6455612 -9.7003388
29 -11.3255647 1.6455612
30 -14.6189724 -11.3255647
31 2.7658027 -14.6189724
32 3.1941072 2.7658027
33 4.4791994 3.1941072
34 -5.3583332 4.4791994
35 19.5506313 -5.3583332
36 0.3566614 19.5506313
37 -2.8444982 0.3566614
38 -2.8755187 -2.8444982
39 9.0151889 -2.8755187
40 -10.5138370 9.0151889
41 5.3719022 -10.5138370
42 -16.8410487 5.3719022
43 0.4313629 -16.8410487
44 11.0304491 0.4313629
45 3.6169869 11.0304491
46 1.4542885 3.6169869
47 -14.4451633 1.4542885
48 9.1421260 -14.4451633
49 7.5462484 9.1421260
50 -9.9021525 7.5462484
51 1.7948007 -9.9021525
52 -6.0221207 1.7948007
53 7.8511071 -6.0221207
54 7.6848678 7.8511071
55 -5.9447757 7.6848678
> 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/7fs3u1258720123.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/8hj8y1258720123.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/9q3zp1258720123.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/10eptx1258720123.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/11wyve1258720123.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/123nwo1258720123.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/1347gz1258720123.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/1470e01258720123.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/15ecak1258720123.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/16r53b1258720123.tab")
+ }
>
> system("convert tmp/1jk8s1258720123.ps tmp/1jk8s1258720123.png")
> system("convert tmp/230pw1258720123.ps tmp/230pw1258720123.png")
> system("convert tmp/3y0w41258720123.ps tmp/3y0w41258720123.png")
> system("convert tmp/4n0fk1258720123.ps tmp/4n0fk1258720123.png")
> system("convert tmp/5ourk1258720123.ps tmp/5ourk1258720123.png")
> system("convert tmp/6f8ey1258720123.ps tmp/6f8ey1258720123.png")
> system("convert tmp/7fs3u1258720123.ps tmp/7fs3u1258720123.png")
> system("convert tmp/8hj8y1258720123.ps tmp/8hj8y1258720123.png")
> system("convert tmp/9q3zp1258720123.ps tmp/9q3zp1258720123.png")
> system("convert tmp/10eptx1258720123.ps tmp/10eptx1258720123.png")
>
>
> proc.time()
user system elapsed
2.344 1.541 2.976