R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(1
+ ,1
+ ,1
+ ,1167
+ ,333
+ ,70
+ ,1
+ ,2
+ ,2
+ ,669
+ ,223
+ ,44
+ ,1
+ ,3
+ ,3
+ ,1053
+ ,371
+ ,35
+ ,1
+ ,4
+ ,4
+ ,1939
+ ,873
+ ,119
+ ,1
+ ,5
+ ,5
+ ,678
+ ,186
+ ,30
+ ,1
+ ,6
+ ,6
+ ,321
+ ,111
+ ,23
+ ,1
+ ,7
+ ,7
+ ,2667
+ ,1277
+ ,46
+ ,1
+ ,8
+ ,8
+ ,345
+ ,102
+ ,39
+ ,1
+ ,9
+ ,9
+ ,1367
+ ,580
+ ,58
+ ,1
+ ,10
+ ,10
+ ,1158
+ ,420
+ ,51
+ ,1
+ ,11
+ ,11
+ ,1385
+ ,521
+ ,65
+ ,1
+ ,12
+ ,12
+ ,1155
+ ,358
+ ,40
+ ,1
+ ,13
+ ,13
+ ,1120
+ ,435
+ ,41
+ ,1
+ ,14
+ ,14
+ ,1703
+ ,690
+ ,76
+ ,1
+ ,15
+ ,15
+ ,1189
+ ,393
+ ,31
+ ,1
+ ,16
+ ,16
+ ,3083
+ ,1149
+ ,82
+ ,1
+ ,17
+ ,17
+ ,1357
+ ,486
+ ,36
+ ,1
+ ,18
+ ,18
+ ,1892
+ ,767
+ ,62
+ ,1
+ ,19
+ ,19
+ ,883
+ ,338
+ ,28
+ ,1
+ ,20
+ ,20
+ ,1627
+ ,485
+ ,38
+ ,1
+ ,21
+ ,21
+ ,1412
+ ,465
+ ,70
+ ,1
+ ,22
+ ,22
+ ,1900
+ ,816
+ ,76
+ ,1
+ ,23
+ ,23
+ ,777
+ ,265
+ ,33
+ ,1
+ ,24
+ ,24
+ ,904
+ ,307
+ ,40
+ ,1
+ ,25
+ ,25
+ ,2115
+ ,850
+ ,126
+ ,1
+ ,26
+ ,26
+ ,1858
+ ,704
+ ,56
+ ,1
+ ,27
+ ,27
+ ,1781
+ ,693
+ ,63
+ ,1
+ ,28
+ ,28
+ ,1286
+ ,387
+ ,46
+ ,1
+ ,29
+ ,29
+ ,1035
+ ,406
+ ,35
+ ,1
+ ,30
+ ,30
+ ,1557
+ ,573
+ ,108
+ ,1
+ ,31
+ ,31
+ ,1527
+ ,595
+ ,34
+ ,1
+ ,32
+ ,32
+ ,1220
+ ,394
+ ,54
+ ,1
+ ,33
+ ,33
+ ,1368
+ ,521
+ ,35
+ ,0
+ ,34
+ ,0
+ ,564
+ ,172
+ ,23
+ ,0
+ ,35
+ ,0
+ ,1990
+ ,835
+ ,46
+ ,0
+ ,36
+ ,0
+ ,1557
+ ,669
+ ,49
+ ,0
+ ,37
+ ,0
+ ,2057
+ ,749
+ ,56
+ ,0
+ ,38
+ ,0
+ ,1111
+ ,368
+ ,38
+ ,0
+ ,39
+ ,0
+ ,686
+ ,216
+ ,19
+ ,0
+ ,40
+ ,0
+ ,2011
+ ,772
+ ,29
+ ,0
+ ,41
+ ,0
+ ,2232
+ ,1084
+ ,26
+ ,0
+ ,42
+ ,0
+ ,1032
+ ,445
+ ,52
+ ,0
+ ,43
+ ,0
+ ,1166
+ ,451
+ ,54
+ ,0
+ ,44
+ ,0
+ ,1020
+ ,300
+ ,45
+ ,0
+ ,45
+ ,0
+ ,1735
+ ,836
+ ,56
+ ,0
+ ,46
+ ,0
+ ,3623
+ ,1417
+ ,596
+ ,0
+ ,47
+ ,0
+ ,918
+ ,330
+ ,57
+ ,0
+ ,48
+ ,0
+ ,1579
+ ,477
+ ,55
+ ,0
+ ,49
+ ,0
+ ,2790
+ ,1028
+ ,99
+ ,0
+ ,50
+ ,0
+ ,1496
+ ,646
+ ,51
+ ,0
+ ,51
+ ,0
+ ,1108
+ ,342
+ ,21
+ ,0
+ ,52
+ ,0
+ ,496
+ ,218
+ ,20
+ ,0
+ ,53
+ ,0
+ ,1750
+ ,591
+ ,58
+ ,0
+ ,54
+ ,0
+ ,744
+ ,255
+ ,21
+ ,0
+ ,55
+ ,0
+ ,1101
+ ,434
+ ,66
+ ,0
+ ,56
+ ,0
+ ,1612
+ ,654
+ ,47
+ ,0
+ ,57
+ ,0
+ ,1805
+ ,478
+ ,55
+ ,0
+ ,58
+ ,0
+ ,2460
+ ,753
+ ,158
+ ,0
+ ,59
+ ,0
+ ,1653
+ ,689
+ ,46
+ ,0
+ ,60
+ ,0
+ ,1234
+ ,470
+ ,45)
+ ,dim=c(6
+ ,60)
+ ,dimnames=list(c('Pop'
+ ,'t'
+ ,'pop_t'
+ ,'TotalNrPV'
+ ,'TotalNrCC'
+ ,'TotalNrPRV')
+ ,1:60))
> y <- array(NA,dim=c(6,60),dimnames=list(c('Pop','t','pop_t','TotalNrPV','TotalNrCC','TotalNrPRV'),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 = 'No Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '4'
> library(lattice)
> library(lmtest)
Loading required package: zoo
> 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
TotalNrPV Pop t pop_t TotalNrCC TotalNrPRV
1 1167 1 1 1 333 70
2 669 1 2 2 223 44
3 1053 1 3 3 371 35
4 1939 1 4 4 873 119
5 678 1 5 5 186 30
6 321 1 6 6 111 23
7 2667 1 7 7 1277 46
8 345 1 8 8 102 39
9 1367 1 9 9 580 58
10 1158 1 10 10 420 51
11 1385 1 11 11 521 65
12 1155 1 12 12 358 40
13 1120 1 13 13 435 41
14 1703 1 14 14 690 76
15 1189 1 15 15 393 31
16 3083 1 16 16 1149 82
17 1357 1 17 17 486 36
18 1892 1 18 18 767 62
19 883 1 19 19 338 28
20 1627 1 20 20 485 38
21 1412 1 21 21 465 70
22 1900 1 22 22 816 76
23 777 1 23 23 265 33
24 904 1 24 24 307 40
25 2115 1 25 25 850 126
26 1858 1 26 26 704 56
27 1781 1 27 27 693 63
28 1286 1 28 28 387 46
29 1035 1 29 29 406 35
30 1557 1 30 30 573 108
31 1527 1 31 31 595 34
32 1220 1 32 32 394 54
33 1368 1 33 33 521 35
34 564 0 34 0 172 23
35 1990 0 35 0 835 46
36 1557 0 36 0 669 49
37 2057 0 37 0 749 56
38 1111 0 38 0 368 38
39 686 0 39 0 216 19
40 2011 0 40 0 772 29
41 2232 0 41 0 1084 26
42 1032 0 42 0 445 52
43 1166 0 43 0 451 54
44 1020 0 44 0 300 45
45 1735 0 45 0 836 56
46 3623 0 46 0 1417 596
47 918 0 47 0 330 57
48 1579 0 48 0 477 55
49 2790 0 49 0 1028 99
50 1496 0 50 0 646 51
51 1108 0 51 0 342 21
52 496 0 52 0 218 20
53 1750 0 53 0 591 58
54 744 0 54 0 255 21
55 1101 0 55 0 434 66
56 1612 0 56 0 654 47
57 1805 0 57 0 478 55
58 2460 0 58 0 753 158
59 1653 0 59 0 689 46
60 1234 0 60 0 470 45
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Pop t pop_t TotalNrCC TotalNrPRV
-60.5774 249.1668 7.1311 -2.9006 2.0625 0.9415
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-302.34 -124.95 -34.48 99.31 421.42
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -60.57740 215.74189 -0.281 0.7799
Pop 249.16676 218.00939 1.143 0.2581
t 7.13110 4.37026 1.632 0.1086
pop_t -2.90055 5.45652 -0.532 0.5972
TotalNrCC 2.06255 0.09812 21.022 <2e-16 ***
TotalNrPRV 0.94149 0.36534 2.577 0.0127 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 176 on 54 degrees of freedom
Multiple R-squared: 0.9322, Adjusted R-squared: 0.9259
F-statistic: 148.5 on 5 and 54 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.4174875482 0.834975096 0.5825125
[2,] 0.4254932424 0.850986485 0.5745068
[3,] 0.3680518963 0.736103793 0.6319481
[4,] 0.3882595170 0.776519034 0.6117405
[5,] 0.2785821477 0.557164295 0.7214179
[6,] 0.1941630504 0.388326101 0.8058369
[7,] 0.1525102704 0.305020541 0.8474897
[8,] 0.5126751726 0.974649655 0.4873248
[9,] 0.4121516399 0.824303280 0.5878484
[10,] 0.3377051848 0.675410370 0.6622948
[11,] 0.3210548088 0.642109618 0.6789452
[12,] 0.4113608498 0.822721700 0.5886392
[13,] 0.3418777104 0.683755421 0.6581223
[14,] 0.3590653485 0.718130697 0.6409347
[15,] 0.3221476665 0.644295333 0.6778523
[16,] 0.2657949868 0.531589974 0.7342050
[17,] 0.2129013445 0.425802689 0.7870987
[18,] 0.1570862910 0.314172582 0.8429137
[19,] 0.1127301658 0.225460332 0.8872698
[20,] 0.0944474524 0.188894905 0.9055525
[21,] 0.0847940449 0.169588090 0.9152060
[22,] 0.0582117879 0.116423576 0.9417882
[23,] 0.0400812921 0.080162584 0.9599187
[24,] 0.0252124871 0.050424974 0.9747875
[25,] 0.0160228634 0.032045727 0.9839771
[26,] 0.0093251598 0.018650320 0.9906748
[27,] 0.0052501539 0.010500308 0.9947498
[28,] 0.0030064253 0.006012851 0.9969936
[29,] 0.0040036022 0.008007204 0.9959964
[30,] 0.0027148369 0.005429674 0.9972852
[31,] 0.0017851889 0.003570378 0.9982148
[32,] 0.0016521297 0.003304259 0.9983479
[33,] 0.0030925993 0.006185199 0.9969074
[34,] 0.0020259625 0.004051925 0.9979740
[35,] 0.0009788220 0.001957644 0.9990212
[36,] 0.0009053302 0.001810660 0.9990947
[37,] 0.0021396916 0.004279383 0.9978603
[38,] 0.0152847858 0.030569572 0.9847152
[39,] 0.0127449038 0.025489808 0.9872551
[40,] 0.0201786699 0.040357340 0.9798213
[41,] 0.0183973020 0.036794604 0.9816027
[42,] 0.0165706995 0.033141399 0.9834293
[43,] 0.0108745868 0.021749174 0.9891254
> postscript(file="/var/wessaorg/rcomp/tmp/1p5fz1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2bdgr1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3auvc1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4uuue1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5i3bz1321900340.ps",horizontal=F,onefile=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 6
221.447071 -29.424360 53.561442 -179.153641 56.379202 -143.569786
7 8 9 10 11 12
-228.385610 -124.531834 -110.548682 12.818907 14.090111 139.592229
13 14 15 16 17 18
-59.395999 -39.528548 97.184870 379.651892 60.199359 -13.085995
19 20 21 22 23 24
-109.472675 317.687297 109.579920 -136.253919 -86.536305 -56.984316
25 26 27 28 29 30
-51.146852 54.659161 -10.473807 137.440721 -146.621802 -42.026885
31 32 33 34 35 36
-51.962956 32.548773 -67.736982 5.707546 35.452796 -65.119818
37 38 39 40 41 42
256.154794 105.801359 5.065932 166.743231 -260.078350 -173.720128
43 44 45 46 47 48
-61.109498 105.677592 -302.335644 -128.213648 -90.890057 261.667283
49 50 51 52 53 54
287.646539 -180.399540 79.728754 -282.704900 159.056856 -126.222859
55 56 57 58 59 60
-187.917253 -119.920523 421.424875 405.119248 -171.561495 -145.053092
> postscript(file="/var/wessaorg/rcomp/tmp/6vi8r1321900340.ps",horizontal=F,onefile=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 221.447071 NA
1 -29.424360 221.447071
2 53.561442 -29.424360
3 -179.153641 53.561442
4 56.379202 -179.153641
5 -143.569786 56.379202
6 -228.385610 -143.569786
7 -124.531834 -228.385610
8 -110.548682 -124.531834
9 12.818907 -110.548682
10 14.090111 12.818907
11 139.592229 14.090111
12 -59.395999 139.592229
13 -39.528548 -59.395999
14 97.184870 -39.528548
15 379.651892 97.184870
16 60.199359 379.651892
17 -13.085995 60.199359
18 -109.472675 -13.085995
19 317.687297 -109.472675
20 109.579920 317.687297
21 -136.253919 109.579920
22 -86.536305 -136.253919
23 -56.984316 -86.536305
24 -51.146852 -56.984316
25 54.659161 -51.146852
26 -10.473807 54.659161
27 137.440721 -10.473807
28 -146.621802 137.440721
29 -42.026885 -146.621802
30 -51.962956 -42.026885
31 32.548773 -51.962956
32 -67.736982 32.548773
33 5.707546 -67.736982
34 35.452796 5.707546
35 -65.119818 35.452796
36 256.154794 -65.119818
37 105.801359 256.154794
38 5.065932 105.801359
39 166.743231 5.065932
40 -260.078350 166.743231
41 -173.720128 -260.078350
42 -61.109498 -173.720128
43 105.677592 -61.109498
44 -302.335644 105.677592
45 -128.213648 -302.335644
46 -90.890057 -128.213648
47 261.667283 -90.890057
48 287.646539 261.667283
49 -180.399540 287.646539
50 79.728754 -180.399540
51 -282.704900 79.728754
52 159.056856 -282.704900
53 -126.222859 159.056856
54 -187.917253 -126.222859
55 -119.920523 -187.917253
56 421.424875 -119.920523
57 405.119248 421.424875
58 -171.561495 405.119248
59 -145.053092 -171.561495
60 NA -145.053092
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -29.424360 221.447071
[2,] 53.561442 -29.424360
[3,] -179.153641 53.561442
[4,] 56.379202 -179.153641
[5,] -143.569786 56.379202
[6,] -228.385610 -143.569786
[7,] -124.531834 -228.385610
[8,] -110.548682 -124.531834
[9,] 12.818907 -110.548682
[10,] 14.090111 12.818907
[11,] 139.592229 14.090111
[12,] -59.395999 139.592229
[13,] -39.528548 -59.395999
[14,] 97.184870 -39.528548
[15,] 379.651892 97.184870
[16,] 60.199359 379.651892
[17,] -13.085995 60.199359
[18,] -109.472675 -13.085995
[19,] 317.687297 -109.472675
[20,] 109.579920 317.687297
[21,] -136.253919 109.579920
[22,] -86.536305 -136.253919
[23,] -56.984316 -86.536305
[24,] -51.146852 -56.984316
[25,] 54.659161 -51.146852
[26,] -10.473807 54.659161
[27,] 137.440721 -10.473807
[28,] -146.621802 137.440721
[29,] -42.026885 -146.621802
[30,] -51.962956 -42.026885
[31,] 32.548773 -51.962956
[32,] -67.736982 32.548773
[33,] 5.707546 -67.736982
[34,] 35.452796 5.707546
[35,] -65.119818 35.452796
[36,] 256.154794 -65.119818
[37,] 105.801359 256.154794
[38,] 5.065932 105.801359
[39,] 166.743231 5.065932
[40,] -260.078350 166.743231
[41,] -173.720128 -260.078350
[42,] -61.109498 -173.720128
[43,] 105.677592 -61.109498
[44,] -302.335644 105.677592
[45,] -128.213648 -302.335644
[46,] -90.890057 -128.213648
[47,] 261.667283 -90.890057
[48,] 287.646539 261.667283
[49,] -180.399540 287.646539
[50,] 79.728754 -180.399540
[51,] -282.704900 79.728754
[52,] 159.056856 -282.704900
[53,] -126.222859 159.056856
[54,] -187.917253 -126.222859
[55,] -119.920523 -187.917253
[56,] 421.424875 -119.920523
[57,] 405.119248 421.424875
[58,] -171.561495 405.119248
[59,] -145.053092 -171.561495
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -29.424360 221.447071
2 53.561442 -29.424360
3 -179.153641 53.561442
4 56.379202 -179.153641
5 -143.569786 56.379202
6 -228.385610 -143.569786
7 -124.531834 -228.385610
8 -110.548682 -124.531834
9 12.818907 -110.548682
10 14.090111 12.818907
11 139.592229 14.090111
12 -59.395999 139.592229
13 -39.528548 -59.395999
14 97.184870 -39.528548
15 379.651892 97.184870
16 60.199359 379.651892
17 -13.085995 60.199359
18 -109.472675 -13.085995
19 317.687297 -109.472675
20 109.579920 317.687297
21 -136.253919 109.579920
22 -86.536305 -136.253919
23 -56.984316 -86.536305
24 -51.146852 -56.984316
25 54.659161 -51.146852
26 -10.473807 54.659161
27 137.440721 -10.473807
28 -146.621802 137.440721
29 -42.026885 -146.621802
30 -51.962956 -42.026885
31 32.548773 -51.962956
32 -67.736982 32.548773
33 5.707546 -67.736982
34 35.452796 5.707546
35 -65.119818 35.452796
36 256.154794 -65.119818
37 105.801359 256.154794
38 5.065932 105.801359
39 166.743231 5.065932
40 -260.078350 166.743231
41 -173.720128 -260.078350
42 -61.109498 -173.720128
43 105.677592 -61.109498
44 -302.335644 105.677592
45 -128.213648 -302.335644
46 -90.890057 -128.213648
47 261.667283 -90.890057
48 287.646539 261.667283
49 -180.399540 287.646539
50 79.728754 -180.399540
51 -282.704900 79.728754
52 159.056856 -282.704900
53 -126.222859 159.056856
54 -187.917253 -126.222859
55 -119.920523 -187.917253
56 421.424875 -119.920523
57 405.119248 421.424875
58 -171.561495 405.119248
59 -145.053092 -171.561495
> 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/wessaorg/rcomp/tmp/7x4pr1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/83iut1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/9nasy1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10o8py1321900340.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/113lby1321900340.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/wessaorg/rcomp/tmp/12f6cy1321900340.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/wessaorg/rcomp/tmp/139ny41321900340.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/wessaorg/rcomp/tmp/1456w31321900340.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/wessaorg/rcomp/tmp/15blvf1321900340.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/wessaorg/rcomp/tmp/164p8r1321900340.tab")
+ }
>
> try(system("convert tmp/1p5fz1321900340.ps tmp/1p5fz1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/2bdgr1321900340.ps tmp/2bdgr1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/3auvc1321900340.ps tmp/3auvc1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/4uuue1321900340.ps tmp/4uuue1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/5i3bz1321900340.ps tmp/5i3bz1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/6vi8r1321900340.ps tmp/6vi8r1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/7x4pr1321900340.ps tmp/7x4pr1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/83iut1321900340.ps tmp/83iut1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/9nasy1321900340.ps tmp/9nasy1321900340.png",intern=TRUE))
character(0)
> try(system("convert tmp/10o8py1321900340.ps tmp/10o8py1321900340.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.214 0.506 3.759