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(9700,0,9081,0,9084,0,9743,0,8587,0,9731,0,9563,0,9998,0,9437,0,10038,0,9918,0,9252,0,9737,0,9035,0,9133,0,9487,0,8700,0,9627,0,8947,0,9283,0,8829,0,9947,0,9628,0,9318,0,9605,0,8640,0,9214,0,9567,0,8547,0,9185,0,9470,0,9123,0,9278,0,10170,0,9434,0,9655,0,9429,0,8739,0,9552,0,9687,0,9019,1,9672,1,9206,1,9069,1,9788,1,10312,1,10105,1,9863,1,9656,1,9295,1,9946,1,9701,1,9049,1,10190,1,9706,1,9765,1,9893,1,9994,1,10433,1,10073,1,10112,1,9266,1,9820,1,10097,1,9115,1,10411,1,9678,1,10408,1,10153,1,10368,1,10581,1,10597,1,10680,1,9738,1,9556,1),dim=c(2,75),dimnames=list(c('Geboortes','X'),1:75))
> y <- array(NA,dim=c(2,75),dimnames=list(c('Geboortes','X'),1:75))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 9700 0 1 0 0 0 0 0 0 0 0 0 0 1
2 9081 0 0 1 0 0 0 0 0 0 0 0 0 2
3 9084 0 0 0 1 0 0 0 0 0 0 0 0 3
4 9743 0 0 0 0 1 0 0 0 0 0 0 0 4
5 8587 0 0 0 0 0 1 0 0 0 0 0 0 5
6 9731 0 0 0 0 0 0 1 0 0 0 0 0 6
7 9563 0 0 0 0 0 0 0 1 0 0 0 0 7
8 9998 0 0 0 0 0 0 0 0 1 0 0 0 8
9 9437 0 0 0 0 0 0 0 0 0 1 0 0 9
10 10038 0 0 0 0 0 0 0 0 0 0 1 0 10
11 9918 0 0 0 0 0 0 0 0 0 0 0 1 11
12 9252 0 0 0 0 0 0 0 0 0 0 0 0 12
13 9737 0 1 0 0 0 0 0 0 0 0 0 0 13
14 9035 0 0 1 0 0 0 0 0 0 0 0 0 14
15 9133 0 0 0 1 0 0 0 0 0 0 0 0 15
16 9487 0 0 0 0 1 0 0 0 0 0 0 0 16
17 8700 0 0 0 0 0 1 0 0 0 0 0 0 17
18 9627 0 0 0 0 0 0 1 0 0 0 0 0 18
19 8947 0 0 0 0 0 0 0 1 0 0 0 0 19
20 9283 0 0 0 0 0 0 0 0 1 0 0 0 20
21 8829 0 0 0 0 0 0 0 0 0 1 0 0 21
22 9947 0 0 0 0 0 0 0 0 0 0 1 0 22
23 9628 0 0 0 0 0 0 0 0 0 0 0 1 23
24 9318 0 0 0 0 0 0 0 0 0 0 0 0 24
25 9605 0 1 0 0 0 0 0 0 0 0 0 0 25
26 8640 0 0 1 0 0 0 0 0 0 0 0 0 26
27 9214 0 0 0 1 0 0 0 0 0 0 0 0 27
28 9567 0 0 0 0 1 0 0 0 0 0 0 0 28
29 8547 0 0 0 0 0 1 0 0 0 0 0 0 29
30 9185 0 0 0 0 0 0 1 0 0 0 0 0 30
31 9470 0 0 0 0 0 0 0 1 0 0 0 0 31
32 9123 0 0 0 0 0 0 0 0 1 0 0 0 32
33 9278 0 0 0 0 0 0 0 0 0 1 0 0 33
34 10170 0 0 0 0 0 0 0 0 0 0 1 0 34
35 9434 0 0 0 0 0 0 0 0 0 0 0 1 35
36 9655 0 0 0 0 0 0 0 0 0 0 0 0 36
37 9429 0 1 0 0 0 0 0 0 0 0 0 0 37
38 8739 0 0 1 0 0 0 0 0 0 0 0 0 38
39 9552 0 0 0 1 0 0 0 0 0 0 0 0 39
40 9687 0 0 0 0 1 0 0 0 0 0 0 0 40
41 9019 1 0 0 0 0 1 0 0 0 0 0 0 41
42 9672 1 0 0 0 0 0 1 0 0 0 0 0 42
43 9206 1 0 0 0 0 0 0 1 0 0 0 0 43
44 9069 1 0 0 0 0 0 0 0 1 0 0 0 44
45 9788 1 0 0 0 0 0 0 0 0 1 0 0 45
46 10312 1 0 0 0 0 0 0 0 0 0 1 0 46
47 10105 1 0 0 0 0 0 0 0 0 0 0 1 47
48 9863 1 0 0 0 0 0 0 0 0 0 0 0 48
49 9656 1 1 0 0 0 0 0 0 0 0 0 0 49
50 9295 1 0 1 0 0 0 0 0 0 0 0 0 50
51 9946 1 0 0 1 0 0 0 0 0 0 0 0 51
52 9701 1 0 0 0 1 0 0 0 0 0 0 0 52
53 9049 1 0 0 0 0 1 0 0 0 0 0 0 53
54 10190 1 0 0 0 0 0 1 0 0 0 0 0 54
55 9706 1 0 0 0 0 0 0 1 0 0 0 0 55
56 9765 1 0 0 0 0 0 0 0 1 0 0 0 56
57 9893 1 0 0 0 0 0 0 0 0 1 0 0 57
58 9994 1 0 0 0 0 0 0 0 0 0 1 0 58
59 10433 1 0 0 0 0 0 0 0 0 0 0 1 59
60 10073 1 0 0 0 0 0 0 0 0 0 0 0 60
61 10112 1 1 0 0 0 0 0 0 0 0 0 0 61
62 9266 1 0 1 0 0 0 0 0 0 0 0 0 62
63 9820 1 0 0 1 0 0 0 0 0 0 0 0 63
64 10097 1 0 0 0 1 0 0 0 0 0 0 0 64
65 9115 1 0 0 0 0 1 0 0 0 0 0 0 65
66 10411 1 0 0 0 0 0 1 0 0 0 0 0 66
67 9678 1 0 0 0 0 0 0 1 0 0 0 0 67
68 10408 1 0 0 0 0 0 0 0 1 0 0 0 68
69 10153 1 0 0 0 0 0 0 0 0 1 0 0 69
70 10368 1 0 0 0 0 0 0 0 0 0 1 0 70
71 10581 1 0 0 0 0 0 0 0 0 0 0 1 71
72 10597 1 0 0 0 0 0 0 0 0 0 0 0 72
73 10680 1 1 0 0 0 0 0 0 0 0 0 0 73
74 9738 1 0 1 0 0 0 0 0 0 0 0 0 74
75 9556 1 0 0 1 0 0 0 0 0 0 0 0 75
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
9433.579 302.401 98.960 -638.141 -284.384 10.728
M5 M6 M7 M8 M9 M10
-922.130 39.412 -339.879 -165.503 -215.127 355.082
M11 t
228.458 4.958
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-719.613 -125.080 -7.113 174.996 690.263
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9433.579 139.584 67.584 < 2e-16 ***
X 302.401 132.824 2.277 0.026324 *
M1 98.960 157.796 0.627 0.532909
M2 -638.141 157.688 -4.047 0.000149 ***
M3 -284.384 157.640 -1.804 0.076167 .
M4 10.728 163.968 0.065 0.948048
M5 -922.130 164.913 -5.592 5.61e-07 ***
M6 39.412 164.543 0.240 0.811501
M7 -339.879 164.230 -2.070 0.042739 *
M8 -165.503 163.973 -1.009 0.316803
M9 -215.127 163.773 -1.314 0.193909
M10 355.082 163.629 2.170 0.033908 *
M11 228.458 163.543 1.397 0.167498
t 4.958 3.062 1.619 0.110537
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 283.2 on 61 degrees of freedom
Multiple R-squared: 0.7387, Adjusted R-squared: 0.6831
F-statistic: 13.27 on 13 and 61 DF, p-value: 2.942e-13
> 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.12855870 0.2571174 0.8714413
[2,] 0.05842723 0.1168545 0.9415728
[3,] 0.33190252 0.6638050 0.6680975
[4,] 0.55021715 0.8995657 0.4497828
[5,] 0.58606600 0.8278680 0.4139340
[6,] 0.51263289 0.9747342 0.4873671
[7,] 0.40704297 0.8140859 0.5929570
[8,] 0.36977791 0.7395558 0.6302221
[9,] 0.31817836 0.6363567 0.6818216
[10,] 0.24873371 0.4974674 0.7512663
[11,] 0.27959815 0.5591963 0.7204019
[12,] 0.23937542 0.4787508 0.7606246
[13,] 0.17982305 0.3596461 0.8201770
[14,] 0.19750773 0.3950155 0.8024923
[15,] 0.29427877 0.5885575 0.7057212
[16,] 0.28327434 0.5665487 0.7167257
[17,] 0.28647636 0.5729527 0.7135236
[18,] 0.36584828 0.7316966 0.6341517
[19,] 0.37000125 0.7400025 0.6299987
[20,] 0.43854162 0.8770832 0.5614584
[21,] 0.39037026 0.7807405 0.6096297
[22,] 0.36631540 0.7326308 0.6336846
[23,] 0.45716300 0.9143260 0.5428370
[24,] 0.39664330 0.7932866 0.6033567
[25,] 0.36248755 0.7249751 0.6375124
[26,] 0.32545941 0.6509188 0.6745406
[27,] 0.29909033 0.5981807 0.7009097
[28,] 0.56166105 0.8766779 0.4383389
[29,] 0.57797441 0.8440512 0.4220256
[30,] 0.64056275 0.7188745 0.3594372
[31,] 0.57590335 0.8481933 0.4240966
[32,] 0.51220415 0.9755917 0.4877958
[33,] 0.56947323 0.8610535 0.4305268
[34,] 0.49126777 0.9825355 0.5087322
[35,] 0.78443993 0.4311201 0.2155601
[36,] 0.71183460 0.5763308 0.2881654
[37,] 0.65407503 0.6918499 0.3459250
[38,] 0.58832591 0.8233482 0.4116741
[39,] 0.58292835 0.8341433 0.4170716
[40,] 0.56019909 0.8796018 0.4398009
[41,] 0.42993851 0.8598770 0.5700615
[42,] 0.29464404 0.5892881 0.7053560
> postscript(file="/var/www/html/rcomp/tmp/12dh31291979777.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/2d5yo1291979777.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/3d5yo1291979777.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/4d5yo1291979777.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/56egr1291979777.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 = 75
Frequency = 1
1 2 3 4 5 6
162.503936 275.646793 -80.067493 278.862770 50.763005 228.263005
7 8 9 10 11 12
434.596339 690.263005 173.929672 199.763005 201.429672 -241.070328
13 14 15 16 17 18
140.012349 170.155206 -90.559079 -36.628816 104.271419 64.771419
19 20 21 22 23 24
-240.895248 -84.228581 -493.561915 49.271419 -148.061915 -234.561915
25 26 27 28 29 30
-51.479237 -284.336380 -69.050666 -16.120403 -108.220168 -436.720168
31 32 33 34 35 36
222.613166 -303.720168 -104.053501 212.779832 -401.553501 42.946499
37 38 39 40 41 42
-286.970824 -244.827966 209.457748 44.388011 1.886834 -311.613166
43 44 45 46 47 48
-403.279832 -719.613166 44.053501 -7.113166 -92.446499 -110.946499
49 50 51 52 53 54
-421.863822 -50.720965 241.564750 -303.504987 -27.604752 146.895248
55 56 57 58 59 60
37.228581 -83.104752 89.561915 -384.604752 176.061915 39.561915
61 62 63 64 65 66
-25.355408 -139.212551 56.073163 33.003426 -21.096339 308.403661
67 68 69 70 71 72
-50.263005 500.403661 290.070328 -70.096339 264.570328 504.070328
73 74 75
483.153005 273.295863 -267.418423
> postscript(file="/var/www/html/rcomp/tmp/66egr1291979777.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 = 75
Frequency = 1
lag(myerror, k = 1) myerror
0 162.503936 NA
1 275.646793 162.503936
2 -80.067493 275.646793
3 278.862770 -80.067493
4 50.763005 278.862770
5 228.263005 50.763005
6 434.596339 228.263005
7 690.263005 434.596339
8 173.929672 690.263005
9 199.763005 173.929672
10 201.429672 199.763005
11 -241.070328 201.429672
12 140.012349 -241.070328
13 170.155206 140.012349
14 -90.559079 170.155206
15 -36.628816 -90.559079
16 104.271419 -36.628816
17 64.771419 104.271419
18 -240.895248 64.771419
19 -84.228581 -240.895248
20 -493.561915 -84.228581
21 49.271419 -493.561915
22 -148.061915 49.271419
23 -234.561915 -148.061915
24 -51.479237 -234.561915
25 -284.336380 -51.479237
26 -69.050666 -284.336380
27 -16.120403 -69.050666
28 -108.220168 -16.120403
29 -436.720168 -108.220168
30 222.613166 -436.720168
31 -303.720168 222.613166
32 -104.053501 -303.720168
33 212.779832 -104.053501
34 -401.553501 212.779832
35 42.946499 -401.553501
36 -286.970824 42.946499
37 -244.827966 -286.970824
38 209.457748 -244.827966
39 44.388011 209.457748
40 1.886834 44.388011
41 -311.613166 1.886834
42 -403.279832 -311.613166
43 -719.613166 -403.279832
44 44.053501 -719.613166
45 -7.113166 44.053501
46 -92.446499 -7.113166
47 -110.946499 -92.446499
48 -421.863822 -110.946499
49 -50.720965 -421.863822
50 241.564750 -50.720965
51 -303.504987 241.564750
52 -27.604752 -303.504987
53 146.895248 -27.604752
54 37.228581 146.895248
55 -83.104752 37.228581
56 89.561915 -83.104752
57 -384.604752 89.561915
58 176.061915 -384.604752
59 39.561915 176.061915
60 -25.355408 39.561915
61 -139.212551 -25.355408
62 56.073163 -139.212551
63 33.003426 56.073163
64 -21.096339 33.003426
65 308.403661 -21.096339
66 -50.263005 308.403661
67 500.403661 -50.263005
68 290.070328 500.403661
69 -70.096339 290.070328
70 264.570328 -70.096339
71 504.070328 264.570328
72 483.153005 504.070328
73 273.295863 483.153005
74 -267.418423 273.295863
75 NA -267.418423
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 275.646793 162.503936
[2,] -80.067493 275.646793
[3,] 278.862770 -80.067493
[4,] 50.763005 278.862770
[5,] 228.263005 50.763005
[6,] 434.596339 228.263005
[7,] 690.263005 434.596339
[8,] 173.929672 690.263005
[9,] 199.763005 173.929672
[10,] 201.429672 199.763005
[11,] -241.070328 201.429672
[12,] 140.012349 -241.070328
[13,] 170.155206 140.012349
[14,] -90.559079 170.155206
[15,] -36.628816 -90.559079
[16,] 104.271419 -36.628816
[17,] 64.771419 104.271419
[18,] -240.895248 64.771419
[19,] -84.228581 -240.895248
[20,] -493.561915 -84.228581
[21,] 49.271419 -493.561915
[22,] -148.061915 49.271419
[23,] -234.561915 -148.061915
[24,] -51.479237 -234.561915
[25,] -284.336380 -51.479237
[26,] -69.050666 -284.336380
[27,] -16.120403 -69.050666
[28,] -108.220168 -16.120403
[29,] -436.720168 -108.220168
[30,] 222.613166 -436.720168
[31,] -303.720168 222.613166
[32,] -104.053501 -303.720168
[33,] 212.779832 -104.053501
[34,] -401.553501 212.779832
[35,] 42.946499 -401.553501
[36,] -286.970824 42.946499
[37,] -244.827966 -286.970824
[38,] 209.457748 -244.827966
[39,] 44.388011 209.457748
[40,] 1.886834 44.388011
[41,] -311.613166 1.886834
[42,] -403.279832 -311.613166
[43,] -719.613166 -403.279832
[44,] 44.053501 -719.613166
[45,] -7.113166 44.053501
[46,] -92.446499 -7.113166
[47,] -110.946499 -92.446499
[48,] -421.863822 -110.946499
[49,] -50.720965 -421.863822
[50,] 241.564750 -50.720965
[51,] -303.504987 241.564750
[52,] -27.604752 -303.504987
[53,] 146.895248 -27.604752
[54,] 37.228581 146.895248
[55,] -83.104752 37.228581
[56,] 89.561915 -83.104752
[57,] -384.604752 89.561915
[58,] 176.061915 -384.604752
[59,] 39.561915 176.061915
[60,] -25.355408 39.561915
[61,] -139.212551 -25.355408
[62,] 56.073163 -139.212551
[63,] 33.003426 56.073163
[64,] -21.096339 33.003426
[65,] 308.403661 -21.096339
[66,] -50.263005 308.403661
[67,] 500.403661 -50.263005
[68,] 290.070328 500.403661
[69,] -70.096339 290.070328
[70,] 264.570328 -70.096339
[71,] 504.070328 264.570328
[72,] 483.153005 504.070328
[73,] 273.295863 483.153005
[74,] -267.418423 273.295863
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 275.646793 162.503936
2 -80.067493 275.646793
3 278.862770 -80.067493
4 50.763005 278.862770
5 228.263005 50.763005
6 434.596339 228.263005
7 690.263005 434.596339
8 173.929672 690.263005
9 199.763005 173.929672
10 201.429672 199.763005
11 -241.070328 201.429672
12 140.012349 -241.070328
13 170.155206 140.012349
14 -90.559079 170.155206
15 -36.628816 -90.559079
16 104.271419 -36.628816
17 64.771419 104.271419
18 -240.895248 64.771419
19 -84.228581 -240.895248
20 -493.561915 -84.228581
21 49.271419 -493.561915
22 -148.061915 49.271419
23 -234.561915 -148.061915
24 -51.479237 -234.561915
25 -284.336380 -51.479237
26 -69.050666 -284.336380
27 -16.120403 -69.050666
28 -108.220168 -16.120403
29 -436.720168 -108.220168
30 222.613166 -436.720168
31 -303.720168 222.613166
32 -104.053501 -303.720168
33 212.779832 -104.053501
34 -401.553501 212.779832
35 42.946499 -401.553501
36 -286.970824 42.946499
37 -244.827966 -286.970824
38 209.457748 -244.827966
39 44.388011 209.457748
40 1.886834 44.388011
41 -311.613166 1.886834
42 -403.279832 -311.613166
43 -719.613166 -403.279832
44 44.053501 -719.613166
45 -7.113166 44.053501
46 -92.446499 -7.113166
47 -110.946499 -92.446499
48 -421.863822 -110.946499
49 -50.720965 -421.863822
50 241.564750 -50.720965
51 -303.504987 241.564750
52 -27.604752 -303.504987
53 146.895248 -27.604752
54 37.228581 146.895248
55 -83.104752 37.228581
56 89.561915 -83.104752
57 -384.604752 89.561915
58 176.061915 -384.604752
59 39.561915 176.061915
60 -25.355408 39.561915
61 -139.212551 -25.355408
62 56.073163 -139.212551
63 33.003426 56.073163
64 -21.096339 33.003426
65 308.403661 -21.096339
66 -50.263005 308.403661
67 500.403661 -50.263005
68 290.070328 500.403661
69 -70.096339 290.070328
70 264.570328 -70.096339
71 504.070328 264.570328
72 483.153005 504.070328
73 273.295863 483.153005
74 -267.418423 273.295863
> 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/7gnfu1291979777.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/8gnfu1291979777.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/99ewf1291979777.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/109ewf1291979777.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/11vxv31291979777.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/12gft91291979777.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/135y821291979777.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/14gq7n1291979777.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/15jq6t1291979777.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/16f0421291979777.tab")
+ }
>
> try(system("convert tmp/12dh31291979777.ps tmp/12dh31291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/2d5yo1291979777.ps tmp/2d5yo1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/3d5yo1291979777.ps tmp/3d5yo1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/4d5yo1291979777.ps tmp/4d5yo1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/56egr1291979777.ps tmp/56egr1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/66egr1291979777.ps tmp/66egr1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/7gnfu1291979777.ps tmp/7gnfu1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/8gnfu1291979777.ps tmp/8gnfu1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/99ewf1291979777.ps tmp/99ewf1291979777.png",intern=TRUE))
character(0)
> try(system("convert tmp/109ewf1291979777.ps tmp/109ewf1291979777.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.650 1.701 5.957