R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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(7
+ ,6.4
+ ,7.7
+ ,19.1
+ ,18.5
+ ,22.4
+ ,5.7
+ ,5.2
+ ,6.4
+ ,7
+ ,6.3
+ ,7.9
+ ,18.1
+ ,16.3
+ ,18.6
+ ,5.9
+ ,5.2
+ ,6.7
+ ,7
+ ,6.2
+ ,7.9
+ ,17
+ ,16.3
+ ,18.6
+ ,5.9
+ ,5.2
+ ,6.8
+ ,7.2
+ ,6.5
+ ,8
+ ,17.1
+ ,16.3
+ ,18.6
+ ,6.1
+ ,5.5
+ ,6.9
+ ,7.3
+ ,6.8
+ ,7.9
+ ,17.4
+ ,16.8
+ ,16.2
+ ,6.3
+ ,5.8
+ ,6.9
+ ,7.1
+ ,6.8
+ ,7.6
+ ,16.8
+ ,16.8
+ ,16.2
+ ,6.2
+ ,5.8
+ ,6.7
+ ,6.8
+ ,6.4
+ ,7.1
+ ,15.3
+ ,16.8
+ ,16.2
+ ,5.9
+ ,5.5
+ ,6.4
+ ,6.4
+ ,6.1
+ ,6.8
+ ,14.3
+ ,14.8
+ ,13.8
+ ,5.7
+ ,5.3
+ ,6.2
+ ,6.1
+ ,5.8
+ ,6.5
+ ,13.4
+ ,14.8
+ ,13.8
+ ,5.4
+ ,5.1
+ ,5.9
+ ,6.5
+ ,6.1
+ ,6.9
+ ,15.3
+ ,14.8
+ ,13.8
+ ,5.6
+ ,5.2
+ ,6.1
+ ,7.7
+ ,7.2
+ ,8.2
+ ,22.1
+ ,21.4
+ ,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+ ,19
+ ,18.4
+ ,6.1
+ ,6
+ ,6.2
+ ,7
+ ,7
+ ,7.1
+ ,17
+ ,16.3
+ ,16.2
+ ,6.2
+ ,6
+ ,6.3
+ ,7
+ ,6.8
+ ,7.1
+ ,15.9
+ ,16.3
+ ,16.2
+ ,6.2
+ ,5.9
+ ,6.4
+ ,7
+ ,6.8
+ ,7.2
+ ,15.8
+ ,16.3
+ ,16.2
+ ,6.2
+ ,5.9
+ ,6.6
+ ,7.7
+ ,7.4
+ ,8
+ ,19.2
+ ,19.7
+ ,21.1
+ ,6.6
+ ,6.3
+ ,7.1
+ ,7.9
+ ,7.6
+ ,8.3
+ ,20.9
+ ,19.7
+ ,21.1
+ ,6.7
+ ,6.3
+ ,7.1
+ ,7.7
+ ,7.6
+ ,7.9
+ ,20.7
+ ,19.7
+ ,21.1
+ ,6.4
+ ,6.2
+ ,6.7)
+ ,dim=c(9
+ ,61)
+ ,dimnames=list(c('Totaal'
+ ,'Mannen'
+ ,'Vrouwen'
+ ,'TotaalJongerdan25jaar'
+ ,'MannenJongerdan25jaar'
+ ,'VrouwenJongerdan25jaar'
+ ,'TotaalOuderdan25'
+ ,'MannenOuderdan25'
+ ,'VrouwenOuderdan25
')
+ ,1:61))
> y <- array(NA,dim=c(9,61),dimnames=list(c('Totaal','Mannen','Vrouwen','TotaalJongerdan25jaar','MannenJongerdan25jaar','VrouwenJongerdan25jaar','TotaalOuderdan25','MannenOuderdan25','VrouwenOuderdan25
'),1:61))
> 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 = '1'
> par3 <- 'No 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
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
Totaal Mannen Vrouwen TotaalJongerdan25jaar MannenJongerdan25jaar
1 7.0 6.4 7.7 19.1 18.5
2 7.0 6.3 7.9 18.1 16.3
3 7.0 6.2 7.9 17.0 16.3
4 7.2 6.5 8.0 17.1 16.3
5 7.3 6.8 7.9 17.4 16.8
6 7.1 6.8 7.6 16.8 16.8
7 6.8 6.4 7.1 15.3 16.8
8 6.4 6.1 6.8 14.3 14.8
9 6.1 5.8 6.5 13.4 14.8
10 6.5 6.1 6.9 15.3 14.8
11 7.7 7.2 8.2 22.1 21.4
12 7.9 7.3 8.7 23.7 21.4
13 7.5 6.9 8.3 22.2 21.4
14 6.9 6.1 7.9 19.5 16.1
15 6.6 5.8 7.5 16.6 16.1
16 6.9 6.2 7.8 17.3 16.1
17 7.7 7.1 8.3 19.8 19.6
18 8.0 7.7 8.4 21.2 19.6
19 8.0 8.0 8.2 21.5 19.6
20 7.7 7.8 7.6 20.6 18.9
21 7.3 7.4 7.2 19.1 18.9
22 7.4 7.4 7.5 19.6 18.9
23 8.1 7.7 8.7 23.4 24.3
24 8.3 7.7 9.0 24.3 24.3
25 8.1 7.8 8.6 24.1 24.3
26 7.9 8.0 7.9 22.8 22.9
27 7.9 8.1 7.8 22.5 22.9
28 8.3 8.4 8.2 23.8 22.9
29 8.6 8.4 8.9 24.9 24.0
30 8.7 8.4 9.0 25.2 24.0
31 8.5 8.3 8.8 24.3 24.0
32 8.3 8.2 8.4 22.8 22.1
33 8.0 8.0 8.0 20.7 22.1
34 8.0 8.0 8.1 19.8 22.1
35 8.8 8.6 9.0 22.5 22.1
36 8.7 8.4 9.2 22.6 22.1
37 8.5 8.2 8.8 22.5 22.1
38 8.1 7.9 8.4 21.8 21.6
39 7.8 7.6 8.0 21.2 21.6
40 7.7 7.6 7.7 20.6 21.6
41 7.5 7.7 7.2 19.9 19.4
42 7.2 7.5 6.8 18.7 19.4
43 6.9 7.1 6.6 17.6 19.4
44 6.6 6.6 6.6 16.4 15.9
45 6.5 6.4 6.6 15.9 15.9
46 6.6 6.5 6.9 16.8 15.9
47 7.7 7.4 7.9 22.8 21.8
48 8.0 7.7 8.3 24.0 21.8
49 7.7 7.6 7.8 22.2 21.8
50 7.2 7.2 7.3 17.9 17.6
51 7.0 7.0 7.1 16.0 17.6
52 7.0 7.0 7.0 16.0 17.6
53 7.3 7.3 7.2 18.5 19.0
54 7.3 7.3 7.2 19.3 19.0
55 7.1 7.1 7.1 18.5 19.0
56 7.0 7.0 7.1 17.0 16.3
57 7.0 6.8 7.1 15.9 16.3
58 7.0 6.8 7.2 15.8 16.3
59 7.7 7.4 8.0 19.2 19.7
60 7.9 7.6 8.3 20.9 19.7
61 7.7 7.6 7.9 20.7 19.7
VrouwenJongerdan25jaar TotaalOuderdan25 MannenOuderdan25 VrouwenOuderdan25\r
1 22.4 5.7 5.2 6.4
2 18.6 5.9 5.2 6.7
3 18.6 5.9 5.2 6.8
4 18.6 6.1 5.5 6.9
5 16.2 6.3 5.8 6.9
6 16.2 6.2 5.8 6.7
7 16.2 5.9 5.5 6.4
8 13.8 5.7 5.3 6.2
9 13.8 5.4 5.1 5.9
10 13.8 5.6 5.2 6.1
11 24.1 6.2 5.8 6.7
12 24.1 6.3 5.8 6.8
13 24.1 6.0 5.5 6.6
14 19.9 5.6 5.0 6.4
15 19.9 5.5 4.9 6.4
16 19.9 5.9 5.3 6.7
17 22.3 6.5 6.1 7.1
18 22.3 6.8 6.5 7.1
19 22.3 6.8 6.8 6.8
20 20.9 6.5 6.7 6.2
21 20.9 6.2 6.4 5.9
22 20.9 6.2 6.3 6.2
23 23.5 6.6 6.2 7.1
24 23.5 6.7 6.1 7.4
25 23.5 6.5 6.2 7.0
26 23.1 6.4 6.4 6.5
27 23.1 6.5 6.6 6.3
28 23.1 6.8 7.0 6.6
29 25.7 7.1 7.0 7.2
30 25.7 7.2 7.0 7.4
31 25.7 7.1 6.9 7.4
32 19.7 7.0 6.8 7.2
33 19.7 6.9 6.7 7.1
34 19.7 6.9 6.7 7.2
35 23.1 7.4 7.1 7.6
36 23.1 7.3 7.0 7.7
37 23.1 7.0 6.8 7.3
38 20.7 6.8 6.5 7.1
39 20.7 6.5 6.2 6.8
40 20.7 6.4 6.3 6.5
41 18.0 6.3 6.4 6.1
42 18.0 6.0 6.3 5.7
43 18.0 5.9 6.1 5.6
44 16.9 5.7 5.7 5.7
45 16.9 5.7 5.6 5.8
46 16.9 5.7 5.6 5.9
47 24.4 6.2 6.2 6.3
48 24.4 6.4 6.3 6.5
49 24.4 6.2 6.2 6.3
50 15.5 6.2 6.0 6.3
51 15.5 6.1 5.9 6.3
52 15.5 6.1 6.0 6.3
53 18.4 6.2 6.1 6.3
54 18.4 6.1 6.1 6.2
55 18.4 6.1 6.0 6.2
56 16.2 6.2 6.0 6.3
57 16.2 6.2 5.9 6.4
58 16.2 6.2 5.9 6.6
59 21.1 6.6 6.3 7.1
60 21.1 6.7 6.3 7.1
61 21.1 6.4 6.2 6.7
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Mannen Vrouwen
0.098147 0.419631 0.338436
TotaalJongerdan25jaar MannenJongerdan25jaar VrouwenJongerdan25jaar
0.011319 0.006737 0.006472
TotaalOuderdan25 MannenOuderdan25 `VrouwenOuderdan25\\r`
0.200739 -0.020104 0.013168
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.076916 -0.025683 0.000527 0.034535 0.065002
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.098147 0.080352 1.221 0.227
Mannen 0.419631 0.070303 5.969 2.16e-07 ***
Vrouwen 0.338436 0.058770 5.759 4.62e-07 ***
TotaalJongerdan25jaar 0.011319 0.011754 0.963 0.340
MannenJongerdan25jaar 0.006737 0.007346 0.917 0.363
VrouwenJongerdan25jaar 0.006472 0.005436 1.191 0.239
TotaalOuderdan25 0.200739 0.163362 1.229 0.225
MannenOuderdan25 -0.020104 0.105651 -0.190 0.850
`VrouwenOuderdan25\\r` 0.013168 0.087707 0.150 0.881
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.03816 on 52 degrees of freedom
Multiple R-squared: 0.997, Adjusted R-squared: 0.9965
F-statistic: 2140 on 8 and 52 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.8983613 0.2032773 0.10163866
[2,] 0.9138851 0.1722297 0.08611486
[3,] 0.8667049 0.2665902 0.13329512
[4,] 0.7969121 0.4061758 0.20308791
[5,] 0.7252935 0.5494129 0.27470646
[6,] 0.6990601 0.6018799 0.30093995
[7,] 0.6010005 0.7979991 0.39899954
[8,] 0.5800578 0.8398844 0.41994221
[9,] 0.7528819 0.4942363 0.24711815
[10,] 0.6786334 0.6427331 0.32136655
[11,] 0.6106745 0.7786511 0.38932554
[12,] 0.6031996 0.7936009 0.39680043
[13,] 0.5623371 0.8753258 0.43766290
[14,] 0.4939000 0.9878001 0.50609997
[15,] 0.4472014 0.8944028 0.55279862
[16,] 0.5440753 0.9118494 0.45592469
[17,] 0.5562407 0.8875186 0.44375929
[18,] 0.5377760 0.9244480 0.46222398
[19,] 0.4587293 0.9174586 0.54127068
[20,] 0.5993417 0.8013166 0.40065828
[21,] 0.5382257 0.9235487 0.46177433
[22,] 0.5118333 0.9763334 0.48816668
[23,] 0.6750703 0.6498594 0.32492970
[24,] 0.6822645 0.6354709 0.31773547
[25,] 0.7287716 0.5424567 0.27122836
[26,] 0.7662877 0.4674247 0.23371233
[27,] 0.7645913 0.4708174 0.23540870
[28,] 0.6968137 0.6063727 0.30318634
[29,] 0.6806524 0.6386952 0.31934762
[30,] 0.6260767 0.7478466 0.37392332
[31,] 0.5640237 0.8719527 0.43597633
[32,] 0.6054629 0.7890743 0.39453714
[33,] 0.5026990 0.9946019 0.49730096
[34,] 0.3974542 0.7949083 0.60254585
[35,] 0.4324671 0.8649342 0.56753290
[36,] 0.3683269 0.7366537 0.63167313
[37,] 0.2887608 0.5775216 0.71123922
[38,] 0.1715303 0.3430605 0.82846974
> postscript(file="/var/fisher/rcomp/tmp/19b8g1353071504.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/fisher/rcomp/tmp/2su6m1353071504.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/fisher/rcomp/tmp/3fkn41353071504.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/fisher/rcomp/tmp/4s3sl1353071504.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/fisher/rcomp/tmp/5s09k1353071504.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 = 61
Frequency = 1
1 2 3 4 5
0.0005269275 -0.0185614777 0.0345353054 0.0382374228 0.0208450437
6 7 8 9 10
-0.0481256018 0.0640632038 -0.0294311739 -0.0316733651 0.0447868174
11 12 13 14 15
0.0388526100 -0.0118288405 -0.0348004066 0.0026029645 0.0147539840
16 17 18 19 20
-0.0387561655 0.0373234486 -0.0163245252 -0.0679405311 0.0091225399
21 22 23 24 25
-0.0125322419 -0.0256831027 -0.0480683011 0.0141795389 -0.0427201974
26 27 28 29 30
-0.0323283435 -0.0504716660 0.0174203589 -0.0242956678 0.0157577390
31 32 33 34 35
-0.0463418270 0.0203037551 -0.0172464222 -0.0422200347 0.0512484082
36 37 38 39 40
-0.0168978294 0.0650023702 -0.0101592320 0.0160361430 0.0503927166
41 42 43 44 45
0.0452176109 0.0415787288 0.0069384883 -0.0081771882 -0.0219189288
46 47 48 49 50
-0.0769163186 0.0572067437 0.0415899612 0.0139153361 -0.0184682600
51 52 53 54 55
-0.0272861207 0.0085679016 0.0404306830 0.0527664210 -0.0224193614
56 57 58 59 60
-0.0524412863 0.0406081460 0.0052628521 0.0107962643 -0.0139761731
61
-0.0128598444
> postscript(file="/var/fisher/rcomp/tmp/68nls1353071504.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 0.0005269275 NA
1 -0.0185614777 0.0005269275
2 0.0345353054 -0.0185614777
3 0.0382374228 0.0345353054
4 0.0208450437 0.0382374228
5 -0.0481256018 0.0208450437
6 0.0640632038 -0.0481256018
7 -0.0294311739 0.0640632038
8 -0.0316733651 -0.0294311739
9 0.0447868174 -0.0316733651
10 0.0388526100 0.0447868174
11 -0.0118288405 0.0388526100
12 -0.0348004066 -0.0118288405
13 0.0026029645 -0.0348004066
14 0.0147539840 0.0026029645
15 -0.0387561655 0.0147539840
16 0.0373234486 -0.0387561655
17 -0.0163245252 0.0373234486
18 -0.0679405311 -0.0163245252
19 0.0091225399 -0.0679405311
20 -0.0125322419 0.0091225399
21 -0.0256831027 -0.0125322419
22 -0.0480683011 -0.0256831027
23 0.0141795389 -0.0480683011
24 -0.0427201974 0.0141795389
25 -0.0323283435 -0.0427201974
26 -0.0504716660 -0.0323283435
27 0.0174203589 -0.0504716660
28 -0.0242956678 0.0174203589
29 0.0157577390 -0.0242956678
30 -0.0463418270 0.0157577390
31 0.0203037551 -0.0463418270
32 -0.0172464222 0.0203037551
33 -0.0422200347 -0.0172464222
34 0.0512484082 -0.0422200347
35 -0.0168978294 0.0512484082
36 0.0650023702 -0.0168978294
37 -0.0101592320 0.0650023702
38 0.0160361430 -0.0101592320
39 0.0503927166 0.0160361430
40 0.0452176109 0.0503927166
41 0.0415787288 0.0452176109
42 0.0069384883 0.0415787288
43 -0.0081771882 0.0069384883
44 -0.0219189288 -0.0081771882
45 -0.0769163186 -0.0219189288
46 0.0572067437 -0.0769163186
47 0.0415899612 0.0572067437
48 0.0139153361 0.0415899612
49 -0.0184682600 0.0139153361
50 -0.0272861207 -0.0184682600
51 0.0085679016 -0.0272861207
52 0.0404306830 0.0085679016
53 0.0527664210 0.0404306830
54 -0.0224193614 0.0527664210
55 -0.0524412863 -0.0224193614
56 0.0406081460 -0.0524412863
57 0.0052628521 0.0406081460
58 0.0107962643 0.0052628521
59 -0.0139761731 0.0107962643
60 -0.0128598444 -0.0139761731
61 NA -0.0128598444
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.018561478 0.0005269275
[2,] 0.034535305 -0.0185614777
[3,] 0.038237423 0.0345353054
[4,] 0.020845044 0.0382374228
[5,] -0.048125602 0.0208450437
[6,] 0.064063204 -0.0481256018
[7,] -0.029431174 0.0640632038
[8,] -0.031673365 -0.0294311739
[9,] 0.044786817 -0.0316733651
[10,] 0.038852610 0.0447868174
[11,] -0.011828840 0.0388526100
[12,] -0.034800407 -0.0118288405
[13,] 0.002602965 -0.0348004066
[14,] 0.014753984 0.0026029645
[15,] -0.038756166 0.0147539840
[16,] 0.037323449 -0.0387561655
[17,] -0.016324525 0.0373234486
[18,] -0.067940531 -0.0163245252
[19,] 0.009122540 -0.0679405311
[20,] -0.012532242 0.0091225399
[21,] -0.025683103 -0.0125322419
[22,] -0.048068301 -0.0256831027
[23,] 0.014179539 -0.0480683011
[24,] -0.042720197 0.0141795389
[25,] -0.032328344 -0.0427201974
[26,] -0.050471666 -0.0323283435
[27,] 0.017420359 -0.0504716660
[28,] -0.024295668 0.0174203589
[29,] 0.015757739 -0.0242956678
[30,] -0.046341827 0.0157577390
[31,] 0.020303755 -0.0463418270
[32,] -0.017246422 0.0203037551
[33,] -0.042220035 -0.0172464222
[34,] 0.051248408 -0.0422200347
[35,] -0.016897829 0.0512484082
[36,] 0.065002370 -0.0168978294
[37,] -0.010159232 0.0650023702
[38,] 0.016036143 -0.0101592320
[39,] 0.050392717 0.0160361430
[40,] 0.045217611 0.0503927166
[41,] 0.041578729 0.0452176109
[42,] 0.006938488 0.0415787288
[43,] -0.008177188 0.0069384883
[44,] -0.021918929 -0.0081771882
[45,] -0.076916319 -0.0219189288
[46,] 0.057206744 -0.0769163186
[47,] 0.041589961 0.0572067437
[48,] 0.013915336 0.0415899612
[49,] -0.018468260 0.0139153361
[50,] -0.027286121 -0.0184682600
[51,] 0.008567902 -0.0272861207
[52,] 0.040430683 0.0085679016
[53,] 0.052766421 0.0404306830
[54,] -0.022419361 0.0527664210
[55,] -0.052441286 -0.0224193614
[56,] 0.040608146 -0.0524412863
[57,] 0.005262852 0.0406081460
[58,] 0.010796264 0.0052628521
[59,] -0.013976173 0.0107962643
[60,] -0.012859844 -0.0139761731
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.018561478 0.0005269275
2 0.034535305 -0.0185614777
3 0.038237423 0.0345353054
4 0.020845044 0.0382374228
5 -0.048125602 0.0208450437
6 0.064063204 -0.0481256018
7 -0.029431174 0.0640632038
8 -0.031673365 -0.0294311739
9 0.044786817 -0.0316733651
10 0.038852610 0.0447868174
11 -0.011828840 0.0388526100
12 -0.034800407 -0.0118288405
13 0.002602965 -0.0348004066
14 0.014753984 0.0026029645
15 -0.038756166 0.0147539840
16 0.037323449 -0.0387561655
17 -0.016324525 0.0373234486
18 -0.067940531 -0.0163245252
19 0.009122540 -0.0679405311
20 -0.012532242 0.0091225399
21 -0.025683103 -0.0125322419
22 -0.048068301 -0.0256831027
23 0.014179539 -0.0480683011
24 -0.042720197 0.0141795389
25 -0.032328344 -0.0427201974
26 -0.050471666 -0.0323283435
27 0.017420359 -0.0504716660
28 -0.024295668 0.0174203589
29 0.015757739 -0.0242956678
30 -0.046341827 0.0157577390
31 0.020303755 -0.0463418270
32 -0.017246422 0.0203037551
33 -0.042220035 -0.0172464222
34 0.051248408 -0.0422200347
35 -0.016897829 0.0512484082
36 0.065002370 -0.0168978294
37 -0.010159232 0.0650023702
38 0.016036143 -0.0101592320
39 0.050392717 0.0160361430
40 0.045217611 0.0503927166
41 0.041578729 0.0452176109
42 0.006938488 0.0415787288
43 -0.008177188 0.0069384883
44 -0.021918929 -0.0081771882
45 -0.076916319 -0.0219189288
46 0.057206744 -0.0769163186
47 0.041589961 0.0572067437
48 0.013915336 0.0415899612
49 -0.018468260 0.0139153361
50 -0.027286121 -0.0184682600
51 0.008567902 -0.0272861207
52 0.040430683 0.0085679016
53 0.052766421 0.0404306830
54 -0.022419361 0.0527664210
55 -0.052441286 -0.0224193614
56 0.040608146 -0.0524412863
57 0.005262852 0.0406081460
58 0.010796264 0.0052628521
59 -0.013976173 0.0107962643
60 -0.012859844 -0.0139761731
> 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/fisher/rcomp/tmp/79jbu1353071504.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/fisher/rcomp/tmp/8v3js1353071504.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/fisher/rcomp/tmp/9cqp31353071504.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/fisher/rcomp/tmp/10t4aw1353071504.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/11nxov1353071504.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/fisher/rcomp/tmp/12qv8f1353071504.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/fisher/rcomp/tmp/136rqp1353071504.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/fisher/rcomp/tmp/14g8cu1353071504.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/fisher/rcomp/tmp/15auw21353071504.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/fisher/rcomp/tmp/16200a1353071504.tab")
+ }
>
> try(system("convert tmp/19b8g1353071504.ps tmp/19b8g1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/2su6m1353071504.ps tmp/2su6m1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/3fkn41353071504.ps tmp/3fkn41353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/4s3sl1353071504.ps tmp/4s3sl1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/5s09k1353071504.ps tmp/5s09k1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/68nls1353071504.ps tmp/68nls1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/79jbu1353071504.ps tmp/79jbu1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/8v3js1353071504.ps tmp/8v3js1353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/9cqp31353071504.ps tmp/9cqp31353071504.png",intern=TRUE))
character(0)
> try(system("convert tmp/10t4aw1353071504.ps tmp/10t4aw1353071504.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.283 1.288 7.569