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(0.2
+ ,1
+ ,0.6
+ ,0
+ ,1.9
+ ,3.2
+ ,0.9
+ ,1
+ ,0.2
+ ,0.6
+ ,0
+ ,1.9
+ ,2.4
+ ,1
+ ,0.9
+ ,0.2
+ ,0.6
+ ,0
+ ,4.7
+ ,1
+ ,2.4
+ ,0.9
+ ,0.2
+ ,0.6
+ ,9.4
+ ,1
+ ,4.7
+ ,2.4
+ ,0.9
+ ,0.2
+ ,12.5
+ ,1
+ ,9.4
+ ,4.7
+ ,2.4
+ ,0.9
+ ,15.8
+ ,1
+ ,12.5
+ ,9.4
+ ,4.7
+ ,2.4
+ ,18.2
+ ,1
+ ,15.8
+ ,12.5
+ ,9.4
+ ,4.7
+ ,16.8
+ ,0
+ ,18.2
+ ,15.8
+ ,12.5
+ ,9.4
+ ,17.3
+ ,0
+ ,16.8
+ ,18.2
+ ,15.8
+ ,12.5
+ ,19.3
+ ,0
+ ,17.3
+ ,16.8
+ ,18.2
+ ,15.8
+ ,17.9
+ ,0
+ ,19.3
+ ,17.3
+ ,16.8
+ ,18.2
+ ,20.2
+ ,0
+ ,17.9
+ ,19.3
+ ,17.3
+ ,16.8
+ ,18.7
+ ,0
+ ,20.2
+ ,17.9
+ ,19.3
+ ,17.3
+ ,20.1
+ ,0
+ ,18.7
+ ,20.2
+ ,17.9
+ ,19.3
+ ,18.2
+ ,0
+ ,20.1
+ ,18.7
+ ,20.2
+ ,17.9
+ ,18.4
+ ,0
+ ,18.2
+ ,20.1
+ ,18.7
+ ,20.2
+ ,18.2
+ ,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> #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 M9 M10 M11 t
1 0.2 1 0.6 0.0 1.9 3.2 1 0 0 0 0 0 0 0 0 0 0 1
2 0.9 1 0.2 0.6 0.0 1.9 0 1 0 0 0 0 0 0 0 0 0 2
3 2.4 1 0.9 0.2 0.6 0.0 0 0 1 0 0 0 0 0 0 0 0 3
4 4.7 1 2.4 0.9 0.2 0.6 0 0 0 1 0 0 0 0 0 0 0 4
5 9.4 1 4.7 2.4 0.9 0.2 0 0 0 0 1 0 0 0 0 0 0 5
6 12.5 1 9.4 4.7 2.4 0.9 0 0 0 0 0 1 0 0 0 0 0 6
7 15.8 1 12.5 9.4 4.7 2.4 0 0 0 0 0 0 1 0 0 0 0 7
8 18.2 1 15.8 12.5 9.4 4.7 0 0 0 0 0 0 0 1 0 0 0 8
9 16.8 0 18.2 15.8 12.5 9.4 0 0 0 0 0 0 0 0 1 0 0 9
10 17.3 0 16.8 18.2 15.8 12.5 0 0 0 0 0 0 0 0 0 1 0 10
11 19.3 0 17.3 16.8 18.2 15.8 0 0 0 0 0 0 0 0 0 0 1 11
12 17.9 0 19.3 17.3 16.8 18.2 0 0 0 0 0 0 0 0 0 0 0 12
13 20.2 0 17.9 19.3 17.3 16.8 1 0 0 0 0 0 0 0 0 0 0 13
14 18.7 0 20.2 17.9 19.3 17.3 0 1 0 0 0 0 0 0 0 0 0 14
15 20.1 0 18.7 20.2 17.9 19.3 0 0 1 0 0 0 0 0 0 0 0 15
16 18.2 0 20.1 18.7 20.2 17.9 0 0 0 1 0 0 0 0 0 0 0 16
17 18.4 0 18.2 20.1 18.7 20.2 0 0 0 0 1 0 0 0 0 0 0 17
18 18.2 0 18.4 18.2 20.1 18.7 0 0 0 0 0 1 0 0 0 0 0 18
19 18.9 0 18.2 18.4 18.2 20.1 0 0 0 0 0 0 1 0 0 0 0 19
20 19.9 0 18.9 18.2 18.4 18.2 0 0 0 0 0 0 0 1 0 0 0 20
21 21.3 0 19.9 18.9 18.2 18.4 0 0 0 0 0 0 0 0 1 0 0 21
22 20.0 0 21.3 19.9 18.9 18.2 0 0 0 0 0 0 0 0 0 1 0 22
23 19.5 0 20.0 21.3 19.9 18.9 0 0 0 0 0 0 0 0 0 0 1 23
24 19.6 0 19.5 20.0 21.3 19.9 0 0 0 0 0 0 0 0 0 0 0 24
25 20.9 0 19.6 19.5 20.0 21.3 1 0 0 0 0 0 0 0 0 0 0 25
26 21.0 0 20.9 19.6 19.5 20.0 0 1 0 0 0 0 0 0 0 0 0 26
27 19.9 0 21.0 20.9 19.6 19.5 0 0 1 0 0 0 0 0 0 0 0 27
28 19.6 0 19.9 21.0 20.9 19.6 0 0 0 1 0 0 0 0 0 0 0 28
29 20.9 0 19.6 19.9 21.0 20.9 0 0 0 0 1 0 0 0 0 0 0 29
30 21.7 0 20.9 19.6 19.9 21.0 0 0 0 0 0 1 0 0 0 0 0 30
31 22.9 0 21.7 20.9 19.6 19.9 0 0 0 0 0 0 1 0 0 0 0 31
32 21.5 0 22.9 21.7 20.9 19.6 0 0 0 0 0 0 0 1 0 0 0 32
33 21.3 0 21.5 22.9 21.7 20.9 0 0 0 0 0 0 0 0 1 0 0 33
34 23.5 0 21.3 21.5 22.9 21.7 0 0 0 0 0 0 0 0 0 1 0 34
35 21.6 0 23.5 21.3 21.5 22.9 0 0 0 0 0 0 0 0 0 0 1 35
36 24.5 0 21.6 23.5 21.3 21.5 0 0 0 0 0 0 0 0 0 0 0 36
37 22.2 0 24.5 21.6 23.5 21.3 1 0 0 0 0 0 0 0 0 0 0 37
38 23.5 0 22.2 24.5 21.6 23.5 0 1 0 0 0 0 0 0 0 0 0 38
39 20.9 0 23.5 22.2 24.5 21.6 0 0 1 0 0 0 0 0 0 0 0 39
40 20.7 0 20.9 23.5 22.2 24.5 0 0 0 1 0 0 0 0 0 0 0 40
41 18.1 0 20.7 20.9 23.5 22.2 0 0 0 0 1 0 0 0 0 0 0 41
42 17.1 0 18.1 20.7 20.9 23.5 0 0 0 0 0 1 0 0 0 0 0 42
43 14.8 0 17.1 18.1 20.7 20.9 0 0 0 0 0 0 1 0 0 0 0 43
44 13.8 0 14.8 17.1 18.1 20.7 0 0 0 0 0 0 0 1 0 0 0 44
45 15.2 0 13.8 14.8 17.1 18.1 0 0 0 0 0 0 0 0 1 0 0 45
46 16.0 0 15.2 13.8 14.8 17.1 0 0 0 0 0 0 0 0 0 1 0 46
47 17.6 0 16.0 15.2 13.8 14.8 0 0 0 0 0 0 0 0 0 0 1 47
48 15.0 0 17.6 16.0 15.2 13.8 0 0 0 0 0 0 0 0 0 0 0 48
49 15.0 0 15.0 17.6 16.0 15.2 1 0 0 0 0 0 0 0 0 0 0 49
50 16.3 0 15.0 15.0 17.6 16.0 0 1 0 0 0 0 0 0 0 0 0 50
51 19.4 0 16.3 15.0 15.0 17.6 0 0 1 0 0 0 0 0 0 0 0 51
52 21.3 0 19.4 16.3 15.0 15.0 0 0 0 1 0 0 0 0 0 0 0 52
53 20.5 0 21.3 19.4 16.3 15.0 0 0 0 0 1 0 0 0 0 0 0 53
54 21.1 0 20.5 21.3 19.4 16.3 0 0 0 0 0 1 0 0 0 0 0 54
55 21.6 0 21.1 20.5 21.3 19.4 0 0 0 0 0 0 1 0 0 0 0 55
56 22.6 0 21.6 21.1 20.5 21.3 0 0 0 0 0 0 0 1 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
0.519647 1.286323 0.928133 0.336765 -0.439356 0.115147
M1 M2 M3 M4 M5 M6
0.182945 0.332355 0.351788 0.236941 0.445900 0.615027
M7 M8 M9 M10 M11 t
0.590841 0.333802 0.492300 0.912247 0.618871 0.008231
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2.54892 -1.19223 0.05452 0.81076 2.60503
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.519647 2.087843 0.249 0.8048
X 1.286323 1.823485 0.705 0.4849
Y1 0.928133 0.160890 5.769 1.18e-06 ***
Y2 0.336765 0.202726 1.661 0.1049
Y3 -0.439356 0.205414 -2.139 0.0389 *
Y4 0.115147 0.152488 0.755 0.4548
M1 0.182945 1.142351 0.160 0.8736
M2 0.332355 1.139071 0.292 0.7720
M3 0.351788 1.134906 0.310 0.7583
M4 0.236941 1.133238 0.209 0.8355
M5 0.445900 1.135870 0.393 0.6968
M6 0.615027 1.140329 0.539 0.5928
M7 0.590841 1.146563 0.515 0.6093
M8 0.333802 1.156665 0.289 0.7745
M9 0.492300 1.191888 0.413 0.6819
M10 0.912247 1.187457 0.768 0.4471
M11 0.618871 1.183090 0.523 0.6039
t 0.008231 0.018177 0.453 0.6532
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.671 on 38 degrees of freedom
Multiple R-squared: 0.9312, Adjusted R-squared: 0.9004
F-statistic: 30.25 on 17 and 38 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.19311367 0.3862273 0.8068863
[2,] 0.47887122 0.9577424 0.5211288
[3,] 0.68213756 0.6357249 0.3178624
[4,] 0.58852067 0.8229587 0.4114793
[5,] 0.49513744 0.9902749 0.5048626
[6,] 0.36830160 0.7366032 0.6316984
[7,] 0.35292728 0.7058546 0.6470727
[8,] 0.24059073 0.4811815 0.7594093
[9,] 0.23028284 0.4605657 0.7697172
[10,] 0.17279284 0.3455857 0.8272072
[11,] 0.13684692 0.2736938 0.8631531
[12,] 0.11945752 0.2389150 0.8805425
[13,] 0.06599591 0.1319918 0.9340041
[14,] 0.08492809 0.1698562 0.9150719
[15,] 0.06041992 0.1208398 0.9395801
> postscript(file="/var/www/html/rcomp/tmp/11z9l1258742024.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/2xgc11258742024.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/3ixqj1258742024.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/4d3cc1258742024.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/56h5o1258742024.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
-1.887719372 -1.861251174 -0.421509387 0.112341614 2.308908338 0.673199118
7 8 9 10 11 12
0.366947799 0.709083064 -2.089352199 -0.433460578 2.533557452 -1.171900944
13 14 15 16 17 18
1.943663806 -0.556073525 0.588510506 -0.827388173 -0.476467935 0.388218685
19 20 21 22 23 24
0.226465411 1.199584420 1.158086893 -1.875662673 -0.996662716 1.115789070
25 26 27 28 29 30
1.567813970 0.199937267 -1.356824913 -0.003291772 1.622644157 0.644936557
31 32 33 34 35 36
0.675446661 -1.253208930 -0.522876238 2.341152287 -2.001516368 2.605028512
37 38 39 40 41 42
-0.948266610 0.264080512 -1.302685997 -0.765164356 -1.685138466 -1.674015578
43 44 45 46 47 48
-1.942828829 -1.341846796 1.454141544 -0.032029036 0.464621632 -2.548916637
49 50 51 52 53 54
-0.675491794 1.953306919 2.492509791 1.483502687 -1.769946094 -0.032338782
55 56
0.673968957 0.686388241
> postscript(file="/var/www/html/rcomp/tmp/6w0l11258742024.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 -1.887719372 NA
1 -1.861251174 -1.887719372
2 -0.421509387 -1.861251174
3 0.112341614 -0.421509387
4 2.308908338 0.112341614
5 0.673199118 2.308908338
6 0.366947799 0.673199118
7 0.709083064 0.366947799
8 -2.089352199 0.709083064
9 -0.433460578 -2.089352199
10 2.533557452 -0.433460578
11 -1.171900944 2.533557452
12 1.943663806 -1.171900944
13 -0.556073525 1.943663806
14 0.588510506 -0.556073525
15 -0.827388173 0.588510506
16 -0.476467935 -0.827388173
17 0.388218685 -0.476467935
18 0.226465411 0.388218685
19 1.199584420 0.226465411
20 1.158086893 1.199584420
21 -1.875662673 1.158086893
22 -0.996662716 -1.875662673
23 1.115789070 -0.996662716
24 1.567813970 1.115789070
25 0.199937267 1.567813970
26 -1.356824913 0.199937267
27 -0.003291772 -1.356824913
28 1.622644157 -0.003291772
29 0.644936557 1.622644157
30 0.675446661 0.644936557
31 -1.253208930 0.675446661
32 -0.522876238 -1.253208930
33 2.341152287 -0.522876238
34 -2.001516368 2.341152287
35 2.605028512 -2.001516368
36 -0.948266610 2.605028512
37 0.264080512 -0.948266610
38 -1.302685997 0.264080512
39 -0.765164356 -1.302685997
40 -1.685138466 -0.765164356
41 -1.674015578 -1.685138466
42 -1.942828829 -1.674015578
43 -1.341846796 -1.942828829
44 1.454141544 -1.341846796
45 -0.032029036 1.454141544
46 0.464621632 -0.032029036
47 -2.548916637 0.464621632
48 -0.675491794 -2.548916637
49 1.953306919 -0.675491794
50 2.492509791 1.953306919
51 1.483502687 2.492509791
52 -1.769946094 1.483502687
53 -0.032338782 -1.769946094
54 0.673968957 -0.032338782
55 0.686388241 0.673968957
56 NA 0.686388241
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.861251174 -1.887719372
[2,] -0.421509387 -1.861251174
[3,] 0.112341614 -0.421509387
[4,] 2.308908338 0.112341614
[5,] 0.673199118 2.308908338
[6,] 0.366947799 0.673199118
[7,] 0.709083064 0.366947799
[8,] -2.089352199 0.709083064
[9,] -0.433460578 -2.089352199
[10,] 2.533557452 -0.433460578
[11,] -1.171900944 2.533557452
[12,] 1.943663806 -1.171900944
[13,] -0.556073525 1.943663806
[14,] 0.588510506 -0.556073525
[15,] -0.827388173 0.588510506
[16,] -0.476467935 -0.827388173
[17,] 0.388218685 -0.476467935
[18,] 0.226465411 0.388218685
[19,] 1.199584420 0.226465411
[20,] 1.158086893 1.199584420
[21,] -1.875662673 1.158086893
[22,] -0.996662716 -1.875662673
[23,] 1.115789070 -0.996662716
[24,] 1.567813970 1.115789070
[25,] 0.199937267 1.567813970
[26,] -1.356824913 0.199937267
[27,] -0.003291772 -1.356824913
[28,] 1.622644157 -0.003291772
[29,] 0.644936557 1.622644157
[30,] 0.675446661 0.644936557
[31,] -1.253208930 0.675446661
[32,] -0.522876238 -1.253208930
[33,] 2.341152287 -0.522876238
[34,] -2.001516368 2.341152287
[35,] 2.605028512 -2.001516368
[36,] -0.948266610 2.605028512
[37,] 0.264080512 -0.948266610
[38,] -1.302685997 0.264080512
[39,] -0.765164356 -1.302685997
[40,] -1.685138466 -0.765164356
[41,] -1.674015578 -1.685138466
[42,] -1.942828829 -1.674015578
[43,] -1.341846796 -1.942828829
[44,] 1.454141544 -1.341846796
[45,] -0.032029036 1.454141544
[46,] 0.464621632 -0.032029036
[47,] -2.548916637 0.464621632
[48,] -0.675491794 -2.548916637
[49,] 1.953306919 -0.675491794
[50,] 2.492509791 1.953306919
[51,] 1.483502687 2.492509791
[52,] -1.769946094 1.483502687
[53,] -0.032338782 -1.769946094
[54,] 0.673968957 -0.032338782
[55,] 0.686388241 0.673968957
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.861251174 -1.887719372
2 -0.421509387 -1.861251174
3 0.112341614 -0.421509387
4 2.308908338 0.112341614
5 0.673199118 2.308908338
6 0.366947799 0.673199118
7 0.709083064 0.366947799
8 -2.089352199 0.709083064
9 -0.433460578 -2.089352199
10 2.533557452 -0.433460578
11 -1.171900944 2.533557452
12 1.943663806 -1.171900944
13 -0.556073525 1.943663806
14 0.588510506 -0.556073525
15 -0.827388173 0.588510506
16 -0.476467935 -0.827388173
17 0.388218685 -0.476467935
18 0.226465411 0.388218685
19 1.199584420 0.226465411
20 1.158086893 1.199584420
21 -1.875662673 1.158086893
22 -0.996662716 -1.875662673
23 1.115789070 -0.996662716
24 1.567813970 1.115789070
25 0.199937267 1.567813970
26 -1.356824913 0.199937267
27 -0.003291772 -1.356824913
28 1.622644157 -0.003291772
29 0.644936557 1.622644157
30 0.675446661 0.644936557
31 -1.253208930 0.675446661
32 -0.522876238 -1.253208930
33 2.341152287 -0.522876238
34 -2.001516368 2.341152287
35 2.605028512 -2.001516368
36 -0.948266610 2.605028512
37 0.264080512 -0.948266610
38 -1.302685997 0.264080512
39 -0.765164356 -1.302685997
40 -1.685138466 -0.765164356
41 -1.674015578 -1.685138466
42 -1.942828829 -1.674015578
43 -1.341846796 -1.942828829
44 1.454141544 -1.341846796
45 -0.032029036 1.454141544
46 0.464621632 -0.032029036
47 -2.548916637 0.464621632
48 -0.675491794 -2.548916637
49 1.953306919 -0.675491794
50 2.492509791 1.953306919
51 1.483502687 2.492509791
52 -1.769946094 1.483502687
53 -0.032338782 -1.769946094
54 0.673968957 -0.032338782
55 0.686388241 0.673968957
> 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/76c5l1258742024.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/8uxx61258742024.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/9zp4y1258742024.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/10bqs11258742024.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/11pypj1258742024.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/12zvop1258742024.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/13vp5t1258742024.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/14gn5e1258742024.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/15e5071258742024.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/16zve41258742024.tab")
+ }
> system("convert tmp/11z9l1258742024.ps tmp/11z9l1258742024.png")
> system("convert tmp/2xgc11258742024.ps tmp/2xgc11258742024.png")
> system("convert tmp/3ixqj1258742024.ps tmp/3ixqj1258742024.png")
> system("convert tmp/4d3cc1258742024.ps tmp/4d3cc1258742024.png")
> system("convert tmp/56h5o1258742024.ps tmp/56h5o1258742024.png")
> system("convert tmp/6w0l11258742024.ps tmp/6w0l11258742024.png")
> system("convert tmp/76c5l1258742024.ps tmp/76c5l1258742024.png")
> system("convert tmp/8uxx61258742024.ps tmp/8uxx61258742024.png")
> system("convert tmp/9zp4y1258742024.ps tmp/9zp4y1258742024.png")
> system("convert tmp/10bqs11258742024.ps tmp/10bqs11258742024.png")
>
>
> proc.time()
user system elapsed
2.319 1.573 2.746