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
+ ,0
+ ,31
+ ,0
+ ,1527
+ ,595
+ ,34
+ ,0
+ ,32
+ ,0
+ ,1220
+ ,394
+ ,54
+ ,0
+ ,33
+ ,0
+ ,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'
+ ,'Pageviews'
+ ,'CourseCompView'
+ ,'CompendiumView_PR')
+ ,1:60))
> y <- array(NA,dim=c(6,60),dimnames=list(c('Pop','t','Pop_t','Pageviews','CourseCompView','CompendiumView_PR'),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
Pageviews Pop t Pop_t CourseCompView CompendiumView_PR
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 0 31 0 595 34
32 1220 0 32 0 394 54
33 1368 0 33 0 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
61.11336 123.68219 4.83284 0.08484
CourseCompView CompendiumView_PR
2.05542 0.93691
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-314.39 -122.74 -25.29 88.99 434.39
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.11336 181.50531 0.337 0.7376
Pop 123.68219 187.00895 0.661 0.5112
t 4.83284 3.76661 1.283 0.2049
Pop_t 0.08484 5.33740 0.016 0.9874
CourseCompView 2.05542 0.09889 20.784 <2e-16 ***
CompendiumView_PR 0.93691 0.36851 2.542 0.0139 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 177.5 on 54 degrees of freedom
Multiple R-squared: 0.9311, Adjusted R-squared: 0.9247
F-statistic: 145.8 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.4078993665 0.815798733 0.5921006
[2,] 0.4141966377 0.828393275 0.5858034
[3,] 0.3563867313 0.712773463 0.6436133
[4,] 0.3746783907 0.749356781 0.6253216
[5,] 0.2670318861 0.534063772 0.7329681
[6,] 0.1854531934 0.370906387 0.8145468
[7,] 0.1449425038 0.289885008 0.8550575
[8,] 0.4943586695 0.988717339 0.5056413
[9,] 0.3939899425 0.787979885 0.6060101
[10,] 0.3206256554 0.641251311 0.6793743
[11,] 0.3066452899 0.613290580 0.6933547
[12,] 0.3894599842 0.778919968 0.6105400
[13,] 0.3224267467 0.644853493 0.6775733
[14,] 0.3366594899 0.673318980 0.6633405
[15,] 0.3001431806 0.600286361 0.6998568
[16,] 0.2463325208 0.492665042 0.7536675
[17,] 0.1979407111 0.395881422 0.8020593
[18,] 0.1444931477 0.288986295 0.8555069
[19,] 0.1055196863 0.211039373 0.8944803
[20,] 0.0853661850 0.170732370 0.9146338
[21,] 0.0748481098 0.149696220 0.9251519
[22,] 0.0507366066 0.101473213 0.9492634
[23,] 0.0330222449 0.066044490 0.9669778
[24,] 0.0233316453 0.046663291 0.9766684
[25,] 0.0153770825 0.030754165 0.9846229
[26,] 0.0092426085 0.018485217 0.9907574
[27,] 0.0052501415 0.010500283 0.9947499
[28,] 0.0029384372 0.005876874 0.9970616
[29,] 0.0053357317 0.010671463 0.9946643
[30,] 0.0034499292 0.006899858 0.9965501
[31,] 0.0019713198 0.003942640 0.9980287
[32,] 0.0019853682 0.003970736 0.9980146
[33,] 0.0030345439 0.006069088 0.9969655
[34,] 0.0019673519 0.003934704 0.9980326
[35,] 0.0009469185 0.001893837 0.9990531
[36,] 0.0008883628 0.001776726 0.9991116
[37,] 0.0020805661 0.004161132 0.9979194
[38,] 0.0148711687 0.029742337 0.9851288
[39,] 0.0123641568 0.024728314 0.9876358
[40,] 0.0204461798 0.040892360 0.9795538
[41,] 0.0203083794 0.040616759 0.9796916
[42,] 0.0173909701 0.034781940 0.9826090
[43,] 0.0116170302 0.023234060 0.9883830
> postscript(file="/var/wessaorg/rcomp/tmp/18bpw1321900114.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/2r3601321900114.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/3x0b51321900114.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/4qees1321900114.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/5gyyf1321900114.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
227.2476741 -25.2139731 58.0981521 -171.3416085 58.2003142 -143.0023843
7 8 9 10 11 12
-220.0904923 -125.3295274 -108.5399934 12.9681367 14.3361330 137.8749154
13 14 15 16 17 18
-61.2471363 -40.0891721 93.6143017 381.0155214 55.9401791 -15.9106220
19 20 21 22 23 24
-116.1975234 311.3687250 102.5783364 -141.4137618 -96.5070449 -67.3108063
25 26 27 28 29 30
-57.8966697 45.8609166 -20.0055047 124.9632705 -159.7014084 -54.2689476
31 32 33 34 35 36
61.2377256 143.8063968 43.7363190 -36.5114920 0.3622614 -99.0813429
37 38 39 40 41 42
225.0937191 74.2408590 -25.3666169 142.6170740 -279.6965505 -195.4747196
43 44 45 46 47 48
-80.5139135 87.4540847 -314.3907046 -131.3550821 -101.9500179 253.9439966
49 50 51 52 53 54
286.3498403 -182.3402852 77.7823235 -283.2413425 163.6509929 -121.8945369
55 56 57 58 59 60
-179.8088012 -108.0330796 434.3929790 422.8174443 -152.5344542 -125.2930766
> postscript(file="/var/wessaorg/rcomp/tmp/6omgz1321900114.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 227.2476741 NA
1 -25.2139731 227.2476741
2 58.0981521 -25.2139731
3 -171.3416085 58.0981521
4 58.2003142 -171.3416085
5 -143.0023843 58.2003142
6 -220.0904923 -143.0023843
7 -125.3295274 -220.0904923
8 -108.5399934 -125.3295274
9 12.9681367 -108.5399934
10 14.3361330 12.9681367
11 137.8749154 14.3361330
12 -61.2471363 137.8749154
13 -40.0891721 -61.2471363
14 93.6143017 -40.0891721
15 381.0155214 93.6143017
16 55.9401791 381.0155214
17 -15.9106220 55.9401791
18 -116.1975234 -15.9106220
19 311.3687250 -116.1975234
20 102.5783364 311.3687250
21 -141.4137618 102.5783364
22 -96.5070449 -141.4137618
23 -67.3108063 -96.5070449
24 -57.8966697 -67.3108063
25 45.8609166 -57.8966697
26 -20.0055047 45.8609166
27 124.9632705 -20.0055047
28 -159.7014084 124.9632705
29 -54.2689476 -159.7014084
30 61.2377256 -54.2689476
31 143.8063968 61.2377256
32 43.7363190 143.8063968
33 -36.5114920 43.7363190
34 0.3622614 -36.5114920
35 -99.0813429 0.3622614
36 225.0937191 -99.0813429
37 74.2408590 225.0937191
38 -25.3666169 74.2408590
39 142.6170740 -25.3666169
40 -279.6965505 142.6170740
41 -195.4747196 -279.6965505
42 -80.5139135 -195.4747196
43 87.4540847 -80.5139135
44 -314.3907046 87.4540847
45 -131.3550821 -314.3907046
46 -101.9500179 -131.3550821
47 253.9439966 -101.9500179
48 286.3498403 253.9439966
49 -182.3402852 286.3498403
50 77.7823235 -182.3402852
51 -283.2413425 77.7823235
52 163.6509929 -283.2413425
53 -121.8945369 163.6509929
54 -179.8088012 -121.8945369
55 -108.0330796 -179.8088012
56 434.3929790 -108.0330796
57 422.8174443 434.3929790
58 -152.5344542 422.8174443
59 -125.2930766 -152.5344542
60 NA -125.2930766
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -25.2139731 227.2476741
[2,] 58.0981521 -25.2139731
[3,] -171.3416085 58.0981521
[4,] 58.2003142 -171.3416085
[5,] -143.0023843 58.2003142
[6,] -220.0904923 -143.0023843
[7,] -125.3295274 -220.0904923
[8,] -108.5399934 -125.3295274
[9,] 12.9681367 -108.5399934
[10,] 14.3361330 12.9681367
[11,] 137.8749154 14.3361330
[12,] -61.2471363 137.8749154
[13,] -40.0891721 -61.2471363
[14,] 93.6143017 -40.0891721
[15,] 381.0155214 93.6143017
[16,] 55.9401791 381.0155214
[17,] -15.9106220 55.9401791
[18,] -116.1975234 -15.9106220
[19,] 311.3687250 -116.1975234
[20,] 102.5783364 311.3687250
[21,] -141.4137618 102.5783364
[22,] -96.5070449 -141.4137618
[23,] -67.3108063 -96.5070449
[24,] -57.8966697 -67.3108063
[25,] 45.8609166 -57.8966697
[26,] -20.0055047 45.8609166
[27,] 124.9632705 -20.0055047
[28,] -159.7014084 124.9632705
[29,] -54.2689476 -159.7014084
[30,] 61.2377256 -54.2689476
[31,] 143.8063968 61.2377256
[32,] 43.7363190 143.8063968
[33,] -36.5114920 43.7363190
[34,] 0.3622614 -36.5114920
[35,] -99.0813429 0.3622614
[36,] 225.0937191 -99.0813429
[37,] 74.2408590 225.0937191
[38,] -25.3666169 74.2408590
[39,] 142.6170740 -25.3666169
[40,] -279.6965505 142.6170740
[41,] -195.4747196 -279.6965505
[42,] -80.5139135 -195.4747196
[43,] 87.4540847 -80.5139135
[44,] -314.3907046 87.4540847
[45,] -131.3550821 -314.3907046
[46,] -101.9500179 -131.3550821
[47,] 253.9439966 -101.9500179
[48,] 286.3498403 253.9439966
[49,] -182.3402852 286.3498403
[50,] 77.7823235 -182.3402852
[51,] -283.2413425 77.7823235
[52,] 163.6509929 -283.2413425
[53,] -121.8945369 163.6509929
[54,] -179.8088012 -121.8945369
[55,] -108.0330796 -179.8088012
[56,] 434.3929790 -108.0330796
[57,] 422.8174443 434.3929790
[58,] -152.5344542 422.8174443
[59,] -125.2930766 -152.5344542
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -25.2139731 227.2476741
2 58.0981521 -25.2139731
3 -171.3416085 58.0981521
4 58.2003142 -171.3416085
5 -143.0023843 58.2003142
6 -220.0904923 -143.0023843
7 -125.3295274 -220.0904923
8 -108.5399934 -125.3295274
9 12.9681367 -108.5399934
10 14.3361330 12.9681367
11 137.8749154 14.3361330
12 -61.2471363 137.8749154
13 -40.0891721 -61.2471363
14 93.6143017 -40.0891721
15 381.0155214 93.6143017
16 55.9401791 381.0155214
17 -15.9106220 55.9401791
18 -116.1975234 -15.9106220
19 311.3687250 -116.1975234
20 102.5783364 311.3687250
21 -141.4137618 102.5783364
22 -96.5070449 -141.4137618
23 -67.3108063 -96.5070449
24 -57.8966697 -67.3108063
25 45.8609166 -57.8966697
26 -20.0055047 45.8609166
27 124.9632705 -20.0055047
28 -159.7014084 124.9632705
29 -54.2689476 -159.7014084
30 61.2377256 -54.2689476
31 143.8063968 61.2377256
32 43.7363190 143.8063968
33 -36.5114920 43.7363190
34 0.3622614 -36.5114920
35 -99.0813429 0.3622614
36 225.0937191 -99.0813429
37 74.2408590 225.0937191
38 -25.3666169 74.2408590
39 142.6170740 -25.3666169
40 -279.6965505 142.6170740
41 -195.4747196 -279.6965505
42 -80.5139135 -195.4747196
43 87.4540847 -80.5139135
44 -314.3907046 87.4540847
45 -131.3550821 -314.3907046
46 -101.9500179 -131.3550821
47 253.9439966 -101.9500179
48 286.3498403 253.9439966
49 -182.3402852 286.3498403
50 77.7823235 -182.3402852
51 -283.2413425 77.7823235
52 163.6509929 -283.2413425
53 -121.8945369 163.6509929
54 -179.8088012 -121.8945369
55 -108.0330796 -179.8088012
56 434.3929790 -108.0330796
57 422.8174443 434.3929790
58 -152.5344542 422.8174443
59 -125.2930766 -152.5344542
> 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/7vdsy1321900114.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/8a29j1321900114.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/9eyg51321900114.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/102m501321900114.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/11ng5d1321900114.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/12vj5b1321900114.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/13i3r71321900114.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/14q86l1321900115.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/15lyjw1321900115.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/161sff1321900115.tab")
+ }
>
> try(system("convert tmp/18bpw1321900114.ps tmp/18bpw1321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/2r3601321900114.ps tmp/2r3601321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/3x0b51321900114.ps tmp/3x0b51321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/4qees1321900114.ps tmp/4qees1321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/5gyyf1321900114.ps tmp/5gyyf1321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/6omgz1321900114.ps tmp/6omgz1321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/7vdsy1321900114.ps tmp/7vdsy1321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/8a29j1321900114.ps tmp/8a29j1321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/9eyg51321900114.ps tmp/9eyg51321900114.png",intern=TRUE))
character(0)
> try(system("convert tmp/102m501321900114.ps tmp/102m501321900114.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.275 0.508 3.808