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(9.3,98.3,9.3,112.3,8.7,113.9,8.2,106.2,8.3,98.6,8.5,96.5,8.6,95.9,8.5,103.7,8.2,103.1,8.1,103.7,7.9,112.1,8.6,86.9,8.7,95,8.7,111.8,8.5,108.8,8.4,109.3,8.5,101.4,8.7,100.5,8.7,100.7,8.6,113.5,8.5,106.1,8.3,111.6,8,114.9,8.2,88.6,8.1,99.5,8.1,115.1,8,118,7.9,111.4,7.9,107.3,8,105.3,8,105.3,7.9,117.9,8,110.2,7.7,112.4,7.2,117.5,7.5,93,7.3,103.5,7,116.3,7,120,7,114.3,7.2,104.7,7.3,109.8,7.1,112.6,6.8,114.4,6.4,115.7,6.1,114.7,6.5,118.4,7.7,94.9,7.9,103.8,7.5,115.1,6.9,113.7,6.6,104,6.9,94.3,7.7,92.5,8,93.2,8,104.7,7.7,94,7.3,98.1,7.4,102.7,8.1,82.4),dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 9.3 98.3 1 0 0 0 0 0 0 0 0 0 0 1
2 9.3 112.3 0 1 0 0 0 0 0 0 0 0 0 2
3 8.7 113.9 0 0 1 0 0 0 0 0 0 0 0 3
4 8.2 106.2 0 0 0 1 0 0 0 0 0 0 0 4
5 8.3 98.6 0 0 0 0 1 0 0 0 0 0 0 5
6 8.5 96.5 0 0 0 0 0 1 0 0 0 0 0 6
7 8.6 95.9 0 0 0 0 0 0 1 0 0 0 0 7
8 8.5 103.7 0 0 0 0 0 0 0 1 0 0 0 8
9 8.2 103.1 0 0 0 0 0 0 0 0 1 0 0 9
10 8.1 103.7 0 0 0 0 0 0 0 0 0 1 0 10
11 7.9 112.1 0 0 0 0 0 0 0 0 0 0 1 11
12 8.6 86.9 0 0 0 0 0 0 0 0 0 0 0 12
13 8.7 95.0 1 0 0 0 0 0 0 0 0 0 0 13
14 8.7 111.8 0 1 0 0 0 0 0 0 0 0 0 14
15 8.5 108.8 0 0 1 0 0 0 0 0 0 0 0 15
16 8.4 109.3 0 0 0 1 0 0 0 0 0 0 0 16
17 8.5 101.4 0 0 0 0 1 0 0 0 0 0 0 17
18 8.7 100.5 0 0 0 0 0 1 0 0 0 0 0 18
19 8.7 100.7 0 0 0 0 0 0 1 0 0 0 0 19
20 8.6 113.5 0 0 0 0 0 0 0 1 0 0 0 20
21 8.5 106.1 0 0 0 0 0 0 0 0 1 0 0 21
22 8.3 111.6 0 0 0 0 0 0 0 0 0 1 0 22
23 8.0 114.9 0 0 0 0 0 0 0 0 0 0 1 23
24 8.2 88.6 0 0 0 0 0 0 0 0 0 0 0 24
25 8.1 99.5 1 0 0 0 0 0 0 0 0 0 0 25
26 8.1 115.1 0 1 0 0 0 0 0 0 0 0 0 26
27 8.0 118.0 0 0 1 0 0 0 0 0 0 0 0 27
28 7.9 111.4 0 0 0 1 0 0 0 0 0 0 0 28
29 7.9 107.3 0 0 0 0 1 0 0 0 0 0 0 29
30 8.0 105.3 0 0 0 0 0 1 0 0 0 0 0 30
31 8.0 105.3 0 0 0 0 0 0 1 0 0 0 0 31
32 7.9 117.9 0 0 0 0 0 0 0 1 0 0 0 32
33 8.0 110.2 0 0 0 0 0 0 0 0 1 0 0 33
34 7.7 112.4 0 0 0 0 0 0 0 0 0 1 0 34
35 7.2 117.5 0 0 0 0 0 0 0 0 0 0 1 35
36 7.5 93.0 0 0 0 0 0 0 0 0 0 0 0 36
37 7.3 103.5 1 0 0 0 0 0 0 0 0 0 0 37
38 7.0 116.3 0 1 0 0 0 0 0 0 0 0 0 38
39 7.0 120.0 0 0 1 0 0 0 0 0 0 0 0 39
40 7.0 114.3 0 0 0 1 0 0 0 0 0 0 0 40
41 7.2 104.7 0 0 0 0 1 0 0 0 0 0 0 41
42 7.3 109.8 0 0 0 0 0 1 0 0 0 0 0 42
43 7.1 112.6 0 0 0 0 0 0 1 0 0 0 0 43
44 6.8 114.4 0 0 0 0 0 0 0 1 0 0 0 44
45 6.4 115.7 0 0 0 0 0 0 0 0 1 0 0 45
46 6.1 114.7 0 0 0 0 0 0 0 0 0 1 0 46
47 6.5 118.4 0 0 0 0 0 0 0 0 0 0 1 47
48 7.7 94.9 0 0 0 0 0 0 0 0 0 0 0 48
49 7.9 103.8 1 0 0 0 0 0 0 0 0 0 0 49
50 7.5 115.1 0 1 0 0 0 0 0 0 0 0 0 50
51 6.9 113.7 0 0 1 0 0 0 0 0 0 0 0 51
52 6.6 104.0 0 0 0 1 0 0 0 0 0 0 0 52
53 6.9 94.3 0 0 0 0 1 0 0 0 0 0 0 53
54 7.7 92.5 0 0 0 0 0 1 0 0 0 0 0 54
55 8.0 93.2 0 0 0 0 0 0 1 0 0 0 0 55
56 8.0 104.7 0 0 0 0 0 0 0 1 0 0 0 56
57 7.7 94.0 0 0 0 0 0 0 0 0 1 0 0 57
58 7.3 98.1 0 0 0 0 0 0 0 0 0 1 0 58
59 7.4 102.7 0 0 0 0 0 0 0 0 0 0 1 59
60 8.1 82.4 0 0 0 0 0 0 0 0 0 0 0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
12.97620 -0.04373 0.39187 0.89784 0.66044 0.23442
M5 M6 M7 M8 M9 M10
0.06357 0.35807 0.45455 0.77060 0.38045 0.24952
M11 t
0.39841 -0.02937
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.75898 -0.27038 0.04229 0.29603 0.60065
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 12.976197 0.911265 14.240 < 2e-16 ***
X -0.043730 0.009977 -4.383 6.73e-05 ***
M1 0.391874 0.278271 1.408 0.1658
M2 0.897838 0.357388 2.512 0.0156 *
M3 0.660440 0.362427 1.822 0.0749 .
M4 0.234422 0.323371 0.725 0.4722
M5 0.063568 0.282031 0.225 0.8227
M6 0.358066 0.280339 1.277 0.2079
M7 0.454546 0.282778 1.607 0.1148
M8 0.770604 0.333843 2.308 0.0255 *
M9 0.380445 0.303591 1.253 0.2165
M10 0.249517 0.316514 0.788 0.4345
M11 0.398410 0.348667 1.143 0.2591
t -0.029367 0.003053 -9.620 1.38e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4012 on 46 degrees of freedom
Multiple R-squared: 0.7497, Adjusted R-squared: 0.679
F-statistic: 10.6 on 13 and 46 DF, p-value: 7.088e-10
> 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.228883200 0.457766399 0.7711168
[2,] 0.107884881 0.215769761 0.8921151
[3,] 0.048682230 0.097364461 0.9513178
[4,] 0.033661354 0.067322709 0.9663386
[5,] 0.022678011 0.045356022 0.9773220
[6,] 0.010854611 0.021709223 0.9891454
[7,] 0.004547492 0.009094985 0.9954525
[8,] 0.004542384 0.009084768 0.9954576
[9,] 0.035463639 0.070927279 0.9645364
[10,] 0.054002234 0.108004468 0.9459978
[11,] 0.048350237 0.096700475 0.9516498
[12,] 0.031937273 0.063874546 0.9680627
[13,] 0.030858638 0.061717276 0.9691414
[14,] 0.021530542 0.043061085 0.9784695
[15,] 0.014785105 0.029570209 0.9852149
[16,] 0.012819117 0.025638233 0.9871809
[17,] 0.014402186 0.028804372 0.9855978
[18,] 0.043296131 0.086592262 0.9567039
[19,] 0.054133547 0.108267094 0.9458665
[20,] 0.044471345 0.088942690 0.9555287
[21,] 0.091109066 0.182218131 0.9088909
[22,] 0.226298611 0.452597221 0.7737014
[23,] 0.188982608 0.377965217 0.8110174
[24,] 0.244152924 0.488305849 0.7558471
[25,] 0.508492298 0.983015404 0.4915077
[26,] 0.618088223 0.763823553 0.3819118
[27,] 0.518257269 0.963485461 0.4817427
> postscript(file="/var/www/html/rcomp/tmp/1u3n51258718554.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/2a5zm1258718554.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/3uorf1258718554.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/4000f1258718554.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/5vg971258718554.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 = 60
Frequency = 1
1 2 3 4 5
0.2599780469 0.3956050227 0.1323384263 -0.2489998246 -0.2811283810
6 7 8 9 10
-0.4380936077 -0.4314445034 -0.4770398671 -0.3837521955 -0.2972190028
11 12 13 14 15
-0.2494107833 -0.2236362840 -0.1319287851 0.1261428695 0.0617171579
16 17 18 19 20
0.4389668950 0.3937192659 0.2892303301 0.2308636283 0.4039194769
21 22 23 24 25
0.3998414999 0.6006528805 0.3254368635 -0.1968919038 -0.1827397261
26 27 28 29 30
0.0228556376 0.3164383564 0.3832033722 0.4041306643 0.1515384619
31 32 33 34 35
0.0844257116 0.2487355116 0.4315384619 0.3880400425 -0.0084615381
36 37 38 39 40
-0.3520758690 -0.4554157883 -0.6722651034 -0.2436981907 -0.0375759567
41 42 43 44 45
-0.0571649980 0.0007275209 -0.1439405506 -0.6519173689 -0.5755422366
46 47 48 49 50
-0.7589774319 -0.3167013519 0.2834145596 0.5101062525 0.1276615737
51 52 53 54 55
-0.2667957500 -0.5355944858 -0.4595565513 -0.0034027053 0.2600957141
56 57 58 59 60
0.4763022475 0.1279144704 0.0675035116 0.2491368098 0.4891894972
> postscript(file="/var/www/html/rcomp/tmp/6or961258718554.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 0.2599780469 NA
1 0.3956050227 0.2599780469
2 0.1323384263 0.3956050227
3 -0.2489998246 0.1323384263
4 -0.2811283810 -0.2489998246
5 -0.4380936077 -0.2811283810
6 -0.4314445034 -0.4380936077
7 -0.4770398671 -0.4314445034
8 -0.3837521955 -0.4770398671
9 -0.2972190028 -0.3837521955
10 -0.2494107833 -0.2972190028
11 -0.2236362840 -0.2494107833
12 -0.1319287851 -0.2236362840
13 0.1261428695 -0.1319287851
14 0.0617171579 0.1261428695
15 0.4389668950 0.0617171579
16 0.3937192659 0.4389668950
17 0.2892303301 0.3937192659
18 0.2308636283 0.2892303301
19 0.4039194769 0.2308636283
20 0.3998414999 0.4039194769
21 0.6006528805 0.3998414999
22 0.3254368635 0.6006528805
23 -0.1968919038 0.3254368635
24 -0.1827397261 -0.1968919038
25 0.0228556376 -0.1827397261
26 0.3164383564 0.0228556376
27 0.3832033722 0.3164383564
28 0.4041306643 0.3832033722
29 0.1515384619 0.4041306643
30 0.0844257116 0.1515384619
31 0.2487355116 0.0844257116
32 0.4315384619 0.2487355116
33 0.3880400425 0.4315384619
34 -0.0084615381 0.3880400425
35 -0.3520758690 -0.0084615381
36 -0.4554157883 -0.3520758690
37 -0.6722651034 -0.4554157883
38 -0.2436981907 -0.6722651034
39 -0.0375759567 -0.2436981907
40 -0.0571649980 -0.0375759567
41 0.0007275209 -0.0571649980
42 -0.1439405506 0.0007275209
43 -0.6519173689 -0.1439405506
44 -0.5755422366 -0.6519173689
45 -0.7589774319 -0.5755422366
46 -0.3167013519 -0.7589774319
47 0.2834145596 -0.3167013519
48 0.5101062525 0.2834145596
49 0.1276615737 0.5101062525
50 -0.2667957500 0.1276615737
51 -0.5355944858 -0.2667957500
52 -0.4595565513 -0.5355944858
53 -0.0034027053 -0.4595565513
54 0.2600957141 -0.0034027053
55 0.4763022475 0.2600957141
56 0.1279144704 0.4763022475
57 0.0675035116 0.1279144704
58 0.2491368098 0.0675035116
59 0.4891894972 0.2491368098
60 NA 0.4891894972
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.3956050227 0.2599780469
[2,] 0.1323384263 0.3956050227
[3,] -0.2489998246 0.1323384263
[4,] -0.2811283810 -0.2489998246
[5,] -0.4380936077 -0.2811283810
[6,] -0.4314445034 -0.4380936077
[7,] -0.4770398671 -0.4314445034
[8,] -0.3837521955 -0.4770398671
[9,] -0.2972190028 -0.3837521955
[10,] -0.2494107833 -0.2972190028
[11,] -0.2236362840 -0.2494107833
[12,] -0.1319287851 -0.2236362840
[13,] 0.1261428695 -0.1319287851
[14,] 0.0617171579 0.1261428695
[15,] 0.4389668950 0.0617171579
[16,] 0.3937192659 0.4389668950
[17,] 0.2892303301 0.3937192659
[18,] 0.2308636283 0.2892303301
[19,] 0.4039194769 0.2308636283
[20,] 0.3998414999 0.4039194769
[21,] 0.6006528805 0.3998414999
[22,] 0.3254368635 0.6006528805
[23,] -0.1968919038 0.3254368635
[24,] -0.1827397261 -0.1968919038
[25,] 0.0228556376 -0.1827397261
[26,] 0.3164383564 0.0228556376
[27,] 0.3832033722 0.3164383564
[28,] 0.4041306643 0.3832033722
[29,] 0.1515384619 0.4041306643
[30,] 0.0844257116 0.1515384619
[31,] 0.2487355116 0.0844257116
[32,] 0.4315384619 0.2487355116
[33,] 0.3880400425 0.4315384619
[34,] -0.0084615381 0.3880400425
[35,] -0.3520758690 -0.0084615381
[36,] -0.4554157883 -0.3520758690
[37,] -0.6722651034 -0.4554157883
[38,] -0.2436981907 -0.6722651034
[39,] -0.0375759567 -0.2436981907
[40,] -0.0571649980 -0.0375759567
[41,] 0.0007275209 -0.0571649980
[42,] -0.1439405506 0.0007275209
[43,] -0.6519173689 -0.1439405506
[44,] -0.5755422366 -0.6519173689
[45,] -0.7589774319 -0.5755422366
[46,] -0.3167013519 -0.7589774319
[47,] 0.2834145596 -0.3167013519
[48,] 0.5101062525 0.2834145596
[49,] 0.1276615737 0.5101062525
[50,] -0.2667957500 0.1276615737
[51,] -0.5355944858 -0.2667957500
[52,] -0.4595565513 -0.5355944858
[53,] -0.0034027053 -0.4595565513
[54,] 0.2600957141 -0.0034027053
[55,] 0.4763022475 0.2600957141
[56,] 0.1279144704 0.4763022475
[57,] 0.0675035116 0.1279144704
[58,] 0.2491368098 0.0675035116
[59,] 0.4891894972 0.2491368098
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.3956050227 0.2599780469
2 0.1323384263 0.3956050227
3 -0.2489998246 0.1323384263
4 -0.2811283810 -0.2489998246
5 -0.4380936077 -0.2811283810
6 -0.4314445034 -0.4380936077
7 -0.4770398671 -0.4314445034
8 -0.3837521955 -0.4770398671
9 -0.2972190028 -0.3837521955
10 -0.2494107833 -0.2972190028
11 -0.2236362840 -0.2494107833
12 -0.1319287851 -0.2236362840
13 0.1261428695 -0.1319287851
14 0.0617171579 0.1261428695
15 0.4389668950 0.0617171579
16 0.3937192659 0.4389668950
17 0.2892303301 0.3937192659
18 0.2308636283 0.2892303301
19 0.4039194769 0.2308636283
20 0.3998414999 0.4039194769
21 0.6006528805 0.3998414999
22 0.3254368635 0.6006528805
23 -0.1968919038 0.3254368635
24 -0.1827397261 -0.1968919038
25 0.0228556376 -0.1827397261
26 0.3164383564 0.0228556376
27 0.3832033722 0.3164383564
28 0.4041306643 0.3832033722
29 0.1515384619 0.4041306643
30 0.0844257116 0.1515384619
31 0.2487355116 0.0844257116
32 0.4315384619 0.2487355116
33 0.3880400425 0.4315384619
34 -0.0084615381 0.3880400425
35 -0.3520758690 -0.0084615381
36 -0.4554157883 -0.3520758690
37 -0.6722651034 -0.4554157883
38 -0.2436981907 -0.6722651034
39 -0.0375759567 -0.2436981907
40 -0.0571649980 -0.0375759567
41 0.0007275209 -0.0571649980
42 -0.1439405506 0.0007275209
43 -0.6519173689 -0.1439405506
44 -0.5755422366 -0.6519173689
45 -0.7589774319 -0.5755422366
46 -0.3167013519 -0.7589774319
47 0.2834145596 -0.3167013519
48 0.5101062525 0.2834145596
49 0.1276615737 0.5101062525
50 -0.2667957500 0.1276615737
51 -0.5355944858 -0.2667957500
52 -0.4595565513 -0.5355944858
53 -0.0034027053 -0.4595565513
54 0.2600957141 -0.0034027053
55 0.4763022475 0.2600957141
56 0.1279144704 0.4763022475
57 0.0675035116 0.1279144704
58 0.2491368098 0.0675035116
59 0.4891894972 0.2491368098
> 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/7nrac1258718554.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/8ess61258718554.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/91a011258718554.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/104e161258718554.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/1147xa1258718554.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/12c9s01258718555.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/13bdvt1258718555.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/14qcd91258718555.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/15rr1c1258718555.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/1686z81258718555.tab")
+ }
>
> system("convert tmp/1u3n51258718554.ps tmp/1u3n51258718554.png")
> system("convert tmp/2a5zm1258718554.ps tmp/2a5zm1258718554.png")
> system("convert tmp/3uorf1258718554.ps tmp/3uorf1258718554.png")
> system("convert tmp/4000f1258718554.ps tmp/4000f1258718554.png")
> system("convert tmp/5vg971258718554.ps tmp/5vg971258718554.png")
> system("convert tmp/6or961258718554.ps tmp/6or961258718554.png")
> system("convert tmp/7nrac1258718554.ps tmp/7nrac1258718554.png")
> system("convert tmp/8ess61258718554.ps tmp/8ess61258718554.png")
> system("convert tmp/91a011258718554.ps tmp/91a011258718554.png")
> system("convert tmp/104e161258718554.ps tmp/104e161258718554.png")
>
>
> proc.time()
user system elapsed
2.402 1.587 2.827