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(100.25
+ ,1.8
+ ,100.03
+ ,99.6
+ ,2.7
+ ,100.25
+ ,100.16
+ ,2.3
+ ,99.6
+ ,100.49
+ ,1.9
+ ,100.16
+ ,99.72
+ ,2
+ ,100.49
+ ,100.14
+ ,2.3
+ ,99.72
+ ,98.48
+ ,2.8
+ ,100.14
+ ,100.38
+ ,2.4
+ ,98.48
+ ,101.45
+ ,2.3
+ ,100.38
+ ,98.42
+ ,2.7
+ ,101.45
+ ,98.6
+ ,2.7
+ ,98.42
+ ,100.06
+ ,2.9
+ ,98.6
+ ,98.62
+ ,3
+ ,100.06
+ ,100.84
+ ,2.2
+ ,98.62
+ ,100.02
+ ,2.3
+ ,100.84
+ ,97.95
+ ,2.8
+ ,100.02
+ ,98.32
+ ,2.8
+ ,97.95
+ ,98.27
+ ,2.8
+ ,98.32
+ ,97.22
+ ,2.2
+ ,98.27
+ ,99.28
+ ,2.6
+ ,97.22
+ ,100.38
+ ,2.8
+ ,99.28
+ ,99.02
+ ,2.5
+ ,100.38
+ ,100.32
+ ,2.4
+ ,99.02
+ ,99.81
+ ,2.3
+ ,100.32
+ ,100.6
+ ,1.9
+ ,99.81
+ ,101.19
+ ,1.7
+ ,100.6
+ ,100.47
+ ,2
+ ,101.19
+ ,101.77
+ ,2.1
+ ,100.47
+ ,102.32
+ ,1.7
+ ,101.77
+ ,102.39
+ ,1.8
+ ,102.32
+ ,101.16
+ ,1.8
+ ,102.39
+ ,100.63
+ ,1.8
+ ,101.16
+ ,101.48
+ ,1.3
+ ,100.63
+ ,101.44
+ ,1.3
+ ,101.48
+ ,100.09
+ ,1.3
+ ,101.44
+ ,100.7
+ ,1.2
+ ,100.09
+ ,100.78
+ ,1.4
+ ,100.7
+ ,99.81
+ ,2.2
+ ,100.78
+ ,98.45
+ ,2.9
+ ,99.81
+ ,98.49
+ ,3.1
+ ,98.45
+ ,97.48
+ ,3.5
+ ,98.49
+ ,97.91
+ ,3.6
+ ,97.48
+ ,96.94
+ ,4.4
+ ,97.91
+ ,98.53
+ ,4.1
+ ,96.94
+ ,96.82
+ ,5.1
+ ,98.53
+ ,95.76
+ ,5.8
+ ,96.82
+ ,95.27
+ ,5.9
+ ,95.76
+ ,97.32
+ ,5.4
+ ,95.27
+ ,96.68
+ ,5.5
+ ,97.32
+ ,97.87
+ ,4.8
+ ,96.68
+ ,97.42
+ ,3.2
+ ,97.87
+ ,97.94
+ ,2.7
+ ,97.42
+ ,99.52
+ ,2.1
+ ,97.94
+ ,100.99
+ ,1.9
+ ,99.52
+ ,99.92
+ ,0.6
+ ,100.99
+ ,101.97
+ ,0.7
+ ,99.92
+ ,101.58
+ ,-0.2
+ ,101.97
+ ,99.54
+ ,-1
+ ,101.58
+ ,100.83
+ ,-1.7
+ ,99.54)
+ ,dim=c(3
+ ,59)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1')
+ ,1:59))
> y <- array(NA,dim=c(3,59),dimnames=list(c('Y','X','Y1'),1:59))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 100.25 1.8 100.03 1 0 0 0 0 0 0 0 0 0 0 1
2 99.60 2.7 100.25 0 1 0 0 0 0 0 0 0 0 0 2
3 100.16 2.3 99.60 0 0 1 0 0 0 0 0 0 0 0 3
4 100.49 1.9 100.16 0 0 0 1 0 0 0 0 0 0 0 4
5 99.72 2.0 100.49 0 0 0 0 1 0 0 0 0 0 0 5
6 100.14 2.3 99.72 0 0 0 0 0 1 0 0 0 0 0 6
7 98.48 2.8 100.14 0 0 0 0 0 0 1 0 0 0 0 7
8 100.38 2.4 98.48 0 0 0 0 0 0 0 1 0 0 0 8
9 101.45 2.3 100.38 0 0 0 0 0 0 0 0 1 0 0 9
10 98.42 2.7 101.45 0 0 0 0 0 0 0 0 0 1 0 10
11 98.60 2.7 98.42 0 0 0 0 0 0 0 0 0 0 1 11
12 100.06 2.9 98.60 0 0 0 0 0 0 0 0 0 0 0 12
13 98.62 3.0 100.06 1 0 0 0 0 0 0 0 0 0 0 13
14 100.84 2.2 98.62 0 1 0 0 0 0 0 0 0 0 0 14
15 100.02 2.3 100.84 0 0 1 0 0 0 0 0 0 0 0 15
16 97.95 2.8 100.02 0 0 0 1 0 0 0 0 0 0 0 16
17 98.32 2.8 97.95 0 0 0 0 1 0 0 0 0 0 0 17
18 98.27 2.8 98.32 0 0 0 0 0 1 0 0 0 0 0 18
19 97.22 2.2 98.27 0 0 0 0 0 0 1 0 0 0 0 19
20 99.28 2.6 97.22 0 0 0 0 0 0 0 1 0 0 0 20
21 100.38 2.8 99.28 0 0 0 0 0 0 0 0 1 0 0 21
22 99.02 2.5 100.38 0 0 0 0 0 0 0 0 0 1 0 22
23 100.32 2.4 99.02 0 0 0 0 0 0 0 0 0 0 1 23
24 99.81 2.3 100.32 0 0 0 0 0 0 0 0 0 0 0 24
25 100.60 1.9 99.81 1 0 0 0 0 0 0 0 0 0 0 25
26 101.19 1.7 100.60 0 1 0 0 0 0 0 0 0 0 0 26
27 100.47 2.0 101.19 0 0 1 0 0 0 0 0 0 0 0 27
28 101.77 2.1 100.47 0 0 0 1 0 0 0 0 0 0 0 28
29 102.32 1.7 101.77 0 0 0 0 1 0 0 0 0 0 0 29
30 102.39 1.8 102.32 0 0 0 0 0 1 0 0 0 0 0 30
31 101.16 1.8 102.39 0 0 0 0 0 0 1 0 0 0 0 31
32 100.63 1.8 101.16 0 0 0 0 0 0 0 1 0 0 0 32
33 101.48 1.3 100.63 0 0 0 0 0 0 0 0 1 0 0 33
34 101.44 1.3 101.48 0 0 0 0 0 0 0 0 0 1 0 34
35 100.09 1.3 101.44 0 0 0 0 0 0 0 0 0 0 1 35
36 100.70 1.2 100.09 0 0 0 0 0 0 0 0 0 0 0 36
37 100.78 1.4 100.70 1 0 0 0 0 0 0 0 0 0 0 37
38 99.81 2.2 100.78 0 1 0 0 0 0 0 0 0 0 0 38
39 98.45 2.9 99.81 0 0 1 0 0 0 0 0 0 0 0 39
40 98.49 3.1 98.45 0 0 0 1 0 0 0 0 0 0 0 40
41 97.48 3.5 98.49 0 0 0 0 1 0 0 0 0 0 0 41
42 97.91 3.6 97.48 0 0 0 0 0 1 0 0 0 0 0 42
43 96.94 4.4 97.91 0 0 0 0 0 0 1 0 0 0 0 43
44 98.53 4.1 96.94 0 0 0 0 0 0 0 1 0 0 0 44
45 96.82 5.1 98.53 0 0 0 0 0 0 0 0 1 0 0 45
46 95.76 5.8 96.82 0 0 0 0 0 0 0 0 0 1 0 46
47 95.27 5.9 95.76 0 0 0 0 0 0 0 0 0 0 1 47
48 97.32 5.4 95.27 0 0 0 0 0 0 0 0 0 0 0 48
49 96.68 5.5 97.32 1 0 0 0 0 0 0 0 0 0 0 49
50 97.87 4.8 96.68 0 1 0 0 0 0 0 0 0 0 0 50
51 97.42 3.2 97.87 0 0 1 0 0 0 0 0 0 0 0 51
52 97.94 2.7 97.42 0 0 0 1 0 0 0 0 0 0 0 52
53 99.52 2.1 97.94 0 0 0 0 1 0 0 0 0 0 0 53
54 100.99 1.9 99.52 0 0 0 0 0 1 0 0 0 0 0 54
55 99.92 0.6 100.99 0 0 0 0 0 0 1 0 0 0 0 55
56 101.97 0.7 99.92 0 0 0 0 0 0 0 1 0 0 0 56
57 101.58 -0.2 101.97 0 0 0 0 0 0 0 0 1 0 0 57
58 99.54 -1.0 101.58 0 0 0 0 0 0 0 0 0 1 0 58
59 100.83 -1.7 99.54 0 0 0 0 0 0 0 0 0 0 1 59
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 M1 M2 M3
54.467184 -0.510591 0.473872 -0.717449 -0.141021 -1.009889
M4 M5 M6 M7 M8 M9
-0.725079 -0.636910 -0.199910 -1.672352 0.294577 -0.215513
M10 M11 t
-1.802104 -0.967334 -0.006601
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.65354 -0.57549 -0.05528 0.54838 1.67502
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 54.467184 12.014833 4.533 4.43e-05 ***
X -0.510591 0.126577 -4.034 0.000215 ***
Y1 0.473872 0.118113 4.012 0.000230 ***
M1 -0.717449 0.590856 -1.214 0.231128
M2 -0.141021 0.587854 -0.240 0.811529
M3 -1.009889 0.594107 -1.700 0.096220 .
M4 -0.725079 0.585960 -1.237 0.222494
M5 -0.636910 0.586093 -1.087 0.283085
M6 -0.199910 0.587800 -0.340 0.735400
M7 -1.672352 0.595058 -2.810 0.007358 **
M8 0.294577 0.586924 0.502 0.618241
M9 -0.215513 0.600171 -0.359 0.721248
M10 -1.802104 0.606040 -2.974 0.004762 **
M11 -0.967334 0.589491 -1.641 0.107935
t -0.006601 0.007182 -0.919 0.363025
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.8697 on 44 degrees of freedom
Multiple R-squared: 0.791, Adjusted R-squared: 0.7245
F-statistic: 11.89 on 14 and 44 DF, p-value: 1.097e-10
> 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.2641945 0.5283889 0.73580555
[2,] 0.5020320 0.9959359 0.49796797
[3,] 0.3720029 0.7440057 0.62799713
[4,] 0.2489246 0.4978493 0.75107536
[5,] 0.2242085 0.4484170 0.77579152
[6,] 0.2602580 0.5205159 0.73974204
[7,] 0.3157142 0.6314283 0.68428584
[8,] 0.2695896 0.5391793 0.73041036
[9,] 0.1842974 0.3685948 0.81570258
[10,] 0.1202142 0.2404285 0.87978575
[11,] 0.3653071 0.7306143 0.63469287
[12,] 0.4451289 0.8902578 0.55487108
[13,] 0.3846203 0.7692406 0.61537970
[14,] 0.3607177 0.7214355 0.63928227
[15,] 0.4624563 0.9249125 0.53754373
[16,] 0.5044916 0.9910168 0.49550839
[17,] 0.8004256 0.3991487 0.19957437
[18,] 0.8233843 0.3532314 0.17661572
[19,] 0.7567018 0.4865963 0.24329816
[20,] 0.7866602 0.4266797 0.21333984
[21,] 0.6980004 0.6039991 0.30199956
[22,] 0.6327521 0.7344958 0.36724792
[23,] 0.8300332 0.3399337 0.16996684
[24,] 0.9447291 0.1105418 0.05527089
> postscript(file="/var/www/html/rcomp/tmp/1m18o1259001615.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/2xueu1259001615.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/32kjr1259001615.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/4hssl1259001615.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/57w861259001615.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 = 59
Frequency = 1
1 2 3 4 5 6
0.02447969 -0.84006726 0.69918302 0.28136926 -0.67551752 -0.16785643
7 8 9 10 11 12
-0.29254429 0.22951980 0.86479422 -0.87482036 -0.08715622 0.42893198
13 14 15 16 17 18
-0.92781269 0.99626414 0.05079620 -1.65354205 -0.38419432 -1.03992491
19 20 21 22 23 24
-0.89354260 -0.09206803 0.65056404 0.20931976 1.27455803 -0.86326801
25 26 27 28 29 30
0.68822043 0.23191642 0.26097853 1.67501674 1.32317842 0.75320988
31 32 33 34 35 36
0.96908196 -0.93838275 0.42416513 1.57456616 -0.58464797 -0.34671233
37 38 39 40 41 42
0.27039355 -0.89887035 -0.56633109 -0.05795551 -0.96424209 -0.43496979
43 44 45 46 47 48
0.27878086 0.21493211 -1.22124322 0.47968451 -0.28512077 0.78104837
49 50 51 52 53 54
-0.05528098 0.51075706 -0.44462666 -0.24488844 0.70077551 0.88954124
55 56 57 58 59
-0.06177593 0.58599886 -0.71828018 -1.38875006 -0.31763306
> postscript(file="/var/www/html/rcomp/tmp/6bzb51259001615.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 = 59
Frequency = 1
lag(myerror, k = 1) myerror
0 0.02447969 NA
1 -0.84006726 0.02447969
2 0.69918302 -0.84006726
3 0.28136926 0.69918302
4 -0.67551752 0.28136926
5 -0.16785643 -0.67551752
6 -0.29254429 -0.16785643
7 0.22951980 -0.29254429
8 0.86479422 0.22951980
9 -0.87482036 0.86479422
10 -0.08715622 -0.87482036
11 0.42893198 -0.08715622
12 -0.92781269 0.42893198
13 0.99626414 -0.92781269
14 0.05079620 0.99626414
15 -1.65354205 0.05079620
16 -0.38419432 -1.65354205
17 -1.03992491 -0.38419432
18 -0.89354260 -1.03992491
19 -0.09206803 -0.89354260
20 0.65056404 -0.09206803
21 0.20931976 0.65056404
22 1.27455803 0.20931976
23 -0.86326801 1.27455803
24 0.68822043 -0.86326801
25 0.23191642 0.68822043
26 0.26097853 0.23191642
27 1.67501674 0.26097853
28 1.32317842 1.67501674
29 0.75320988 1.32317842
30 0.96908196 0.75320988
31 -0.93838275 0.96908196
32 0.42416513 -0.93838275
33 1.57456616 0.42416513
34 -0.58464797 1.57456616
35 -0.34671233 -0.58464797
36 0.27039355 -0.34671233
37 -0.89887035 0.27039355
38 -0.56633109 -0.89887035
39 -0.05795551 -0.56633109
40 -0.96424209 -0.05795551
41 -0.43496979 -0.96424209
42 0.27878086 -0.43496979
43 0.21493211 0.27878086
44 -1.22124322 0.21493211
45 0.47968451 -1.22124322
46 -0.28512077 0.47968451
47 0.78104837 -0.28512077
48 -0.05528098 0.78104837
49 0.51075706 -0.05528098
50 -0.44462666 0.51075706
51 -0.24488844 -0.44462666
52 0.70077551 -0.24488844
53 0.88954124 0.70077551
54 -0.06177593 0.88954124
55 0.58599886 -0.06177593
56 -0.71828018 0.58599886
57 -1.38875006 -0.71828018
58 -0.31763306 -1.38875006
59 NA -0.31763306
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.84006726 0.02447969
[2,] 0.69918302 -0.84006726
[3,] 0.28136926 0.69918302
[4,] -0.67551752 0.28136926
[5,] -0.16785643 -0.67551752
[6,] -0.29254429 -0.16785643
[7,] 0.22951980 -0.29254429
[8,] 0.86479422 0.22951980
[9,] -0.87482036 0.86479422
[10,] -0.08715622 -0.87482036
[11,] 0.42893198 -0.08715622
[12,] -0.92781269 0.42893198
[13,] 0.99626414 -0.92781269
[14,] 0.05079620 0.99626414
[15,] -1.65354205 0.05079620
[16,] -0.38419432 -1.65354205
[17,] -1.03992491 -0.38419432
[18,] -0.89354260 -1.03992491
[19,] -0.09206803 -0.89354260
[20,] 0.65056404 -0.09206803
[21,] 0.20931976 0.65056404
[22,] 1.27455803 0.20931976
[23,] -0.86326801 1.27455803
[24,] 0.68822043 -0.86326801
[25,] 0.23191642 0.68822043
[26,] 0.26097853 0.23191642
[27,] 1.67501674 0.26097853
[28,] 1.32317842 1.67501674
[29,] 0.75320988 1.32317842
[30,] 0.96908196 0.75320988
[31,] -0.93838275 0.96908196
[32,] 0.42416513 -0.93838275
[33,] 1.57456616 0.42416513
[34,] -0.58464797 1.57456616
[35,] -0.34671233 -0.58464797
[36,] 0.27039355 -0.34671233
[37,] -0.89887035 0.27039355
[38,] -0.56633109 -0.89887035
[39,] -0.05795551 -0.56633109
[40,] -0.96424209 -0.05795551
[41,] -0.43496979 -0.96424209
[42,] 0.27878086 -0.43496979
[43,] 0.21493211 0.27878086
[44,] -1.22124322 0.21493211
[45,] 0.47968451 -1.22124322
[46,] -0.28512077 0.47968451
[47,] 0.78104837 -0.28512077
[48,] -0.05528098 0.78104837
[49,] 0.51075706 -0.05528098
[50,] -0.44462666 0.51075706
[51,] -0.24488844 -0.44462666
[52,] 0.70077551 -0.24488844
[53,] 0.88954124 0.70077551
[54,] -0.06177593 0.88954124
[55,] 0.58599886 -0.06177593
[56,] -0.71828018 0.58599886
[57,] -1.38875006 -0.71828018
[58,] -0.31763306 -1.38875006
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.84006726 0.02447969
2 0.69918302 -0.84006726
3 0.28136926 0.69918302
4 -0.67551752 0.28136926
5 -0.16785643 -0.67551752
6 -0.29254429 -0.16785643
7 0.22951980 -0.29254429
8 0.86479422 0.22951980
9 -0.87482036 0.86479422
10 -0.08715622 -0.87482036
11 0.42893198 -0.08715622
12 -0.92781269 0.42893198
13 0.99626414 -0.92781269
14 0.05079620 0.99626414
15 -1.65354205 0.05079620
16 -0.38419432 -1.65354205
17 -1.03992491 -0.38419432
18 -0.89354260 -1.03992491
19 -0.09206803 -0.89354260
20 0.65056404 -0.09206803
21 0.20931976 0.65056404
22 1.27455803 0.20931976
23 -0.86326801 1.27455803
24 0.68822043 -0.86326801
25 0.23191642 0.68822043
26 0.26097853 0.23191642
27 1.67501674 0.26097853
28 1.32317842 1.67501674
29 0.75320988 1.32317842
30 0.96908196 0.75320988
31 -0.93838275 0.96908196
32 0.42416513 -0.93838275
33 1.57456616 0.42416513
34 -0.58464797 1.57456616
35 -0.34671233 -0.58464797
36 0.27039355 -0.34671233
37 -0.89887035 0.27039355
38 -0.56633109 -0.89887035
39 -0.05795551 -0.56633109
40 -0.96424209 -0.05795551
41 -0.43496979 -0.96424209
42 0.27878086 -0.43496979
43 0.21493211 0.27878086
44 -1.22124322 0.21493211
45 0.47968451 -1.22124322
46 -0.28512077 0.47968451
47 0.78104837 -0.28512077
48 -0.05528098 0.78104837
49 0.51075706 -0.05528098
50 -0.44462666 0.51075706
51 -0.24488844 -0.44462666
52 0.70077551 -0.24488844
53 0.88954124 0.70077551
54 -0.06177593 0.88954124
55 0.58599886 -0.06177593
56 -0.71828018 0.58599886
57 -1.38875006 -0.71828018
58 -0.31763306 -1.38875006
> 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/7t1sm1259001615.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/8goy01259001615.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/942ix1259001615.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/106hg01259001615.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/11uim71259001615.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/1212w61259001615.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/13q9by1259001615.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/14t0nj1259001615.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/153pdz1259001615.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/16fuk21259001615.tab")
+ }
>
> system("convert tmp/1m18o1259001615.ps tmp/1m18o1259001615.png")
> system("convert tmp/2xueu1259001615.ps tmp/2xueu1259001615.png")
> system("convert tmp/32kjr1259001615.ps tmp/32kjr1259001615.png")
> system("convert tmp/4hssl1259001615.ps tmp/4hssl1259001615.png")
> system("convert tmp/57w861259001615.ps tmp/57w861259001615.png")
> system("convert tmp/6bzb51259001615.ps tmp/6bzb51259001615.png")
> system("convert tmp/7t1sm1259001615.ps tmp/7t1sm1259001615.png")
> system("convert tmp/8goy01259001615.ps tmp/8goy01259001615.png")
> system("convert tmp/942ix1259001615.ps tmp/942ix1259001615.png")
> system("convert tmp/106hg01259001615.ps tmp/106hg01259001615.png")
>
>
> proc.time()
user system elapsed
2.414 1.610 3.436