R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(317539
+ ,277915
+ ,317480
+ ,328282
+ ,326011
+ ,325412
+ ,313737
+ ,277128
+ ,317539
+ ,317480
+ ,328282
+ ,326011
+ ,312276
+ ,277103
+ ,313737
+ ,317539
+ ,317480
+ ,328282
+ ,309391
+ ,275037
+ ,312276
+ ,313737
+ ,317539
+ ,317480
+ ,302950
+ ,270150
+ ,309391
+ ,312276
+ ,313737
+ ,317539
+ ,300316
+ ,267140
+ ,302950
+ ,309391
+ ,312276
+ ,313737
+ ,304035
+ ,264993
+ ,300316
+ ,302950
+ ,309391
+ ,312276
+ ,333476
+ ,287259
+ ,304035
+ ,300316
+ ,302950
+ ,309391
+ ,337698
+ ,291186
+ ,333476
+ ,304035
+ ,300316
+ ,302950
+ ,335932
+ ,292300
+ ,337698
+ ,333476
+ ,304035
+ ,300316
+ ,323931
+ ,288186
+ ,335932
+ ,337698
+ ,333476
+ ,304035
+ ,313927
+ ,281477
+ ,323931
+ ,335932
+ ,337698
+ ,333476
+ ,314485
+ ,282656
+ ,313927
+ ,323931
+ ,335932
+ ,337698
+ ,313218
+ ,280190
+ ,314485
+ ,313927
+ ,323931
+ ,335932
+ ,309664
+ ,280408
+ ,313218
+ ,314485
+ ,313927
+ ,323931
+ ,302963
+ ,276836
+ ,309664
+ ,313218
+ ,314485
+ ,313927
+ ,298989
+ ,275216
+ ,302963
+ ,309664
+ ,313218
+ ,314485
+ ,298423
+ ,274352
+ ,298989
+ ,302963
+ ,309664
+ ,313218
+ ,310631
+ ,271311
+ ,298423
+ ,298989
+ ,302963
+ ,309664
+ ,329765
+ ,289802
+ ,310631
+ ,298423
+ ,298989
+ ,302963
+ ,335083
+ ,290726
+ ,329765
+ ,310631
+ ,298423
+ ,298989
+ ,327616
+ ,292300
+ ,335083
+ ,329765
+ ,310631
+ ,298423
+ ,309119
+ ,278506
+ ,327616
+ ,335083
+ ,329765
+ ,310631
+ ,295916
+ ,269826
+ ,309119
+ ,327616
+ ,335083
+ ,329765
+ ,291413
+ ,265861
+ ,295916
+ ,309119
+ ,327616
+ ,335083
+ ,291542
+ ,269034
+ ,291413
+ ,295916
+ ,309119
+ ,327616
+ ,284678
+ ,264176
+ ,291542
+ ,291413
+ ,295916
+ ,309119
+ ,276475
+ ,255198
+ ,284678
+ ,291542
+ ,291413
+ ,295916
+ ,272566
+ ,253353
+ ,276475
+ ,284678
+ ,291542
+ ,291413
+ ,264981
+ ,246057
+ ,272566
+ ,276475
+ ,284678
+ ,291542
+ ,263290
+ ,235372
+ ,264981
+ ,272566
+ ,276475
+ ,284678
+ ,296806
+ ,258556
+ ,263290
+ ,264981
+ ,272566
+ ,276475
+ ,303598
+ ,260993
+ ,296806
+ ,263290
+ ,264981
+ ,272566
+ ,286994
+ ,254663
+ ,303598
+ ,296806
+ ,263290
+ ,264981
+ ,276427
+ ,250643
+ ,286994
+ ,303598
+ ,296806
+ ,263290
+ ,266424
+ ,243422
+ ,276427
+ ,286994
+ ,303598
+ ,296806
+ ,267153
+ ,247105
+ ,266424
+ ,276427
+ ,286994
+ ,303598
+ ,268381
+ ,248541
+ ,267153
+ ,266424
+ ,276427
+ ,286994
+ ,262522
+ ,245039
+ ,268381
+ ,267153
+ ,266424
+ ,276427
+ ,255542
+ ,237080
+ ,262522
+ ,268381
+ ,267153
+ ,266424
+ ,253158
+ ,237085
+ ,255542
+ ,262522
+ ,268381
+ ,267153
+ ,243803
+ ,225554
+ ,253158
+ ,255542
+ ,262522
+ ,268381
+ ,250741
+ ,226839
+ ,243803
+ ,253158
+ ,255542
+ ,262522
+ ,280445
+ ,247934
+ ,250741
+ ,243803
+ ,253158
+ ,255542
+ ,285257
+ ,248333
+ ,280445
+ ,250741
+ ,243803
+ ,253158
+ ,270976
+ ,246969
+ ,285257
+ ,280445
+ ,250741
+ ,243803
+ ,261076
+ ,245098
+ ,270976
+ ,285257
+ ,280445
+ ,250741
+ ,255603
+ ,246263
+ ,261076
+ ,270976
+ ,285257
+ ,280445
+ ,260376
+ ,255765
+ ,255603
+ ,261076
+ ,270976
+ ,285257
+ ,263903
+ ,264319
+ ,260376
+ ,255603
+ ,261076
+ ,270976
+ ,264291
+ ,268347
+ ,263903
+ ,260376
+ ,255603
+ ,261076
+ ,263276
+ ,273046
+ ,264291
+ ,263903
+ ,260376
+ ,255603
+ ,262572
+ ,273963
+ ,263276
+ ,264291
+ ,263903
+ ,260376
+ ,256167
+ ,267430
+ ,262572
+ ,263276
+ ,264291
+ ,263903
+ ,264221
+ ,271993
+ ,256167
+ ,262572
+ ,263276
+ ,264291
+ ,293860
+ ,292710
+ ,264221
+ ,256167
+ ,262572
+ ,263276
+ ,300713
+ ,295881
+ ,293860
+ ,264221
+ ,256167
+ ,262572
+ ,287224
+ ,293299
+ ,300713
+ ,293860
+ ,264221
+ ,256167)
+ ,dim=c(6
+ ,58)
+ ,dimnames=list(c('Werkl_vrouwen'
+ ,'Werkl_mannen'
+ ,'Y_(t)min1'
+ ,'Y_(t)min2'
+ ,'Y_(t)min3'
+ ,'Y_(t)min4')
+ ,1:58))
> y <- array(NA,dim=c(6,58),dimnames=list(c('Werkl_vrouwen','Werkl_mannen','Y_(t)min1','Y_(t)min2','Y_(t)min3','Y_(t)min4'),1:58))
> 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 = '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
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Werkl_vrouwen Werkl_mannen Y_(t)min1 Y_(t)min2 Y_(t)min3 Y_(t)min4 M1 M2 M3
1 317539 277915 317480 328282 326011 325412 1 0 0
2 313737 277128 317539 317480 328282 326011 0 1 0
3 312276 277103 313737 317539 317480 328282 0 0 1
4 309391 275037 312276 313737 317539 317480 0 0 0
5 302950 270150 309391 312276 313737 317539 0 0 0
6 300316 267140 302950 309391 312276 313737 0 0 0
7 304035 264993 300316 302950 309391 312276 0 0 0
8 333476 287259 304035 300316 302950 309391 0 0 0
9 337698 291186 333476 304035 300316 302950 0 0 0
10 335932 292300 337698 333476 304035 300316 0 0 0
11 323931 288186 335932 337698 333476 304035 0 0 0
12 313927 281477 323931 335932 337698 333476 0 0 0
13 314485 282656 313927 323931 335932 337698 1 0 0
14 313218 280190 314485 313927 323931 335932 0 1 0
15 309664 280408 313218 314485 313927 323931 0 0 1
16 302963 276836 309664 313218 314485 313927 0 0 0
17 298989 275216 302963 309664 313218 314485 0 0 0
18 298423 274352 298989 302963 309664 313218 0 0 0
19 310631 271311 298423 298989 302963 309664 0 0 0
20 329765 289802 310631 298423 298989 302963 0 0 0
21 335083 290726 329765 310631 298423 298989 0 0 0
22 327616 292300 335083 329765 310631 298423 0 0 0
23 309119 278506 327616 335083 329765 310631 0 0 0
24 295916 269826 309119 327616 335083 329765 0 0 0
25 291413 265861 295916 309119 327616 335083 1 0 0
26 291542 269034 291413 295916 309119 327616 0 1 0
27 284678 264176 291542 291413 295916 309119 0 0 1
28 276475 255198 284678 291542 291413 295916 0 0 0
29 272566 253353 276475 284678 291542 291413 0 0 0
30 264981 246057 272566 276475 284678 291542 0 0 0
31 263290 235372 264981 272566 276475 284678 0 0 0
32 296806 258556 263290 264981 272566 276475 0 0 0
33 303598 260993 296806 263290 264981 272566 0 0 0
34 286994 254663 303598 296806 263290 264981 0 0 0
35 276427 250643 286994 303598 296806 263290 0 0 0
36 266424 243422 276427 286994 303598 296806 0 0 0
37 267153 247105 266424 276427 286994 303598 1 0 0
38 268381 248541 267153 266424 276427 286994 0 1 0
39 262522 245039 268381 267153 266424 276427 0 0 1
40 255542 237080 262522 268381 267153 266424 0 0 0
41 253158 237085 255542 262522 268381 267153 0 0 0
42 243803 225554 253158 255542 262522 268381 0 0 0
43 250741 226839 243803 253158 255542 262522 0 0 0
44 280445 247934 250741 243803 253158 255542 0 0 0
45 285257 248333 280445 250741 243803 253158 0 0 0
46 270976 246969 285257 280445 250741 243803 0 0 0
47 261076 245098 270976 285257 280445 250741 0 0 0
48 255603 246263 261076 270976 285257 280445 0 0 0
49 260376 255765 255603 261076 270976 285257 1 0 0
50 263903 264319 260376 255603 261076 270976 0 1 0
51 264291 268347 263903 260376 255603 261076 0 0 1
52 263276 273046 264291 263903 260376 255603 0 0 0
53 262572 273963 263276 264291 263903 260376 0 0 0
54 256167 267430 262572 263276 264291 263903 0 0 0
55 264221 271993 256167 262572 263276 264291 0 0 0
56 293860 292710 264221 256167 262572 263276 0 0 0
57 300713 295881 293860 264221 256167 262572 0 0 0
58 287224 293299 300713 293860 264221 256167 0 0 0
M4 M5 M6 M7 M8 M9 M10 M11 t
1 0 0 0 0 0 0 0 0 1
2 0 0 0 0 0 0 0 0 2
3 0 0 0 0 0 0 0 0 3
4 1 0 0 0 0 0 0 0 4
5 0 1 0 0 0 0 0 0 5
6 0 0 1 0 0 0 0 0 6
7 0 0 0 1 0 0 0 0 7
8 0 0 0 0 1 0 0 0 8
9 0 0 0 0 0 1 0 0 9
10 0 0 0 0 0 0 1 0 10
11 0 0 0 0 0 0 0 1 11
12 0 0 0 0 0 0 0 0 12
13 0 0 0 0 0 0 0 0 13
14 0 0 0 0 0 0 0 0 14
15 0 0 0 0 0 0 0 0 15
16 1 0 0 0 0 0 0 0 16
17 0 1 0 0 0 0 0 0 17
18 0 0 1 0 0 0 0 0 18
19 0 0 0 1 0 0 0 0 19
20 0 0 0 0 1 0 0 0 20
21 0 0 0 0 0 1 0 0 21
22 0 0 0 0 0 0 1 0 22
23 0 0 0 0 0 0 0 1 23
24 0 0 0 0 0 0 0 0 24
25 0 0 0 0 0 0 0 0 25
26 0 0 0 0 0 0 0 0 26
27 0 0 0 0 0 0 0 0 27
28 1 0 0 0 0 0 0 0 28
29 0 1 0 0 0 0 0 0 29
30 0 0 1 0 0 0 0 0 30
31 0 0 0 1 0 0 0 0 31
32 0 0 0 0 1 0 0 0 32
33 0 0 0 0 0 1 0 0 33
34 0 0 0 0 0 0 1 0 34
35 0 0 0 0 0 0 0 1 35
36 0 0 0 0 0 0 0 0 36
37 0 0 0 0 0 0 0 0 37
38 0 0 0 0 0 0 0 0 38
39 0 0 0 0 0 0 0 0 39
40 1 0 0 0 0 0 0 0 40
41 0 1 0 0 0 0 0 0 41
42 0 0 1 0 0 0 0 0 42
43 0 0 0 1 0 0 0 0 43
44 0 0 0 0 1 0 0 0 44
45 0 0 0 0 0 1 0 0 45
46 0 0 0 0 0 0 1 0 46
47 0 0 0 0 0 0 0 1 47
48 0 0 0 0 0 0 0 0 48
49 0 0 0 0 0 0 0 0 49
50 0 0 0 0 0 0 0 0 50
51 0 0 0 0 0 0 0 0 51
52 1 0 0 0 0 0 0 0 52
53 0 1 0 0 0 0 0 0 53
54 0 0 1 0 0 0 0 0 54
55 0 0 0 1 0 0 0 0 55
56 0 0 0 0 1 0 0 0 56
57 0 0 0 0 0 1 0 0 57
58 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Werkl_mannen `Y_(t)min1` `Y_(t)min2` `Y_(t)min3`
8.258e+04 4.369e-01 3.176e-01 -7.569e-02 5.829e-02
`Y_(t)min4` M1 M2 M3 M4
5.182e-02 2.259e+03 2.068e+03 6.650e+02 -7.493e+02
M5 M6 M7 M8 M9
-1.635e+03 -2.882e+03 6.330e+03 2.417e+04 2.136e+04
M10 M11 t
1.218e+04 5.210e+03 -5.870e+02
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4662.46 -1296.56 15.27 1180.30 8470.46
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.258e+04 1.739e+04 4.749 2.63e-05 ***
Werkl_mannen 4.369e-01 5.947e-02 7.346 6.20e-09 ***
`Y_(t)min1` 3.176e-01 1.360e-01 2.335 0.0246 *
`Y_(t)min2` -7.569e-02 1.355e-01 -0.559 0.5796
`Y_(t)min3` 5.829e-02 1.339e-01 0.435 0.6657
`Y_(t)min4` 5.182e-02 9.243e-02 0.561 0.5782
M1 2.259e+03 2.484e+03 0.909 0.3686
M2 2.068e+03 2.880e+03 0.718 0.4768
M3 6.650e+02 3.016e+03 0.220 0.8266
M4 -7.493e+02 2.494e+03 -0.300 0.7654
M5 -1.635e+03 2.467e+03 -0.663 0.5114
M6 -2.882e+03 2.566e+03 -1.123 0.2681
M7 6.330e+03 2.760e+03 2.293 0.0272 *
M8 2.417e+04 3.488e+03 6.931 2.34e-08 ***
M9 2.136e+04 4.935e+03 4.328 9.77e-05 ***
M10 1.218e+04 4.576e+03 2.663 0.0111 *
M11 5.210e+03 3.290e+03 1.583 0.1212
t -5.870e+02 9.266e+01 -6.335 1.60e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2578 on 40 degrees of freedom
Multiple R-squared: 0.9929, Adjusted R-squared: 0.9898
F-statistic: 327.7 on 17 and 40 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.7184567 0.5630865161 0.2815432580
[2,] 0.9916611 0.0166778952 0.0083389476
[3,] 0.9970415 0.0059170567 0.0029585283
[4,] 0.9978536 0.0042928110 0.0021464055
[5,] 0.9948282 0.0103435714 0.0051717857
[6,] 0.9953362 0.0093275860 0.0046637930
[7,] 0.9901828 0.0196344117 0.0098172059
[8,] 0.9827362 0.0345275505 0.0172637753
[9,] 0.9797221 0.0405558607 0.0202779304
[10,] 0.9618149 0.0763701601 0.0381850800
[11,] 0.9996109 0.0007782524 0.0003891262
[12,] 0.9996802 0.0006396396 0.0003198198
[13,] 0.9996098 0.0007803992 0.0003901996
[14,] 0.9983106 0.0033788999 0.0016894499
[15,] 0.9936551 0.0126898438 0.0063449219
[16,] 0.9770778 0.0458444601 0.0229222300
[17,] 0.9319920 0.1360160436 0.0680080218
> postscript(file="/var/www/html/rcomp/tmp/1d0m81258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2h74b1258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3sx8p1258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4xe991258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5av3c1258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 58
Frequency = 1
1 2 3 4 5 6
1.876407 -3678.556800 -1414.099722 -662.484712 -2471.459246 153.746856
7 8 9 10 11 12
-3220.925002 -1621.421296 -4295.967750 4019.801912 349.962806 980.598461
13 14 15 16 17 18
1504.976332 1949.536505 1940.519741 320.363885 430.959709 3104.742085
19 20 21 22 23 24
8470.462794 -1073.468003 2327.960888 3011.507143 -870.267349 -475.397983
25 26 27 28 29 30
-1964.537518 -548.339082 -1952.855785 -1095.189422 -413.835831 -1962.467424
31 32 33 34 35 36
-4662.455755 2082.570357 1082.631947 -2123.043104 550.310766 -533.871466
37 38 39 40 41 42
-92.610609 1773.188363 230.638650 1159.232241 1909.679196 -65.910527
43 44 45 46 47 48
1187.324640 2006.067950 1804.631374 -1318.716302 -30.006223 28.670988
49 50 51 52 53 54
550.295388 504.171015 1195.797115 278.078009 544.656172 -1230.110990
55 56 57 58
-1774.406677 -1393.749007 -919.256460 -3589.549648
> postscript(file="/var/www/html/rcomp/tmp/6fh2t1258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 1.876407 NA
1 -3678.556800 1.876407
2 -1414.099722 -3678.556800
3 -662.484712 -1414.099722
4 -2471.459246 -662.484712
5 153.746856 -2471.459246
6 -3220.925002 153.746856
7 -1621.421296 -3220.925002
8 -4295.967750 -1621.421296
9 4019.801912 -4295.967750
10 349.962806 4019.801912
11 980.598461 349.962806
12 1504.976332 980.598461
13 1949.536505 1504.976332
14 1940.519741 1949.536505
15 320.363885 1940.519741
16 430.959709 320.363885
17 3104.742085 430.959709
18 8470.462794 3104.742085
19 -1073.468003 8470.462794
20 2327.960888 -1073.468003
21 3011.507143 2327.960888
22 -870.267349 3011.507143
23 -475.397983 -870.267349
24 -1964.537518 -475.397983
25 -548.339082 -1964.537518
26 -1952.855785 -548.339082
27 -1095.189422 -1952.855785
28 -413.835831 -1095.189422
29 -1962.467424 -413.835831
30 -4662.455755 -1962.467424
31 2082.570357 -4662.455755
32 1082.631947 2082.570357
33 -2123.043104 1082.631947
34 550.310766 -2123.043104
35 -533.871466 550.310766
36 -92.610609 -533.871466
37 1773.188363 -92.610609
38 230.638650 1773.188363
39 1159.232241 230.638650
40 1909.679196 1159.232241
41 -65.910527 1909.679196
42 1187.324640 -65.910527
43 2006.067950 1187.324640
44 1804.631374 2006.067950
45 -1318.716302 1804.631374
46 -30.006223 -1318.716302
47 28.670988 -30.006223
48 550.295388 28.670988
49 504.171015 550.295388
50 1195.797115 504.171015
51 278.078009 1195.797115
52 544.656172 278.078009
53 -1230.110990 544.656172
54 -1774.406677 -1230.110990
55 -1393.749007 -1774.406677
56 -919.256460 -1393.749007
57 -3589.549648 -919.256460
58 NA -3589.549648
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3678.55680 1.876407
[2,] -1414.09972 -3678.556800
[3,] -662.48471 -1414.099722
[4,] -2471.45925 -662.484712
[5,] 153.74686 -2471.459246
[6,] -3220.92500 153.746856
[7,] -1621.42130 -3220.925002
[8,] -4295.96775 -1621.421296
[9,] 4019.80191 -4295.967750
[10,] 349.96281 4019.801912
[11,] 980.59846 349.962806
[12,] 1504.97633 980.598461
[13,] 1949.53650 1504.976332
[14,] 1940.51974 1949.536505
[15,] 320.36389 1940.519741
[16,] 430.95971 320.363885
[17,] 3104.74208 430.959709
[18,] 8470.46279 3104.742085
[19,] -1073.46800 8470.462794
[20,] 2327.96089 -1073.468003
[21,] 3011.50714 2327.960888
[22,] -870.26735 3011.507143
[23,] -475.39798 -870.267349
[24,] -1964.53752 -475.397983
[25,] -548.33908 -1964.537518
[26,] -1952.85578 -548.339082
[27,] -1095.18942 -1952.855785
[28,] -413.83583 -1095.189422
[29,] -1962.46742 -413.835831
[30,] -4662.45575 -1962.467424
[31,] 2082.57036 -4662.455755
[32,] 1082.63195 2082.570357
[33,] -2123.04310 1082.631947
[34,] 550.31077 -2123.043104
[35,] -533.87147 550.310766
[36,] -92.61061 -533.871466
[37,] 1773.18836 -92.610609
[38,] 230.63865 1773.188363
[39,] 1159.23224 230.638650
[40,] 1909.67920 1159.232241
[41,] -65.91053 1909.679196
[42,] 1187.32464 -65.910527
[43,] 2006.06795 1187.324640
[44,] 1804.63137 2006.067950
[45,] -1318.71630 1804.631374
[46,] -30.00622 -1318.716302
[47,] 28.67099 -30.006223
[48,] 550.29539 28.670988
[49,] 504.17101 550.295388
[50,] 1195.79712 504.171015
[51,] 278.07801 1195.797115
[52,] 544.65617 278.078009
[53,] -1230.11099 544.656172
[54,] -1774.40668 -1230.110990
[55,] -1393.74901 -1774.406677
[56,] -919.25646 -1393.749007
[57,] -3589.54965 -919.256460
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3678.55680 1.876407
2 -1414.09972 -3678.556800
3 -662.48471 -1414.099722
4 -2471.45925 -662.484712
5 153.74686 -2471.459246
6 -3220.92500 153.746856
7 -1621.42130 -3220.925002
8 -4295.96775 -1621.421296
9 4019.80191 -4295.967750
10 349.96281 4019.801912
11 980.59846 349.962806
12 1504.97633 980.598461
13 1949.53650 1504.976332
14 1940.51974 1949.536505
15 320.36389 1940.519741
16 430.95971 320.363885
17 3104.74208 430.959709
18 8470.46279 3104.742085
19 -1073.46800 8470.462794
20 2327.96089 -1073.468003
21 3011.50714 2327.960888
22 -870.26735 3011.507143
23 -475.39798 -870.267349
24 -1964.53752 -475.397983
25 -548.33908 -1964.537518
26 -1952.85578 -548.339082
27 -1095.18942 -1952.855785
28 -413.83583 -1095.189422
29 -1962.46742 -413.835831
30 -4662.45575 -1962.467424
31 2082.57036 -4662.455755
32 1082.63195 2082.570357
33 -2123.04310 1082.631947
34 550.31077 -2123.043104
35 -533.87147 550.310766
36 -92.61061 -533.871466
37 1773.18836 -92.610609
38 230.63865 1773.188363
39 1159.23224 230.638650
40 1909.67920 1159.232241
41 -65.91053 1909.679196
42 1187.32464 -65.910527
43 2006.06795 1187.324640
44 1804.63137 2006.067950
45 -1318.71630 1804.631374
46 -30.00622 -1318.716302
47 28.67099 -30.006223
48 550.29539 28.670988
49 504.17101 550.295388
50 1195.79712 504.171015
51 278.07801 1195.797115
52 544.65617 278.078009
53 -1230.11099 544.656172
54 -1774.40668 -1230.110990
55 -1393.74901 -1774.406677
56 -919.25646 -1393.749007
57 -3589.54965 -919.256460
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7piv71258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8vzcj1258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9d6y31258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10nugw1258483540.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/1154si1258483540.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/12j9z41258483540.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/13gkn91258483540.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/14ssxb1258483540.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/15rn6f1258483540.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/16cw2u1258483540.tab")
+ }
>
> system("convert tmp/1d0m81258483540.ps tmp/1d0m81258483540.png")
> system("convert tmp/2h74b1258483540.ps tmp/2h74b1258483540.png")
> system("convert tmp/3sx8p1258483540.ps tmp/3sx8p1258483540.png")
> system("convert tmp/4xe991258483540.ps tmp/4xe991258483540.png")
> system("convert tmp/5av3c1258483540.ps tmp/5av3c1258483540.png")
> system("convert tmp/6fh2t1258483540.ps tmp/6fh2t1258483540.png")
> system("convert tmp/7piv71258483540.ps tmp/7piv71258483540.png")
> system("convert tmp/8vzcj1258483540.ps tmp/8vzcj1258483540.png")
> system("convert tmp/9d6y31258483540.ps tmp/9d6y31258483540.png")
> system("convert tmp/10nugw1258483540.ps tmp/10nugw1258483540.png")
>
>
> proc.time()
user system elapsed
2.404 1.612 4.215