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(37,30,47,35,30,43,82,40,47,19,52,136,80,42,54,66,81,63,137,72,107,58,36,52,79,77,54,84,48,96,83,66,61,53,30,74,69,59,42,65,70,100,63,105,82,81,75,102,121,98,76,77,63,37,35,23,40,29,37,51,20,28,13,22,25,13,16,13,16,17,9,17,25,14,8,7,10,7,10,3),dim=c(1,80),dimnames=list(c('Sol.KIA'),1:80))
> y <- array(NA,dim=c(1,80),dimnames=list(c('Sol.KIA'),1:80))
> 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
Sol.KIA M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 37 1 0 0 0 0 0 0 0 0 0 0 1
2 30 0 1 0 0 0 0 0 0 0 0 0 2
3 47 0 0 1 0 0 0 0 0 0 0 0 3
4 35 0 0 0 1 0 0 0 0 0 0 0 4
5 30 0 0 0 0 1 0 0 0 0 0 0 5
6 43 0 0 0 0 0 1 0 0 0 0 0 6
7 82 0 0 0 0 0 0 1 0 0 0 0 7
8 40 0 0 0 0 0 0 0 1 0 0 0 8
9 47 0 0 0 0 0 0 0 0 1 0 0 9
10 19 0 0 0 0 0 0 0 0 0 1 0 10
11 52 0 0 0 0 0 0 0 0 0 0 1 11
12 136 0 0 0 0 0 0 0 0 0 0 0 12
13 80 1 0 0 0 0 0 0 0 0 0 0 13
14 42 0 1 0 0 0 0 0 0 0 0 0 14
15 54 0 0 1 0 0 0 0 0 0 0 0 15
16 66 0 0 0 1 0 0 0 0 0 0 0 16
17 81 0 0 0 0 1 0 0 0 0 0 0 17
18 63 0 0 0 0 0 1 0 0 0 0 0 18
19 137 0 0 0 0 0 0 1 0 0 0 0 19
20 72 0 0 0 0 0 0 0 1 0 0 0 20
21 107 0 0 0 0 0 0 0 0 1 0 0 21
22 58 0 0 0 0 0 0 0 0 0 1 0 22
23 36 0 0 0 0 0 0 0 0 0 0 1 23
24 52 0 0 0 0 0 0 0 0 0 0 0 24
25 79 1 0 0 0 0 0 0 0 0 0 0 25
26 77 0 1 0 0 0 0 0 0 0 0 0 26
27 54 0 0 1 0 0 0 0 0 0 0 0 27
28 84 0 0 0 1 0 0 0 0 0 0 0 28
29 48 0 0 0 0 1 0 0 0 0 0 0 29
30 96 0 0 0 0 0 1 0 0 0 0 0 30
31 83 0 0 0 0 0 0 1 0 0 0 0 31
32 66 0 0 0 0 0 0 0 1 0 0 0 32
33 61 0 0 0 0 0 0 0 0 1 0 0 33
34 53 0 0 0 0 0 0 0 0 0 1 0 34
35 30 0 0 0 0 0 0 0 0 0 0 1 35
36 74 0 0 0 0 0 0 0 0 0 0 0 36
37 69 1 0 0 0 0 0 0 0 0 0 0 37
38 59 0 1 0 0 0 0 0 0 0 0 0 38
39 42 0 0 1 0 0 0 0 0 0 0 0 39
40 65 0 0 0 1 0 0 0 0 0 0 0 40
41 70 0 0 0 0 1 0 0 0 0 0 0 41
42 100 0 0 0 0 0 1 0 0 0 0 0 42
43 63 0 0 0 0 0 0 1 0 0 0 0 43
44 105 0 0 0 0 0 0 0 1 0 0 0 44
45 82 0 0 0 0 0 0 0 0 1 0 0 45
46 81 0 0 0 0 0 0 0 0 0 1 0 46
47 75 0 0 0 0 0 0 0 0 0 0 1 47
48 102 0 0 0 0 0 0 0 0 0 0 0 48
49 121 1 0 0 0 0 0 0 0 0 0 0 49
50 98 0 1 0 0 0 0 0 0 0 0 0 50
51 76 0 0 1 0 0 0 0 0 0 0 0 51
52 77 0 0 0 1 0 0 0 0 0 0 0 52
53 63 0 0 0 0 1 0 0 0 0 0 0 53
54 37 0 0 0 0 0 1 0 0 0 0 0 54
55 35 0 0 0 0 0 0 1 0 0 0 0 55
56 23 0 0 0 0 0 0 0 1 0 0 0 56
57 40 0 0 0 0 0 0 0 0 1 0 0 57
58 29 0 0 0 0 0 0 0 0 0 1 0 58
59 37 0 0 0 0 0 0 0 0 0 0 1 59
60 51 0 0 0 0 0 0 0 0 0 0 0 60
61 20 1 0 0 0 0 0 0 0 0 0 0 61
62 28 0 1 0 0 0 0 0 0 0 0 0 62
63 13 0 0 1 0 0 0 0 0 0 0 0 63
64 22 0 0 0 1 0 0 0 0 0 0 0 64
65 25 0 0 0 0 1 0 0 0 0 0 0 65
66 13 0 0 0 0 0 1 0 0 0 0 0 66
67 16 0 0 0 0 0 0 1 0 0 0 0 67
68 13 0 0 0 0 0 0 0 1 0 0 0 68
69 16 0 0 0 0 0 0 0 0 1 0 0 69
70 17 0 0 0 0 0 0 0 0 0 1 0 70
71 9 0 0 0 0 0 0 0 0 0 0 1 71
72 17 0 0 0 0 0 0 0 0 0 0 0 72
73 25 1 0 0 0 0 0 0 0 0 0 0 73
74 14 0 1 0 0 0 0 0 0 0 0 0 74
75 8 0 0 1 0 0 0 0 0 0 0 0 75
76 7 0 0 0 1 0 0 0 0 0 0 0 76
77 10 0 0 0 0 1 0 0 0 0 0 0 77
78 7 0 0 0 0 0 1 0 0 0 0 0 78
79 10 0 0 0 0 0 0 1 0 0 0 0 79
80 3 0 0 0 0 0 0 0 1 0 0 0 80
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) M1 M2 M3 M4 M5
99.3512 -13.6847 -24.8906 -31.9537 -22.4453 -25.9369
M6 M7 M8 M9 M10 M11
-20.7143 -10.4916 -24.6976 -15.1203 -30.4691 -32.8179
t
-0.6512
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-48.02 -18.14 -5.00 14.19 67.24
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 99.3512 13.2048 7.524 1.74e-10 ***
M1 -13.6847 16.1106 -0.849 0.3987
M2 -24.8906 16.1051 -1.546 0.1269
M3 -31.9537 16.1008 -1.985 0.0513 .
M4 -22.4453 16.0977 -1.394 0.1678
M5 -25.9369 16.0959 -1.611 0.1118
M6 -20.7143 16.0953 -1.287 0.2025
M7 -10.4916 16.0959 -0.652 0.5167
M8 -24.6976 16.0977 -1.534 0.1297
M9 -15.1203 16.7082 -0.905 0.3687
M10 -30.4691 16.7052 -1.824 0.0726 .
M11 -32.8179 16.7035 -1.965 0.0536 .
t -0.6512 0.1406 -4.632 1.72e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 28.93 on 67 degrees of freedom
Multiple R-squared: 0.3033, Adjusted R-squared: 0.1785
F-statistic: 2.431 on 12 and 67 DF, p-value: 0.01096
> 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.13616995 2.723399e-01 8.638301e-01
[2,] 0.13275338 2.655068e-01 8.672466e-01
[3,] 0.07087295 1.417459e-01 9.291270e-01
[4,] 0.08484731 1.696946e-01 9.151527e-01
[5,] 0.04272494 8.544988e-02 9.572751e-01
[6,] 0.04882668 9.765335e-02 9.511733e-01
[7,] 0.02676174 5.352347e-02 9.732383e-01
[8,] 0.11529154 2.305831e-01 8.847085e-01
[9,] 0.85970358 2.805928e-01 1.402964e-01
[10,] 0.81951903 3.609619e-01 1.804810e-01
[11,] 0.76947399 4.610520e-01 2.305260e-01
[12,] 0.75731081 4.853784e-01 2.426892e-01
[13,] 0.68791046 6.241791e-01 3.120895e-01
[14,] 0.74235924 5.152815e-01 2.576408e-01
[15,] 0.69018731 6.196254e-01 3.098127e-01
[16,] 0.74602277 5.079545e-01 2.539772e-01
[17,] 0.69968645 6.006271e-01 3.003135e-01
[18,] 0.71418399 5.716320e-01 2.858160e-01
[19,] 0.68809436 6.238113e-01 3.119056e-01
[20,] 0.79171068 4.165786e-01 2.082893e-01
[21,] 0.81607657 3.678469e-01 1.839234e-01
[22,] 0.82597053 3.480589e-01 1.740295e-01
[23,] 0.84906902 3.018620e-01 1.509310e-01
[24,] 0.90885183 1.822963e-01 9.114817e-02
[25,] 0.91054577 1.789085e-01 8.945423e-02
[26,] 0.90180443 1.963911e-01 9.819557e-02
[27,] 0.88852366 2.229527e-01 1.114763e-01
[28,] 0.92019974 1.596005e-01 7.980026e-02
[29,] 0.93890497 1.221901e-01 6.109503e-02
[30,] 0.91325365 1.734927e-01 8.674635e-02
[31,] 0.89587861 2.082428e-01 1.041214e-01
[32,] 0.86677042 2.664592e-01 1.332296e-01
[33,] 0.85511785 2.897643e-01 1.448822e-01
[34,] 0.97710322 4.579356e-02 2.289678e-02
[35,] 0.99489909 1.020182e-02 5.100911e-03
[36,] 0.99868694 2.626119e-03 1.313059e-03
[37,] 0.99992496 1.500895e-04 7.504473e-05
[38,] 0.99998379 3.241584e-05 1.620792e-05
[39,] 0.99998011 3.978018e-05 1.989009e-05
[40,] 0.99997351 5.298509e-05 2.649255e-05
[41,] 0.99995023 9.953407e-05 4.976703e-05
[42,] 0.99990831 1.833845e-04 9.169224e-05
[43,] 0.99969943 6.011424e-04 3.005712e-04
[44,] 0.99959060 8.187933e-04 4.093967e-04
[45,] 0.99995923 8.153551e-05 4.076776e-05
[46,] 0.99998919 2.161274e-05 1.080637e-05
[47,] 0.99993599 1.280151e-04 6.400754e-05
[48,] 0.99967408 6.518421e-04 3.259210e-04
[49,] 0.99835519 3.289626e-03 1.644813e-03
> postscript(file="/var/www/html/rcomp/tmp/1u5f71291026536.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/2u5f71291026536.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/35eea1291026536.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/45eea1291026536.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/55eea1291026536.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 = 80
Frequency = 1
1 2 3 4 5
-4.801531e+01 -4.315816e+01 -1.844388e+01 -3.930102e+01 -4.015816e+01
6 7 8 9 10
-3.172959e+01 -2.301020e+00 -2.944388e+01 -3.136990e+01 -4.336990e+01
11 12 13 14 15
-7.369898e+00 4.446344e+01 2.799320e+00 -2.334354e+01 -3.629252e+00
16 17 18 19 20
-4.863946e-01 1.865646e+01 -3.914966e+00 6.051361e+01 1.037075e+01
21 22 23 24 25
3.644473e+01 3.444728e+00 -1.555527e+01 -3.172194e+01 9.613946e+00
26 27 28 29 30
1.947109e+01 4.185374e+00 2.532823e+01 -6.528912e+00 3.689966e+01
31 32 33 34 35
1.432823e+01 1.218537e+01 -1.740646e+00 6.259354e+00 -1.374065e+01
36 37 38 39 40
-1.907313e+00 7.428571e+00 9.285714e+00 -1.776357e-14 1.414286e+01
41 42 43 44 45
2.328571e+01 4.871429e+01 2.142857e+00 5.900000e+01 2.707398e+01
46 47 48 49 50
4.207398e+01 3.907398e+01 3.390731e+01 6.724320e+01 5.610034e+01
51 52 53 54 55
4.181463e+01 3.395748e+01 2.410034e+01 -6.471088e+00 -1.804252e+01
56 57 58 59 60
-1.518537e+01 -7.111395e+00 -2.111395e+00 8.888605e+00 -9.278061e+00
61 62 63 64 65
-2.594218e+01 -6.085034e+00 -1.337075e+01 -1.322789e+01 -6.085034e+00
66 67 68 69 70
-2.265646e+01 -2.922789e+01 -1.737075e+01 -2.329677e+01 -6.296769e+00
71 72 73 74 75
-1.129677e+01 -3.546344e+01 -1.312755e+01 -1.227041e+01 -1.055612e+01
76 77 78 79 80
-2.041327e+01 -1.327041e+01 -2.084184e+01 -2.741327e+01 -1.955612e+01
> postscript(file="/var/www/html/rcomp/tmp/6fndu1291026536.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 = 80
Frequency = 1
lag(myerror, k = 1) myerror
0 -4.801531e+01 NA
1 -4.315816e+01 -4.801531e+01
2 -1.844388e+01 -4.315816e+01
3 -3.930102e+01 -1.844388e+01
4 -4.015816e+01 -3.930102e+01
5 -3.172959e+01 -4.015816e+01
6 -2.301020e+00 -3.172959e+01
7 -2.944388e+01 -2.301020e+00
8 -3.136990e+01 -2.944388e+01
9 -4.336990e+01 -3.136990e+01
10 -7.369898e+00 -4.336990e+01
11 4.446344e+01 -7.369898e+00
12 2.799320e+00 4.446344e+01
13 -2.334354e+01 2.799320e+00
14 -3.629252e+00 -2.334354e+01
15 -4.863946e-01 -3.629252e+00
16 1.865646e+01 -4.863946e-01
17 -3.914966e+00 1.865646e+01
18 6.051361e+01 -3.914966e+00
19 1.037075e+01 6.051361e+01
20 3.644473e+01 1.037075e+01
21 3.444728e+00 3.644473e+01
22 -1.555527e+01 3.444728e+00
23 -3.172194e+01 -1.555527e+01
24 9.613946e+00 -3.172194e+01
25 1.947109e+01 9.613946e+00
26 4.185374e+00 1.947109e+01
27 2.532823e+01 4.185374e+00
28 -6.528912e+00 2.532823e+01
29 3.689966e+01 -6.528912e+00
30 1.432823e+01 3.689966e+01
31 1.218537e+01 1.432823e+01
32 -1.740646e+00 1.218537e+01
33 6.259354e+00 -1.740646e+00
34 -1.374065e+01 6.259354e+00
35 -1.907313e+00 -1.374065e+01
36 7.428571e+00 -1.907313e+00
37 9.285714e+00 7.428571e+00
38 -1.776357e-14 9.285714e+00
39 1.414286e+01 -1.776357e-14
40 2.328571e+01 1.414286e+01
41 4.871429e+01 2.328571e+01
42 2.142857e+00 4.871429e+01
43 5.900000e+01 2.142857e+00
44 2.707398e+01 5.900000e+01
45 4.207398e+01 2.707398e+01
46 3.907398e+01 4.207398e+01
47 3.390731e+01 3.907398e+01
48 6.724320e+01 3.390731e+01
49 5.610034e+01 6.724320e+01
50 4.181463e+01 5.610034e+01
51 3.395748e+01 4.181463e+01
52 2.410034e+01 3.395748e+01
53 -6.471088e+00 2.410034e+01
54 -1.804252e+01 -6.471088e+00
55 -1.518537e+01 -1.804252e+01
56 -7.111395e+00 -1.518537e+01
57 -2.111395e+00 -7.111395e+00
58 8.888605e+00 -2.111395e+00
59 -9.278061e+00 8.888605e+00
60 -2.594218e+01 -9.278061e+00
61 -6.085034e+00 -2.594218e+01
62 -1.337075e+01 -6.085034e+00
63 -1.322789e+01 -1.337075e+01
64 -6.085034e+00 -1.322789e+01
65 -2.265646e+01 -6.085034e+00
66 -2.922789e+01 -2.265646e+01
67 -1.737075e+01 -2.922789e+01
68 -2.329677e+01 -1.737075e+01
69 -6.296769e+00 -2.329677e+01
70 -1.129677e+01 -6.296769e+00
71 -3.546344e+01 -1.129677e+01
72 -1.312755e+01 -3.546344e+01
73 -1.227041e+01 -1.312755e+01
74 -1.055612e+01 -1.227041e+01
75 -2.041327e+01 -1.055612e+01
76 -1.327041e+01 -2.041327e+01
77 -2.084184e+01 -1.327041e+01
78 -2.741327e+01 -2.084184e+01
79 -1.955612e+01 -2.741327e+01
80 NA -1.955612e+01
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.315816e+01 -4.801531e+01
[2,] -1.844388e+01 -4.315816e+01
[3,] -3.930102e+01 -1.844388e+01
[4,] -4.015816e+01 -3.930102e+01
[5,] -3.172959e+01 -4.015816e+01
[6,] -2.301020e+00 -3.172959e+01
[7,] -2.944388e+01 -2.301020e+00
[8,] -3.136990e+01 -2.944388e+01
[9,] -4.336990e+01 -3.136990e+01
[10,] -7.369898e+00 -4.336990e+01
[11,] 4.446344e+01 -7.369898e+00
[12,] 2.799320e+00 4.446344e+01
[13,] -2.334354e+01 2.799320e+00
[14,] -3.629252e+00 -2.334354e+01
[15,] -4.863946e-01 -3.629252e+00
[16,] 1.865646e+01 -4.863946e-01
[17,] -3.914966e+00 1.865646e+01
[18,] 6.051361e+01 -3.914966e+00
[19,] 1.037075e+01 6.051361e+01
[20,] 3.644473e+01 1.037075e+01
[21,] 3.444728e+00 3.644473e+01
[22,] -1.555527e+01 3.444728e+00
[23,] -3.172194e+01 -1.555527e+01
[24,] 9.613946e+00 -3.172194e+01
[25,] 1.947109e+01 9.613946e+00
[26,] 4.185374e+00 1.947109e+01
[27,] 2.532823e+01 4.185374e+00
[28,] -6.528912e+00 2.532823e+01
[29,] 3.689966e+01 -6.528912e+00
[30,] 1.432823e+01 3.689966e+01
[31,] 1.218537e+01 1.432823e+01
[32,] -1.740646e+00 1.218537e+01
[33,] 6.259354e+00 -1.740646e+00
[34,] -1.374065e+01 6.259354e+00
[35,] -1.907313e+00 -1.374065e+01
[36,] 7.428571e+00 -1.907313e+00
[37,] 9.285714e+00 7.428571e+00
[38,] -1.776357e-14 9.285714e+00
[39,] 1.414286e+01 -1.776357e-14
[40,] 2.328571e+01 1.414286e+01
[41,] 4.871429e+01 2.328571e+01
[42,] 2.142857e+00 4.871429e+01
[43,] 5.900000e+01 2.142857e+00
[44,] 2.707398e+01 5.900000e+01
[45,] 4.207398e+01 2.707398e+01
[46,] 3.907398e+01 4.207398e+01
[47,] 3.390731e+01 3.907398e+01
[48,] 6.724320e+01 3.390731e+01
[49,] 5.610034e+01 6.724320e+01
[50,] 4.181463e+01 5.610034e+01
[51,] 3.395748e+01 4.181463e+01
[52,] 2.410034e+01 3.395748e+01
[53,] -6.471088e+00 2.410034e+01
[54,] -1.804252e+01 -6.471088e+00
[55,] -1.518537e+01 -1.804252e+01
[56,] -7.111395e+00 -1.518537e+01
[57,] -2.111395e+00 -7.111395e+00
[58,] 8.888605e+00 -2.111395e+00
[59,] -9.278061e+00 8.888605e+00
[60,] -2.594218e+01 -9.278061e+00
[61,] -6.085034e+00 -2.594218e+01
[62,] -1.337075e+01 -6.085034e+00
[63,] -1.322789e+01 -1.337075e+01
[64,] -6.085034e+00 -1.322789e+01
[65,] -2.265646e+01 -6.085034e+00
[66,] -2.922789e+01 -2.265646e+01
[67,] -1.737075e+01 -2.922789e+01
[68,] -2.329677e+01 -1.737075e+01
[69,] -6.296769e+00 -2.329677e+01
[70,] -1.129677e+01 -6.296769e+00
[71,] -3.546344e+01 -1.129677e+01
[72,] -1.312755e+01 -3.546344e+01
[73,] -1.227041e+01 -1.312755e+01
[74,] -1.055612e+01 -1.227041e+01
[75,] -2.041327e+01 -1.055612e+01
[76,] -1.327041e+01 -2.041327e+01
[77,] -2.084184e+01 -1.327041e+01
[78,] -2.741327e+01 -2.084184e+01
[79,] -1.955612e+01 -2.741327e+01
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.315816e+01 -4.801531e+01
2 -1.844388e+01 -4.315816e+01
3 -3.930102e+01 -1.844388e+01
4 -4.015816e+01 -3.930102e+01
5 -3.172959e+01 -4.015816e+01
6 -2.301020e+00 -3.172959e+01
7 -2.944388e+01 -2.301020e+00
8 -3.136990e+01 -2.944388e+01
9 -4.336990e+01 -3.136990e+01
10 -7.369898e+00 -4.336990e+01
11 4.446344e+01 -7.369898e+00
12 2.799320e+00 4.446344e+01
13 -2.334354e+01 2.799320e+00
14 -3.629252e+00 -2.334354e+01
15 -4.863946e-01 -3.629252e+00
16 1.865646e+01 -4.863946e-01
17 -3.914966e+00 1.865646e+01
18 6.051361e+01 -3.914966e+00
19 1.037075e+01 6.051361e+01
20 3.644473e+01 1.037075e+01
21 3.444728e+00 3.644473e+01
22 -1.555527e+01 3.444728e+00
23 -3.172194e+01 -1.555527e+01
24 9.613946e+00 -3.172194e+01
25 1.947109e+01 9.613946e+00
26 4.185374e+00 1.947109e+01
27 2.532823e+01 4.185374e+00
28 -6.528912e+00 2.532823e+01
29 3.689966e+01 -6.528912e+00
30 1.432823e+01 3.689966e+01
31 1.218537e+01 1.432823e+01
32 -1.740646e+00 1.218537e+01
33 6.259354e+00 -1.740646e+00
34 -1.374065e+01 6.259354e+00
35 -1.907313e+00 -1.374065e+01
36 7.428571e+00 -1.907313e+00
37 9.285714e+00 7.428571e+00
38 -1.776357e-14 9.285714e+00
39 1.414286e+01 -1.776357e-14
40 2.328571e+01 1.414286e+01
41 4.871429e+01 2.328571e+01
42 2.142857e+00 4.871429e+01
43 5.900000e+01 2.142857e+00
44 2.707398e+01 5.900000e+01
45 4.207398e+01 2.707398e+01
46 3.907398e+01 4.207398e+01
47 3.390731e+01 3.907398e+01
48 6.724320e+01 3.390731e+01
49 5.610034e+01 6.724320e+01
50 4.181463e+01 5.610034e+01
51 3.395748e+01 4.181463e+01
52 2.410034e+01 3.395748e+01
53 -6.471088e+00 2.410034e+01
54 -1.804252e+01 -6.471088e+00
55 -1.518537e+01 -1.804252e+01
56 -7.111395e+00 -1.518537e+01
57 -2.111395e+00 -7.111395e+00
58 8.888605e+00 -2.111395e+00
59 -9.278061e+00 8.888605e+00
60 -2.594218e+01 -9.278061e+00
61 -6.085034e+00 -2.594218e+01
62 -1.337075e+01 -6.085034e+00
63 -1.322789e+01 -1.337075e+01
64 -6.085034e+00 -1.322789e+01
65 -2.265646e+01 -6.085034e+00
66 -2.922789e+01 -2.265646e+01
67 -1.737075e+01 -2.922789e+01
68 -2.329677e+01 -1.737075e+01
69 -6.296769e+00 -2.329677e+01
70 -1.129677e+01 -6.296769e+00
71 -3.546344e+01 -1.129677e+01
72 -1.312755e+01 -3.546344e+01
73 -1.227041e+01 -1.312755e+01
74 -1.055612e+01 -1.227041e+01
75 -2.041327e+01 -1.055612e+01
76 -1.327041e+01 -2.041327e+01
77 -2.084184e+01 -1.327041e+01
78 -2.741327e+01 -2.084184e+01
79 -1.955612e+01 -2.741327e+01
> 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/78ecx1291026536.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/88ecx1291026536.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/98ecx1291026536.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/101oci1291026536.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/11m6s61291026536.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/127pru1291026536.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/13ly6l1291026536.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/147z5r1291026536.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/15ai3x1291026536.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/16w0kk1291026536.tab")
+ }
>
> try(system("convert tmp/1u5f71291026536.ps tmp/1u5f71291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/2u5f71291026536.ps tmp/2u5f71291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/35eea1291026536.ps tmp/35eea1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/45eea1291026536.ps tmp/45eea1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/55eea1291026536.ps tmp/55eea1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/6fndu1291026536.ps tmp/6fndu1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/78ecx1291026536.ps tmp/78ecx1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/88ecx1291026536.ps tmp/88ecx1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/98ecx1291026536.ps tmp/98ecx1291026536.png",intern=TRUE))
character(0)
> try(system("convert tmp/101oci1291026536.ps tmp/101oci1291026536.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.687 1.643 6.938