R version 2.12.1 (2010-12-16)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(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,1,9628,1,9318,1,9605,1,8640,1,9214,1,9567,1,8547,1,9185,1,9470,1,9123,1,9278,1,10170,1,9434,1,9655,1,9429,1,8739,1,9552,1,9687,1,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('Monthly_births','Dummy'),1:75))
> y <- array(NA,dim=c(2,75),dimnames=list(c('Monthly_births','Dummy'),1:75))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par20 = ''
> par19 = ''
> par18 = ''
> par17 = ''
> par16 = ''
> par15 = ''
> par14 = ''
> par13 = ''
> par12 = ''
> par11 = ''
> par10 = ''
> par9 = ''
> par8 = ''
> par7 = ''
> par6 = ''
> par5 = ''
> par4 = ''
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> library(lattice)
> library(lmtest)
Loading required package: zoo
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Monthly_births Dummy 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 1 0 0 0 0 0 0 0 0 0 1 0 22
23 9628 1 0 0 0 0 0 0 0 0 0 0 1 23
24 9318 1 0 0 0 0 0 0 0 0 0 0 0 24
25 9605 1 1 0 0 0 0 0 0 0 0 0 0 25
26 8640 1 0 1 0 0 0 0 0 0 0 0 0 26
27 9214 1 0 0 1 0 0 0 0 0 0 0 0 27
28 9567 1 0 0 0 1 0 0 0 0 0 0 0 28
29 8547 1 0 0 0 0 1 0 0 0 0 0 0 29
30 9185 1 0 0 0 0 0 1 0 0 0 0 0 30
31 9470 1 0 0 0 0 0 0 1 0 0 0 0 31
32 9123 1 0 0 0 0 0 0 0 1 0 0 0 32
33 9278 1 0 0 0 0 0 0 0 0 1 0 0 33
34 10170 1 0 0 0 0 0 0 0 0 0 1 0 34
35 9434 1 0 0 0 0 0 0 0 0 0 0 1 35
36 9655 1 0 0 0 0 0 0 0 0 0 0 0 36
37 9429 1 1 0 0 0 0 0 0 0 0 0 0 37
38 8739 1 0 1 0 0 0 0 0 0 0 0 0 38
39 9552 1 0 0 1 0 0 0 0 0 0 0 0 39
40 9687 1 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) Dummy M1 M2 M3 M4
9394.563 -401.306 92.042 -657.550 -316.285 -6.626
M5 M6 M7 M8 M9 M10
-901.575 47.476 -344.306 -182.422 -244.537 380.065
M11 t
240.949 17.449
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-687.46 -150.46 32.52 176.78 646.27
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9394.563 126.031 74.542 < 2e-16 ***
Dummy -401.306 110.822 -3.621 0.000598 ***
M1 92.042 149.134 0.617 0.539416
M2 -657.550 149.134 -4.409 4.29e-05 ***
M3 -316.285 149.169 -2.120 0.038054 *
M4 -6.626 155.004 -0.043 0.966045
M5 -901.575 154.963 -5.818 2.36e-07 ***
M6 47.476 154.956 0.306 0.760354
M7 -344.306 154.983 -2.222 0.030033 *
M8 -182.422 155.043 -1.177 0.243932
M9 -244.537 155.137 -1.576 0.120137
M10 380.065 154.588 2.459 0.016803 *
M11 240.949 154.537 1.559 0.124130
t 17.449 2.285 7.636 1.86e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 267.6 on 61 degrees of freedom
Multiple R-squared: 0.7667, Adjusted R-squared: 0.717
F-statistic: 15.42 on 13 and 61 DF, p-value: 1.134e-14
> 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.1292099 0.2584198 0.8707901
[2,] 0.0583943 0.1167886 0.9416057
[3,] 0.3320659 0.6641317 0.6679341
[4,] 0.5766588 0.8466825 0.4233412
[5,] 0.5854660 0.8290679 0.4145340
[6,] 0.4958271 0.9916541 0.5041729
[7,] 0.4034130 0.8068260 0.5965870
[8,] 0.3391892 0.6783783 0.6608108
[9,] 0.2698921 0.5397843 0.7301079
[10,] 0.2235399 0.4470798 0.7764601
[11,] 0.2274406 0.4548812 0.7725594
[12,] 0.1809673 0.3619346 0.8190327
[13,] 0.1268737 0.2537474 0.8731263
[14,] 0.1590520 0.3181041 0.8409480
[15,] 0.2287311 0.4574623 0.7712689
[16,] 0.2385994 0.4771988 0.7614006
[17,] 0.2327631 0.4655262 0.7672369
[18,] 0.3229424 0.6458848 0.6770576
[19,] 0.3278783 0.6557566 0.6721217
[20,] 0.4200428 0.8400857 0.5799572
[21,] 0.3649284 0.7298568 0.6350716
[22,] 0.3133257 0.6266514 0.6866743
[23,] 0.4419721 0.8839442 0.5580279
[24,] 0.3947190 0.7894380 0.6052810
[25,] 0.4729935 0.9459870 0.5270065
[26,] 0.4391076 0.8782152 0.5608924
[27,] 0.3642892 0.7285784 0.6357108
[28,] 0.5806249 0.8387501 0.4193751
[29,] 0.6450529 0.7098943 0.3549471
[30,] 0.7171928 0.5656144 0.2828072
[31,] 0.6800808 0.6398384 0.3199192
[32,] 0.6387351 0.7225298 0.3612649
[33,] 0.6815200 0.6369599 0.3184800
[34,] 0.6153057 0.7693885 0.3846943
[35,] 0.8607013 0.2785975 0.1392987
[36,] 0.7987939 0.4024123 0.2012061
[37,] 0.7445625 0.5108750 0.2554375
[38,] 0.6720214 0.6559572 0.3279786
[39,] 0.6580060 0.6839881 0.3419940
[40,] 0.6279942 0.7440117 0.3720058
[41,] 0.4905398 0.9810797 0.5094602
[42,] 0.3535629 0.7071259 0.6464371
> postscript(file="/var/www/rcomp/tmp/1xxo81322596447.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/rcomp/tmp/2s5h91322596447.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/rcomp/tmp/3sm1k1322596447.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/rcomp/tmp/441161322596447.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/rcomp/tmp/50v7g1322596447.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
195.945788 309.088645 -46.625640 285.266313 6.766313 184.266313
7 8 9 10 11 12
390.599646 646.266313 129.932979 88.882009 90.548676 -351.951324
13 14 15 16 17 18
23.557711 53.700568 -207.013718 -180.121765 -89.621765 -129.121765
19 20 21 22 23 24
-434.788432 -278.121765 -687.455098 189.799753 -7.533580 -94.033580
25 26 27 28 29 30
83.475455 -149.381688 65.904027 91.795979 -50.704021 -379.204021
31 32 33 34 35 36
280.129313 -246.204021 -46.537354 203.411676 -410.921658 33.578342
37 38 39 40 41 42
-301.912622 -259.769765 194.515949 2.407902 211.907902 -101.592098
43 44 45 46 47 48
-193.258765 -509.592098 254.074569 136.023598 50.690265 32.190265
49 50 51 52 53 54
-284.300700 86.842157 379.127872 -192.980176 32.519824 207.019824
55 56 57 58 59 60
97.353158 -22.980176 149.686491 -391.364479 169.302187 32.802187
61 62 63 64 65 66
-37.688777 -151.545920 43.739794 -6.368253 -110.868253 218.631747
67 68 69 70 71 72
-140.034920 410.631747 200.298414 -226.752557 107.914110 347.414110
73 74 75
320.923145 111.066002 -429.648283
> postscript(file="/var/www/rcomp/tmp/6qni61322596447.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 195.945788 NA
1 309.088645 195.945788
2 -46.625640 309.088645
3 285.266313 -46.625640
4 6.766313 285.266313
5 184.266313 6.766313
6 390.599646 184.266313
7 646.266313 390.599646
8 129.932979 646.266313
9 88.882009 129.932979
10 90.548676 88.882009
11 -351.951324 90.548676
12 23.557711 -351.951324
13 53.700568 23.557711
14 -207.013718 53.700568
15 -180.121765 -207.013718
16 -89.621765 -180.121765
17 -129.121765 -89.621765
18 -434.788432 -129.121765
19 -278.121765 -434.788432
20 -687.455098 -278.121765
21 189.799753 -687.455098
22 -7.533580 189.799753
23 -94.033580 -7.533580
24 83.475455 -94.033580
25 -149.381688 83.475455
26 65.904027 -149.381688
27 91.795979 65.904027
28 -50.704021 91.795979
29 -379.204021 -50.704021
30 280.129313 -379.204021
31 -246.204021 280.129313
32 -46.537354 -246.204021
33 203.411676 -46.537354
34 -410.921658 203.411676
35 33.578342 -410.921658
36 -301.912622 33.578342
37 -259.769765 -301.912622
38 194.515949 -259.769765
39 2.407902 194.515949
40 211.907902 2.407902
41 -101.592098 211.907902
42 -193.258765 -101.592098
43 -509.592098 -193.258765
44 254.074569 -509.592098
45 136.023598 254.074569
46 50.690265 136.023598
47 32.190265 50.690265
48 -284.300700 32.190265
49 86.842157 -284.300700
50 379.127872 86.842157
51 -192.980176 379.127872
52 32.519824 -192.980176
53 207.019824 32.519824
54 97.353158 207.019824
55 -22.980176 97.353158
56 149.686491 -22.980176
57 -391.364479 149.686491
58 169.302187 -391.364479
59 32.802187 169.302187
60 -37.688777 32.802187
61 -151.545920 -37.688777
62 43.739794 -151.545920
63 -6.368253 43.739794
64 -110.868253 -6.368253
65 218.631747 -110.868253
66 -140.034920 218.631747
67 410.631747 -140.034920
68 200.298414 410.631747
69 -226.752557 200.298414
70 107.914110 -226.752557
71 347.414110 107.914110
72 320.923145 347.414110
73 111.066002 320.923145
74 -429.648283 111.066002
75 NA -429.648283
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 309.088645 195.945788
[2,] -46.625640 309.088645
[3,] 285.266313 -46.625640
[4,] 6.766313 285.266313
[5,] 184.266313 6.766313
[6,] 390.599646 184.266313
[7,] 646.266313 390.599646
[8,] 129.932979 646.266313
[9,] 88.882009 129.932979
[10,] 90.548676 88.882009
[11,] -351.951324 90.548676
[12,] 23.557711 -351.951324
[13,] 53.700568 23.557711
[14,] -207.013718 53.700568
[15,] -180.121765 -207.013718
[16,] -89.621765 -180.121765
[17,] -129.121765 -89.621765
[18,] -434.788432 -129.121765
[19,] -278.121765 -434.788432
[20,] -687.455098 -278.121765
[21,] 189.799753 -687.455098
[22,] -7.533580 189.799753
[23,] -94.033580 -7.533580
[24,] 83.475455 -94.033580
[25,] -149.381688 83.475455
[26,] 65.904027 -149.381688
[27,] 91.795979 65.904027
[28,] -50.704021 91.795979
[29,] -379.204021 -50.704021
[30,] 280.129313 -379.204021
[31,] -246.204021 280.129313
[32,] -46.537354 -246.204021
[33,] 203.411676 -46.537354
[34,] -410.921658 203.411676
[35,] 33.578342 -410.921658
[36,] -301.912622 33.578342
[37,] -259.769765 -301.912622
[38,] 194.515949 -259.769765
[39,] 2.407902 194.515949
[40,] 211.907902 2.407902
[41,] -101.592098 211.907902
[42,] -193.258765 -101.592098
[43,] -509.592098 -193.258765
[44,] 254.074569 -509.592098
[45,] 136.023598 254.074569
[46,] 50.690265 136.023598
[47,] 32.190265 50.690265
[48,] -284.300700 32.190265
[49,] 86.842157 -284.300700
[50,] 379.127872 86.842157
[51,] -192.980176 379.127872
[52,] 32.519824 -192.980176
[53,] 207.019824 32.519824
[54,] 97.353158 207.019824
[55,] -22.980176 97.353158
[56,] 149.686491 -22.980176
[57,] -391.364479 149.686491
[58,] 169.302187 -391.364479
[59,] 32.802187 169.302187
[60,] -37.688777 32.802187
[61,] -151.545920 -37.688777
[62,] 43.739794 -151.545920
[63,] -6.368253 43.739794
[64,] -110.868253 -6.368253
[65,] 218.631747 -110.868253
[66,] -140.034920 218.631747
[67,] 410.631747 -140.034920
[68,] 200.298414 410.631747
[69,] -226.752557 200.298414
[70,] 107.914110 -226.752557
[71,] 347.414110 107.914110
[72,] 320.923145 347.414110
[73,] 111.066002 320.923145
[74,] -429.648283 111.066002
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 309.088645 195.945788
2 -46.625640 309.088645
3 285.266313 -46.625640
4 6.766313 285.266313
5 184.266313 6.766313
6 390.599646 184.266313
7 646.266313 390.599646
8 129.932979 646.266313
9 88.882009 129.932979
10 90.548676 88.882009
11 -351.951324 90.548676
12 23.557711 -351.951324
13 53.700568 23.557711
14 -207.013718 53.700568
15 -180.121765 -207.013718
16 -89.621765 -180.121765
17 -129.121765 -89.621765
18 -434.788432 -129.121765
19 -278.121765 -434.788432
20 -687.455098 -278.121765
21 189.799753 -687.455098
22 -7.533580 189.799753
23 -94.033580 -7.533580
24 83.475455 -94.033580
25 -149.381688 83.475455
26 65.904027 -149.381688
27 91.795979 65.904027
28 -50.704021 91.795979
29 -379.204021 -50.704021
30 280.129313 -379.204021
31 -246.204021 280.129313
32 -46.537354 -246.204021
33 203.411676 -46.537354
34 -410.921658 203.411676
35 33.578342 -410.921658
36 -301.912622 33.578342
37 -259.769765 -301.912622
38 194.515949 -259.769765
39 2.407902 194.515949
40 211.907902 2.407902
41 -101.592098 211.907902
42 -193.258765 -101.592098
43 -509.592098 -193.258765
44 254.074569 -509.592098
45 136.023598 254.074569
46 50.690265 136.023598
47 32.190265 50.690265
48 -284.300700 32.190265
49 86.842157 -284.300700
50 379.127872 86.842157
51 -192.980176 379.127872
52 32.519824 -192.980176
53 207.019824 32.519824
54 97.353158 207.019824
55 -22.980176 97.353158
56 149.686491 -22.980176
57 -391.364479 149.686491
58 169.302187 -391.364479
59 32.802187 169.302187
60 -37.688777 32.802187
61 -151.545920 -37.688777
62 43.739794 -151.545920
63 -6.368253 43.739794
64 -110.868253 -6.368253
65 218.631747 -110.868253
66 -140.034920 218.631747
67 410.631747 -140.034920
68 200.298414 410.631747
69 -226.752557 200.298414
70 107.914110 -226.752557
71 347.414110 107.914110
72 320.923145 347.414110
73 111.066002 320.923145
74 -429.648283 111.066002
> 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/rcomp/tmp/778nh1322596447.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/rcomp/tmp/8wwet1322596447.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/rcomp/tmp/9t21l1322596447.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/rcomp/tmp/107iu01322596447.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/115wka1322596447.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/rcomp/tmp/12ylhz1322596447.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/rcomp/tmp/13hof81322596448.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/rcomp/tmp/14cyej1322596448.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/rcomp/tmp/1561121322596448.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/rcomp/tmp/16yfws1322596448.tab")
+ }
>
> try(system("convert tmp/1xxo81322596447.ps tmp/1xxo81322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/2s5h91322596447.ps tmp/2s5h91322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/3sm1k1322596447.ps tmp/3sm1k1322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/441161322596447.ps tmp/441161322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/50v7g1322596447.ps tmp/50v7g1322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/6qni61322596447.ps tmp/6qni61322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/778nh1322596447.ps tmp/778nh1322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/8wwet1322596447.ps tmp/8wwet1322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/9t21l1322596447.ps tmp/9t21l1322596447.png",intern=TRUE))
character(0)
> try(system("convert tmp/107iu01322596447.ps tmp/107iu01322596447.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.208 0.640 4.968