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(98.2
+ ,137.7
+ ,98.54
+ ,98.71
+ ,96.92
+ ,148.3
+ ,98.2
+ ,98.54
+ ,99.06
+ ,152.2
+ ,96.92
+ ,98.2
+ ,99.65
+ ,169.4
+ ,99.06
+ ,96.92
+ ,99.82
+ ,168.6
+ ,99.65
+ ,99.06
+ ,99.99
+ ,161.1
+ ,99.82
+ ,99.65
+ ,100.33
+ ,174.1
+ ,99.99
+ ,99.82
+ ,99.31
+ ,179
+ ,100.33
+ ,99.99
+ ,101.1
+ ,190.6
+ ,99.31
+ ,100.33
+ ,101.1
+ ,190
+ ,101.1
+ ,99.31
+ ,100.93
+ ,181.6
+ ,101.1
+ ,101.1
+ ,100.85
+ ,174.8
+ ,100.93
+ ,101.1
+ ,100.93
+ ,180.5
+ ,100.85
+ ,100.93
+ ,99.6
+ ,196.8
+ ,100.93
+ ,100.85
+ ,101.88
+ ,193.8
+ ,99.6
+ ,100.93
+ ,101.81
+ ,197
+ ,101.88
+ ,99.6
+ ,102.38
+ ,216.3
+ ,101.81
+ ,101.88
+ ,102.74
+ ,221.4
+ ,102.38
+ ,101.81
+ ,102.82
+ ,217.9
+ ,102.74
+ ,102.38
+ ,101.72
+ ,229.7
+ ,102.82
+ ,102.74
+ ,103.47
+ ,227.4
+ ,101.72
+ ,102.82
+ ,102.98
+ ,204.2
+ ,103.47
+ ,101.72
+ ,102.68
+ ,196.6
+ ,102.98
+ ,103.47
+ ,102.9
+ ,198.8
+ ,102.68
+ ,102.98
+ ,103.03
+ ,207.5
+ ,102.9
+ ,102.68
+ ,101.29
+ ,190.7
+ ,103.03
+ ,102.9
+ ,103.69
+ ,201.6
+ ,101.29
+ ,103.03
+ ,103.68
+ ,210.5
+ ,103.69
+ ,101.29
+ ,104.2
+ ,223.5
+ ,103.68
+ ,103.69
+ ,104.08
+ ,223.8
+ ,104.2
+ ,103.68
+ ,104.16
+ ,231.2
+ ,104.08
+ ,104.2
+ ,103.05
+ ,244
+ ,104.16
+ ,104.08
+ ,104.66
+ ,234.7
+ ,103.05
+ ,104.16
+ ,104.46
+ ,250.2
+ ,104.66
+ ,103.05
+ ,104.95
+ ,265.7
+ ,104.46
+ ,104.66
+ ,105.85
+ ,287.6
+ ,104.95
+ ,104.46
+ ,106.23
+ ,283.3
+ ,105.85
+ ,104.95
+ ,104.86
+ ,295.4
+ ,106.23
+ ,105.85
+ ,107.44
+ ,312.3
+ ,104.86
+ ,106.23
+ ,108.23
+ ,333.8
+ ,107.44
+ ,104.86
+ ,108.45
+ ,347.7
+ ,108.23
+ ,107.44
+ ,109.39
+ ,383.2
+ ,108.45
+ ,108.23
+ ,110.15
+ ,407.1
+ ,109.39
+ ,108.45
+ ,109.13
+ ,413.6
+ ,110.15
+ ,109.39
+ ,110.28
+ ,362.7
+ ,109.13
+ ,110.15
+ ,110.17
+ ,321.9
+ ,110.28
+ ,109.13
+ ,109.99
+ ,239.4
+ ,110.17
+ ,110.28
+ ,109.26
+ ,191
+ ,109.99
+ ,110.17
+ ,109.11
+ ,159.7
+ ,109.26
+ ,109.99
+ ,107.06
+ ,163.4
+ ,109.11
+ ,109.26
+ ,109.53
+ ,157.6
+ ,107.06
+ ,109.11
+ ,108.92
+ ,166.2
+ ,109.53
+ ,107.06
+ ,109.24
+ ,176.7
+ ,108.92
+ ,109.53
+ ,109.12
+ ,198.3
+ ,109.24
+ ,108.92
+ ,109
+ ,226.2
+ ,109.12
+ ,109.24
+ ,107.23
+ ,216.2
+ ,109
+ ,109.12
+ ,109.49
+ ,235.9
+ ,107.23
+ ,109
+ ,109.04
+ ,226.9
+ ,109.49
+ ,107.23)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('Y','X','Y1','Y2'),1:58))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 98.20 137.7 98.54 98.71 1 0 0 0 0 0 0 0 0 0 0 1
2 96.92 148.3 98.20 98.54 0 1 0 0 0 0 0 0 0 0 0 2
3 99.06 152.2 96.92 98.20 0 0 1 0 0 0 0 0 0 0 0 3
4 99.65 169.4 99.06 96.92 0 0 0 1 0 0 0 0 0 0 0 4
5 99.82 168.6 99.65 99.06 0 0 0 0 1 0 0 0 0 0 0 5
6 99.99 161.1 99.82 99.65 0 0 0 0 0 1 0 0 0 0 0 6
7 100.33 174.1 99.99 99.82 0 0 0 0 0 0 1 0 0 0 0 7
8 99.31 179.0 100.33 99.99 0 0 0 0 0 0 0 1 0 0 0 8
9 101.10 190.6 99.31 100.33 0 0 0 0 0 0 0 0 1 0 0 9
10 101.10 190.0 101.10 99.31 0 0 0 0 0 0 0 0 0 1 0 10
11 100.93 181.6 101.10 101.10 0 0 0 0 0 0 0 0 0 0 1 11
12 100.85 174.8 100.93 101.10 0 0 0 0 0 0 0 0 0 0 0 12
13 100.93 180.5 100.85 100.93 1 0 0 0 0 0 0 0 0 0 0 13
14 99.60 196.8 100.93 100.85 0 1 0 0 0 0 0 0 0 0 0 14
15 101.88 193.8 99.60 100.93 0 0 1 0 0 0 0 0 0 0 0 15
16 101.81 197.0 101.88 99.60 0 0 0 1 0 0 0 0 0 0 0 16
17 102.38 216.3 101.81 101.88 0 0 0 0 1 0 0 0 0 0 0 17
18 102.74 221.4 102.38 101.81 0 0 0 0 0 1 0 0 0 0 0 18
19 102.82 217.9 102.74 102.38 0 0 0 0 0 0 1 0 0 0 0 19
20 101.72 229.7 102.82 102.74 0 0 0 0 0 0 0 1 0 0 0 20
21 103.47 227.4 101.72 102.82 0 0 0 0 0 0 0 0 1 0 0 21
22 102.98 204.2 103.47 101.72 0 0 0 0 0 0 0 0 0 1 0 22
23 102.68 196.6 102.98 103.47 0 0 0 0 0 0 0 0 0 0 1 23
24 102.90 198.8 102.68 102.98 0 0 0 0 0 0 0 0 0 0 0 24
25 103.03 207.5 102.90 102.68 1 0 0 0 0 0 0 0 0 0 0 25
26 101.29 190.7 103.03 102.90 0 1 0 0 0 0 0 0 0 0 0 26
27 103.69 201.6 101.29 103.03 0 0 1 0 0 0 0 0 0 0 0 27
28 103.68 210.5 103.69 101.29 0 0 0 1 0 0 0 0 0 0 0 28
29 104.20 223.5 103.68 103.69 0 0 0 0 1 0 0 0 0 0 0 29
30 104.08 223.8 104.20 103.68 0 0 0 0 0 1 0 0 0 0 0 30
31 104.16 231.2 104.08 104.20 0 0 0 0 0 0 1 0 0 0 0 31
32 103.05 244.0 104.16 104.08 0 0 0 0 0 0 0 1 0 0 0 32
33 104.66 234.7 103.05 104.16 0 0 0 0 0 0 0 0 1 0 0 33
34 104.46 250.2 104.66 103.05 0 0 0 0 0 0 0 0 0 1 0 34
35 104.95 265.7 104.46 104.66 0 0 0 0 0 0 0 0 0 0 1 35
36 105.85 287.6 104.95 104.46 0 0 0 0 0 0 0 0 0 0 0 36
37 106.23 283.3 105.85 104.95 1 0 0 0 0 0 0 0 0 0 0 37
38 104.86 295.4 106.23 105.85 0 1 0 0 0 0 0 0 0 0 0 38
39 107.44 312.3 104.86 106.23 0 0 1 0 0 0 0 0 0 0 0 39
40 108.23 333.8 107.44 104.86 0 0 0 1 0 0 0 0 0 0 0 40
41 108.45 347.7 108.23 107.44 0 0 0 0 1 0 0 0 0 0 0 41
42 109.39 383.2 108.45 108.23 0 0 0 0 0 1 0 0 0 0 0 42
43 110.15 407.1 109.39 108.45 0 0 0 0 0 0 1 0 0 0 0 43
44 109.13 413.6 110.15 109.39 0 0 0 0 0 0 0 1 0 0 0 44
45 110.28 362.7 109.13 110.15 0 0 0 0 0 0 0 0 1 0 0 45
46 110.17 321.9 110.28 109.13 0 0 0 0 0 0 0 0 0 1 0 46
47 109.99 239.4 110.17 110.28 0 0 0 0 0 0 0 0 0 0 1 47
48 109.26 191.0 109.99 110.17 0 0 0 0 0 0 0 0 0 0 0 48
49 109.11 159.7 109.26 109.99 1 0 0 0 0 0 0 0 0 0 0 49
50 107.06 163.4 109.11 109.26 0 1 0 0 0 0 0 0 0 0 0 50
51 109.53 157.6 107.06 109.11 0 0 1 0 0 0 0 0 0 0 0 51
52 108.92 166.2 109.53 107.06 0 0 0 1 0 0 0 0 0 0 0 52
53 109.24 176.7 108.92 109.53 0 0 0 0 1 0 0 0 0 0 0 53
54 109.12 198.3 109.24 108.92 0 0 0 0 0 1 0 0 0 0 0 54
55 109.00 226.2 109.12 109.24 0 0 0 0 0 0 1 0 0 0 0 55
56 107.23 216.2 109.00 109.12 0 0 0 0 0 0 0 1 0 0 0 56
57 109.49 235.9 107.23 109.00 0 0 0 0 0 0 0 0 1 0 0 57
58 109.04 226.9 109.49 107.23 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 M1 M2
16.110688 0.005503 0.563482 0.264939 -0.008916 -1.634690
M3 M4 M5 M6 M7 M8
1.559876 0.681932 0.249104 0.170577 0.064394 -1.386452
M9 M10 M11 t
0.953327 0.096990 -0.171227 0.024583
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.561860 -0.165051 0.001580 0.172213 0.504618
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 16.1106883 4.3494657 3.704 0.000613 ***
X 0.0055026 0.0008687 6.334 1.31e-07 ***
Y1 0.5634817 0.1393797 4.043 0.000221 ***
Y2 0.2649392 0.1304382 2.031 0.048601 *
M1 -0.0089157 0.1840119 -0.048 0.961586
M2 -1.6346903 0.1839233 -8.888 3.35e-11 ***
M3 1.5598763 0.2853579 5.466 2.32e-06 ***
M4 0.6819323 0.3618672 1.884 0.066433 .
M5 0.2491039 0.1841427 1.353 0.183365
M6 0.1705770 0.1884065 0.905 0.370436
M7 0.0643935 0.1859282 0.346 0.730820
M8 -1.3864521 0.1859068 -7.458 3.24e-09 ***
M9 0.9533267 0.2575042 3.702 0.000617 ***
M10 0.0969898 0.2877601 0.337 0.737757
M11 -0.1712266 0.1948904 -0.879 0.384628
t 0.0245832 0.0093077 2.641 0.011553 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.273 on 42 degrees of freedom
Multiple R-squared: 0.9961, Adjusted R-squared: 0.9948
F-statistic: 721.2 on 15 and 42 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.1772499204 0.354499841 0.8227501
[2,] 0.1308189226 0.261637845 0.8691811
[3,] 0.0891291954 0.178258391 0.9108708
[4,] 0.0676857565 0.135371513 0.9323142
[5,] 0.0407010408 0.081402082 0.9592990
[6,] 0.0178522224 0.035704445 0.9821478
[7,] 0.0074243926 0.014848785 0.9925756
[8,] 0.0038078308 0.007615662 0.9961922
[9,] 0.0026903872 0.005380774 0.9973096
[10,] 0.0014648806 0.002929761 0.9985351
[11,] 0.0005881538 0.001176308 0.9994118
[12,] 0.0022635628 0.004527126 0.9977364
[13,] 0.0051038025 0.010207605 0.9948962
[14,] 0.0067510194 0.013502039 0.9932490
[15,] 0.0056105757 0.011221151 0.9943894
[16,] 0.0074057427 0.014811485 0.9925943
[17,] 0.0037458145 0.007491629 0.9962542
[18,] 0.0083529814 0.016705963 0.9916470
[19,] 0.0194753230 0.038950646 0.9805247
[20,] 0.0268924206 0.053784841 0.9731076
[21,] 0.0198125921 0.039625184 0.9801874
> postscript(file="/var/www/html/rcomp/tmp/1fr9l1258723537.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/20g5t1258723538.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/3v3xp1258723538.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/4a9c41258723538.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/5ztlw1258723538.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 = 58
Frequency = 1
1 2 3 4 5
-0.3616958491 0.1377914306 -0.1514826631 0.3305048807 0.0137280698
6 7 8 9 10
0.0268351288 0.2360701073 0.3787463204 0.2252261527 0.3218871373
11 12 13 14 15
-0.0324990215 -0.1750992802 -0.0520134386 0.1056022050 -0.0888043459
16 17 18 19 20
-0.2554209006 0.0520064739 0.1352480091 -0.0377613423 0.0831137263
21 22 23 24 25
0.0800423996 -0.1452034949 -0.3472881495 -0.0363389633 -0.0143633176
26 27 28 29 30
-0.1922675215 -0.1253796654 -0.2223537535 0.0041383845 -0.3539298786
31 32 33 34 35
-0.3031993915 -0.0706561011 -0.1695744243 -0.2362340416 0.0982530942
36 37 38 39 40
0.4588182138 0.2098581307 -0.0781002363 -0.1389509860 0.2952879833
41 42 43 44 45
-0.2816466041 0.1836868107 0.3058156294 -0.0009778028 -0.5618600550
46 47 48 49 50
0.0066336382 0.2815340768 -0.2473799703 0.2182144746 0.0269741222
51 52 53 54 55
0.5046176605 -0.1480182099 0.2117736760 0.0081599300 -0.2009250029
56 57 58
-0.3902261427 0.4261659269 0.0529167609
> postscript(file="/var/www/html/rcomp/tmp/6py111258723538.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.3616958491 NA
1 0.1377914306 -0.3616958491
2 -0.1514826631 0.1377914306
3 0.3305048807 -0.1514826631
4 0.0137280698 0.3305048807
5 0.0268351288 0.0137280698
6 0.2360701073 0.0268351288
7 0.3787463204 0.2360701073
8 0.2252261527 0.3787463204
9 0.3218871373 0.2252261527
10 -0.0324990215 0.3218871373
11 -0.1750992802 -0.0324990215
12 -0.0520134386 -0.1750992802
13 0.1056022050 -0.0520134386
14 -0.0888043459 0.1056022050
15 -0.2554209006 -0.0888043459
16 0.0520064739 -0.2554209006
17 0.1352480091 0.0520064739
18 -0.0377613423 0.1352480091
19 0.0831137263 -0.0377613423
20 0.0800423996 0.0831137263
21 -0.1452034949 0.0800423996
22 -0.3472881495 -0.1452034949
23 -0.0363389633 -0.3472881495
24 -0.0143633176 -0.0363389633
25 -0.1922675215 -0.0143633176
26 -0.1253796654 -0.1922675215
27 -0.2223537535 -0.1253796654
28 0.0041383845 -0.2223537535
29 -0.3539298786 0.0041383845
30 -0.3031993915 -0.3539298786
31 -0.0706561011 -0.3031993915
32 -0.1695744243 -0.0706561011
33 -0.2362340416 -0.1695744243
34 0.0982530942 -0.2362340416
35 0.4588182138 0.0982530942
36 0.2098581307 0.4588182138
37 -0.0781002363 0.2098581307
38 -0.1389509860 -0.0781002363
39 0.2952879833 -0.1389509860
40 -0.2816466041 0.2952879833
41 0.1836868107 -0.2816466041
42 0.3058156294 0.1836868107
43 -0.0009778028 0.3058156294
44 -0.5618600550 -0.0009778028
45 0.0066336382 -0.5618600550
46 0.2815340768 0.0066336382
47 -0.2473799703 0.2815340768
48 0.2182144746 -0.2473799703
49 0.0269741222 0.2182144746
50 0.5046176605 0.0269741222
51 -0.1480182099 0.5046176605
52 0.2117736760 -0.1480182099
53 0.0081599300 0.2117736760
54 -0.2009250029 0.0081599300
55 -0.3902261427 -0.2009250029
56 0.4261659269 -0.3902261427
57 0.0529167609 0.4261659269
58 NA 0.0529167609
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.1377914306 -0.3616958491
[2,] -0.1514826631 0.1377914306
[3,] 0.3305048807 -0.1514826631
[4,] 0.0137280698 0.3305048807
[5,] 0.0268351288 0.0137280698
[6,] 0.2360701073 0.0268351288
[7,] 0.3787463204 0.2360701073
[8,] 0.2252261527 0.3787463204
[9,] 0.3218871373 0.2252261527
[10,] -0.0324990215 0.3218871373
[11,] -0.1750992802 -0.0324990215
[12,] -0.0520134386 -0.1750992802
[13,] 0.1056022050 -0.0520134386
[14,] -0.0888043459 0.1056022050
[15,] -0.2554209006 -0.0888043459
[16,] 0.0520064739 -0.2554209006
[17,] 0.1352480091 0.0520064739
[18,] -0.0377613423 0.1352480091
[19,] 0.0831137263 -0.0377613423
[20,] 0.0800423996 0.0831137263
[21,] -0.1452034949 0.0800423996
[22,] -0.3472881495 -0.1452034949
[23,] -0.0363389633 -0.3472881495
[24,] -0.0143633176 -0.0363389633
[25,] -0.1922675215 -0.0143633176
[26,] -0.1253796654 -0.1922675215
[27,] -0.2223537535 -0.1253796654
[28,] 0.0041383845 -0.2223537535
[29,] -0.3539298786 0.0041383845
[30,] -0.3031993915 -0.3539298786
[31,] -0.0706561011 -0.3031993915
[32,] -0.1695744243 -0.0706561011
[33,] -0.2362340416 -0.1695744243
[34,] 0.0982530942 -0.2362340416
[35,] 0.4588182138 0.0982530942
[36,] 0.2098581307 0.4588182138
[37,] -0.0781002363 0.2098581307
[38,] -0.1389509860 -0.0781002363
[39,] 0.2952879833 -0.1389509860
[40,] -0.2816466041 0.2952879833
[41,] 0.1836868107 -0.2816466041
[42,] 0.3058156294 0.1836868107
[43,] -0.0009778028 0.3058156294
[44,] -0.5618600550 -0.0009778028
[45,] 0.0066336382 -0.5618600550
[46,] 0.2815340768 0.0066336382
[47,] -0.2473799703 0.2815340768
[48,] 0.2182144746 -0.2473799703
[49,] 0.0269741222 0.2182144746
[50,] 0.5046176605 0.0269741222
[51,] -0.1480182099 0.5046176605
[52,] 0.2117736760 -0.1480182099
[53,] 0.0081599300 0.2117736760
[54,] -0.2009250029 0.0081599300
[55,] -0.3902261427 -0.2009250029
[56,] 0.4261659269 -0.3902261427
[57,] 0.0529167609 0.4261659269
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.1377914306 -0.3616958491
2 -0.1514826631 0.1377914306
3 0.3305048807 -0.1514826631
4 0.0137280698 0.3305048807
5 0.0268351288 0.0137280698
6 0.2360701073 0.0268351288
7 0.3787463204 0.2360701073
8 0.2252261527 0.3787463204
9 0.3218871373 0.2252261527
10 -0.0324990215 0.3218871373
11 -0.1750992802 -0.0324990215
12 -0.0520134386 -0.1750992802
13 0.1056022050 -0.0520134386
14 -0.0888043459 0.1056022050
15 -0.2554209006 -0.0888043459
16 0.0520064739 -0.2554209006
17 0.1352480091 0.0520064739
18 -0.0377613423 0.1352480091
19 0.0831137263 -0.0377613423
20 0.0800423996 0.0831137263
21 -0.1452034949 0.0800423996
22 -0.3472881495 -0.1452034949
23 -0.0363389633 -0.3472881495
24 -0.0143633176 -0.0363389633
25 -0.1922675215 -0.0143633176
26 -0.1253796654 -0.1922675215
27 -0.2223537535 -0.1253796654
28 0.0041383845 -0.2223537535
29 -0.3539298786 0.0041383845
30 -0.3031993915 -0.3539298786
31 -0.0706561011 -0.3031993915
32 -0.1695744243 -0.0706561011
33 -0.2362340416 -0.1695744243
34 0.0982530942 -0.2362340416
35 0.4588182138 0.0982530942
36 0.2098581307 0.4588182138
37 -0.0781002363 0.2098581307
38 -0.1389509860 -0.0781002363
39 0.2952879833 -0.1389509860
40 -0.2816466041 0.2952879833
41 0.1836868107 -0.2816466041
42 0.3058156294 0.1836868107
43 -0.0009778028 0.3058156294
44 -0.5618600550 -0.0009778028
45 0.0066336382 -0.5618600550
46 0.2815340768 0.0066336382
47 -0.2473799703 0.2815340768
48 0.2182144746 -0.2473799703
49 0.0269741222 0.2182144746
50 0.5046176605 0.0269741222
51 -0.1480182099 0.5046176605
52 0.2117736760 -0.1480182099
53 0.0081599300 0.2117736760
54 -0.2009250029 0.0081599300
55 -0.3902261427 -0.2009250029
56 0.4261659269 -0.3902261427
57 0.0529167609 0.4261659269
> 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/7nx7v1258723538.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/8vi9g1258723538.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/9nfyb1258723538.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/100hhq1258723538.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/11kk8p1258723538.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/12hl161258723538.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/13std71258723538.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/14otn61258723538.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/15zyyc1258723538.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/16vlb11258723538.tab")
+ }
>
> system("convert tmp/1fr9l1258723537.ps tmp/1fr9l1258723537.png")
> system("convert tmp/20g5t1258723538.ps tmp/20g5t1258723538.png")
> system("convert tmp/3v3xp1258723538.ps tmp/3v3xp1258723538.png")
> system("convert tmp/4a9c41258723538.ps tmp/4a9c41258723538.png")
> system("convert tmp/5ztlw1258723538.ps tmp/5ztlw1258723538.png")
> system("convert tmp/6py111258723538.ps tmp/6py111258723538.png")
> system("convert tmp/7nx7v1258723538.ps tmp/7nx7v1258723538.png")
> system("convert tmp/8vi9g1258723538.ps tmp/8vi9g1258723538.png")
> system("convert tmp/9nfyb1258723538.ps tmp/9nfyb1258723538.png")
> system("convert tmp/100hhq1258723538.ps tmp/100hhq1258723538.png")
>
>
> proc.time()
user system elapsed
2.368 1.573 2.790