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(105.4
+ ,119.5
+ ,109
+ ,116.7
+ ,102.7
+ ,115.1
+ ,119.5
+ ,109
+ ,98.1
+ ,107.1
+ ,115.1
+ ,119.5
+ ,104.5
+ ,109.7
+ ,107.1
+ ,115.1
+ ,87.4
+ ,110.4
+ ,109.7
+ ,107.1
+ ,89.9
+ ,105
+ ,110.4
+ ,109.7
+ ,109.8
+ ,115.8
+ ,105
+ ,110.4
+ ,111.7
+ ,116.4
+ ,115.8
+ ,105
+ ,98.6
+ ,111.1
+ ,116.4
+ ,115.8
+ ,96.9
+ ,119.5
+ ,111.1
+ ,116.4
+ ,95.1
+ ,110.9
+ ,119.5
+ ,111.1
+ ,97
+ ,115.1
+ ,110.9
+ ,119.5
+ ,112.7
+ ,125.2
+ ,115.1
+ ,110.9
+ ,102.9
+ ,116
+ ,125.2
+ ,115.1
+ ,97.4
+ ,112.9
+ ,116
+ ,125.2
+ ,111.4
+ ,121.7
+ ,112.9
+ ,116
+ ,87.4
+ ,123.2
+ ,121.7
+ ,112.9
+ ,96.8
+ ,116.6
+ ,123.2
+ ,121.7
+ ,114.1
+ ,136.2
+ ,116.6
+ ,123.2
+ ,110.3
+ ,120.9
+ ,136.2
+ ,116.6
+ ,103.9
+ ,119.6
+ ,120.9
+ ,136.2
+ ,101.6
+ ,125.9
+ ,119.6
+ ,120.9
+ ,94.6
+ ,116.1
+ ,125.9
+ ,119.6
+ ,95.9
+ ,107.5
+ ,116.1
+ ,125.9
+ ,104.7
+ ,116.7
+ ,107.5
+ ,116.1
+ ,102.8
+ ,112.5
+ ,116.7
+ ,107.5
+ ,98.1
+ ,113
+ ,112.5
+ ,116.7
+ ,113.9
+ ,126.4
+ ,113
+ ,112.5
+ ,80.9
+ ,114.1
+ ,126.4
+ ,113
+ ,95.7
+ ,112.5
+ ,114.1
+ ,126.4
+ ,113.2
+ ,112.4
+ ,112.5
+ ,114.1
+ ,105.9
+ ,113.1
+ ,112.4
+ ,112.5
+ ,108.8
+ ,116.3
+ ,113.1
+ ,112.4
+ ,102.3
+ ,111.7
+ ,116.3
+ ,113.1
+ ,99
+ ,118.8
+ ,111.7
+ ,116.3
+ ,100.7
+ ,116.5
+ ,118.8
+ ,111.7
+ ,115.5
+ ,125.1
+ ,116.5
+ ,118.8
+ ,100.7
+ ,113.1
+ ,125.1
+ ,116.5
+ ,109.9
+ ,119.6
+ ,113.1
+ ,125.1
+ ,114.6
+ ,114.4
+ ,119.6
+ ,113.1
+ ,85.4
+ ,114
+ ,114.4
+ ,119.6
+ ,100.5
+ ,117.8
+ ,114
+ ,114.4
+ ,114.8
+ ,117
+ ,117.8
+ ,114
+ ,116.5
+ ,120.9
+ ,117
+ ,117.8
+ ,112.9
+ ,115
+ ,120.9
+ ,117
+ ,102
+ ,117.3
+ ,115
+ ,120.9
+ ,106
+ ,119.4
+ ,117.3
+ ,115
+ ,105.3
+ ,114.9
+ ,119.4
+ ,117.3
+ ,118.8
+ ,125.8
+ ,114.9
+ ,119.4
+ ,106.1
+ ,117.6
+ ,125.8
+ ,114.9
+ ,109.3
+ ,117.6
+ ,117.6
+ ,125.8
+ ,117.2
+ ,114.9
+ ,117.6
+ ,117.6
+ ,92.5
+ ,121.9
+ ,114.9
+ ,117.6
+ ,104.2
+ ,117
+ ,121.9
+ ,114.9
+ ,112.5
+ ,106.4
+ ,117
+ ,121.9
+ ,122.4
+ ,110.5
+ ,106.4
+ ,117
+ ,113.3
+ ,113.6
+ ,110.5
+ ,106.4
+ ,100
+ ,114.2
+ ,113.6
+ ,110.5)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('Tip'
+ ,'ipchn'
+ ,'y(t-1)'
+ ,'y(t-2)')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('Tip','ipchn','y(t-1)','y(t-2)'),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 = '2'
> #'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
ipchn Tip y(t-1) y(t-2) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 119.5 105.4 109.0 116.7 1 0 0 0 0 0 0 0 0 0 0 1
2 115.1 102.7 119.5 109.0 0 1 0 0 0 0 0 0 0 0 0 2
3 107.1 98.1 115.1 119.5 0 0 1 0 0 0 0 0 0 0 0 3
4 109.7 104.5 107.1 115.1 0 0 0 1 0 0 0 0 0 0 0 4
5 110.4 87.4 109.7 107.1 0 0 0 0 1 0 0 0 0 0 0 5
6 105.0 89.9 110.4 109.7 0 0 0 0 0 1 0 0 0 0 0 6
7 115.8 109.8 105.0 110.4 0 0 0 0 0 0 1 0 0 0 0 7
8 116.4 111.7 115.8 105.0 0 0 0 0 0 0 0 1 0 0 0 8
9 111.1 98.6 116.4 115.8 0 0 0 0 0 0 0 0 1 0 0 9
10 119.5 96.9 111.1 116.4 0 0 0 0 0 0 0 0 0 1 0 10
11 110.9 95.1 119.5 111.1 0 0 0 0 0 0 0 0 0 0 1 11
12 115.1 97.0 110.9 119.5 0 0 0 0 0 0 0 0 0 0 0 12
13 125.2 112.7 115.1 110.9 1 0 0 0 0 0 0 0 0 0 0 13
14 116.0 102.9 125.2 115.1 0 1 0 0 0 0 0 0 0 0 0 14
15 112.9 97.4 116.0 125.2 0 0 1 0 0 0 0 0 0 0 0 15
16 121.7 111.4 112.9 116.0 0 0 0 1 0 0 0 0 0 0 0 16
17 123.2 87.4 121.7 112.9 0 0 0 0 1 0 0 0 0 0 0 17
18 116.6 96.8 123.2 121.7 0 0 0 0 0 1 0 0 0 0 0 18
19 136.2 114.1 116.6 123.2 0 0 0 0 0 0 1 0 0 0 0 19
20 120.9 110.3 136.2 116.6 0 0 0 0 0 0 0 1 0 0 0 20
21 119.6 103.9 120.9 136.2 0 0 0 0 0 0 0 0 1 0 0 21
22 125.9 101.6 119.6 120.9 0 0 0 0 0 0 0 0 0 1 0 22
23 116.1 94.6 125.9 119.6 0 0 0 0 0 0 0 0 0 0 1 23
24 107.5 95.9 116.1 125.9 0 0 0 0 0 0 0 0 0 0 0 24
25 116.7 104.7 107.5 116.1 1 0 0 0 0 0 0 0 0 0 0 25
26 112.5 102.8 116.7 107.5 0 1 0 0 0 0 0 0 0 0 0 26
27 113.0 98.1 112.5 116.7 0 0 1 0 0 0 0 0 0 0 0 27
28 126.4 113.9 113.0 112.5 0 0 0 1 0 0 0 0 0 0 0 28
29 114.1 80.9 126.4 113.0 0 0 0 0 1 0 0 0 0 0 0 29
30 112.5 95.7 114.1 126.4 0 0 0 0 0 1 0 0 0 0 0 30
31 112.4 113.2 112.5 114.1 0 0 0 0 0 0 1 0 0 0 0 31
32 113.1 105.9 112.4 112.5 0 0 0 0 0 0 0 1 0 0 0 32
33 116.3 108.8 113.1 112.4 0 0 0 0 0 0 0 0 1 0 0 33
34 111.7 102.3 116.3 113.1 0 0 0 0 0 0 0 0 0 1 0 34
35 118.8 99.0 111.7 116.3 0 0 0 0 0 0 0 0 0 0 1 35
36 116.5 100.7 118.8 111.7 0 0 0 0 0 0 0 0 0 0 0 36
37 125.1 115.5 116.5 118.8 1 0 0 0 0 0 0 0 0 0 0 37
38 113.1 100.7 125.1 116.5 0 1 0 0 0 0 0 0 0 0 0 38
39 119.6 109.9 113.1 125.1 0 0 1 0 0 0 0 0 0 0 0 39
40 114.4 114.6 119.6 113.1 0 0 0 1 0 0 0 0 0 0 0 40
41 114.0 85.4 114.4 119.6 0 0 0 0 1 0 0 0 0 0 0 41
42 117.8 100.5 114.0 114.4 0 0 0 0 0 1 0 0 0 0 0 42
43 117.0 114.8 117.8 114.0 0 0 0 0 0 0 1 0 0 0 0 43
44 120.9 116.5 117.0 117.8 0 0 0 0 0 0 0 1 0 0 0 44
45 115.0 112.9 120.9 117.0 0 0 0 0 0 0 0 0 1 0 0 45
46 117.3 102.0 115.0 120.9 0 0 0 0 0 0 0 0 0 1 0 46
47 119.4 106.0 117.3 115.0 0 0 0 0 0 0 0 0 0 0 1 47
48 114.9 105.3 119.4 117.3 0 0 0 0 0 0 0 0 0 0 0 48
49 125.8 118.8 114.9 119.4 1 0 0 0 0 0 0 0 0 0 0 49
50 117.6 106.1 125.8 114.9 0 1 0 0 0 0 0 0 0 0 0 50
51 117.6 109.3 117.6 125.8 0 0 1 0 0 0 0 0 0 0 0 51
52 114.9 117.2 117.6 117.6 0 0 0 1 0 0 0 0 0 0 0 52
53 121.9 92.5 114.9 117.6 0 0 0 0 1 0 0 0 0 0 0 53
54 117.0 104.2 121.9 114.9 0 0 0 0 0 1 0 0 0 0 0 54
55 106.4 112.5 117.0 121.9 0 0 0 0 0 0 1 0 0 0 0 55
56 110.5 122.4 106.4 117.0 0 0 0 0 0 0 0 1 0 0 0 56
57 113.6 113.3 110.5 106.4 0 0 0 0 0 0 0 0 1 0 0 57
58 114.2 100.0 113.6 110.5 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) Tip `y(t-1)` `y(t-2)` M1 M2
-22.33892 0.83224 0.25419 0.23468 -0.07021 -2.16351
M3 M4 M5 M6 M7 M8
-2.81444 -5.41335 14.67702 2.36848 -5.65463 -7.37323
M9 M10 M11 t
-4.16665 4.95764 3.66500 -0.15173
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-9.2363 -1.4635 0.1655 2.2728 13.5663
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -22.33892 26.83430 -0.832 0.409849
Tip 0.83224 0.19918 4.178 0.000145 ***
`y(t-1)` 0.25419 0.12778 1.989 0.053208 .
`y(t-2)` 0.23468 0.12875 1.823 0.075464 .
M1 -0.07021 3.98167 -0.018 0.986014
M2 -2.16351 3.39199 -0.638 0.527048
M3 -2.81444 3.20669 -0.878 0.385111
M4 -5.41335 4.00683 -1.351 0.183919
M5 14.67702 4.07977 3.598 0.000840 ***
M6 2.36848 3.10604 0.763 0.449998
M7 -5.65463 4.00832 -1.411 0.165691
M8 -7.37323 4.05972 -1.816 0.076483 .
M9 -4.16665 3.38213 -1.232 0.224816
M10 4.95764 3.08283 1.608 0.115296
M11 3.66500 3.28568 1.115 0.271000
t -0.15173 0.05310 -2.858 0.006613 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.568 on 42 degrees of freedom
Multiple R-squared: 0.4997, Adjusted R-squared: 0.321
F-statistic: 2.796 on 15 and 42 DF, p-value: 0.004408
> 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.6910867 0.6178266 0.30891332
[2,] 0.6647367 0.6705266 0.33526332
[3,] 0.6752888 0.6494223 0.32471116
[4,] 0.6418973 0.7162054 0.35810272
[5,] 0.5160991 0.9678019 0.48390093
[6,] 0.6958289 0.6083422 0.30417111
[7,] 0.5999405 0.8001191 0.40005953
[8,] 0.5373153 0.9253695 0.46268474
[9,] 0.4947814 0.9895629 0.50521857
[10,] 0.6439280 0.7121441 0.35607203
[11,] 0.6419052 0.7161897 0.35809483
[12,] 0.5438737 0.9122526 0.45612629
[13,] 0.8162159 0.3675683 0.18378413
[14,] 0.7515895 0.4968209 0.24841047
[15,] 0.6703318 0.6593364 0.32966819
[16,] 0.9083538 0.1832924 0.09164619
[17,] 0.8992017 0.2015966 0.10079829
[18,] 0.8307251 0.3385498 0.16927491
[19,] 0.7496699 0.5006603 0.25033014
[20,] 0.6228687 0.7542626 0.37713129
[21,] 0.4475200 0.8950400 0.55248000
> postscript(file="/var/www/html/rcomp/tmp/1kl7j1259064985.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/2p4h81259064985.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/3d24i1259064985.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/40r341259064985.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/5boft1259064985.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 6 7
-0.7515001 -1.5213456 -6.2361189 -3.1457006 -6.9364457 -2.7448869 0.8767145
8 9 10 11 12 13 14
0.2878466 0.1482453 2.1968838 -4.3520795 2.2980846 0.5045418 -1.8474592
15 16 17 18 19 20 21
0.4007659 3.2471127 3.2729013 -1.1363890 13.5663173 -0.1340262 0.1267548
22 23 24 25 26 27 28
3.2894529 -0.5367986 -5.3894271 1.1947317 0.5007555 4.6234572 8.4832710
29 30 31 32 33 34 35
0.1850898 -1.2900313 -4.4860830 4.5605247 2.1377132 -7.0029723 4.7060734
36 37 38 39 40 41 42
4.0828031 -0.4940288 0.4219004 1.0999488 -4.0969722 -0.3378484 4.6776245
43 44 45 46 47 48 49
-0.7206177 2.9464672 -3.8159094 -0.8326031 0.1828048 -0.9914606 -0.4537446
50 51 52 53 54 55 56
2.4461490 0.1119471 -4.4877109 3.8163031 0.4936827 -9.2363310 -7.6608123
57 58
1.4031962 2.3492387
> postscript(file="/var/www/html/rcomp/tmp/6dtv81259064985.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.7515001 NA
1 -1.5213456 -0.7515001
2 -6.2361189 -1.5213456
3 -3.1457006 -6.2361189
4 -6.9364457 -3.1457006
5 -2.7448869 -6.9364457
6 0.8767145 -2.7448869
7 0.2878466 0.8767145
8 0.1482453 0.2878466
9 2.1968838 0.1482453
10 -4.3520795 2.1968838
11 2.2980846 -4.3520795
12 0.5045418 2.2980846
13 -1.8474592 0.5045418
14 0.4007659 -1.8474592
15 3.2471127 0.4007659
16 3.2729013 3.2471127
17 -1.1363890 3.2729013
18 13.5663173 -1.1363890
19 -0.1340262 13.5663173
20 0.1267548 -0.1340262
21 3.2894529 0.1267548
22 -0.5367986 3.2894529
23 -5.3894271 -0.5367986
24 1.1947317 -5.3894271
25 0.5007555 1.1947317
26 4.6234572 0.5007555
27 8.4832710 4.6234572
28 0.1850898 8.4832710
29 -1.2900313 0.1850898
30 -4.4860830 -1.2900313
31 4.5605247 -4.4860830
32 2.1377132 4.5605247
33 -7.0029723 2.1377132
34 4.7060734 -7.0029723
35 4.0828031 4.7060734
36 -0.4940288 4.0828031
37 0.4219004 -0.4940288
38 1.0999488 0.4219004
39 -4.0969722 1.0999488
40 -0.3378484 -4.0969722
41 4.6776245 -0.3378484
42 -0.7206177 4.6776245
43 2.9464672 -0.7206177
44 -3.8159094 2.9464672
45 -0.8326031 -3.8159094
46 0.1828048 -0.8326031
47 -0.9914606 0.1828048
48 -0.4537446 -0.9914606
49 2.4461490 -0.4537446
50 0.1119471 2.4461490
51 -4.4877109 0.1119471
52 3.8163031 -4.4877109
53 0.4936827 3.8163031
54 -9.2363310 0.4936827
55 -7.6608123 -9.2363310
56 1.4031962 -7.6608123
57 2.3492387 1.4031962
58 NA 2.3492387
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.5213456 -0.7515001
[2,] -6.2361189 -1.5213456
[3,] -3.1457006 -6.2361189
[4,] -6.9364457 -3.1457006
[5,] -2.7448869 -6.9364457
[6,] 0.8767145 -2.7448869
[7,] 0.2878466 0.8767145
[8,] 0.1482453 0.2878466
[9,] 2.1968838 0.1482453
[10,] -4.3520795 2.1968838
[11,] 2.2980846 -4.3520795
[12,] 0.5045418 2.2980846
[13,] -1.8474592 0.5045418
[14,] 0.4007659 -1.8474592
[15,] 3.2471127 0.4007659
[16,] 3.2729013 3.2471127
[17,] -1.1363890 3.2729013
[18,] 13.5663173 -1.1363890
[19,] -0.1340262 13.5663173
[20,] 0.1267548 -0.1340262
[21,] 3.2894529 0.1267548
[22,] -0.5367986 3.2894529
[23,] -5.3894271 -0.5367986
[24,] 1.1947317 -5.3894271
[25,] 0.5007555 1.1947317
[26,] 4.6234572 0.5007555
[27,] 8.4832710 4.6234572
[28,] 0.1850898 8.4832710
[29,] -1.2900313 0.1850898
[30,] -4.4860830 -1.2900313
[31,] 4.5605247 -4.4860830
[32,] 2.1377132 4.5605247
[33,] -7.0029723 2.1377132
[34,] 4.7060734 -7.0029723
[35,] 4.0828031 4.7060734
[36,] -0.4940288 4.0828031
[37,] 0.4219004 -0.4940288
[38,] 1.0999488 0.4219004
[39,] -4.0969722 1.0999488
[40,] -0.3378484 -4.0969722
[41,] 4.6776245 -0.3378484
[42,] -0.7206177 4.6776245
[43,] 2.9464672 -0.7206177
[44,] -3.8159094 2.9464672
[45,] -0.8326031 -3.8159094
[46,] 0.1828048 -0.8326031
[47,] -0.9914606 0.1828048
[48,] -0.4537446 -0.9914606
[49,] 2.4461490 -0.4537446
[50,] 0.1119471 2.4461490
[51,] -4.4877109 0.1119471
[52,] 3.8163031 -4.4877109
[53,] 0.4936827 3.8163031
[54,] -9.2363310 0.4936827
[55,] -7.6608123 -9.2363310
[56,] 1.4031962 -7.6608123
[57,] 2.3492387 1.4031962
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.5213456 -0.7515001
2 -6.2361189 -1.5213456
3 -3.1457006 -6.2361189
4 -6.9364457 -3.1457006
5 -2.7448869 -6.9364457
6 0.8767145 -2.7448869
7 0.2878466 0.8767145
8 0.1482453 0.2878466
9 2.1968838 0.1482453
10 -4.3520795 2.1968838
11 2.2980846 -4.3520795
12 0.5045418 2.2980846
13 -1.8474592 0.5045418
14 0.4007659 -1.8474592
15 3.2471127 0.4007659
16 3.2729013 3.2471127
17 -1.1363890 3.2729013
18 13.5663173 -1.1363890
19 -0.1340262 13.5663173
20 0.1267548 -0.1340262
21 3.2894529 0.1267548
22 -0.5367986 3.2894529
23 -5.3894271 -0.5367986
24 1.1947317 -5.3894271
25 0.5007555 1.1947317
26 4.6234572 0.5007555
27 8.4832710 4.6234572
28 0.1850898 8.4832710
29 -1.2900313 0.1850898
30 -4.4860830 -1.2900313
31 4.5605247 -4.4860830
32 2.1377132 4.5605247
33 -7.0029723 2.1377132
34 4.7060734 -7.0029723
35 4.0828031 4.7060734
36 -0.4940288 4.0828031
37 0.4219004 -0.4940288
38 1.0999488 0.4219004
39 -4.0969722 1.0999488
40 -0.3378484 -4.0969722
41 4.6776245 -0.3378484
42 -0.7206177 4.6776245
43 2.9464672 -0.7206177
44 -3.8159094 2.9464672
45 -0.8326031 -3.8159094
46 0.1828048 -0.8326031
47 -0.9914606 0.1828048
48 -0.4537446 -0.9914606
49 2.4461490 -0.4537446
50 0.1119471 2.4461490
51 -4.4877109 0.1119471
52 3.8163031 -4.4877109
53 0.4936827 3.8163031
54 -9.2363310 0.4936827
55 -7.6608123 -9.2363310
56 1.4031962 -7.6608123
57 2.3492387 1.4031962
> 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/7utms1259064985.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/8llsl1259064985.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/9vla61259064985.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/10074i1259064985.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/11qd671259064985.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/12omth1259064985.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/13vqz71259064985.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/14fxms1259064985.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/15d6yl1259064985.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/16ommn1259064985.tab")
+ }
>
> system("convert tmp/1kl7j1259064985.ps tmp/1kl7j1259064985.png")
> system("convert tmp/2p4h81259064985.ps tmp/2p4h81259064985.png")
> system("convert tmp/3d24i1259064985.ps tmp/3d24i1259064985.png")
> system("convert tmp/40r341259064985.ps tmp/40r341259064985.png")
> system("convert tmp/5boft1259064985.ps tmp/5boft1259064985.png")
> system("convert tmp/6dtv81259064985.ps tmp/6dtv81259064985.png")
> system("convert tmp/7utms1259064985.ps tmp/7utms1259064985.png")
> system("convert tmp/8llsl1259064985.ps tmp/8llsl1259064985.png")
> system("convert tmp/9vla61259064985.ps tmp/9vla61259064985.png")
> system("convert tmp/10074i1259064985.ps tmp/10074i1259064985.png")
>
>
> proc.time()
user system elapsed
2.346 1.541 3.813