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(6129
+ ,6314
+ ,4796
+ ,3624
+ ,3700
+ ,3075
+ ,502
+ ,513
+ ,419
+ ,165
+ ,167
+ ,151
+ ,337
+ ,347
+ ,268
+ ,784
+ ,780
+ ,813
+ ,217
+ ,224
+ ,167
+ ,149
+ ,146
+ ,169
+ ,117
+ ,118
+ ,108
+ ,138
+ ,132
+ ,182
+ ,117
+ ,114
+ ,139
+ ,46
+ ,46
+ ,47
+ ,380
+ ,398
+ ,255
+ ,141
+ ,146
+ ,102
+ ,240
+ ,252
+ ,153
+ ,679
+ ,694
+ ,572
+ ,232
+ ,239
+ ,182
+ ,210
+ ,218
+ ,156
+ ,113
+ ,112
+ ,117
+ ,124
+ ,125
+ ,117
+ ,1278
+ ,1314
+ ,1016
+ ,132
+ ,135
+ ,107
+ ,103
+ ,104
+ ,91
+ ,667
+ ,688
+ ,510
+ ,333
+ ,339
+ ,291
+ ,43
+ ,47
+ ,16
+ ,2505
+ ,2613
+ ,1721
+ ,412
+ ,441
+ ,203
+ ,16557
+ ,16899
+ ,14102
+ ,9812
+ ,10046
+ ,8132
+ ,6277
+ ,6646
+ ,3630
+ ,3351
+ ,3506
+ ,2242
+ ,1814
+ ,1942
+ ,894
+ ,1112
+ ,1198
+ ,495
+ ,2900
+ ,2716
+ ,4216
+ ,635
+ ,684
+ ,286
+ ,3660
+ ,3647
+ ,3749
+ ,440
+ ,429
+ ,517
+ ,1413
+ ,1399
+ ,1513
+ ,140
+ ,153
+ ,49
+ ,1178
+ ,1172
+ ,1221
+ ,489
+ ,495
+ ,449
+ ,1007
+ ,1050
+ ,704
+ ,340
+ ,352
+ ,256
+ ,667
+ ,698
+ ,448
+ ,612
+ ,634
+ ,449
+ ,150
+ ,149
+ ,157
+ ,329
+ ,344
+ ,219
+ ,132
+ ,141
+ ,73
+ ,1467
+ ,1522
+ ,1068
+ ,102
+ ,107
+ ,71
+ ,355
+ ,360
+ ,324
+ ,36
+ ,34
+ ,52
+ ,209
+ ,214
+ ,173
+ ,107
+ ,113
+ ,60
+ ,657
+ ,694
+ ,389
+ ,1700
+ ,1737
+ ,1429
+ ,382
+ ,395
+ ,289
+ ,304
+ ,318
+ ,202
+ ,78
+ ,77
+ ,86
+ ,663
+ ,677
+ ,558
+ ,562
+ ,575
+ ,466
+ ,101
+ ,102
+ ,91
+ ,91
+ ,92
+ ,80
+ ,303
+ ,301
+ ,323
+ ,261
+ ,273
+ ,180
+ ,7677
+ ,7950
+ ,5724
+ ,2588
+ ,2727
+ ,1591
+ ,1219
+ ,1283
+ ,764
+ ,1318
+ ,1386
+ ,827
+ ,2132
+ ,2182
+ ,1775
+ ,2464
+ ,2525
+ ,2025
+ ,243
+ ,250
+ ,193
+ ,787
+ ,813
+ ,602
+ ,1010
+ ,1019
+ ,946
+ ,423
+ ,443
+ ,285
+ ,493
+ ,515
+ ,333
+ ,3157
+ ,3355
+ ,1734
+ ,1831
+ ,1925
+ ,1156
+ ,722
+ ,790
+ ,239
+ ,485
+ ,515
+ ,272
+ ,119
+ ,126
+ ,66
+ ,2504
+ ,2665
+ ,1352
+ ,581
+ ,635
+ ,195
+ ,954
+ ,970
+ ,841
+ ,606
+ ,663
+ ,192
+ ,364
+ ,397
+ ,125
+ ,582
+ ,590
+ ,525
+ ,100
+ ,108
+ ,41
+ ,1074
+ ,1163
+ ,441
+ ,362
+ ,380
+ ,231
+ ,849
+ ,891
+ ,549
+ ,1633
+ ,1675
+ ,1334
+ ,5373
+ ,5647
+ ,3401
+ ,318
+ ,333
+ ,212
+ ,5054
+ ,5315
+ ,3189)
+ ,dim=c(3
+ ,96)
+ ,dimnames=list(c('total'
+ ,'white'
+ ,'black')
+ ,1:96))
> y <- array(NA,dim=c(3,96),dimnames=list(c('total','white','black'),1:96))
> 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 = '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
> 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
total white black M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 6129 6314 4796 1 0 0 0 0 0 0 0 0 0 0
2 3624 3700 3075 0 1 0 0 0 0 0 0 0 0 0
3 502 513 419 0 0 1 0 0 0 0 0 0 0 0
4 165 167 151 0 0 0 1 0 0 0 0 0 0 0
5 337 347 268 0 0 0 0 1 0 0 0 0 0 0
6 784 780 813 0 0 0 0 0 1 0 0 0 0 0
7 217 224 167 0 0 0 0 0 0 1 0 0 0 0
8 149 146 169 0 0 0 0 0 0 0 1 0 0 0
9 117 118 108 0 0 0 0 0 0 0 0 1 0 0
10 138 132 182 0 0 0 0 0 0 0 0 0 1 0
11 117 114 139 0 0 0 0 0 0 0 0 0 0 1
12 46 46 47 0 0 0 0 0 0 0 0 0 0 0
13 380 398 255 1 0 0 0 0 0 0 0 0 0 0
14 141 146 102 0 1 0 0 0 0 0 0 0 0 0
15 240 252 153 0 0 1 0 0 0 0 0 0 0 0
16 679 694 572 0 0 0 1 0 0 0 0 0 0 0
17 232 239 182 0 0 0 0 1 0 0 0 0 0 0
18 210 218 156 0 0 0 0 0 1 0 0 0 0 0
19 113 112 117 0 0 0 0 0 0 1 0 0 0 0
20 124 125 117 0 0 0 0 0 0 0 1 0 0 0
21 1278 1314 1016 0 0 0 0 0 0 0 0 1 0 0
22 132 135 107 0 0 0 0 0 0 0 0 0 1 0
23 103 104 91 0 0 0 0 0 0 0 0 0 0 1
24 667 688 510 0 0 0 0 0 0 0 0 0 0 0
25 333 339 291 1 0 0 0 0 0 0 0 0 0 0
26 43 47 16 0 1 0 0 0 0 0 0 0 0 0
27 2505 2613 1721 0 0 1 0 0 0 0 0 0 0 0
28 412 441 203 0 0 0 1 0 0 0 0 0 0 0
29 16557 16899 14102 0 0 0 0 1 0 0 0 0 0 0
30 9812 10046 8132 0 0 0 0 0 1 0 0 0 0 0
31 6277 6646 3630 0 0 0 0 0 0 1 0 0 0 0
32 3351 3506 2242 0 0 0 0 0 0 0 1 0 0 0
33 1814 1942 894 0 0 0 0 0 0 0 0 1 0 0
34 1112 1198 495 0 0 0 0 0 0 0 0 0 1 0
35 2900 2716 4216 0 0 0 0 0 0 0 0 0 0 1
36 635 684 286 0 0 0 0 0 0 0 0 0 0 0
37 3660 3647 3749 1 0 0 0 0 0 0 0 0 0 0
38 440 429 517 0 1 0 0 0 0 0 0 0 0 0
39 1413 1399 1513 0 0 1 0 0 0 0 0 0 0 0
40 140 153 49 0 0 0 1 0 0 0 0 0 0 0
41 1178 1172 1221 0 0 0 0 1 0 0 0 0 0 0
42 489 495 449 0 0 0 0 0 1 0 0 0 0 0
43 1007 1050 704 0 0 0 0 0 0 1 0 0 0 0
44 340 352 256 0 0 0 0 0 0 0 1 0 0 0
45 667 698 448 0 0 0 0 0 0 0 0 1 0 0
46 612 634 449 0 0 0 0 0 0 0 0 0 1 0
47 150 149 157 0 0 0 0 0 0 0 0 0 0 1
48 329 344 219 0 0 0 0 0 0 0 0 0 0 0
49 132 141 73 1 0 0 0 0 0 0 0 0 0 0
50 1467 1522 1068 0 1 0 0 0 0 0 0 0 0 0
51 102 107 71 0 0 1 0 0 0 0 0 0 0 0
52 355 360 324 0 0 0 1 0 0 0 0 0 0 0
53 36 34 52 0 0 0 0 1 0 0 0 0 0 0
54 209 214 173 0 0 0 0 0 1 0 0 0 0 0
55 107 113 60 0 0 0 0 0 0 1 0 0 0 0
56 657 694 389 0 0 0 0 0 0 0 1 0 0 0
57 1700 1737 1429 0 0 0 0 0 0 0 0 1 0 0
58 382 395 289 0 0 0 0 0 0 0 0 0 1 0
59 304 318 202 0 0 0 0 0 0 0 0 0 0 1
60 78 77 86 0 0 0 0 0 0 0 0 0 0 0
61 663 677 558 1 0 0 0 0 0 0 0 0 0 0
62 562 575 466 0 1 0 0 0 0 0 0 0 0 0
63 101 102 91 0 0 1 0 0 0 0 0 0 0 0
64 91 92 80 0 0 0 1 0 0 0 0 0 0 0
65 303 301 323 0 0 0 0 1 0 0 0 0 0 0
66 261 273 180 0 0 0 0 0 1 0 0 0 0 0
67 7677 7950 5724 0 0 0 0 0 0 1 0 0 0 0
68 2588 2727 1591 0 0 0 0 0 0 0 1 0 0 0
69 1219 1283 764 0 0 0 0 0 0 0 0 1 0 0
70 1318 1386 827 0 0 0 0 0 0 0 0 0 1 0
71 2132 2182 1775 0 0 0 0 0 0 0 0 0 0 1
72 2464 2525 2025 0 0 0 0 0 0 0 0 0 0 0
73 243 250 193 1 0 0 0 0 0 0 0 0 0 0
74 787 813 602 0 1 0 0 0 0 0 0 0 0 0
75 1010 1019 946 0 0 1 0 0 0 0 0 0 0 0
76 423 443 285 0 0 0 1 0 0 0 0 0 0 0
77 493 515 333 0 0 0 0 1 0 0 0 0 0 0
78 3157 3355 1734 0 0 0 0 0 1 0 0 0 0 0
79 1831 1925 1156 0 0 0 0 0 0 1 0 0 0 0
80 722 790 239 0 0 0 0 0 0 0 1 0 0 0
81 485 515 272 0 0 0 0 0 0 0 0 1 0 0
82 119 126 66 0 0 0 0 0 0 0 0 0 1 0
83 2504 2665 1352 0 0 0 0 0 0 0 0 0 0 1
84 581 635 195 0 0 0 0 0 0 0 0 0 0 0
85 954 970 841 1 0 0 0 0 0 0 0 0 0 0
86 606 663 192 0 1 0 0 0 0 0 0 0 0 0
87 364 397 125 0 0 1 0 0 0 0 0 0 0 0
88 582 590 525 0 0 0 1 0 0 0 0 0 0 0
89 100 108 41 0 0 0 0 1 0 0 0 0 0 0
90 1074 1163 441 0 0 0 0 0 1 0 0 0 0 0
91 362 380 231 0 0 0 0 0 0 1 0 0 0 0
92 849 891 549 0 0 0 0 0 0 0 1 0 0 0
93 1633 1675 1334 0 0 0 0 0 0 0 0 1 0 0
94 5373 5647 3401 0 0 0 0 0 0 0 0 0 1 0
95 318 333 212 0 0 0 0 0 0 0 0 0 0 1
96 5054 5315 3189 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) white black M1 M2 M3
-0.03725 0.87753 0.12253 0.01300 0.29254 0.23797
M4 M5 M6 M7 M8 M9
-0.10831 -0.11923 -0.19001 0.02451 -0.06109 0.04886
M10 M11
0.35559 0.03740
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.79633 -0.25479 0.02628 0.25223 0.93288
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.725e-02 1.426e-01 -0.261 0.7947
white 8.775e-01 8.945e-05 9810.649 <2e-16 ***
black 1.225e-01 1.128e-04 1086.803 <2e-16 ***
M1 1.300e-02 1.998e-01 0.065 0.9483
M2 2.925e-01 1.981e-01 1.477 0.1435
M3 2.380e-01 1.984e-01 1.199 0.2338
M4 -1.083e-01 1.986e-01 -0.545 0.5871
M5 -1.192e-01 2.018e-01 -0.591 0.5562
M6 -1.900e-01 1.977e-01 -0.961 0.3394
M7 2.451e-02 1.984e-01 0.124 0.9020
M8 -6.109e-02 1.971e-01 -0.310 0.7574
M9 4.886e-02 1.972e-01 0.248 0.8049
M10 3.556e-01 1.971e-01 1.804 0.0749 .
M11 3.740e-02 2.014e-01 0.186 0.8531
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.3941 on 82 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 2.556e+08 on 13 and 82 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.19925283 0.3985057 0.8007472
[2,] 0.21716897 0.4343379 0.7828310
[3,] 0.19370428 0.3874086 0.8062957
[4,] 0.12101411 0.2420282 0.8789859
[5,] 0.06844419 0.1368884 0.9315558
[6,] 0.07526351 0.1505270 0.9247365
[7,] 0.10977280 0.2195456 0.8902272
[8,] 0.20137195 0.4027439 0.7986280
[9,] 0.17119033 0.3423807 0.8288097
[10,] 0.15716295 0.3143259 0.8428370
[11,] 0.18217949 0.3643590 0.8178205
[12,] 0.13380744 0.2676149 0.8661926
[13,] 0.15310895 0.3062179 0.8468910
[14,] 0.13503045 0.2700609 0.8649696
[15,] 0.35801699 0.7160340 0.6419830
[16,] 0.35298281 0.7059656 0.6470172
[17,] 0.30615496 0.6123099 0.6938450
[18,] 0.25498438 0.5099688 0.7450156
[19,] 0.20073277 0.4014655 0.7992672
[20,] 0.21863693 0.4372739 0.7813631
[21,] 0.20406775 0.4081355 0.7959322
[22,] 0.15647252 0.3129450 0.8435275
[23,] 0.17396820 0.3479364 0.8260318
[24,] 0.14091964 0.2818393 0.8590804
[25,] 0.11072786 0.2214557 0.8892721
[26,] 0.08394004 0.1678801 0.9160600
[27,] 0.15590032 0.3118006 0.8440997
[28,] 0.12275794 0.2455159 0.8772421
[29,] 0.15193467 0.3038693 0.8480653
[30,] 0.14562966 0.2912593 0.8543703
[31,] 0.11464287 0.2292857 0.8853571
[32,] 0.09835339 0.1967068 0.9016466
[33,] 0.16000660 0.3200132 0.8399934
[34,] 0.14067326 0.2813465 0.8593267
[35,] 0.28132427 0.5626485 0.7186757
[36,] 0.29509901 0.5901980 0.7049010
[37,] 0.24086469 0.4817294 0.7591353
[38,] 0.21126497 0.4225299 0.7887350
[39,] 0.22241339 0.4448268 0.7775866
[40,] 0.23020848 0.4604170 0.7697915
[41,] 0.40192591 0.8038518 0.5980741
[42,] 0.40607684 0.8121537 0.5939232
[43,] 0.36814100 0.7362820 0.6318590
[44,] 0.31195492 0.6239098 0.6880451
[45,] 0.38057144 0.7611429 0.6194286
[46,] 0.31699352 0.6339870 0.6830065
[47,] 0.26159820 0.5231964 0.7384018
[48,] 0.36116238 0.7223248 0.6388376
[49,] 0.49848834 0.9969767 0.5015117
[50,] 0.49061889 0.9812378 0.5093811
[51,] 0.62828200 0.7434360 0.3717180
[52,] 0.57849738 0.8430052 0.4215026
[53,] 0.54818960 0.9036208 0.4518104
[54,] 0.47054591 0.9410918 0.5294541
[55,] 0.39387565 0.7877513 0.6061243
[56,] 0.50248969 0.9950206 0.4975103
[57,] 0.40373610 0.8074722 0.5962639
[58,] 0.45224877 0.9044975 0.5477512
[59,] 0.39196503 0.7839301 0.6080350
[60,] 0.40969361 0.8193872 0.5903064
[61,] 0.30679120 0.6135824 0.6932088
[62,] 0.58416413 0.8316717 0.4158359
[63,] 0.41959591 0.8391918 0.5804041
> postscript(file="/var/wessaorg/rcomp/tmp/16i771322147052.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/2cg801322147052.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/3nzaf1322147052.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/47m351322147052.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/514ed1322147052.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 = 96
Frequency = 1
1 2 3 4 5 6
0.628358058 0.092736555 0.284781165 0.095462601 -0.185453107 0.134035958
7 8 9 10 11 12
-0.017106473 0.270778157 0.206210682 -0.453414079 -0.070744539 -0.088214346
13 14 15 16 17 18
-0.478791052 0.126886677 -0.085948712 0.050483490 0.125681356 -0.189536772
19 20 21 22 23 24
0.392944786 0.070650706 0.419760999 0.104003510 0.586162360 0.804432301
25 26 27 28 29 30
-0.115714832 -0.459750403 0.932880692 0.280456703 -0.192476977 0.117210966
31 32 33 34 35 36
0.150825728 -0.242421498 0.279893242 -0.253543876 0.026909192 -0.237956148
37 38 39 40 41 42
0.293838135 -0.065529978 -0.258535495 -0.120703981 0.077785917 -0.167692553
43 44 45 46 47 48
-0.657486013 -0.160846538 -0.422658760 0.310011064 0.010097519 0.332042680
49 50 51 52 53 54
-0.652450689 0.278066554 -0.796331675 -0.466145824 -0.051286142 0.237515410
55 56 57 58 59 60
0.499820772 0.426887162 0.618187238 -0.354927367 0.193493701 -0.070453871
61 62 63 64 65 66
0.562658410 0.064270515 0.140650354 0.610099789 -0.558404500 -0.394498788
67 68 69 70 71 72
-0.733543916 0.122852305 -0.498376466 0.089681379 -0.267848944 0.143343881
73 74 75 76 77 78
-0.007252329 -0.452458290 -0.320609132 -0.522345832 0.424804419 0.640545257
79 80 81 82 83 84
0.118498566 -0.435993083 -0.268751725 0.025646148 -0.283276006 -0.088434588
85 86 87 88 89 90
-0.230645699 0.415778370 0.103112802 0.072693054 0.359349034 -0.377579479
91 92 93 94 95 96
0.246046551 -0.051907211 -0.334265209 0.532543222 -0.194793282 -0.794759910
> postscript(file="/var/wessaorg/rcomp/tmp/6ssbm1322147052.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 = 96
Frequency = 1
lag(myerror, k = 1) myerror
0 0.628358058 NA
1 0.092736555 0.628358058
2 0.284781165 0.092736555
3 0.095462601 0.284781165
4 -0.185453107 0.095462601
5 0.134035958 -0.185453107
6 -0.017106473 0.134035958
7 0.270778157 -0.017106473
8 0.206210682 0.270778157
9 -0.453414079 0.206210682
10 -0.070744539 -0.453414079
11 -0.088214346 -0.070744539
12 -0.478791052 -0.088214346
13 0.126886677 -0.478791052
14 -0.085948712 0.126886677
15 0.050483490 -0.085948712
16 0.125681356 0.050483490
17 -0.189536772 0.125681356
18 0.392944786 -0.189536772
19 0.070650706 0.392944786
20 0.419760999 0.070650706
21 0.104003510 0.419760999
22 0.586162360 0.104003510
23 0.804432301 0.586162360
24 -0.115714832 0.804432301
25 -0.459750403 -0.115714832
26 0.932880692 -0.459750403
27 0.280456703 0.932880692
28 -0.192476977 0.280456703
29 0.117210966 -0.192476977
30 0.150825728 0.117210966
31 -0.242421498 0.150825728
32 0.279893242 -0.242421498
33 -0.253543876 0.279893242
34 0.026909192 -0.253543876
35 -0.237956148 0.026909192
36 0.293838135 -0.237956148
37 -0.065529978 0.293838135
38 -0.258535495 -0.065529978
39 -0.120703981 -0.258535495
40 0.077785917 -0.120703981
41 -0.167692553 0.077785917
42 -0.657486013 -0.167692553
43 -0.160846538 -0.657486013
44 -0.422658760 -0.160846538
45 0.310011064 -0.422658760
46 0.010097519 0.310011064
47 0.332042680 0.010097519
48 -0.652450689 0.332042680
49 0.278066554 -0.652450689
50 -0.796331675 0.278066554
51 -0.466145824 -0.796331675
52 -0.051286142 -0.466145824
53 0.237515410 -0.051286142
54 0.499820772 0.237515410
55 0.426887162 0.499820772
56 0.618187238 0.426887162
57 -0.354927367 0.618187238
58 0.193493701 -0.354927367
59 -0.070453871 0.193493701
60 0.562658410 -0.070453871
61 0.064270515 0.562658410
62 0.140650354 0.064270515
63 0.610099789 0.140650354
64 -0.558404500 0.610099789
65 -0.394498788 -0.558404500
66 -0.733543916 -0.394498788
67 0.122852305 -0.733543916
68 -0.498376466 0.122852305
69 0.089681379 -0.498376466
70 -0.267848944 0.089681379
71 0.143343881 -0.267848944
72 -0.007252329 0.143343881
73 -0.452458290 -0.007252329
74 -0.320609132 -0.452458290
75 -0.522345832 -0.320609132
76 0.424804419 -0.522345832
77 0.640545257 0.424804419
78 0.118498566 0.640545257
79 -0.435993083 0.118498566
80 -0.268751725 -0.435993083
81 0.025646148 -0.268751725
82 -0.283276006 0.025646148
83 -0.088434588 -0.283276006
84 -0.230645699 -0.088434588
85 0.415778370 -0.230645699
86 0.103112802 0.415778370
87 0.072693054 0.103112802
88 0.359349034 0.072693054
89 -0.377579479 0.359349034
90 0.246046551 -0.377579479
91 -0.051907211 0.246046551
92 -0.334265209 -0.051907211
93 0.532543222 -0.334265209
94 -0.194793282 0.532543222
95 -0.794759910 -0.194793282
96 NA -0.794759910
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.092736555 0.628358058
[2,] 0.284781165 0.092736555
[3,] 0.095462601 0.284781165
[4,] -0.185453107 0.095462601
[5,] 0.134035958 -0.185453107
[6,] -0.017106473 0.134035958
[7,] 0.270778157 -0.017106473
[8,] 0.206210682 0.270778157
[9,] -0.453414079 0.206210682
[10,] -0.070744539 -0.453414079
[11,] -0.088214346 -0.070744539
[12,] -0.478791052 -0.088214346
[13,] 0.126886677 -0.478791052
[14,] -0.085948712 0.126886677
[15,] 0.050483490 -0.085948712
[16,] 0.125681356 0.050483490
[17,] -0.189536772 0.125681356
[18,] 0.392944786 -0.189536772
[19,] 0.070650706 0.392944786
[20,] 0.419760999 0.070650706
[21,] 0.104003510 0.419760999
[22,] 0.586162360 0.104003510
[23,] 0.804432301 0.586162360
[24,] -0.115714832 0.804432301
[25,] -0.459750403 -0.115714832
[26,] 0.932880692 -0.459750403
[27,] 0.280456703 0.932880692
[28,] -0.192476977 0.280456703
[29,] 0.117210966 -0.192476977
[30,] 0.150825728 0.117210966
[31,] -0.242421498 0.150825728
[32,] 0.279893242 -0.242421498
[33,] -0.253543876 0.279893242
[34,] 0.026909192 -0.253543876
[35,] -0.237956148 0.026909192
[36,] 0.293838135 -0.237956148
[37,] -0.065529978 0.293838135
[38,] -0.258535495 -0.065529978
[39,] -0.120703981 -0.258535495
[40,] 0.077785917 -0.120703981
[41,] -0.167692553 0.077785917
[42,] -0.657486013 -0.167692553
[43,] -0.160846538 -0.657486013
[44,] -0.422658760 -0.160846538
[45,] 0.310011064 -0.422658760
[46,] 0.010097519 0.310011064
[47,] 0.332042680 0.010097519
[48,] -0.652450689 0.332042680
[49,] 0.278066554 -0.652450689
[50,] -0.796331675 0.278066554
[51,] -0.466145824 -0.796331675
[52,] -0.051286142 -0.466145824
[53,] 0.237515410 -0.051286142
[54,] 0.499820772 0.237515410
[55,] 0.426887162 0.499820772
[56,] 0.618187238 0.426887162
[57,] -0.354927367 0.618187238
[58,] 0.193493701 -0.354927367
[59,] -0.070453871 0.193493701
[60,] 0.562658410 -0.070453871
[61,] 0.064270515 0.562658410
[62,] 0.140650354 0.064270515
[63,] 0.610099789 0.140650354
[64,] -0.558404500 0.610099789
[65,] -0.394498788 -0.558404500
[66,] -0.733543916 -0.394498788
[67,] 0.122852305 -0.733543916
[68,] -0.498376466 0.122852305
[69,] 0.089681379 -0.498376466
[70,] -0.267848944 0.089681379
[71,] 0.143343881 -0.267848944
[72,] -0.007252329 0.143343881
[73,] -0.452458290 -0.007252329
[74,] -0.320609132 -0.452458290
[75,] -0.522345832 -0.320609132
[76,] 0.424804419 -0.522345832
[77,] 0.640545257 0.424804419
[78,] 0.118498566 0.640545257
[79,] -0.435993083 0.118498566
[80,] -0.268751725 -0.435993083
[81,] 0.025646148 -0.268751725
[82,] -0.283276006 0.025646148
[83,] -0.088434588 -0.283276006
[84,] -0.230645699 -0.088434588
[85,] 0.415778370 -0.230645699
[86,] 0.103112802 0.415778370
[87,] 0.072693054 0.103112802
[88,] 0.359349034 0.072693054
[89,] -0.377579479 0.359349034
[90,] 0.246046551 -0.377579479
[91,] -0.051907211 0.246046551
[92,] -0.334265209 -0.051907211
[93,] 0.532543222 -0.334265209
[94,] -0.194793282 0.532543222
[95,] -0.794759910 -0.194793282
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.092736555 0.628358058
2 0.284781165 0.092736555
3 0.095462601 0.284781165
4 -0.185453107 0.095462601
5 0.134035958 -0.185453107
6 -0.017106473 0.134035958
7 0.270778157 -0.017106473
8 0.206210682 0.270778157
9 -0.453414079 0.206210682
10 -0.070744539 -0.453414079
11 -0.088214346 -0.070744539
12 -0.478791052 -0.088214346
13 0.126886677 -0.478791052
14 -0.085948712 0.126886677
15 0.050483490 -0.085948712
16 0.125681356 0.050483490
17 -0.189536772 0.125681356
18 0.392944786 -0.189536772
19 0.070650706 0.392944786
20 0.419760999 0.070650706
21 0.104003510 0.419760999
22 0.586162360 0.104003510
23 0.804432301 0.586162360
24 -0.115714832 0.804432301
25 -0.459750403 -0.115714832
26 0.932880692 -0.459750403
27 0.280456703 0.932880692
28 -0.192476977 0.280456703
29 0.117210966 -0.192476977
30 0.150825728 0.117210966
31 -0.242421498 0.150825728
32 0.279893242 -0.242421498
33 -0.253543876 0.279893242
34 0.026909192 -0.253543876
35 -0.237956148 0.026909192
36 0.293838135 -0.237956148
37 -0.065529978 0.293838135
38 -0.258535495 -0.065529978
39 -0.120703981 -0.258535495
40 0.077785917 -0.120703981
41 -0.167692553 0.077785917
42 -0.657486013 -0.167692553
43 -0.160846538 -0.657486013
44 -0.422658760 -0.160846538
45 0.310011064 -0.422658760
46 0.010097519 0.310011064
47 0.332042680 0.010097519
48 -0.652450689 0.332042680
49 0.278066554 -0.652450689
50 -0.796331675 0.278066554
51 -0.466145824 -0.796331675
52 -0.051286142 -0.466145824
53 0.237515410 -0.051286142
54 0.499820772 0.237515410
55 0.426887162 0.499820772
56 0.618187238 0.426887162
57 -0.354927367 0.618187238
58 0.193493701 -0.354927367
59 -0.070453871 0.193493701
60 0.562658410 -0.070453871
61 0.064270515 0.562658410
62 0.140650354 0.064270515
63 0.610099789 0.140650354
64 -0.558404500 0.610099789
65 -0.394498788 -0.558404500
66 -0.733543916 -0.394498788
67 0.122852305 -0.733543916
68 -0.498376466 0.122852305
69 0.089681379 -0.498376466
70 -0.267848944 0.089681379
71 0.143343881 -0.267848944
72 -0.007252329 0.143343881
73 -0.452458290 -0.007252329
74 -0.320609132 -0.452458290
75 -0.522345832 -0.320609132
76 0.424804419 -0.522345832
77 0.640545257 0.424804419
78 0.118498566 0.640545257
79 -0.435993083 0.118498566
80 -0.268751725 -0.435993083
81 0.025646148 -0.268751725
82 -0.283276006 0.025646148
83 -0.088434588 -0.283276006
84 -0.230645699 -0.088434588
85 0.415778370 -0.230645699
86 0.103112802 0.415778370
87 0.072693054 0.103112802
88 0.359349034 0.072693054
89 -0.377579479 0.359349034
90 0.246046551 -0.377579479
91 -0.051907211 0.246046551
92 -0.334265209 -0.051907211
93 0.532543222 -0.334265209
94 -0.194793282 0.532543222
95 -0.794759910 -0.194793282
> 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/7hjrb1322147052.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/8x3y31322147052.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/9m5by1322147052.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/10mjz91322147052.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/11j9pq1322147052.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/12vsvx1322147052.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/13xabp1322147052.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/142mcj1322147052.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/1564v31322147052.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/167t7t1322147052.tab")
+ }
>
> try(system("convert tmp/16i771322147052.ps tmp/16i771322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/2cg801322147052.ps tmp/2cg801322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/3nzaf1322147052.ps tmp/3nzaf1322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/47m351322147052.ps tmp/47m351322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/514ed1322147052.ps tmp/514ed1322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ssbm1322147052.ps tmp/6ssbm1322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/7hjrb1322147052.ps tmp/7hjrb1322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/8x3y31322147052.ps tmp/8x3y31322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/9m5by1322147052.ps tmp/9m5by1322147052.png",intern=TRUE))
character(0)
> try(system("convert tmp/10mjz91322147052.ps tmp/10mjz91322147052.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.710 0.489 4.255