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(2
+ ,210907
+ ,79
+ ,30
+ ,112285
+ ,4
+ ,179321
+ ,108
+ ,30
+ ,101193
+ ,0
+ ,149061
+ ,43
+ ,26
+ ,116174
+ ,0
+ ,237213
+ ,78
+ ,38
+ ,66198
+ ,-4
+ ,173326
+ ,86
+ ,44
+ ,71701
+ ,4
+ ,133131
+ ,44
+ ,30
+ ,57793
+ ,4
+ ,258873
+ ,104
+ ,40
+ ,80444
+ ,0
+ ,324799
+ ,158
+ ,47
+ ,97668
+ ,-1
+ ,230964
+ ,102
+ ,30
+ ,133824
+ ,0
+ ,236785
+ ,77
+ ,31
+ ,101481
+ ,1
+ ,344297
+ ,80
+ ,30
+ ,67654
+ ,0
+ ,174724
+ ,123
+ ,34
+ ,69112
+ ,3
+ ,174415
+ ,73
+ ,31
+ ,82753
+ ,-1
+ ,223632
+ ,105
+ ,33
+ ,72654
+ ,4
+ ,294424
+ ,107
+ ,33
+ ,101494
+ ,3
+ ,325107
+ ,84
+ ,36
+ ,79215
+ ,1
+ ,106408
+ ,33
+ ,14
+ ,31081
+ ,0
+ ,96560
+ ,42
+ ,17
+ ,22996
+ ,-2
+ ,265769
+ ,96
+ ,32
+ ,83122
+ ,-3
+ ,269651
+ ,106
+ ,30
+ ,70106
+ ,-4
+ ,149112
+ ,56
+ ,35
+ ,60578
+ ,2
+ ,152871
+ ,59
+ ,28
+ ,79892
+ ,2
+ ,362301
+ ,76
+ ,34
+ ,100708
+ ,-4
+ ,183167
+ ,91
+ ,39
+ ,82875
+ ,3
+ ,277965
+ ,115
+ ,39
+ ,139077
+ ,2
+ ,218946
+ ,76
+ ,29
+ ,80670
+ ,2
+ ,244052
+ ,101
+ ,44
+ ,143558
+ ,0
+ ,341570
+ ,94
+ ,21
+ ,117105
+ ,5
+ ,233328
+ ,92
+ ,28
+ ,120733
+ ,-2
+ ,206161
+ ,75
+ ,28
+ ,73107
+ ,0
+ ,311473
+ ,128
+ ,38
+ ,132068
+ ,-2
+ ,207176
+ ,56
+ ,32
+ ,87011
+ ,-3
+ ,196553
+ ,41
+ ,29
+ ,95260
+ ,2
+ ,143246
+ ,67
+ ,27
+ ,106671
+ ,2
+ ,182192
+ ,77
+ ,40
+ ,70054
+ ,2
+ ,194979
+ ,66
+ ,40
+ ,74011
+ ,0
+ ,167488
+ ,69
+ ,28
+ ,83737
+ ,4
+ ,143756
+ ,105
+ ,34
+ ,69094
+ ,4
+ ,275541
+ ,116
+ ,33
+ ,93133
+ ,2
+ ,152299
+ ,62
+ ,33
+ ,61370
+ ,2
+ ,193339
+ ,100
+ ,35
+ ,84651
+ ,-4
+ ,130585
+ ,67
+ ,29
+ ,95364
+ ,3
+ ,112611
+ ,46
+ ,20
+ ,26706
+ ,3
+ ,148446
+ ,135
+ ,37
+ ,126846
+ ,2
+ ,182079
+ ,124
+ ,33
+ ,102860
+ ,-1
+ ,243060
+ ,58
+ ,29
+ ,111813
+ ,-3
+ ,162765
+ ,68
+ ,28
+ ,120293
+ ,0
+ ,85574
+ ,37
+ ,21
+ ,24266
+ ,1
+ ,225060
+ ,93
+ ,41
+ ,109825
+ ,-3
+ ,133328
+ ,56
+ ,20
+ ,40909
+ ,3
+ ,100750
+ ,83
+ ,30
+ ,140867
+ ,0
+ ,101523
+ ,59
+ ,22
+ ,61056
+ ,0
+ ,243511
+ ,133
+ ,42
+ ,101338
+ ,0
+ ,152474
+ ,106
+ ,32
+ ,65567
+ ,3
+ ,132487
+ ,71
+ ,36
+ ,40735
+ ,-3
+ ,317394
+ ,116
+ ,31
+ ,91413
+ ,0
+ ,244749
+ ,98
+ ,33
+ ,76643
+ ,-4
+ ,184510
+ ,64
+ ,40
+ ,110681
+ ,2
+ ,128423
+ ,32
+ ,38
+ ,92696
+ ,-1
+ ,97839
+ ,25
+ ,24
+ ,94785
+ ,3
+ ,172494
+ ,46
+ ,43
+ ,86687
+ ,2
+ ,229242
+ ,63
+ ,31
+ ,91721
+ ,5
+ ,351619
+ ,95
+ ,40
+ ,115168
+ ,2
+ ,324598
+ ,113
+ ,37
+ ,135777
+ ,-2
+ ,195838
+ ,111
+ ,31
+ ,102372
+ ,0
+ ,254488
+ ,120
+ ,39
+ ,103772
+ ,3
+ ,199476
+ ,87
+ ,32
+ ,135400
+ ,-2
+ ,92499
+ ,25
+ ,18
+ ,21399
+ ,0
+ ,224330
+ ,131
+ ,39
+ ,130115
+ ,6
+ ,181633
+ ,47
+ ,30
+ ,64466
+ ,-3
+ ,271856
+ ,109
+ ,37
+ ,54990
+ ,3
+ ,95227
+ ,37
+ ,32
+ ,34777
+ ,0
+ ,98146
+ ,15
+ ,17
+ ,27114
+ ,-2
+ ,118612
+ ,54
+ ,12
+ ,30080
+ ,1
+ ,65475
+ ,16
+ ,13
+ ,69008
+ ,0
+ ,108446
+ ,22
+ ,17
+ ,46300
+ ,2
+ ,121848
+ ,37
+ ,17
+ ,30594
+ ,2
+ ,76302
+ ,29
+ ,20
+ ,30976
+ ,-3
+ ,98104
+ ,55
+ ,17
+ ,25568
+ ,-2
+ ,30989
+ ,5
+ ,17
+ ,4154
+ ,1
+ ,31774
+ ,0
+ ,17
+ ,4143
+ ,-4
+ ,150580
+ ,27
+ ,22
+ ,45588
+ ,0
+ ,54157
+ ,37
+ ,15
+ ,18625
+ ,1
+ ,59382
+ ,29
+ ,12
+ ,26263
+ ,0
+ ,84105
+ ,17
+ ,17
+ ,20055)
+ ,dim=c(5
+ ,85)
+ ,dimnames=list(c('testscore'
+ ,'time_rfc'
+ ,'blogged_comp'
+ ,'comp_reviewed'
+ ,'total_size')
+ ,1:85))
> y <- array(NA,dim=c(5,85),dimnames=list(c('testscore','time_rfc','blogged_comp','comp_reviewed','total_size'),1:85))
> 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
> 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
testscore time_rfc blogged_comp comp_reviewed total_size t
1 2 210907 79 30 112285 1
2 4 179321 108 30 101193 2
3 0 149061 43 26 116174 3
4 0 237213 78 38 66198 4
5 -4 173326 86 44 71701 5
6 4 133131 44 30 57793 6
7 4 258873 104 40 80444 7
8 0 324799 158 47 97668 8
9 -1 230964 102 30 133824 9
10 0 236785 77 31 101481 10
11 1 344297 80 30 67654 11
12 0 174724 123 34 69112 12
13 3 174415 73 31 82753 13
14 -1 223632 105 33 72654 14
15 4 294424 107 33 101494 15
16 3 325107 84 36 79215 16
17 1 106408 33 14 31081 17
18 0 96560 42 17 22996 18
19 -2 265769 96 32 83122 19
20 -3 269651 106 30 70106 20
21 -4 149112 56 35 60578 21
22 2 152871 59 28 79892 22
23 2 362301 76 34 100708 23
24 -4 183167 91 39 82875 24
25 3 277965 115 39 139077 25
26 2 218946 76 29 80670 26
27 2 244052 101 44 143558 27
28 0 341570 94 21 117105 28
29 5 233328 92 28 120733 29
30 -2 206161 75 28 73107 30
31 0 311473 128 38 132068 31
32 -2 207176 56 32 87011 32
33 -3 196553 41 29 95260 33
34 2 143246 67 27 106671 34
35 2 182192 77 40 70054 35
36 2 194979 66 40 74011 36
37 0 167488 69 28 83737 37
38 4 143756 105 34 69094 38
39 4 275541 116 33 93133 39
40 2 152299 62 33 61370 40
41 2 193339 100 35 84651 41
42 -4 130585 67 29 95364 42
43 3 112611 46 20 26706 43
44 3 148446 135 37 126846 44
45 2 182079 124 33 102860 45
46 -1 243060 58 29 111813 46
47 -3 162765 68 28 120293 47
48 0 85574 37 21 24266 48
49 1 225060 93 41 109825 49
50 -3 133328 56 20 40909 50
51 3 100750 83 30 140867 51
52 0 101523 59 22 61056 52
53 0 243511 133 42 101338 53
54 0 152474 106 32 65567 54
55 3 132487 71 36 40735 55
56 -3 317394 116 31 91413 56
57 0 244749 98 33 76643 57
58 -4 184510 64 40 110681 58
59 2 128423 32 38 92696 59
60 -1 97839 25 24 94785 60
61 3 172494 46 43 86687 61
62 2 229242 63 31 91721 62
63 5 351619 95 40 115168 63
64 2 324598 113 37 135777 64
65 -2 195838 111 31 102372 65
66 0 254488 120 39 103772 66
67 3 199476 87 32 135400 67
68 -2 92499 25 18 21399 68
69 0 224330 131 39 130115 69
70 6 181633 47 30 64466 70
71 -3 271856 109 37 54990 71
72 3 95227 37 32 34777 72
73 0 98146 15 17 27114 73
74 -2 118612 54 12 30080 74
75 1 65475 16 13 69008 75
76 0 108446 22 17 46300 76
77 2 121848 37 17 30594 77
78 2 76302 29 20 30976 78
79 -3 98104 55 17 25568 79
80 -2 30989 5 17 4154 80
81 1 31774 0 17 4143 81
82 -4 150580 27 22 45588 82
83 0 54157 37 15 18625 83
84 1 59382 29 12 26263 84
85 0 84105 17 17 20055 85
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) time_rfc blogged_comp comp_reviewed total_size
-5.995e-01 -6.090e-07 -3.887e-03 3.018e-02 9.778e-06
t
-3.262e-03
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-5.1398 -1.6550 0.1775 1.4676 5.5853
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.995e-01 1.405e+00 -0.427 0.671
time_rfc -6.090e-07 5.345e-06 -0.114 0.910
blogged_comp -3.887e-03 1.316e-02 -0.295 0.768
comp_reviewed 3.018e-02 4.855e-02 0.622 0.536
total_size 9.778e-06 1.105e-05 0.885 0.379
t -3.262e-03 1.259e-02 -0.259 0.796
Residual standard error: 2.494 on 79 degrees of freedom
Multiple R-squared: 0.03531, Adjusted R-squared: -0.02574
F-statistic: 0.5784 on 5 and 79 DF, p-value: 0.7164
> 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.5186478 0.9627044 0.4813522
[2,] 0.4058710 0.8117419 0.5941290
[3,] 0.5061092 0.9877816 0.4938908
[4,] 0.5020004 0.9959992 0.4979996
[5,] 0.5741827 0.8516345 0.4258173
[6,] 0.5323992 0.9352016 0.4676008
[7,] 0.6349597 0.7300806 0.3650403
[8,] 0.6041813 0.7916373 0.3958187
[9,] 0.5787932 0.8424136 0.4212068
[10,] 0.5109314 0.9781372 0.4890686
[11,] 0.5032835 0.9934330 0.4967165
[12,] 0.5479544 0.9040912 0.4520456
[13,] 0.5317044 0.9365911 0.4682956
[14,] 0.5976180 0.8047640 0.4023820
[15,] 0.5479197 0.9041606 0.4520803
[16,] 0.5724860 0.8550281 0.4275140
[17,] 0.6365370 0.7269261 0.3634630
[18,] 0.6074170 0.7851660 0.3925830
[19,] 0.5736164 0.8527671 0.4263836
[20,] 0.5585576 0.8828847 0.4414424
[21,] 0.6947187 0.6105627 0.3052813
[22,] 0.6658231 0.6683537 0.3341769
[23,] 0.6037332 0.7925336 0.3962668
[24,] 0.5780106 0.8439788 0.4219894
[25,] 0.6109991 0.7780017 0.3890009
[26,] 0.5847231 0.8305538 0.4152769
[27,] 0.6145245 0.7709509 0.3854755
[28,] 0.6017518 0.7964963 0.3982482
[29,] 0.5369955 0.9260089 0.4630045
[30,] 0.6050911 0.7898178 0.3949089
[31,] 0.6598486 0.6803027 0.3401514
[32,] 0.6208034 0.7583931 0.3791966
[33,] 0.5743117 0.8513766 0.4256883
[34,] 0.7214489 0.5571022 0.2785511
[35,] 0.7660839 0.4678322 0.2339161
[36,] 0.7463765 0.5072471 0.2536235
[37,] 0.7331924 0.5336152 0.2668076
[38,] 0.6921838 0.6156325 0.3078162
[39,] 0.7484381 0.5031239 0.2515619
[40,] 0.6967328 0.6065344 0.3032672
[41,] 0.6367294 0.7265412 0.3632706
[42,] 0.6400922 0.7198156 0.3599078
[43,] 0.6262771 0.7474459 0.3737229
[44,] 0.5648638 0.8702723 0.4351362
[45,] 0.5010794 0.9978411 0.4989206
[46,] 0.4483408 0.8966816 0.5516592
[47,] 0.5493256 0.9013488 0.4506744
[48,] 0.5558621 0.8882757 0.4441379
[49,] 0.4930974 0.9861948 0.5069026
[50,] 0.7449845 0.5100310 0.2550155
[51,] 0.7142706 0.5714589 0.2857294
[52,] 0.7608810 0.4782380 0.2391190
[53,] 0.7538500 0.4923001 0.2461500
[54,] 0.7022727 0.5954546 0.2977273
[55,] 0.7434898 0.5130204 0.2565102
[56,] 0.6907205 0.6185590 0.3092795
[57,] 0.6764034 0.6471933 0.3235966
[58,] 0.5958301 0.8083398 0.4041699
[59,] 0.5178365 0.9643270 0.4821635
[60,] 0.5537740 0.8924520 0.4462260
[61,] 0.4978785 0.9957571 0.5021215
[62,] 0.7981548 0.4036903 0.2018452
[63,] 0.7282982 0.5434035 0.2717018
[64,] 0.6809735 0.6380529 0.3190265
[65,] 0.5618613 0.8762774 0.4381387
[66,] 0.5121222 0.9757556 0.4878778
[67,] 0.4046397 0.8092794 0.5953603
[68,] 0.3708159 0.7416317 0.6291841
> postscript(file="/var/wessaorg/rcomp/tmp/1lxpq1323941892.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/25ej81323941892.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/3i4xt1323941892.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/4ny541323941892.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/5uwd61323941892.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 = 85
Frequency = 1
1 2 3 4 5 6
1.03484994 3.24007021 -1.05352937 -0.73405620 -4.97352154 3.40056800
7 8 9 10 11 12
3.19032384 -0.93605483 -2.04804300 -0.85234766 0.58900900 -0.47884150
13 14 15 16 17 18
2.28702978 -1.51695447 3.25519229 2.31502693 1.12156089 0.14231531
19 20 21 22 23 24
-2.58214313 -3.34999997 -4.67227710 1.36737081 1.17961819 -4.84445511
25 26 27 28 29 30
1.76028268 1.44895451 0.49698928 -0.51466020 4.16813612 -2.44553451
31 32 33 34 35 36
-1.05048175 -2.76894851 -3.82057494 1.20008309 1.23159029 1.16118579
37 38 39 40 41 42
-0.57352216 3.51730882 3.43871932 1.46758850 1.35555039 -4.73133932
43 44 45 46 47 48
3.12235633 2.00109134 1.33735481 -1.84561961 -3.90512140 0.08088678
49 50 51 52 53 54
-0.05351233 -2.94219962 1.86692087 -0.20075571 -0.82092736 -0.32644737
55 56 57 58 59 60
2.65065770 -3.40315125 -0.43005062 -5.13977275 0.94116373 -1.69925651
61 62 63 64 65 66
1.93678710 1.35368730 4.05494714 1.00075914 -2.57442370 -0.75562080
67 68 69 70 71 72
1.98787693 -1.77771948 -0.97902965 5.58527882 -3.23412326 2.73024149
73 74 75 76 77 78
0.17745671 -1.53328733 0.87905777 0.03312166 2.25643439 2.10656881
79 80 81 82 83 84
-2.63238388 -1.65497676 1.32943368 -4.04616940 0.41218421 1.40339623
85
0.28484713
> postscript(file="/var/wessaorg/rcomp/tmp/613fo1323941892.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 = 85
Frequency = 1
lag(myerror, k = 1) myerror
0 1.03484994 NA
1 3.24007021 1.03484994
2 -1.05352937 3.24007021
3 -0.73405620 -1.05352937
4 -4.97352154 -0.73405620
5 3.40056800 -4.97352154
6 3.19032384 3.40056800
7 -0.93605483 3.19032384
8 -2.04804300 -0.93605483
9 -0.85234766 -2.04804300
10 0.58900900 -0.85234766
11 -0.47884150 0.58900900
12 2.28702978 -0.47884150
13 -1.51695447 2.28702978
14 3.25519229 -1.51695447
15 2.31502693 3.25519229
16 1.12156089 2.31502693
17 0.14231531 1.12156089
18 -2.58214313 0.14231531
19 -3.34999997 -2.58214313
20 -4.67227710 -3.34999997
21 1.36737081 -4.67227710
22 1.17961819 1.36737081
23 -4.84445511 1.17961819
24 1.76028268 -4.84445511
25 1.44895451 1.76028268
26 0.49698928 1.44895451
27 -0.51466020 0.49698928
28 4.16813612 -0.51466020
29 -2.44553451 4.16813612
30 -1.05048175 -2.44553451
31 -2.76894851 -1.05048175
32 -3.82057494 -2.76894851
33 1.20008309 -3.82057494
34 1.23159029 1.20008309
35 1.16118579 1.23159029
36 -0.57352216 1.16118579
37 3.51730882 -0.57352216
38 3.43871932 3.51730882
39 1.46758850 3.43871932
40 1.35555039 1.46758850
41 -4.73133932 1.35555039
42 3.12235633 -4.73133932
43 2.00109134 3.12235633
44 1.33735481 2.00109134
45 -1.84561961 1.33735481
46 -3.90512140 -1.84561961
47 0.08088678 -3.90512140
48 -0.05351233 0.08088678
49 -2.94219962 -0.05351233
50 1.86692087 -2.94219962
51 -0.20075571 1.86692087
52 -0.82092736 -0.20075571
53 -0.32644737 -0.82092736
54 2.65065770 -0.32644737
55 -3.40315125 2.65065770
56 -0.43005062 -3.40315125
57 -5.13977275 -0.43005062
58 0.94116373 -5.13977275
59 -1.69925651 0.94116373
60 1.93678710 -1.69925651
61 1.35368730 1.93678710
62 4.05494714 1.35368730
63 1.00075914 4.05494714
64 -2.57442370 1.00075914
65 -0.75562080 -2.57442370
66 1.98787693 -0.75562080
67 -1.77771948 1.98787693
68 -0.97902965 -1.77771948
69 5.58527882 -0.97902965
70 -3.23412326 5.58527882
71 2.73024149 -3.23412326
72 0.17745671 2.73024149
73 -1.53328733 0.17745671
74 0.87905777 -1.53328733
75 0.03312166 0.87905777
76 2.25643439 0.03312166
77 2.10656881 2.25643439
78 -2.63238388 2.10656881
79 -1.65497676 -2.63238388
80 1.32943368 -1.65497676
81 -4.04616940 1.32943368
82 0.41218421 -4.04616940
83 1.40339623 0.41218421
84 0.28484713 1.40339623
85 NA 0.28484713
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3.24007021 1.03484994
[2,] -1.05352937 3.24007021
[3,] -0.73405620 -1.05352937
[4,] -4.97352154 -0.73405620
[5,] 3.40056800 -4.97352154
[6,] 3.19032384 3.40056800
[7,] -0.93605483 3.19032384
[8,] -2.04804300 -0.93605483
[9,] -0.85234766 -2.04804300
[10,] 0.58900900 -0.85234766
[11,] -0.47884150 0.58900900
[12,] 2.28702978 -0.47884150
[13,] -1.51695447 2.28702978
[14,] 3.25519229 -1.51695447
[15,] 2.31502693 3.25519229
[16,] 1.12156089 2.31502693
[17,] 0.14231531 1.12156089
[18,] -2.58214313 0.14231531
[19,] -3.34999997 -2.58214313
[20,] -4.67227710 -3.34999997
[21,] 1.36737081 -4.67227710
[22,] 1.17961819 1.36737081
[23,] -4.84445511 1.17961819
[24,] 1.76028268 -4.84445511
[25,] 1.44895451 1.76028268
[26,] 0.49698928 1.44895451
[27,] -0.51466020 0.49698928
[28,] 4.16813612 -0.51466020
[29,] -2.44553451 4.16813612
[30,] -1.05048175 -2.44553451
[31,] -2.76894851 -1.05048175
[32,] -3.82057494 -2.76894851
[33,] 1.20008309 -3.82057494
[34,] 1.23159029 1.20008309
[35,] 1.16118579 1.23159029
[36,] -0.57352216 1.16118579
[37,] 3.51730882 -0.57352216
[38,] 3.43871932 3.51730882
[39,] 1.46758850 3.43871932
[40,] 1.35555039 1.46758850
[41,] -4.73133932 1.35555039
[42,] 3.12235633 -4.73133932
[43,] 2.00109134 3.12235633
[44,] 1.33735481 2.00109134
[45,] -1.84561961 1.33735481
[46,] -3.90512140 -1.84561961
[47,] 0.08088678 -3.90512140
[48,] -0.05351233 0.08088678
[49,] -2.94219962 -0.05351233
[50,] 1.86692087 -2.94219962
[51,] -0.20075571 1.86692087
[52,] -0.82092736 -0.20075571
[53,] -0.32644737 -0.82092736
[54,] 2.65065770 -0.32644737
[55,] -3.40315125 2.65065770
[56,] -0.43005062 -3.40315125
[57,] -5.13977275 -0.43005062
[58,] 0.94116373 -5.13977275
[59,] -1.69925651 0.94116373
[60,] 1.93678710 -1.69925651
[61,] 1.35368730 1.93678710
[62,] 4.05494714 1.35368730
[63,] 1.00075914 4.05494714
[64,] -2.57442370 1.00075914
[65,] -0.75562080 -2.57442370
[66,] 1.98787693 -0.75562080
[67,] -1.77771948 1.98787693
[68,] -0.97902965 -1.77771948
[69,] 5.58527882 -0.97902965
[70,] -3.23412326 5.58527882
[71,] 2.73024149 -3.23412326
[72,] 0.17745671 2.73024149
[73,] -1.53328733 0.17745671
[74,] 0.87905777 -1.53328733
[75,] 0.03312166 0.87905777
[76,] 2.25643439 0.03312166
[77,] 2.10656881 2.25643439
[78,] -2.63238388 2.10656881
[79,] -1.65497676 -2.63238388
[80,] 1.32943368 -1.65497676
[81,] -4.04616940 1.32943368
[82,] 0.41218421 -4.04616940
[83,] 1.40339623 0.41218421
[84,] 0.28484713 1.40339623
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3.24007021 1.03484994
2 -1.05352937 3.24007021
3 -0.73405620 -1.05352937
4 -4.97352154 -0.73405620
5 3.40056800 -4.97352154
6 3.19032384 3.40056800
7 -0.93605483 3.19032384
8 -2.04804300 -0.93605483
9 -0.85234766 -2.04804300
10 0.58900900 -0.85234766
11 -0.47884150 0.58900900
12 2.28702978 -0.47884150
13 -1.51695447 2.28702978
14 3.25519229 -1.51695447
15 2.31502693 3.25519229
16 1.12156089 2.31502693
17 0.14231531 1.12156089
18 -2.58214313 0.14231531
19 -3.34999997 -2.58214313
20 -4.67227710 -3.34999997
21 1.36737081 -4.67227710
22 1.17961819 1.36737081
23 -4.84445511 1.17961819
24 1.76028268 -4.84445511
25 1.44895451 1.76028268
26 0.49698928 1.44895451
27 -0.51466020 0.49698928
28 4.16813612 -0.51466020
29 -2.44553451 4.16813612
30 -1.05048175 -2.44553451
31 -2.76894851 -1.05048175
32 -3.82057494 -2.76894851
33 1.20008309 -3.82057494
34 1.23159029 1.20008309
35 1.16118579 1.23159029
36 -0.57352216 1.16118579
37 3.51730882 -0.57352216
38 3.43871932 3.51730882
39 1.46758850 3.43871932
40 1.35555039 1.46758850
41 -4.73133932 1.35555039
42 3.12235633 -4.73133932
43 2.00109134 3.12235633
44 1.33735481 2.00109134
45 -1.84561961 1.33735481
46 -3.90512140 -1.84561961
47 0.08088678 -3.90512140
48 -0.05351233 0.08088678
49 -2.94219962 -0.05351233
50 1.86692087 -2.94219962
51 -0.20075571 1.86692087
52 -0.82092736 -0.20075571
53 -0.32644737 -0.82092736
54 2.65065770 -0.32644737
55 -3.40315125 2.65065770
56 -0.43005062 -3.40315125
57 -5.13977275 -0.43005062
58 0.94116373 -5.13977275
59 -1.69925651 0.94116373
60 1.93678710 -1.69925651
61 1.35368730 1.93678710
62 4.05494714 1.35368730
63 1.00075914 4.05494714
64 -2.57442370 1.00075914
65 -0.75562080 -2.57442370
66 1.98787693 -0.75562080
67 -1.77771948 1.98787693
68 -0.97902965 -1.77771948
69 5.58527882 -0.97902965
70 -3.23412326 5.58527882
71 2.73024149 -3.23412326
72 0.17745671 2.73024149
73 -1.53328733 0.17745671
74 0.87905777 -1.53328733
75 0.03312166 0.87905777
76 2.25643439 0.03312166
77 2.10656881 2.25643439
78 -2.63238388 2.10656881
79 -1.65497676 -2.63238388
80 1.32943368 -1.65497676
81 -4.04616940 1.32943368
82 0.41218421 -4.04616940
83 1.40339623 0.41218421
84 0.28484713 1.40339623
> 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/7qnvf1323941892.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/8gld11323941892.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/9i2ro1323941892.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/10gbxz1323941892.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/11fus31323941892.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/12sx7m1323941892.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/13uktw1323941892.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/14o8lf1323941892.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/15wguc1323941892.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/1627el1323941892.tab")
+ }
>
> try(system("convert tmp/1lxpq1323941892.ps tmp/1lxpq1323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/25ej81323941892.ps tmp/25ej81323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/3i4xt1323941892.ps tmp/3i4xt1323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ny541323941892.ps tmp/4ny541323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/5uwd61323941892.ps tmp/5uwd61323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/613fo1323941892.ps tmp/613fo1323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/7qnvf1323941892.ps tmp/7qnvf1323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/8gld11323941892.ps tmp/8gld11323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/9i2ro1323941892.ps tmp/9i2ro1323941892.png",intern=TRUE))
character(0)
> try(system("convert tmp/10gbxz1323941892.ps tmp/10gbxz1323941892.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.349 0.578 4.086