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(8587
+ ,0
+ ,9743
+ ,9084
+ ,9081
+ ,9700
+ ,9731
+ ,0
+ ,8587
+ ,9743
+ ,9084
+ ,9081
+ ,9563
+ ,0
+ ,9731
+ ,8587
+ ,9743
+ ,9084
+ ,9998
+ ,0
+ ,9563
+ ,9731
+ ,8587
+ ,9743
+ ,9437
+ ,0
+ ,9998
+ ,9563
+ ,9731
+ ,8587
+ ,10038
+ ,0
+ ,9437
+ ,9998
+ ,9563
+ ,9731
+ ,9918
+ ,0
+ ,10038
+ ,9437
+ ,9998
+ ,9563
+ ,9252
+ ,0
+ ,9918
+ ,10038
+ ,9437
+ ,9998
+ ,9737
+ ,0
+ ,9252
+ ,9918
+ ,10038
+ ,9437
+ ,9035
+ ,0
+ ,9737
+ ,9252
+ ,9918
+ ,10038
+ ,9133
+ ,0
+ ,9035
+ ,9737
+ ,9252
+ ,9918
+ ,9487
+ ,0
+ ,9133
+ ,9035
+ ,9737
+ ,9252
+ ,8700
+ ,0
+ ,9487
+ ,9133
+ ,9035
+ ,9737
+ ,9627
+ ,0
+ ,8700
+ ,9487
+ ,9133
+ ,9035
+ ,8947
+ ,0
+ ,9627
+ ,8700
+ ,9487
+ ,9133
+ ,9283
+ ,0
+ ,8947
+ ,9627
+ ,8700
+ ,9487
+ ,8829
+ ,0
+ ,9283
+ ,8947
+ ,9627
+ ,8700
+ ,9947
+ ,0
+ ,8829
+ ,9283
+ ,8947
+ ,9627
+ ,9628
+ ,0
+ ,9947
+ ,8829
+ ,9283
+ ,8947
+ ,9318
+ ,0
+ ,9628
+ ,9947
+ ,8829
+ ,9283
+ ,9605
+ ,0
+ ,9318
+ ,9628
+ ,9947
+ ,8829
+ ,8640
+ ,0
+ ,9605
+ ,9318
+ ,9628
+ ,9947
+ ,9214
+ ,0
+ ,8640
+ ,9605
+ ,9318
+ ,9628
+ ,9567
+ ,0
+ ,9214
+ ,8640
+ ,9605
+ ,9318
+ ,8547
+ ,0
+ ,9567
+ ,9214
+ ,8640
+ ,9605
+ ,9185
+ ,0
+ ,8547
+ ,9567
+ ,9214
+ ,8640
+ ,9470
+ ,0
+ ,9185
+ ,8547
+ ,9567
+ ,9214
+ ,9123
+ ,0
+ ,9470
+ ,9185
+ ,8547
+ ,9567
+ ,9278
+ ,0
+ ,9123
+ ,9470
+ ,9185
+ ,8547
+ ,10170
+ ,0
+ ,9278
+ ,9123
+ ,9470
+ ,9185
+ ,9434
+ ,0
+ ,10170
+ ,9278
+ ,9123
+ ,9470
+ ,9655
+ ,0
+ ,9434
+ ,10170
+ ,9278
+ ,9123
+ ,9429
+ ,0
+ ,9655
+ ,9434
+ ,10170
+ ,9278
+ ,8739
+ ,0
+ ,9429
+ ,9655
+ ,9434
+ ,10170
+ ,9552
+ ,0
+ ,8739
+ ,9429
+ ,9655
+ ,9434
+ ,9687
+ ,0
+ ,9552
+ ,8739
+ ,9429
+ ,9655
+ ,9019
+ ,1
+ ,9687
+ ,9552
+ ,8739
+ ,9429
+ ,9672
+ ,1
+ ,9019
+ ,9687
+ ,9552
+ ,8739
+ ,9206
+ ,1
+ ,9672
+ ,9019
+ ,9687
+ ,9552
+ ,9069
+ ,1
+ ,9206
+ ,9672
+ ,9019
+ ,9687
+ ,9788
+ ,1
+ ,9069
+ ,9206
+ ,9672
+ ,9019
+ ,10312
+ ,1
+ ,9788
+ ,9069
+ ,9206
+ ,9672
+ ,10105
+ ,1
+ ,10312
+ ,9788
+ ,9069
+ ,9206
+ ,9863
+ ,1
+ ,10105
+ ,10312
+ ,9788
+ ,9069
+ ,9656
+ ,1
+ ,9863
+ ,10105
+ ,10312
+ ,9788
+ ,9295
+ ,1
+ ,9656
+ ,9863
+ ,10105
+ ,10312
+ ,9946
+ ,1
+ ,9295
+ ,9656
+ ,9863
+ ,10105
+ ,9701
+ ,1
+ ,9946
+ ,9295
+ ,9656
+ ,9863
+ ,9049
+ ,1
+ ,9701
+ ,9946
+ ,9295
+ ,9656
+ ,10190
+ ,1
+ ,9049
+ ,9701
+ ,9946
+ ,9295
+ ,9706
+ ,1
+ ,10190
+ ,9049
+ ,9701
+ ,9946
+ ,9765
+ ,1
+ ,9706
+ ,10190
+ ,9049
+ ,9701
+ ,9893
+ ,1
+ ,9765
+ ,9706
+ ,10190
+ ,9049
+ ,9994
+ ,1
+ ,9893
+ ,9765
+ ,9706
+ ,10190
+ ,10433
+ ,1
+ ,9994
+ ,9893
+ ,9765
+ ,9706
+ ,10073
+ ,1
+ ,10433
+ ,9994
+ ,9893
+ ,9765
+ ,10112
+ ,1
+ ,10073
+ ,10433
+ ,9994
+ ,9893
+ ,9266
+ ,1
+ ,10112
+ ,10073
+ ,10433
+ ,9994
+ ,9820
+ ,1
+ ,9266
+ ,10112
+ ,10073
+ ,10433
+ ,10097
+ ,1
+ ,9820
+ ,9266
+ ,10112
+ ,10073
+ ,9115
+ ,1
+ ,10097
+ ,9820
+ ,9266
+ ,10112
+ ,10411
+ ,1
+ ,9115
+ ,10097
+ ,9820
+ ,9266
+ ,9678
+ ,1
+ ,10411
+ ,9115
+ ,10097
+ ,9820
+ ,10408
+ ,1
+ ,9678
+ ,10411
+ ,9115
+ ,10097
+ ,10153
+ ,1
+ ,10408
+ ,9678
+ ,10411
+ ,9115
+ ,10368
+ ,1
+ ,10153
+ ,10408
+ ,9678
+ ,10411
+ ,10581
+ ,1
+ ,10368
+ ,10153
+ ,10408
+ ,9678
+ ,10597
+ ,1
+ ,10581
+ ,10368
+ ,10153
+ ,10408
+ ,10680
+ ,1
+ ,10597
+ ,10581
+ ,10368
+ ,10153
+ ,9738
+ ,1
+ ,10680
+ ,10597
+ ,10581
+ ,10368
+ ,9556
+ ,1
+ ,9738
+ ,10680
+ ,10597
+ ,10581)
+ ,dim=c(6
+ ,71)
+ ,dimnames=list(c('Geboortes'
+ ,'X'
+ ,'(t-1)'
+ ,'(t-2)'
+ ,'(t-3)'
+ ,'(t-4)')
+ ,1:71))
> y <- array(NA,dim=c(6,71),dimnames=list(c('Geboortes','X','(t-1)','(t-2)','(t-3)','(t-4)'),1:71))
> 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
Geboortes X (t-1) (t-2) (t-3) (t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 8587 0 9743 9084 9081 9700 1 0 0 0 0 0 0 0 0 0 0 1
2 9731 0 8587 9743 9084 9081 0 1 0 0 0 0 0 0 0 0 0 2
3 9563 0 9731 8587 9743 9084 0 0 1 0 0 0 0 0 0 0 0 3
4 9998 0 9563 9731 8587 9743 0 0 0 1 0 0 0 0 0 0 0 4
5 9437 0 9998 9563 9731 8587 0 0 0 0 1 0 0 0 0 0 0 5
6 10038 0 9437 9998 9563 9731 0 0 0 0 0 1 0 0 0 0 0 6
7 9918 0 10038 9437 9998 9563 0 0 0 0 0 0 1 0 0 0 0 7
8 9252 0 9918 10038 9437 9998 0 0 0 0 0 0 0 1 0 0 0 8
9 9737 0 9252 9918 10038 9437 0 0 0 0 0 0 0 0 1 0 0 9
10 9035 0 9737 9252 9918 10038 0 0 0 0 0 0 0 0 0 1 0 10
11 9133 0 9035 9737 9252 9918 0 0 0 0 0 0 0 0 0 0 1 11
12 9487 0 9133 9035 9737 9252 0 0 0 0 0 0 0 0 0 0 0 12
13 8700 0 9487 9133 9035 9737 1 0 0 0 0 0 0 0 0 0 0 13
14 9627 0 8700 9487 9133 9035 0 1 0 0 0 0 0 0 0 0 0 14
15 8947 0 9627 8700 9487 9133 0 0 1 0 0 0 0 0 0 0 0 15
16 9283 0 8947 9627 8700 9487 0 0 0 1 0 0 0 0 0 0 0 16
17 8829 0 9283 8947 9627 8700 0 0 0 0 1 0 0 0 0 0 0 17
18 9947 0 8829 9283 8947 9627 0 0 0 0 0 1 0 0 0 0 0 18
19 9628 0 9947 8829 9283 8947 0 0 0 0 0 0 1 0 0 0 0 19
20 9318 0 9628 9947 8829 9283 0 0 0 0 0 0 0 1 0 0 0 20
21 9605 0 9318 9628 9947 8829 0 0 0 0 0 0 0 0 1 0 0 21
22 8640 0 9605 9318 9628 9947 0 0 0 0 0 0 0 0 0 1 0 22
23 9214 0 8640 9605 9318 9628 0 0 0 0 0 0 0 0 0 0 1 23
24 9567 0 9214 8640 9605 9318 0 0 0 0 0 0 0 0 0 0 0 24
25 8547 0 9567 9214 8640 9605 1 0 0 0 0 0 0 0 0 0 0 25
26 9185 0 8547 9567 9214 8640 0 1 0 0 0 0 0 0 0 0 0 26
27 9470 0 9185 8547 9567 9214 0 0 1 0 0 0 0 0 0 0 0 27
28 9123 0 9470 9185 8547 9567 0 0 0 1 0 0 0 0 0 0 0 28
29 9278 0 9123 9470 9185 8547 0 0 0 0 1 0 0 0 0 0 0 29
30 10170 0 9278 9123 9470 9185 0 0 0 0 0 1 0 0 0 0 0 30
31 9434 0 10170 9278 9123 9470 0 0 0 0 0 0 1 0 0 0 0 31
32 9655 0 9434 10170 9278 9123 0 0 0 0 0 0 0 1 0 0 0 32
33 9429 0 9655 9434 10170 9278 0 0 0 0 0 0 0 0 1 0 0 33
34 8739 0 9429 9655 9434 10170 0 0 0 0 0 0 0 0 0 1 0 34
35 9552 0 8739 9429 9655 9434 0 0 0 0 0 0 0 0 0 0 1 35
36 9687 0 9552 8739 9429 9655 0 0 0 0 0 0 0 0 0 0 0 36
37 9019 1 9687 9552 8739 9429 1 0 0 0 0 0 0 0 0 0 0 37
38 9672 1 9019 9687 9552 8739 0 1 0 0 0 0 0 0 0 0 0 38
39 9206 1 9672 9019 9687 9552 0 0 1 0 0 0 0 0 0 0 0 39
40 9069 1 9206 9672 9019 9687 0 0 0 1 0 0 0 0 0 0 0 40
41 9788 1 9069 9206 9672 9019 0 0 0 0 1 0 0 0 0 0 0 41
42 10312 1 9788 9069 9206 9672 0 0 0 0 0 1 0 0 0 0 0 42
43 10105 1 10312 9788 9069 9206 0 0 0 0 0 0 1 0 0 0 0 43
44 9863 1 10105 10312 9788 9069 0 0 0 0 0 0 0 1 0 0 0 44
45 9656 1 9863 10105 10312 9788 0 0 0 0 0 0 0 0 1 0 0 45
46 9295 1 9656 9863 10105 10312 0 0 0 0 0 0 0 0 0 1 0 46
47 9946 1 9295 9656 9863 10105 0 0 0 0 0 0 0 0 0 0 1 47
48 9701 1 9946 9295 9656 9863 0 0 0 0 0 0 0 0 0 0 0 48
49 9049 1 9701 9946 9295 9656 1 0 0 0 0 0 0 0 0 0 0 49
50 10190 1 9049 9701 9946 9295 0 1 0 0 0 0 0 0 0 0 0 50
51 9706 1 10190 9049 9701 9946 0 0 1 0 0 0 0 0 0 0 0 51
52 9765 1 9706 10190 9049 9701 0 0 0 1 0 0 0 0 0 0 0 52
53 9893 1 9765 9706 10190 9049 0 0 0 0 1 0 0 0 0 0 0 53
54 9994 1 9893 9765 9706 10190 0 0 0 0 0 1 0 0 0 0 0 54
55 10433 1 9994 9893 9765 9706 0 0 0 0 0 0 1 0 0 0 0 55
56 10073 1 10433 9994 9893 9765 0 0 0 0 0 0 0 1 0 0 0 56
57 10112 1 10073 10433 9994 9893 0 0 0 0 0 0 0 0 1 0 0 57
58 9266 1 10112 10073 10433 9994 0 0 0 0 0 0 0 0 0 1 0 58
59 9820 1 9266 10112 10073 10433 0 0 0 0 0 0 0 0 0 0 1 59
60 10097 1 9820 9266 10112 10073 0 0 0 0 0 0 0 0 0 0 0 60
61 9115 1 10097 9820 9266 10112 1 0 0 0 0 0 0 0 0 0 0 61
62 10411 1 9115 10097 9820 9266 0 1 0 0 0 0 0 0 0 0 0 62
63 9678 1 10411 9115 10097 9820 0 0 1 0 0 0 0 0 0 0 0 63
64 10408 1 9678 10411 9115 10097 0 0 0 1 0 0 0 0 0 0 0 64
65 10153 1 10408 9678 10411 9115 0 0 0 0 1 0 0 0 0 0 0 65
66 10368 1 10153 10408 9678 10411 0 0 0 0 0 1 0 0 0 0 0 66
67 10581 1 10368 10153 10408 9678 0 0 0 0 0 0 1 0 0 0 0 67
68 10597 1 10581 10368 10153 10408 0 0 0 0 0 0 0 1 0 0 0 68
69 10680 1 10597 10581 10368 10153 0 0 0 0 0 0 0 0 1 0 0 69
70 9738 1 10680 10597 10581 10368 0 0 0 0 0 0 0 0 0 1 0 70
71 9556 1 9738 10680 10597 10581 0 0 0 0 0 0 0 0 0 0 1 71
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X `(t-1)` `(t-2)` `(t-3)` `(t-4)`
4305.74117 111.79702 0.11436 0.14979 0.23190 0.05575
M1 M2 M3 M4 M5 M6
-796.75067 162.95881 -278.39216 -15.42474 -203.39683 379.29033
M7 M8 M9 M10 M11 t
174.16298 -124.86974 -138.79706 -872.60920 -325.27226 3.65374
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-612.40 -117.72 25.07 139.25 607.32
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4305.74117 1689.95810 2.548 0.013775 *
X 111.79702 141.18304 0.792 0.431973
`(t-1)` 0.11436 0.14464 0.791 0.432663
`(t-2)` 0.14979 0.13815 1.084 0.283164
`(t-3)` 0.23190 0.13827 1.677 0.099392 .
`(t-4)` 0.05575 0.14613 0.381 0.704369
M1 -796.75067 211.41494 -3.769 0.000414 ***
M2 162.95881 238.07796 0.684 0.496657
M3 -278.39216 175.87676 -1.583 0.119398
M4 -15.42474 241.10946 -0.064 0.949232
M5 -203.39683 220.11003 -0.924 0.359639
M6 379.29033 191.05324 1.985 0.052301 .
M7 174.16298 208.61837 0.835 0.407555
M8 -124.86974 236.09641 -0.529 0.599088
M9 -138.79706 216.34358 -0.642 0.523925
M10 -872.60920 192.81281 -4.526 3.44e-05 ***
M11 -325.27226 220.44733 -1.476 0.145992
t 3.65374 3.51596 1.039 0.303436
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 272.1 on 53 degrees of freedom
Multiple R-squared: 0.7836, Adjusted R-squared: 0.7142
F-statistic: 11.29 on 17 and 53 DF, p-value: 4.217e-12
> 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.8221705 0.3556590 0.1778295
[2,] 0.7262843 0.5474314 0.2737157
[3,] 0.7341191 0.5317619 0.2658809
[4,] 0.6953216 0.6093568 0.3046784
[5,] 0.6166122 0.7667756 0.3833878
[6,] 0.5649007 0.8701987 0.4350993
[7,] 0.7707962 0.4584077 0.2292038
[8,] 0.7296563 0.5406873 0.2703437
[9,] 0.6671935 0.6656130 0.3328065
[10,] 0.8353458 0.3293084 0.1646542
[11,] 0.8029552 0.3940896 0.1970448
[12,] 0.7901492 0.4197015 0.2098508
[13,] 0.7173029 0.5653942 0.2826971
[14,] 0.7161752 0.5676495 0.2838248
[15,] 0.7014174 0.5971652 0.2985826
[16,] 0.6772723 0.6454555 0.3227277
[17,] 0.6258600 0.7482800 0.3741400
[18,] 0.5571272 0.8857455 0.4428728
[19,] 0.4900986 0.9801972 0.5099014
[20,] 0.7073840 0.5852321 0.2926160
[21,] 0.7700749 0.4598503 0.2299251
[22,] 0.7364107 0.5271786 0.2635893
[23,] 0.7034113 0.5931774 0.2965887
[24,] 0.6456828 0.7086344 0.3543172
[25,] 0.5704220 0.8591561 0.4295780
[26,] 0.4745355 0.9490711 0.5254645
[27,] 0.7320092 0.5359817 0.2679908
[28,] 0.6095326 0.7809348 0.3904674
[29,] 0.8340806 0.3318388 0.1659194
[30,] 0.7077345 0.5845311 0.2922655
> postscript(file="/var/www/html/rcomp/tmp/18g771291980692.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/www/html/rcomp/tmp/2jp7a1291980692.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/www/html/rcomp/tmp/3jp7a1291980692.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/www/html/rcomp/tmp/4jp7a1291980692.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/www/html/rcomp/tmp/5jp7a1291980692.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 = 71
Frequency = 1
1 2 3 4 5 6
-47.2215283 200.7201080 359.7524337 607.3246769 5.2090248 -5.9482069
7 8 9 10 11 12
-0.6863663 -341.7611625 139.5552597 206.3311763 -77.8886095 -34.2139275
13 14 15 16 17 18
52.4757771 69.4995799 -248.4898616 -77.4275108 -454.7771312 184.4883673
19 20 21 22 23 24
-32.9023899 -91.9545337 54.5988774 -154.9795423 25.0737137 78.7762989
25 26 27 28 29 30
-66.6916353 -407.5945505 281.0642106 -243.8564271 1.3656811 239.6168352
31 32 33 34 35 36
-355.5577370 94.7801285 -251.4718179 -97.6184818 266.9342696 123.4750018
37 38 39 40 41 42
172.1672750 -232.0923248 -311.6442748 -612.4008451 262.1953999 209.8109684
43 44 45 46 47 48
94.4079442 -66.1289654 -365.7714061 82.1011963 322.0620032 -210.7462302
49 50 51 52 53 54
-43.8874116 114.1703062 55.5657008 -102.7561068 47.0615013 -413.1233850
55 56 57 58 59 60
209.9260375 46.9982200 41.1273192 -132.6851141 20.2451925 42.7088570
61 62 63 64 65 66
-66.8424770 255.2968812 -136.2482087 429.1162129 138.9455242 -214.8445789
67 68 69 70 71
84.8125115 358.0663131 381.9617677 96.8507656 -556.4265694
> postscript(file="/var/www/html/rcomp/tmp/6uzov1291980692.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 = 71
Frequency = 1
lag(myerror, k = 1) myerror
0 -47.2215283 NA
1 200.7201080 -47.2215283
2 359.7524337 200.7201080
3 607.3246769 359.7524337
4 5.2090248 607.3246769
5 -5.9482069 5.2090248
6 -0.6863663 -5.9482069
7 -341.7611625 -0.6863663
8 139.5552597 -341.7611625
9 206.3311763 139.5552597
10 -77.8886095 206.3311763
11 -34.2139275 -77.8886095
12 52.4757771 -34.2139275
13 69.4995799 52.4757771
14 -248.4898616 69.4995799
15 -77.4275108 -248.4898616
16 -454.7771312 -77.4275108
17 184.4883673 -454.7771312
18 -32.9023899 184.4883673
19 -91.9545337 -32.9023899
20 54.5988774 -91.9545337
21 -154.9795423 54.5988774
22 25.0737137 -154.9795423
23 78.7762989 25.0737137
24 -66.6916353 78.7762989
25 -407.5945505 -66.6916353
26 281.0642106 -407.5945505
27 -243.8564271 281.0642106
28 1.3656811 -243.8564271
29 239.6168352 1.3656811
30 -355.5577370 239.6168352
31 94.7801285 -355.5577370
32 -251.4718179 94.7801285
33 -97.6184818 -251.4718179
34 266.9342696 -97.6184818
35 123.4750018 266.9342696
36 172.1672750 123.4750018
37 -232.0923248 172.1672750
38 -311.6442748 -232.0923248
39 -612.4008451 -311.6442748
40 262.1953999 -612.4008451
41 209.8109684 262.1953999
42 94.4079442 209.8109684
43 -66.1289654 94.4079442
44 -365.7714061 -66.1289654
45 82.1011963 -365.7714061
46 322.0620032 82.1011963
47 -210.7462302 322.0620032
48 -43.8874116 -210.7462302
49 114.1703062 -43.8874116
50 55.5657008 114.1703062
51 -102.7561068 55.5657008
52 47.0615013 -102.7561068
53 -413.1233850 47.0615013
54 209.9260375 -413.1233850
55 46.9982200 209.9260375
56 41.1273192 46.9982200
57 -132.6851141 41.1273192
58 20.2451925 -132.6851141
59 42.7088570 20.2451925
60 -66.8424770 42.7088570
61 255.2968812 -66.8424770
62 -136.2482087 255.2968812
63 429.1162129 -136.2482087
64 138.9455242 429.1162129
65 -214.8445789 138.9455242
66 84.8125115 -214.8445789
67 358.0663131 84.8125115
68 381.9617677 358.0663131
69 96.8507656 381.9617677
70 -556.4265694 96.8507656
71 NA -556.4265694
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 200.7201080 -47.2215283
[2,] 359.7524337 200.7201080
[3,] 607.3246769 359.7524337
[4,] 5.2090248 607.3246769
[5,] -5.9482069 5.2090248
[6,] -0.6863663 -5.9482069
[7,] -341.7611625 -0.6863663
[8,] 139.5552597 -341.7611625
[9,] 206.3311763 139.5552597
[10,] -77.8886095 206.3311763
[11,] -34.2139275 -77.8886095
[12,] 52.4757771 -34.2139275
[13,] 69.4995799 52.4757771
[14,] -248.4898616 69.4995799
[15,] -77.4275108 -248.4898616
[16,] -454.7771312 -77.4275108
[17,] 184.4883673 -454.7771312
[18,] -32.9023899 184.4883673
[19,] -91.9545337 -32.9023899
[20,] 54.5988774 -91.9545337
[21,] -154.9795423 54.5988774
[22,] 25.0737137 -154.9795423
[23,] 78.7762989 25.0737137
[24,] -66.6916353 78.7762989
[25,] -407.5945505 -66.6916353
[26,] 281.0642106 -407.5945505
[27,] -243.8564271 281.0642106
[28,] 1.3656811 -243.8564271
[29,] 239.6168352 1.3656811
[30,] -355.5577370 239.6168352
[31,] 94.7801285 -355.5577370
[32,] -251.4718179 94.7801285
[33,] -97.6184818 -251.4718179
[34,] 266.9342696 -97.6184818
[35,] 123.4750018 266.9342696
[36,] 172.1672750 123.4750018
[37,] -232.0923248 172.1672750
[38,] -311.6442748 -232.0923248
[39,] -612.4008451 -311.6442748
[40,] 262.1953999 -612.4008451
[41,] 209.8109684 262.1953999
[42,] 94.4079442 209.8109684
[43,] -66.1289654 94.4079442
[44,] -365.7714061 -66.1289654
[45,] 82.1011963 -365.7714061
[46,] 322.0620032 82.1011963
[47,] -210.7462302 322.0620032
[48,] -43.8874116 -210.7462302
[49,] 114.1703062 -43.8874116
[50,] 55.5657008 114.1703062
[51,] -102.7561068 55.5657008
[52,] 47.0615013 -102.7561068
[53,] -413.1233850 47.0615013
[54,] 209.9260375 -413.1233850
[55,] 46.9982200 209.9260375
[56,] 41.1273192 46.9982200
[57,] -132.6851141 41.1273192
[58,] 20.2451925 -132.6851141
[59,] 42.7088570 20.2451925
[60,] -66.8424770 42.7088570
[61,] 255.2968812 -66.8424770
[62,] -136.2482087 255.2968812
[63,] 429.1162129 -136.2482087
[64,] 138.9455242 429.1162129
[65,] -214.8445789 138.9455242
[66,] 84.8125115 -214.8445789
[67,] 358.0663131 84.8125115
[68,] 381.9617677 358.0663131
[69,] 96.8507656 381.9617677
[70,] -556.4265694 96.8507656
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 200.7201080 -47.2215283
2 359.7524337 200.7201080
3 607.3246769 359.7524337
4 5.2090248 607.3246769
5 -5.9482069 5.2090248
6 -0.6863663 -5.9482069
7 -341.7611625 -0.6863663
8 139.5552597 -341.7611625
9 206.3311763 139.5552597
10 -77.8886095 206.3311763
11 -34.2139275 -77.8886095
12 52.4757771 -34.2139275
13 69.4995799 52.4757771
14 -248.4898616 69.4995799
15 -77.4275108 -248.4898616
16 -454.7771312 -77.4275108
17 184.4883673 -454.7771312
18 -32.9023899 184.4883673
19 -91.9545337 -32.9023899
20 54.5988774 -91.9545337
21 -154.9795423 54.5988774
22 25.0737137 -154.9795423
23 78.7762989 25.0737137
24 -66.6916353 78.7762989
25 -407.5945505 -66.6916353
26 281.0642106 -407.5945505
27 -243.8564271 281.0642106
28 1.3656811 -243.8564271
29 239.6168352 1.3656811
30 -355.5577370 239.6168352
31 94.7801285 -355.5577370
32 -251.4718179 94.7801285
33 -97.6184818 -251.4718179
34 266.9342696 -97.6184818
35 123.4750018 266.9342696
36 172.1672750 123.4750018
37 -232.0923248 172.1672750
38 -311.6442748 -232.0923248
39 -612.4008451 -311.6442748
40 262.1953999 -612.4008451
41 209.8109684 262.1953999
42 94.4079442 209.8109684
43 -66.1289654 94.4079442
44 -365.7714061 -66.1289654
45 82.1011963 -365.7714061
46 322.0620032 82.1011963
47 -210.7462302 322.0620032
48 -43.8874116 -210.7462302
49 114.1703062 -43.8874116
50 55.5657008 114.1703062
51 -102.7561068 55.5657008
52 47.0615013 -102.7561068
53 -413.1233850 47.0615013
54 209.9260375 -413.1233850
55 46.9982200 209.9260375
56 41.1273192 46.9982200
57 -132.6851141 41.1273192
58 20.2451925 -132.6851141
59 42.7088570 20.2451925
60 -66.8424770 42.7088570
61 255.2968812 -66.8424770
62 -136.2482087 255.2968812
63 429.1162129 -136.2482087
64 138.9455242 429.1162129
65 -214.8445789 138.9455242
66 84.8125115 -214.8445789
67 358.0663131 84.8125115
68 381.9617677 358.0663131
69 96.8507656 381.9617677
70 -556.4265694 96.8507656
> 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/7n85g1291980692.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/www/html/rcomp/tmp/8n85g1291980692.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/www/html/rcomp/tmp/9n85g1291980692.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/www/html/rcomp/tmp/10yz5j1291980692.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/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/111zl71291980692.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/124ikv1291980692.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/13iahl1291980692.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/144ay91291980692.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/15pbff1291980692.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/16llu61291980692.tab")
+ }
>
> try(system("convert tmp/18g771291980692.ps tmp/18g771291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/2jp7a1291980692.ps tmp/2jp7a1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/3jp7a1291980692.ps tmp/3jp7a1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/4jp7a1291980692.ps tmp/4jp7a1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/5jp7a1291980692.ps tmp/5jp7a1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/6uzov1291980692.ps tmp/6uzov1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/7n85g1291980692.ps tmp/7n85g1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/8n85g1291980692.ps tmp/8n85g1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/9n85g1291980692.ps tmp/9n85g1291980692.png",intern=TRUE))
character(0)
> try(system("convert tmp/10yz5j1291980692.ps tmp/10yz5j1291980692.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.645 1.711 6.531