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(22,0,22,20,0,22,21,0,20,20,0,21,21,0,20,21,0,21,21,0,21,19,0,21,21,0,19,21,0,21,22,0,21,19,0,22,24,0,19,22,0,24,22,0,22,22,0,22,24,0,22,22,0,24,23,0,22,24,0,23,21,0,24,20,0,21,22,0,20,23,0,22,23,0,23,22,0,23,20,0,22,21,1,20,21,1,21,20,1,21,20,1,20,17,1,20,18,1,17,19,1,18,19,1,19,20,1,19,21,1,20,20,1,21,21,1,20,19,1,21,22,1,19,20,1,22,18,1,20,16,1,18,17,1,16,18,1,17,19,1,18,18,1,19,20,1,18,21,1,20,18,1,21,19,1,18,19,1,19,19,1,19,21,1,19,19,1,21,19,1,19,17,1,19,16,1,17,16,1,16,17,1,16,16,1,17,15,1,16,16,1,15,16,1,16,16,1,16,18,1,16,19,1,18,16,1,19,16,1,16,16,1,16),dim=c(3,71),dimnames=list(c('Y','X','Y1'),1:71))
> y <- array(NA,dim=c(3,71),dimnames=list(c('Y','X','Y1'),1:71))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 22 0 22 1 0 0 0 0 0 0 0 0 0 0 1
2 20 0 22 0 1 0 0 0 0 0 0 0 0 0 2
3 21 0 20 0 0 1 0 0 0 0 0 0 0 0 3
4 20 0 21 0 0 0 1 0 0 0 0 0 0 0 4
5 21 0 20 0 0 0 0 1 0 0 0 0 0 0 5
6 21 0 21 0 0 0 0 0 1 0 0 0 0 0 6
7 21 0 21 0 0 0 0 0 0 1 0 0 0 0 7
8 19 0 21 0 0 0 0 0 0 0 1 0 0 0 8
9 21 0 19 0 0 0 0 0 0 0 0 1 0 0 9
10 21 0 21 0 0 0 0 0 0 0 0 0 1 0 10
11 22 0 21 0 0 0 0 0 0 0 0 0 0 1 11
12 19 0 22 0 0 0 0 0 0 0 0 0 0 0 12
13 24 0 19 1 0 0 0 0 0 0 0 0 0 0 13
14 22 0 24 0 1 0 0 0 0 0 0 0 0 0 14
15 22 0 22 0 0 1 0 0 0 0 0 0 0 0 15
16 22 0 22 0 0 0 1 0 0 0 0 0 0 0 16
17 24 0 22 0 0 0 0 1 0 0 0 0 0 0 17
18 22 0 24 0 0 0 0 0 1 0 0 0 0 0 18
19 23 0 22 0 0 0 0 0 0 1 0 0 0 0 19
20 24 0 23 0 0 0 0 0 0 0 1 0 0 0 20
21 21 0 24 0 0 0 0 0 0 0 0 1 0 0 21
22 20 0 21 0 0 0 0 0 0 0 0 0 1 0 22
23 22 0 20 0 0 0 0 0 0 0 0 0 0 1 23
24 23 0 22 0 0 0 0 0 0 0 0 0 0 0 24
25 23 0 23 1 0 0 0 0 0 0 0 0 0 0 25
26 22 0 23 0 1 0 0 0 0 0 0 0 0 0 26
27 20 0 22 0 0 1 0 0 0 0 0 0 0 0 27
28 21 1 20 0 0 0 1 0 0 0 0 0 0 0 28
29 21 1 21 0 0 0 0 1 0 0 0 0 0 0 29
30 20 1 21 0 0 0 0 0 1 0 0 0 0 0 30
31 20 1 20 0 0 0 0 0 0 1 0 0 0 0 31
32 17 1 20 0 0 0 0 0 0 0 1 0 0 0 32
33 18 1 17 0 0 0 0 0 0 0 0 1 0 0 33
34 19 1 18 0 0 0 0 0 0 0 0 0 1 0 34
35 19 1 19 0 0 0 0 0 0 0 0 0 0 1 35
36 20 1 19 0 0 0 0 0 0 0 0 0 0 0 36
37 21 1 20 1 0 0 0 0 0 0 0 0 0 0 37
38 20 1 21 0 1 0 0 0 0 0 0 0 0 0 38
39 21 1 20 0 0 1 0 0 0 0 0 0 0 0 39
40 19 1 21 0 0 0 1 0 0 0 0 0 0 0 40
41 22 1 19 0 0 0 0 1 0 0 0 0 0 0 41
42 20 1 22 0 0 0 0 0 1 0 0 0 0 0 42
43 18 1 20 0 0 0 0 0 0 1 0 0 0 0 43
44 16 1 18 0 0 0 0 0 0 0 1 0 0 0 44
45 17 1 16 0 0 0 0 0 0 0 0 1 0 0 45
46 18 1 17 0 0 0 0 0 0 0 0 0 1 0 46
47 19 1 18 0 0 0 0 0 0 0 0 0 0 1 47
48 18 1 19 0 0 0 0 0 0 0 0 0 0 0 48
49 20 1 18 1 0 0 0 0 0 0 0 0 0 0 49
50 21 1 20 0 1 0 0 0 0 0 0 0 0 0 50
51 18 1 21 0 0 1 0 0 0 0 0 0 0 0 51
52 19 1 18 0 0 0 1 0 0 0 0 0 0 0 52
53 19 1 19 0 0 0 0 1 0 0 0 0 0 0 53
54 19 1 19 0 0 0 0 0 1 0 0 0 0 0 54
55 21 1 19 0 0 0 0 0 0 1 0 0 0 0 55
56 19 1 21 0 0 0 0 0 0 0 1 0 0 0 56
57 19 1 19 0 0 0 0 0 0 0 0 1 0 0 57
58 17 1 19 0 0 0 0 0 0 0 0 0 1 0 58
59 16 1 17 0 0 0 0 0 0 0 0 0 0 1 59
60 16 1 16 0 0 0 0 0 0 0 0 0 0 0 60
61 17 1 16 1 0 0 0 0 0 0 0 0 0 0 61
62 16 1 17 0 1 0 0 0 0 0 0 0 0 0 62
63 15 1 16 0 0 1 0 0 0 0 0 0 0 0 63
64 16 1 15 0 0 0 1 0 0 0 0 0 0 0 64
65 16 1 16 0 0 0 0 1 0 0 0 0 0 0 65
66 16 1 16 0 0 0 0 0 1 0 0 0 0 0 66
67 18 1 16 0 0 0 0 0 0 1 0 0 0 0 67
68 19 1 18 0 0 0 0 0 0 0 1 0 0 0 68
69 16 1 19 0 0 0 0 0 0 0 0 1 0 0 69
70 16 1 16 0 0 0 0 0 0 0 0 0 1 0 70
71 16 1 16 0 0 0 0 0 0 0 0 0 0 1 71
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 M1 M2 M3
10.06777 -0.47206 0.53198 1.74354 -0.02634 -0.13294
M4 M5 M6 M7 M8 M9
0.32848 1.35658 0.01936 0.99076 -0.41380 -0.09840
M10 M11 t
-0.05965 0.55711 -0.02809
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2.43419 -0.94776 -0.09012 0.78353 2.67237
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.06777 2.61959 3.843 0.000312 ***
X -0.47206 0.62674 -0.753 0.454491
Y1 0.53198 0.11364 4.681 1.85e-05 ***
M1 1.74354 0.81268 2.145 0.036271 *
M2 -0.02634 0.82356 -0.032 0.974600
M3 -0.13294 0.81227 -0.164 0.870588
M4 0.32848 0.81384 0.404 0.688027
M5 1.35658 0.81273 1.669 0.100668
M6 0.01936 0.81941 0.024 0.981238
M7 0.99076 0.81174 1.221 0.227375
M8 -0.41380 0.81571 -0.507 0.613943
M9 -0.09840 0.81226 -0.121 0.904011
M10 -0.05965 0.81473 -0.073 0.941898
M11 0.55711 0.81649 0.682 0.497848
t -0.02809 0.01592 -1.765 0.083022 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.339 on 56 degrees of freedom
Multiple R-squared: 0.728, Adjusted R-squared: 0.6599
F-statistic: 10.7 on 14 and 56 DF, p-value: 3.202e-11
> 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.1506783 0.3013565 0.8493217
[2,] 0.0610202 0.1220404 0.9389798
[3,] 0.3771116 0.7542233 0.6228884
[4,] 0.3837102 0.7674204 0.6162898
[5,] 0.5753475 0.8493051 0.4246525
[6,] 0.5514490 0.8971020 0.4485510
[7,] 0.6073411 0.7853177 0.3926589
[8,] 0.6520383 0.6959233 0.3479617
[9,] 0.5860786 0.8278428 0.4139214
[10,] 0.7075115 0.5849771 0.2924885
[11,] 0.6299154 0.7401692 0.3700846
[12,] 0.5634066 0.8731867 0.4365934
[13,] 0.4789087 0.9578173 0.5210913
[14,] 0.4122915 0.8245831 0.5877085
[15,] 0.5773519 0.8452962 0.4226481
[16,] 0.4973966 0.9947933 0.5026034
[17,] 0.4157863 0.8315727 0.5842137
[18,] 0.3475331 0.6950662 0.6524669
[19,] 0.3037750 0.6075499 0.6962250
[20,] 0.2328806 0.4657612 0.7671194
[21,] 0.1755874 0.3511748 0.8244126
[22,] 0.2209567 0.4419134 0.7790433
[23,] 0.2242688 0.4485376 0.7757312
[24,] 0.2797710 0.5595420 0.7202290
[25,] 0.2182326 0.4364652 0.7817674
[26,] 0.5396069 0.9207862 0.4603931
[27,] 0.8530298 0.2939405 0.1469702
[28,] 0.8288981 0.3422039 0.1711019
[29,] 0.7704601 0.4590798 0.2295399
[30,] 0.6809164 0.6381672 0.3190836
[31,] 0.5936996 0.8126008 0.4063004
[32,] 0.4947474 0.9894948 0.5052526
[33,] 0.6383632 0.7232737 0.3616368
[34,] 0.5450081 0.9099837 0.4549919
[35,] 0.4350308 0.8700617 0.5649692
[36,] 0.3562973 0.7125946 0.6437027
> postscript(file="/var/www/html/rcomp/tmp/1b2lz1258729064.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/250sa1258729064.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/391v71258729064.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/43apz1258729064.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/5xian1258729064.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 = 71
Frequency = 1
1 2 3 4 5 6
-1.48673541 -1.68876806 0.50987684 -1.45542989 -0.92345165 -0.09011832
7 8 9 10 11 12
-1.03343351 -1.60077773 1.17587080 0.10125492 0.51259188 -2.43418833
13 14 15 16 17 18
2.44630217 -0.41562166 0.78302325 0.34969476 1.34969476 -0.34895015
19 20 21 22 23 24
0.77169113 2.67236868 -1.14691750 -0.56164221 1.38167299 1.90291455
25 26 27 28 29 30
-0.34450790 0.45345946 -0.87987388 1.22281211 -0.30916612 0.05614545
31 32 33 34 35 36
-0.35519152 -1.92253573 0.38609104 0.84345339 -0.27718789 1.30801014
37 38 39 40 41 42
0.06058770 0.32657681 1.99324348 -0.97206325 2.09189323 -0.13872991
43 44 45 46 47 48
-2.01808864 -1.52147638 0.25517215 0.71253450 0.59189323 -0.35488698
49 50 51 52 53 54
0.46164705 2.19565793 -1.20163188 0.96097434 -0.57100390 0.79430767
55 56 57 58 59 60
1.85099248 0.21969179 0.99634032 -1.01431909 -1.53902566 -0.42184939
61 62 63 64 65 66
-1.13729360 -0.87130448 -1.20463782 -0.10598807 -1.63796631 -0.27265474
67 68 69 70 71
0.78403006 2.15272937 -1.66655681 -0.08128151 -0.66994455
> postscript(file="/var/www/html/rcomp/tmp/65zzx1258729064.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 = 71
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.48673541 NA
1 -1.68876806 -1.48673541
2 0.50987684 -1.68876806
3 -1.45542989 0.50987684
4 -0.92345165 -1.45542989
5 -0.09011832 -0.92345165
6 -1.03343351 -0.09011832
7 -1.60077773 -1.03343351
8 1.17587080 -1.60077773
9 0.10125492 1.17587080
10 0.51259188 0.10125492
11 -2.43418833 0.51259188
12 2.44630217 -2.43418833
13 -0.41562166 2.44630217
14 0.78302325 -0.41562166
15 0.34969476 0.78302325
16 1.34969476 0.34969476
17 -0.34895015 1.34969476
18 0.77169113 -0.34895015
19 2.67236868 0.77169113
20 -1.14691750 2.67236868
21 -0.56164221 -1.14691750
22 1.38167299 -0.56164221
23 1.90291455 1.38167299
24 -0.34450790 1.90291455
25 0.45345946 -0.34450790
26 -0.87987388 0.45345946
27 1.22281211 -0.87987388
28 -0.30916612 1.22281211
29 0.05614545 -0.30916612
30 -0.35519152 0.05614545
31 -1.92253573 -0.35519152
32 0.38609104 -1.92253573
33 0.84345339 0.38609104
34 -0.27718789 0.84345339
35 1.30801014 -0.27718789
36 0.06058770 1.30801014
37 0.32657681 0.06058770
38 1.99324348 0.32657681
39 -0.97206325 1.99324348
40 2.09189323 -0.97206325
41 -0.13872991 2.09189323
42 -2.01808864 -0.13872991
43 -1.52147638 -2.01808864
44 0.25517215 -1.52147638
45 0.71253450 0.25517215
46 0.59189323 0.71253450
47 -0.35488698 0.59189323
48 0.46164705 -0.35488698
49 2.19565793 0.46164705
50 -1.20163188 2.19565793
51 0.96097434 -1.20163188
52 -0.57100390 0.96097434
53 0.79430767 -0.57100390
54 1.85099248 0.79430767
55 0.21969179 1.85099248
56 0.99634032 0.21969179
57 -1.01431909 0.99634032
58 -1.53902566 -1.01431909
59 -0.42184939 -1.53902566
60 -1.13729360 -0.42184939
61 -0.87130448 -1.13729360
62 -1.20463782 -0.87130448
63 -0.10598807 -1.20463782
64 -1.63796631 -0.10598807
65 -0.27265474 -1.63796631
66 0.78403006 -0.27265474
67 2.15272937 0.78403006
68 -1.66655681 2.15272937
69 -0.08128151 -1.66655681
70 -0.66994455 -0.08128151
71 NA -0.66994455
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.68876806 -1.48673541
[2,] 0.50987684 -1.68876806
[3,] -1.45542989 0.50987684
[4,] -0.92345165 -1.45542989
[5,] -0.09011832 -0.92345165
[6,] -1.03343351 -0.09011832
[7,] -1.60077773 -1.03343351
[8,] 1.17587080 -1.60077773
[9,] 0.10125492 1.17587080
[10,] 0.51259188 0.10125492
[11,] -2.43418833 0.51259188
[12,] 2.44630217 -2.43418833
[13,] -0.41562166 2.44630217
[14,] 0.78302325 -0.41562166
[15,] 0.34969476 0.78302325
[16,] 1.34969476 0.34969476
[17,] -0.34895015 1.34969476
[18,] 0.77169113 -0.34895015
[19,] 2.67236868 0.77169113
[20,] -1.14691750 2.67236868
[21,] -0.56164221 -1.14691750
[22,] 1.38167299 -0.56164221
[23,] 1.90291455 1.38167299
[24,] -0.34450790 1.90291455
[25,] 0.45345946 -0.34450790
[26,] -0.87987388 0.45345946
[27,] 1.22281211 -0.87987388
[28,] -0.30916612 1.22281211
[29,] 0.05614545 -0.30916612
[30,] -0.35519152 0.05614545
[31,] -1.92253573 -0.35519152
[32,] 0.38609104 -1.92253573
[33,] 0.84345339 0.38609104
[34,] -0.27718789 0.84345339
[35,] 1.30801014 -0.27718789
[36,] 0.06058770 1.30801014
[37,] 0.32657681 0.06058770
[38,] 1.99324348 0.32657681
[39,] -0.97206325 1.99324348
[40,] 2.09189323 -0.97206325
[41,] -0.13872991 2.09189323
[42,] -2.01808864 -0.13872991
[43,] -1.52147638 -2.01808864
[44,] 0.25517215 -1.52147638
[45,] 0.71253450 0.25517215
[46,] 0.59189323 0.71253450
[47,] -0.35488698 0.59189323
[48,] 0.46164705 -0.35488698
[49,] 2.19565793 0.46164705
[50,] -1.20163188 2.19565793
[51,] 0.96097434 -1.20163188
[52,] -0.57100390 0.96097434
[53,] 0.79430767 -0.57100390
[54,] 1.85099248 0.79430767
[55,] 0.21969179 1.85099248
[56,] 0.99634032 0.21969179
[57,] -1.01431909 0.99634032
[58,] -1.53902566 -1.01431909
[59,] -0.42184939 -1.53902566
[60,] -1.13729360 -0.42184939
[61,] -0.87130448 -1.13729360
[62,] -1.20463782 -0.87130448
[63,] -0.10598807 -1.20463782
[64,] -1.63796631 -0.10598807
[65,] -0.27265474 -1.63796631
[66,] 0.78403006 -0.27265474
[67,] 2.15272937 0.78403006
[68,] -1.66655681 2.15272937
[69,] -0.08128151 -1.66655681
[70,] -0.66994455 -0.08128151
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.68876806 -1.48673541
2 0.50987684 -1.68876806
3 -1.45542989 0.50987684
4 -0.92345165 -1.45542989
5 -0.09011832 -0.92345165
6 -1.03343351 -0.09011832
7 -1.60077773 -1.03343351
8 1.17587080 -1.60077773
9 0.10125492 1.17587080
10 0.51259188 0.10125492
11 -2.43418833 0.51259188
12 2.44630217 -2.43418833
13 -0.41562166 2.44630217
14 0.78302325 -0.41562166
15 0.34969476 0.78302325
16 1.34969476 0.34969476
17 -0.34895015 1.34969476
18 0.77169113 -0.34895015
19 2.67236868 0.77169113
20 -1.14691750 2.67236868
21 -0.56164221 -1.14691750
22 1.38167299 -0.56164221
23 1.90291455 1.38167299
24 -0.34450790 1.90291455
25 0.45345946 -0.34450790
26 -0.87987388 0.45345946
27 1.22281211 -0.87987388
28 -0.30916612 1.22281211
29 0.05614545 -0.30916612
30 -0.35519152 0.05614545
31 -1.92253573 -0.35519152
32 0.38609104 -1.92253573
33 0.84345339 0.38609104
34 -0.27718789 0.84345339
35 1.30801014 -0.27718789
36 0.06058770 1.30801014
37 0.32657681 0.06058770
38 1.99324348 0.32657681
39 -0.97206325 1.99324348
40 2.09189323 -0.97206325
41 -0.13872991 2.09189323
42 -2.01808864 -0.13872991
43 -1.52147638 -2.01808864
44 0.25517215 -1.52147638
45 0.71253450 0.25517215
46 0.59189323 0.71253450
47 -0.35488698 0.59189323
48 0.46164705 -0.35488698
49 2.19565793 0.46164705
50 -1.20163188 2.19565793
51 0.96097434 -1.20163188
52 -0.57100390 0.96097434
53 0.79430767 -0.57100390
54 1.85099248 0.79430767
55 0.21969179 1.85099248
56 0.99634032 0.21969179
57 -1.01431909 0.99634032
58 -1.53902566 -1.01431909
59 -0.42184939 -1.53902566
60 -1.13729360 -0.42184939
61 -0.87130448 -1.13729360
62 -1.20463782 -0.87130448
63 -0.10598807 -1.20463782
64 -1.63796631 -0.10598807
65 -0.27265474 -1.63796631
66 0.78403006 -0.27265474
67 2.15272937 0.78403006
68 -1.66655681 2.15272937
69 -0.08128151 -1.66655681
70 -0.66994455 -0.08128151
> 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/7mlwb1258729064.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/8vzc31258729064.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/9jyn51258729064.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/10weov1258729064.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/11iyju1258729064.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/12j28b1258729064.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/13crdi1258729064.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/14qtat1258729064.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/15m5v41258729064.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/16rbym1258729064.tab")
+ }
> system("convert tmp/1b2lz1258729064.ps tmp/1b2lz1258729064.png")
> system("convert tmp/250sa1258729064.ps tmp/250sa1258729064.png")
> system("convert tmp/391v71258729064.ps tmp/391v71258729064.png")
> system("convert tmp/43apz1258729064.ps tmp/43apz1258729064.png")
> system("convert tmp/5xian1258729064.ps tmp/5xian1258729064.png")
> system("convert tmp/65zzx1258729064.ps tmp/65zzx1258729064.png")
> system("convert tmp/7mlwb1258729064.ps tmp/7mlwb1258729064.png")
> system("convert tmp/8vzc31258729064.ps tmp/8vzc31258729064.png")
> system("convert tmp/9jyn51258729064.ps tmp/9jyn51258729064.png")
> system("convert tmp/10weov1258729064.ps tmp/10weov1258729064.png")
>
>
> proc.time()
user system elapsed
2.467 1.536 2.936