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(140.4
+ ,139.5
+ ,138.1
+ ,136.7
+ ,130
+ ,0
+ ,144.6
+ ,140.4
+ ,139.5
+ ,138.1
+ ,136.7
+ ,0
+ ,151.4
+ ,144.6
+ ,140.4
+ ,139.5
+ ,138.1
+ ,0
+ ,147.9
+ ,151.4
+ ,144.6
+ ,140.4
+ ,139.5
+ ,0
+ ,141.5
+ ,147.9
+ ,151.4
+ ,144.6
+ ,140.4
+ ,0
+ ,143.8
+ ,141.5
+ ,147.9
+ ,151.4
+ ,144.6
+ ,0
+ ,143.6
+ ,143.8
+ ,141.5
+ ,147.9
+ ,151.4
+ ,0
+ ,150.5
+ ,143.6
+ ,143.8
+ ,141.5
+ ,147.9
+ ,0
+ ,150.1
+ ,150.5
+ ,143.6
+ ,143.8
+ ,141.5
+ ,0
+ ,154.9
+ ,150.1
+ ,150.5
+ ,143.6
+ ,143.8
+ ,0
+ ,162.1
+ ,154.9
+ ,150.1
+ ,150.5
+ ,143.6
+ ,0
+ ,176.7
+ ,162.1
+ ,154.9
+ ,150.1
+ ,150.5
+ ,0
+ ,186.6
+ ,176.7
+ ,162.1
+ ,154.9
+ ,150.1
+ ,0
+ ,194.8
+ ,186.6
+ ,176.7
+ ,162.1
+ ,154.9
+ ,0
+ ,196.3
+ ,194.8
+ ,186.6
+ ,176.7
+ ,162.1
+ ,0
+ ,228.8
+ ,196.3
+ ,194.8
+ ,186.6
+ ,176.7
+ ,0
+ ,267.2
+ ,228.8
+ ,196.3
+ ,194.8
+ ,186.6
+ ,0
+ ,237.2
+ ,267.2
+ ,228.8
+ ,196.3
+ ,194.8
+ ,0
+ ,254.7
+ ,237.2
+ ,267.2
+ ,228.8
+ ,196.3
+ ,0
+ ,258.2
+ ,254.7
+ ,237.2
+ ,267.2
+ ,228.8
+ ,0
+ ,257.9
+ ,258.2
+ ,254.7
+ ,237.2
+ ,267.2
+ ,0
+ ,269.6
+ ,257.9
+ ,258.2
+ ,254.7
+ ,237.2
+ ,0
+ ,266.9
+ ,269.6
+ ,257.9
+ ,258.2
+ ,254.7
+ ,0
+ ,269.6
+ ,266.9
+ ,269.6
+ ,257.9
+ ,258.2
+ ,0
+ ,253.9
+ ,269.6
+ ,266.9
+ ,269.6
+ ,257.9
+ ,0
+ ,258.6
+ ,253.9
+ ,269.6
+ ,266.9
+ ,269.6
+ ,0
+ ,274.2
+ ,258.6
+ ,253.9
+ ,269.6
+ ,266.9
+ ,0
+ ,301.5
+ ,274.2
+ ,258.6
+ ,253.9
+ ,269.6
+ ,0
+ ,304.5
+ ,301.5
+ ,274.2
+ ,258.6
+ ,253.9
+ ,0
+ ,285.1
+ ,304.5
+ ,301.5
+ ,274.2
+ ,258.6
+ ,0
+ ,287.7
+ ,285.1
+ ,304.5
+ ,301.5
+ ,274.2
+ ,0
+ ,265.5
+ ,287.7
+ ,285.1
+ ,304.5
+ ,301.5
+ ,0
+ ,264.1
+ ,265.5
+ ,287.7
+ ,285.1
+ ,304.5
+ ,0
+ ,276.1
+ ,264.1
+ ,265.5
+ ,287.7
+ ,285.1
+ ,0
+ ,258.9
+ ,276.1
+ ,264.1
+ ,265.5
+ ,287.7
+ ,0
+ ,239.1
+ ,258.9
+ ,276.1
+ ,264.1
+ ,265.5
+ ,0
+ ,250.1
+ ,239.1
+ ,258.9
+ ,276.1
+ ,264.1
+ ,1
+ ,276.8
+ ,250.1
+ ,239.1
+ ,258.9
+ ,276.1
+ ,1
+ ,297.6
+ ,276.8
+ ,250.1
+ ,239.1
+ ,258.9
+ ,1
+ ,295.4
+ ,297.6
+ ,276.8
+ ,250.1
+ ,239.1
+ ,1
+ ,283
+ ,295.4
+ ,297.6
+ ,276.8
+ ,250.1
+ ,1
+ ,275.8
+ ,283
+ ,295.4
+ ,297.6
+ ,276.8
+ ,1
+ ,279.7
+ ,275.8
+ ,283
+ ,295.4
+ ,297.6
+ ,1
+ ,254.6
+ ,279.7
+ ,275.8
+ ,283
+ ,295.4
+ ,1
+ ,234.6
+ ,254.6
+ ,279.7
+ ,275.8
+ ,283
+ ,1
+ ,176.9
+ ,234.6
+ ,254.6
+ ,279.7
+ ,275.8
+ ,1
+ ,148.1
+ ,176.9
+ ,234.6
+ ,254.6
+ ,279.7
+ ,1
+ ,122.7
+ ,148.1
+ ,176.9
+ ,234.6
+ ,254.6
+ ,1
+ ,124.9
+ ,122.7
+ ,148.1
+ ,176.9
+ ,234.6
+ ,1
+ ,121.6
+ ,124.9
+ ,122.7
+ ,148.1
+ ,176.9
+ ,1
+ ,128.4
+ ,121.6
+ ,124.9
+ ,122.7
+ ,148.1
+ ,1
+ ,144.5
+ ,128.4
+ ,121.6
+ ,124.9
+ ,122.7
+ ,1
+ ,151.8
+ ,144.5
+ ,128.4
+ ,121.6
+ ,124.9
+ ,1
+ ,167.1
+ ,151.8
+ ,144.5
+ ,128.4
+ ,121.6
+ ,1
+ ,173.8
+ ,167.1
+ ,151.8
+ ,144.5
+ ,128.4
+ ,1
+ ,203.7
+ ,173.8
+ ,167.1
+ ,151.8
+ ,144.5
+ ,1
+ ,199.8
+ ,203.7
+ ,173.8
+ ,167.1
+ ,151.8
+ ,1)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('Y(t)'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)'
+ ,'X(t)')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('Y(t)','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)','X(t)'),1:57))
> 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(t) Y(t-1) Y(t-2) Y(t-3) Y(t-4) X(t) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 140.4 139.5 138.1 136.7 130.0 0 1 0 0 0 0 0 0 0 0 0 0 1
2 144.6 140.4 139.5 138.1 136.7 0 0 1 0 0 0 0 0 0 0 0 0 2
3 151.4 144.6 140.4 139.5 138.1 0 0 0 1 0 0 0 0 0 0 0 0 3
4 147.9 151.4 144.6 140.4 139.5 0 0 0 0 1 0 0 0 0 0 0 0 4
5 141.5 147.9 151.4 144.6 140.4 0 0 0 0 0 1 0 0 0 0 0 0 5
6 143.8 141.5 147.9 151.4 144.6 0 0 0 0 0 0 1 0 0 0 0 0 6
7 143.6 143.8 141.5 147.9 151.4 0 0 0 0 0 0 0 1 0 0 0 0 7
8 150.5 143.6 143.8 141.5 147.9 0 0 0 0 0 0 0 0 1 0 0 0 8
9 150.1 150.5 143.6 143.8 141.5 0 0 0 0 0 0 0 0 0 1 0 0 9
10 154.9 150.1 150.5 143.6 143.8 0 0 0 0 0 0 0 0 0 0 1 0 10
11 162.1 154.9 150.1 150.5 143.6 0 0 0 0 0 0 0 0 0 0 0 1 11
12 176.7 162.1 154.9 150.1 150.5 0 0 0 0 0 0 0 0 0 0 0 0 12
13 186.6 176.7 162.1 154.9 150.1 0 1 0 0 0 0 0 0 0 0 0 0 13
14 194.8 186.6 176.7 162.1 154.9 0 0 1 0 0 0 0 0 0 0 0 0 14
15 196.3 194.8 186.6 176.7 162.1 0 0 0 1 0 0 0 0 0 0 0 0 15
16 228.8 196.3 194.8 186.6 176.7 0 0 0 0 1 0 0 0 0 0 0 0 16
17 267.2 228.8 196.3 194.8 186.6 0 0 0 0 0 1 0 0 0 0 0 0 17
18 237.2 267.2 228.8 196.3 194.8 0 0 0 0 0 0 1 0 0 0 0 0 18
19 254.7 237.2 267.2 228.8 196.3 0 0 0 0 0 0 0 1 0 0 0 0 19
20 258.2 254.7 237.2 267.2 228.8 0 0 0 0 0 0 0 0 1 0 0 0 20
21 257.9 258.2 254.7 237.2 267.2 0 0 0 0 0 0 0 0 0 1 0 0 21
22 269.6 257.9 258.2 254.7 237.2 0 0 0 0 0 0 0 0 0 0 1 0 22
23 266.9 269.6 257.9 258.2 254.7 0 0 0 0 0 0 0 0 0 0 0 1 23
24 269.6 266.9 269.6 257.9 258.2 0 0 0 0 0 0 0 0 0 0 0 0 24
25 253.9 269.6 266.9 269.6 257.9 0 1 0 0 0 0 0 0 0 0 0 0 25
26 258.6 253.9 269.6 266.9 269.6 0 0 1 0 0 0 0 0 0 0 0 0 26
27 274.2 258.6 253.9 269.6 266.9 0 0 0 1 0 0 0 0 0 0 0 0 27
28 301.5 274.2 258.6 253.9 269.6 0 0 0 0 1 0 0 0 0 0 0 0 28
29 304.5 301.5 274.2 258.6 253.9 0 0 0 0 0 1 0 0 0 0 0 0 29
30 285.1 304.5 301.5 274.2 258.6 0 0 0 0 0 0 1 0 0 0 0 0 30
31 287.7 285.1 304.5 301.5 274.2 0 0 0 0 0 0 0 1 0 0 0 0 31
32 265.5 287.7 285.1 304.5 301.5 0 0 0 0 0 0 0 0 1 0 0 0 32
33 264.1 265.5 287.7 285.1 304.5 0 0 0 0 0 0 0 0 0 1 0 0 33
34 276.1 264.1 265.5 287.7 285.1 0 0 0 0 0 0 0 0 0 0 1 0 34
35 258.9 276.1 264.1 265.5 287.7 0 0 0 0 0 0 0 0 0 0 0 1 35
36 239.1 258.9 276.1 264.1 265.5 0 0 0 0 0 0 0 0 0 0 0 0 36
37 250.1 239.1 258.9 276.1 264.1 1 1 0 0 0 0 0 0 0 0 0 0 37
38 276.8 250.1 239.1 258.9 276.1 1 0 1 0 0 0 0 0 0 0 0 0 38
39 297.6 276.8 250.1 239.1 258.9 1 0 0 1 0 0 0 0 0 0 0 0 39
40 295.4 297.6 276.8 250.1 239.1 1 0 0 0 1 0 0 0 0 0 0 0 40
41 283.0 295.4 297.6 276.8 250.1 1 0 0 0 0 1 0 0 0 0 0 0 41
42 275.8 283.0 295.4 297.6 276.8 1 0 0 0 0 0 1 0 0 0 0 0 42
43 279.7 275.8 283.0 295.4 297.6 1 0 0 0 0 0 0 1 0 0 0 0 43
44 254.6 279.7 275.8 283.0 295.4 1 0 0 0 0 0 0 0 1 0 0 0 44
45 234.6 254.6 279.7 275.8 283.0 1 0 0 0 0 0 0 0 0 1 0 0 45
46 176.9 234.6 254.6 279.7 275.8 1 0 0 0 0 0 0 0 0 0 1 0 46
47 148.1 176.9 234.6 254.6 279.7 1 0 0 0 0 0 0 0 0 0 0 1 47
48 122.7 148.1 176.9 234.6 254.6 1 0 0 0 0 0 0 0 0 0 0 0 48
49 124.9 122.7 148.1 176.9 234.6 1 1 0 0 0 0 0 0 0 0 0 0 49
50 121.6 124.9 122.7 148.1 176.9 1 0 1 0 0 0 0 0 0 0 0 0 50
51 128.4 121.6 124.9 122.7 148.1 1 0 0 1 0 0 0 0 0 0 0 0 51
52 144.5 128.4 121.6 124.9 122.7 1 0 0 0 1 0 0 0 0 0 0 0 52
53 151.8 144.5 128.4 121.6 124.9 1 0 0 0 0 1 0 0 0 0 0 0 53
54 167.1 151.8 144.5 128.4 121.6 1 0 0 0 0 0 1 0 0 0 0 0 54
55 173.8 167.1 151.8 144.5 128.4 1 0 0 0 0 0 0 1 0 0 0 0 55
56 203.7 173.8 167.1 151.8 144.5 1 0 0 0 0 0 0 0 1 0 0 0 56
57 199.8 203.7 173.8 167.1 151.8 1 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)` `X(t)`
7.29386 1.16543 -0.12911 -0.03690 -0.07007 -9.64429
M1 M2 M3 M4 M5 M6
8.60005 13.25240 13.35177 15.90608 7.05103 -5.17540
M7 M8 M9 M10 M11 t
11.80924 3.27991 0.41276 -0.38428 -3.10604 0.21752
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-41.263 -8.817 -1.101 9.989 28.115
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.29386 12.28741 0.594 0.556
`Y(t-1)` 1.16543 0.16200 7.194 1.16e-08 ***
`Y(t-2)` -0.12911 0.25675 -0.503 0.618
`Y(t-3)` -0.03690 0.26534 -0.139 0.890
`Y(t-4)` -0.07007 0.17028 -0.411 0.683
`X(t)` -9.64429 9.79921 -0.984 0.331
M1 8.60005 11.51841 0.747 0.460
M2 13.25240 11.63096 1.139 0.261
M3 13.35177 11.83512 1.128 0.266
M4 15.90608 11.99981 1.326 0.193
M5 7.05103 12.24353 0.576 0.568
M6 -5.17540 12.13070 -0.427 0.672
M7 11.80924 11.82689 0.999 0.324
M8 3.27991 11.71275 0.280 0.781
M9 0.41276 11.57573 0.036 0.972
M10 -0.38428 12.00040 -0.032 0.975
M11 -3.10604 11.84919 -0.262 0.795
t 0.21752 0.29144 0.746 0.460
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 16.68 on 39 degrees of freedom
Multiple R-squared: 0.9454, Adjusted R-squared: 0.9216
F-statistic: 39.7 on 17 and 39 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.76095346 0.4780931 0.2390465
[2,] 0.60924244 0.7815151 0.3907576
[3,] 0.47293819 0.9458764 0.5270618
[4,] 0.36223659 0.7244732 0.6377634
[5,] 0.49420151 0.9884030 0.5057985
[6,] 0.37558513 0.7511703 0.6244149
[7,] 0.26441764 0.5288353 0.7355824
[8,] 0.20015577 0.4003115 0.7998442
[9,] 0.14429030 0.2885806 0.8557097
[10,] 0.15529458 0.3105892 0.8447054
[11,] 0.10257213 0.2051443 0.8974279
[12,] 0.18049331 0.3609866 0.8195067
[13,] 0.12413493 0.2482699 0.8758651
[14,] 0.20110100 0.4022020 0.7988990
[15,] 0.12869938 0.2573988 0.8713006
[16,] 0.08949272 0.1789854 0.9105073
> postscript(file="/var/www/html/rcomp/tmp/11dj41259396605.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/2022o1259396605.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/3qvzn1259396605.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/4qq6w1259396605.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/56q9f1259396605.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 = 57
Frequency = 1
1 2 3 4 5 6
-6.30531289 -7.32220949 -5.46793143 -18.99108363 -11.57855411 10.28238284
7 8 9 10 11 12
-10.27928160 4.98118724 -1.19999476 5.69034880 9.98948626 13.96329578
13 14 15 16 17 18
-0.89080006 -6.61135427 -12.66331846 17.76369750 28.11475986 -29.80264744
19 20 21 22 23 24
11.72024273 2.95774914 5.07141137 16.69622593 4.18153428 8.44941276
25 26 27 28 29 30
-19.15271591 0.04335567 7.73234579 14.29655784 -4.79449269 -11.25214176
31 32 33 34 35 36
-0.75732247 -18.15693061 8.79522128 18.87670072 -10.62192440 -13.75789983
37 38 39 40 41 42
19.26821324 25.92833936 14.77908395 -11.96770609 -8.72475980 12.88964321
43 44 45 46 47 48
7.75373853 -15.12092342 -3.85002808 -41.26327545 -3.54909614 -8.65480870
49 50 51 52 53 54
7.08061562 -12.03813128 -4.38017986 -1.10146562 -3.01695326 17.88276315
55 56 57
-8.43737720 25.33891764 -8.81660981
> postscript(file="/var/www/html/rcomp/tmp/6y0n01259396605.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -6.30531289 NA
1 -7.32220949 -6.30531289
2 -5.46793143 -7.32220949
3 -18.99108363 -5.46793143
4 -11.57855411 -18.99108363
5 10.28238284 -11.57855411
6 -10.27928160 10.28238284
7 4.98118724 -10.27928160
8 -1.19999476 4.98118724
9 5.69034880 -1.19999476
10 9.98948626 5.69034880
11 13.96329578 9.98948626
12 -0.89080006 13.96329578
13 -6.61135427 -0.89080006
14 -12.66331846 -6.61135427
15 17.76369750 -12.66331846
16 28.11475986 17.76369750
17 -29.80264744 28.11475986
18 11.72024273 -29.80264744
19 2.95774914 11.72024273
20 5.07141137 2.95774914
21 16.69622593 5.07141137
22 4.18153428 16.69622593
23 8.44941276 4.18153428
24 -19.15271591 8.44941276
25 0.04335567 -19.15271591
26 7.73234579 0.04335567
27 14.29655784 7.73234579
28 -4.79449269 14.29655784
29 -11.25214176 -4.79449269
30 -0.75732247 -11.25214176
31 -18.15693061 -0.75732247
32 8.79522128 -18.15693061
33 18.87670072 8.79522128
34 -10.62192440 18.87670072
35 -13.75789983 -10.62192440
36 19.26821324 -13.75789983
37 25.92833936 19.26821324
38 14.77908395 25.92833936
39 -11.96770609 14.77908395
40 -8.72475980 -11.96770609
41 12.88964321 -8.72475980
42 7.75373853 12.88964321
43 -15.12092342 7.75373853
44 -3.85002808 -15.12092342
45 -41.26327545 -3.85002808
46 -3.54909614 -41.26327545
47 -8.65480870 -3.54909614
48 7.08061562 -8.65480870
49 -12.03813128 7.08061562
50 -4.38017986 -12.03813128
51 -1.10146562 -4.38017986
52 -3.01695326 -1.10146562
53 17.88276315 -3.01695326
54 -8.43737720 17.88276315
55 25.33891764 -8.43737720
56 -8.81660981 25.33891764
57 NA -8.81660981
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -7.32220949 -6.30531289
[2,] -5.46793143 -7.32220949
[3,] -18.99108363 -5.46793143
[4,] -11.57855411 -18.99108363
[5,] 10.28238284 -11.57855411
[6,] -10.27928160 10.28238284
[7,] 4.98118724 -10.27928160
[8,] -1.19999476 4.98118724
[9,] 5.69034880 -1.19999476
[10,] 9.98948626 5.69034880
[11,] 13.96329578 9.98948626
[12,] -0.89080006 13.96329578
[13,] -6.61135427 -0.89080006
[14,] -12.66331846 -6.61135427
[15,] 17.76369750 -12.66331846
[16,] 28.11475986 17.76369750
[17,] -29.80264744 28.11475986
[18,] 11.72024273 -29.80264744
[19,] 2.95774914 11.72024273
[20,] 5.07141137 2.95774914
[21,] 16.69622593 5.07141137
[22,] 4.18153428 16.69622593
[23,] 8.44941276 4.18153428
[24,] -19.15271591 8.44941276
[25,] 0.04335567 -19.15271591
[26,] 7.73234579 0.04335567
[27,] 14.29655784 7.73234579
[28,] -4.79449269 14.29655784
[29,] -11.25214176 -4.79449269
[30,] -0.75732247 -11.25214176
[31,] -18.15693061 -0.75732247
[32,] 8.79522128 -18.15693061
[33,] 18.87670072 8.79522128
[34,] -10.62192440 18.87670072
[35,] -13.75789983 -10.62192440
[36,] 19.26821324 -13.75789983
[37,] 25.92833936 19.26821324
[38,] 14.77908395 25.92833936
[39,] -11.96770609 14.77908395
[40,] -8.72475980 -11.96770609
[41,] 12.88964321 -8.72475980
[42,] 7.75373853 12.88964321
[43,] -15.12092342 7.75373853
[44,] -3.85002808 -15.12092342
[45,] -41.26327545 -3.85002808
[46,] -3.54909614 -41.26327545
[47,] -8.65480870 -3.54909614
[48,] 7.08061562 -8.65480870
[49,] -12.03813128 7.08061562
[50,] -4.38017986 -12.03813128
[51,] -1.10146562 -4.38017986
[52,] -3.01695326 -1.10146562
[53,] 17.88276315 -3.01695326
[54,] -8.43737720 17.88276315
[55,] 25.33891764 -8.43737720
[56,] -8.81660981 25.33891764
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -7.32220949 -6.30531289
2 -5.46793143 -7.32220949
3 -18.99108363 -5.46793143
4 -11.57855411 -18.99108363
5 10.28238284 -11.57855411
6 -10.27928160 10.28238284
7 4.98118724 -10.27928160
8 -1.19999476 4.98118724
9 5.69034880 -1.19999476
10 9.98948626 5.69034880
11 13.96329578 9.98948626
12 -0.89080006 13.96329578
13 -6.61135427 -0.89080006
14 -12.66331846 -6.61135427
15 17.76369750 -12.66331846
16 28.11475986 17.76369750
17 -29.80264744 28.11475986
18 11.72024273 -29.80264744
19 2.95774914 11.72024273
20 5.07141137 2.95774914
21 16.69622593 5.07141137
22 4.18153428 16.69622593
23 8.44941276 4.18153428
24 -19.15271591 8.44941276
25 0.04335567 -19.15271591
26 7.73234579 0.04335567
27 14.29655784 7.73234579
28 -4.79449269 14.29655784
29 -11.25214176 -4.79449269
30 -0.75732247 -11.25214176
31 -18.15693061 -0.75732247
32 8.79522128 -18.15693061
33 18.87670072 8.79522128
34 -10.62192440 18.87670072
35 -13.75789983 -10.62192440
36 19.26821324 -13.75789983
37 25.92833936 19.26821324
38 14.77908395 25.92833936
39 -11.96770609 14.77908395
40 -8.72475980 -11.96770609
41 12.88964321 -8.72475980
42 7.75373853 12.88964321
43 -15.12092342 7.75373853
44 -3.85002808 -15.12092342
45 -41.26327545 -3.85002808
46 -3.54909614 -41.26327545
47 -8.65480870 -3.54909614
48 7.08061562 -8.65480870
49 -12.03813128 7.08061562
50 -4.38017986 -12.03813128
51 -1.10146562 -4.38017986
52 -3.01695326 -1.10146562
53 17.88276315 -3.01695326
54 -8.43737720 17.88276315
55 25.33891764 -8.43737720
56 -8.81660981 25.33891764
> 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/718je1259396605.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/8yepd1259396605.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/9ednu1259396605.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/1045pb1259396605.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/11sveg1259396605.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/12l15s1259396605.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/13kqzg1259396605.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/14fuqc1259396605.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/156fwz1259396605.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/16wsf61259396605.tab")
+ }
>
> system("convert tmp/11dj41259396605.ps tmp/11dj41259396605.png")
> system("convert tmp/2022o1259396605.ps tmp/2022o1259396605.png")
> system("convert tmp/3qvzn1259396605.ps tmp/3qvzn1259396605.png")
> system("convert tmp/4qq6w1259396605.ps tmp/4qq6w1259396605.png")
> system("convert tmp/56q9f1259396605.ps tmp/56q9f1259396605.png")
> system("convert tmp/6y0n01259396605.ps tmp/6y0n01259396605.png")
> system("convert tmp/718je1259396605.ps tmp/718je1259396605.png")
> system("convert tmp/8yepd1259396605.ps tmp/8yepd1259396605.png")
> system("convert tmp/9ednu1259396605.ps tmp/9ednu1259396605.png")
> system("convert tmp/1045pb1259396605.ps tmp/1045pb1259396605.png")
>
>
> proc.time()
user system elapsed
2.364 1.589 9.936