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(103.91
+ ,89.00
+ ,103.88
+ ,103.77
+ ,103.91
+ ,86.40
+ ,103.91
+ ,103.88
+ ,103.92
+ ,84.50
+ ,103.91
+ ,103.91
+ ,104.05
+ ,82.70
+ ,103.92
+ ,103.91
+ ,104.23
+ ,80.80
+ ,104.05
+ ,103.92
+ ,104.30
+ ,81.80
+ ,104.23
+ ,104.05
+ ,104.31
+ ,81.80
+ ,104.30
+ ,104.23
+ ,104.31
+ ,82.90
+ ,104.31
+ ,104.30
+ ,104.34
+ ,83.80
+ ,104.31
+ ,104.31
+ ,104.55
+ ,86.20
+ ,104.34
+ ,104.31
+ ,104.65
+ ,86.10
+ ,104.55
+ ,104.34
+ ,104.73
+ ,86.20
+ ,104.65
+ ,104.55
+ ,104.75
+ ,88.80
+ ,104.73
+ ,104.65
+ ,104.75
+ ,89.60
+ ,104.75
+ ,104.73
+ ,104.76
+ ,87.80
+ ,104.75
+ ,104.75
+ ,104.94
+ ,88.30
+ ,104.76
+ ,104.75
+ ,105.29
+ ,88.60
+ ,104.94
+ ,104.76
+ ,105.38
+ ,91.00
+ ,105.29
+ ,104.94
+ ,105.43
+ ,91.50
+ ,105.38
+ ,105.29
+ ,105.43
+ ,95.40
+ ,105.43
+ ,105.38
+ ,105.42
+ ,98.70
+ ,105.43
+ ,105.43
+ ,105.52
+ ,99.90
+ ,105.42
+ ,105.43
+ ,105.69
+ ,98.60
+ ,105.52
+ ,105.42
+ ,105.72
+ ,100.30
+ ,105.69
+ ,105.52
+ ,105.74
+ ,100.20
+ ,105.72
+ ,105.69
+ ,105.74
+ ,100.40
+ ,105.74
+ ,105.72
+ ,105.74
+ ,101.40
+ ,105.74
+ ,105.74
+ ,105.95
+ ,103.00
+ ,105.74
+ ,105.74
+ ,106.17
+ ,109.10
+ ,105.95
+ ,105.74
+ ,106.34
+ ,111.40
+ ,106.17
+ ,105.95
+ ,106.37
+ ,114.10
+ ,106.34
+ ,106.17
+ ,106.37
+ ,121.80
+ ,106.37
+ ,106.34
+ ,106.36
+ ,127.60
+ ,106.37
+ ,106.37
+ ,106.44
+ ,129.90
+ ,106.36
+ ,106.37
+ ,106.29
+ ,128.00
+ ,106.44
+ ,106.36
+ ,106.23
+ ,123.50
+ ,106.29
+ ,106.44
+ ,106.23
+ ,124.00
+ ,106.23
+ ,106.29
+ ,106.23
+ ,127.40
+ ,106.23
+ ,106.23
+ ,106.23
+ ,127.60
+ ,106.23
+ ,106.23
+ ,106.34
+ ,128.40
+ ,106.23
+ ,106.23
+ ,106.44
+ ,131.40
+ ,106.34
+ ,106.23
+ ,106.44
+ ,135.10
+ ,106.44
+ ,106.34
+ ,106.48
+ ,134.00
+ ,106.44
+ ,106.44
+ ,106.50
+ ,144.50
+ ,106.48
+ ,106.44
+ ,106.57
+ ,147.30
+ ,106.50
+ ,106.48
+ ,106.40
+ ,150.90
+ ,106.57
+ ,106.50
+ ,106.37
+ ,148.70
+ ,106.40
+ ,106.57
+ ,106.25
+ ,141.40
+ ,106.37
+ ,106.40
+ ,106.21
+ ,138.90
+ ,106.25
+ ,106.37
+ ,106.21
+ ,139.80
+ ,106.21
+ ,106.25
+ ,106.24
+ ,145.60
+ ,106.21
+ ,106.21
+ ,106.19
+ ,147.90
+ ,106.24
+ ,106.21
+ ,106.08
+ ,148.50
+ ,106.19
+ ,106.24
+ ,106.13
+ ,151.10
+ ,106.08
+ ,106.19
+ ,106.09
+ ,157.50
+ ,106.13
+ ,106.08)
+ ,dim=c(4
+ ,55)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2
')
+ ,1:55))
> y <- array(NA,dim=c(4,55),dimnames=list(c('Y','X','Y1','Y2
'),1:55))
> 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 = 'Do not include Seasonal 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\r t
1 103.91 89.0 103.88 103.77 1
2 103.91 86.4 103.91 103.88 2
3 103.92 84.5 103.91 103.91 3
4 104.05 82.7 103.92 103.91 4
5 104.23 80.8 104.05 103.92 5
6 104.30 81.8 104.23 104.05 6
7 104.31 81.8 104.30 104.23 7
8 104.31 82.9 104.31 104.30 8
9 104.34 83.8 104.31 104.31 9
10 104.55 86.2 104.34 104.31 10
11 104.65 86.1 104.55 104.34 11
12 104.73 86.2 104.65 104.55 12
13 104.75 88.8 104.73 104.65 13
14 104.75 89.6 104.75 104.73 14
15 104.76 87.8 104.75 104.75 15
16 104.94 88.3 104.76 104.75 16
17 105.29 88.6 104.94 104.76 17
18 105.38 91.0 105.29 104.94 18
19 105.43 91.5 105.38 105.29 19
20 105.43 95.4 105.43 105.38 20
21 105.42 98.7 105.43 105.43 21
22 105.52 99.9 105.42 105.43 22
23 105.69 98.6 105.52 105.42 23
24 105.72 100.3 105.69 105.52 24
25 105.74 100.2 105.72 105.69 25
26 105.74 100.4 105.74 105.72 26
27 105.74 101.4 105.74 105.74 27
28 105.95 103.0 105.74 105.74 28
29 106.17 109.1 105.95 105.74 29
30 106.34 111.4 106.17 105.95 30
31 106.37 114.1 106.34 106.17 31
32 106.37 121.8 106.37 106.34 32
33 106.36 127.6 106.37 106.37 33
34 106.44 129.9 106.36 106.37 34
35 106.29 128.0 106.44 106.36 35
36 106.23 123.5 106.29 106.44 36
37 106.23 124.0 106.23 106.29 37
38 106.23 127.4 106.23 106.23 38
39 106.23 127.6 106.23 106.23 39
40 106.34 128.4 106.23 106.23 40
41 106.44 131.4 106.34 106.23 41
42 106.44 135.1 106.44 106.34 42
43 106.48 134.0 106.44 106.44 43
44 106.50 144.5 106.48 106.44 44
45 106.57 147.3 106.50 106.48 45
46 106.40 150.9 106.57 106.50 46
47 106.37 148.7 106.40 106.57 47
48 106.25 141.4 106.37 106.40 48
49 106.21 138.9 106.25 106.37 49
50 106.21 139.8 106.21 106.25 50
51 106.24 145.6 106.21 106.21 51
52 106.19 147.9 106.24 106.21 52
53 106.08 148.5 106.19 106.24 53
54 106.13 151.1 106.08 106.19 54
55 106.09 157.5 106.13 106.08 55
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 `Y2\r` t
2.851332 -0.004682 1.266511 -0.289999 0.006459
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.15137 -0.06080 -0.01914 0.06217 0.21620
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.851332 3.467109 0.822 0.4148
X -0.004682 0.001887 -2.481 0.0165 *
Y1 1.266511 0.128257 9.875 2.45e-13 ***
`Y2\r` -0.289999 0.133035 -2.180 0.0340 *
t 0.006459 0.003566 1.811 0.0761 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.08089 on 50 degrees of freedom
Multiple R-squared: 0.9916, Adjusted R-squared: 0.9909
F-statistic: 1478 on 4 and 50 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.046505192 0.09301038 0.95349481
[2,] 0.015752703 0.03150541 0.98424730
[3,] 0.031796913 0.06359383 0.96820309
[4,] 0.038903808 0.07780762 0.96109619
[5,] 0.034918175 0.06983635 0.96508183
[6,] 0.016364705 0.03272941 0.98363529
[7,] 0.009041332 0.01808266 0.99095867
[8,] 0.010299996 0.02059999 0.98970000
[9,] 0.006820844 0.01364169 0.99317916
[10,] 0.098844228 0.19768846 0.90115577
[11,] 0.065064545 0.13012909 0.93493545
[12,] 0.282858853 0.56571771 0.71714115
[13,] 0.248402936 0.49680587 0.75159706
[14,] 0.210577172 0.42115434 0.78942283
[15,] 0.160419037 0.32083807 0.83958096
[16,] 0.127177752 0.25435550 0.87282225
[17,] 0.150412331 0.30082466 0.84958767
[18,] 0.128239490 0.25647898 0.87176051
[19,] 0.169209118 0.33841824 0.83079088
[20,] 0.352493072 0.70498614 0.64750693
[21,] 0.305721589 0.61144318 0.69427841
[22,] 0.241953670 0.48390734 0.75804633
[23,] 0.213860805 0.42772161 0.78613919
[24,] 0.158781176 0.31756235 0.84121882
[25,] 0.113115163 0.22623033 0.88688484
[26,] 0.085409494 0.17081899 0.91459051
[27,] 0.073076873 0.14615375 0.92692313
[28,] 0.536687754 0.92662449 0.46331225
[29,] 0.573330133 0.85333973 0.42666987
[30,] 0.602238744 0.79552251 0.39776126
[31,] 0.678537219 0.64292556 0.32146278
[32,] 0.859139732 0.28172054 0.14086027
[33,] 0.893333421 0.21333316 0.10666658
[34,] 0.880633124 0.23873375 0.11936688
[35,] 0.962619956 0.07476009 0.03738004
[36,] 0.935881922 0.12823616 0.06411808
[37,] 0.978036620 0.04392676 0.02196338
[38,] 0.981675429 0.03664914 0.01832457
[39,] 0.959295032 0.08140994 0.04070497
[40,] 0.906090928 0.18781814 0.09390907
> postscript(file="/var/www/html/rcomp/tmp/1h3ea1258577839.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/23bsg1258577839.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/3u3s71258577839.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/4rvoo1258577839.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/5pau91258577839.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 = 55
Frequency = 1
1 2 3 4 5 6
-0.003173606 -0.027901143 -0.024555936 0.077892383 0.080791125 -0.041258571
7 8 9 10 11 12
-0.074173907 -0.067848378 -0.037194013 0.139587769 -0.024607140 -0.016349682
13 14 15 16 17 18
-0.062957254 -0.067801404 -0.066888000 0.096328532 0.216201729 -0.080100429
19 20 21 22 23 24
-0.046705327 -0.072131159 -0.058640456 0.053183588 0.081086803 -0.073720452
25 26 27 28 29 30
-0.049343497 -0.071496673 -0.067474140 0.143557522 0.119690014 0.076266122
31 32 33 34 35 36
-0.039059476 0.001835767 0.021231078 0.118205137 -0.151370517 -0.025721422
37 38 39 40 41 42
0.002651134 -0.005289820 -0.010812722 0.096473474 0.064743436 -0.019144365
43 44 45 46 47 48
0.038246205 0.050285710 0.113205281 -0.129255227 0.059592325 -0.112348722
49 50 51 52 53 54
-0.027231148 -0.013616133 0.025479281 -0.058207120 -0.099831759 0.080698072
55
-0.031022888
> postscript(file="/var/www/html/rcomp/tmp/6aff81258577839.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 = 55
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.003173606 NA
1 -0.027901143 -0.003173606
2 -0.024555936 -0.027901143
3 0.077892383 -0.024555936
4 0.080791125 0.077892383
5 -0.041258571 0.080791125
6 -0.074173907 -0.041258571
7 -0.067848378 -0.074173907
8 -0.037194013 -0.067848378
9 0.139587769 -0.037194013
10 -0.024607140 0.139587769
11 -0.016349682 -0.024607140
12 -0.062957254 -0.016349682
13 -0.067801404 -0.062957254
14 -0.066888000 -0.067801404
15 0.096328532 -0.066888000
16 0.216201729 0.096328532
17 -0.080100429 0.216201729
18 -0.046705327 -0.080100429
19 -0.072131159 -0.046705327
20 -0.058640456 -0.072131159
21 0.053183588 -0.058640456
22 0.081086803 0.053183588
23 -0.073720452 0.081086803
24 -0.049343497 -0.073720452
25 -0.071496673 -0.049343497
26 -0.067474140 -0.071496673
27 0.143557522 -0.067474140
28 0.119690014 0.143557522
29 0.076266122 0.119690014
30 -0.039059476 0.076266122
31 0.001835767 -0.039059476
32 0.021231078 0.001835767
33 0.118205137 0.021231078
34 -0.151370517 0.118205137
35 -0.025721422 -0.151370517
36 0.002651134 -0.025721422
37 -0.005289820 0.002651134
38 -0.010812722 -0.005289820
39 0.096473474 -0.010812722
40 0.064743436 0.096473474
41 -0.019144365 0.064743436
42 0.038246205 -0.019144365
43 0.050285710 0.038246205
44 0.113205281 0.050285710
45 -0.129255227 0.113205281
46 0.059592325 -0.129255227
47 -0.112348722 0.059592325
48 -0.027231148 -0.112348722
49 -0.013616133 -0.027231148
50 0.025479281 -0.013616133
51 -0.058207120 0.025479281
52 -0.099831759 -0.058207120
53 0.080698072 -0.099831759
54 -0.031022888 0.080698072
55 NA -0.031022888
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.027901143 -0.003173606
[2,] -0.024555936 -0.027901143
[3,] 0.077892383 -0.024555936
[4,] 0.080791125 0.077892383
[5,] -0.041258571 0.080791125
[6,] -0.074173907 -0.041258571
[7,] -0.067848378 -0.074173907
[8,] -0.037194013 -0.067848378
[9,] 0.139587769 -0.037194013
[10,] -0.024607140 0.139587769
[11,] -0.016349682 -0.024607140
[12,] -0.062957254 -0.016349682
[13,] -0.067801404 -0.062957254
[14,] -0.066888000 -0.067801404
[15,] 0.096328532 -0.066888000
[16,] 0.216201729 0.096328532
[17,] -0.080100429 0.216201729
[18,] -0.046705327 -0.080100429
[19,] -0.072131159 -0.046705327
[20,] -0.058640456 -0.072131159
[21,] 0.053183588 -0.058640456
[22,] 0.081086803 0.053183588
[23,] -0.073720452 0.081086803
[24,] -0.049343497 -0.073720452
[25,] -0.071496673 -0.049343497
[26,] -0.067474140 -0.071496673
[27,] 0.143557522 -0.067474140
[28,] 0.119690014 0.143557522
[29,] 0.076266122 0.119690014
[30,] -0.039059476 0.076266122
[31,] 0.001835767 -0.039059476
[32,] 0.021231078 0.001835767
[33,] 0.118205137 0.021231078
[34,] -0.151370517 0.118205137
[35,] -0.025721422 -0.151370517
[36,] 0.002651134 -0.025721422
[37,] -0.005289820 0.002651134
[38,] -0.010812722 -0.005289820
[39,] 0.096473474 -0.010812722
[40,] 0.064743436 0.096473474
[41,] -0.019144365 0.064743436
[42,] 0.038246205 -0.019144365
[43,] 0.050285710 0.038246205
[44,] 0.113205281 0.050285710
[45,] -0.129255227 0.113205281
[46,] 0.059592325 -0.129255227
[47,] -0.112348722 0.059592325
[48,] -0.027231148 -0.112348722
[49,] -0.013616133 -0.027231148
[50,] 0.025479281 -0.013616133
[51,] -0.058207120 0.025479281
[52,] -0.099831759 -0.058207120
[53,] 0.080698072 -0.099831759
[54,] -0.031022888 0.080698072
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.027901143 -0.003173606
2 -0.024555936 -0.027901143
3 0.077892383 -0.024555936
4 0.080791125 0.077892383
5 -0.041258571 0.080791125
6 -0.074173907 -0.041258571
7 -0.067848378 -0.074173907
8 -0.037194013 -0.067848378
9 0.139587769 -0.037194013
10 -0.024607140 0.139587769
11 -0.016349682 -0.024607140
12 -0.062957254 -0.016349682
13 -0.067801404 -0.062957254
14 -0.066888000 -0.067801404
15 0.096328532 -0.066888000
16 0.216201729 0.096328532
17 -0.080100429 0.216201729
18 -0.046705327 -0.080100429
19 -0.072131159 -0.046705327
20 -0.058640456 -0.072131159
21 0.053183588 -0.058640456
22 0.081086803 0.053183588
23 -0.073720452 0.081086803
24 -0.049343497 -0.073720452
25 -0.071496673 -0.049343497
26 -0.067474140 -0.071496673
27 0.143557522 -0.067474140
28 0.119690014 0.143557522
29 0.076266122 0.119690014
30 -0.039059476 0.076266122
31 0.001835767 -0.039059476
32 0.021231078 0.001835767
33 0.118205137 0.021231078
34 -0.151370517 0.118205137
35 -0.025721422 -0.151370517
36 0.002651134 -0.025721422
37 -0.005289820 0.002651134
38 -0.010812722 -0.005289820
39 0.096473474 -0.010812722
40 0.064743436 0.096473474
41 -0.019144365 0.064743436
42 0.038246205 -0.019144365
43 0.050285710 0.038246205
44 0.113205281 0.050285710
45 -0.129255227 0.113205281
46 0.059592325 -0.129255227
47 -0.112348722 0.059592325
48 -0.027231148 -0.112348722
49 -0.013616133 -0.027231148
50 0.025479281 -0.013616133
51 -0.058207120 0.025479281
52 -0.099831759 -0.058207120
53 0.080698072 -0.099831759
54 -0.031022888 0.080698072
> 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/7tysp1258577839.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/8fqhy1258577839.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/9uvfv1258577839.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/10rnk71258577839.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/11hvb01258577839.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/12kcfw1258577839.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/13wqki1258577839.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/14a7om1258577840.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/15rw681258577840.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/16s5z61258577840.tab")
+ }
>
> system("convert tmp/1h3ea1258577839.ps tmp/1h3ea1258577839.png")
> system("convert tmp/23bsg1258577839.ps tmp/23bsg1258577839.png")
> system("convert tmp/3u3s71258577839.ps tmp/3u3s71258577839.png")
> system("convert tmp/4rvoo1258577839.ps tmp/4rvoo1258577839.png")
> system("convert tmp/5pau91258577839.ps tmp/5pau91258577839.png")
> system("convert tmp/6aff81258577839.ps tmp/6aff81258577839.png")
> system("convert tmp/7tysp1258577839.ps tmp/7tysp1258577839.png")
> system("convert tmp/8fqhy1258577839.ps tmp/8fqhy1258577839.png")
> system("convert tmp/9uvfv1258577839.ps tmp/9uvfv1258577839.png")
> system("convert tmp/10rnk71258577839.ps tmp/10rnk71258577839.png")
>
>
> proc.time()
user system elapsed
2.416 1.592 3.036