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(7969
+ ,0
+ ,8255
+ ,8776
+ ,8823
+ ,9051
+ ,8758
+ ,0
+ ,7969
+ ,8255
+ ,8776
+ ,8823
+ ,8693
+ ,0
+ ,8758
+ ,7969
+ ,8255
+ ,8776
+ ,8271
+ ,0
+ ,8693
+ ,8758
+ ,7969
+ ,8255
+ ,7790
+ ,0
+ ,8271
+ ,8693
+ ,8758
+ ,7969
+ ,7769
+ ,0
+ ,7790
+ ,8271
+ ,8693
+ ,8758
+ ,8170
+ ,0
+ ,7769
+ ,7790
+ ,8271
+ ,8693
+ ,8209
+ ,0
+ ,8170
+ ,7769
+ ,7790
+ ,8271
+ ,9395
+ ,0
+ ,8209
+ ,8170
+ ,7769
+ ,7790
+ ,9260
+ ,0
+ ,9395
+ ,8209
+ ,8170
+ ,7769
+ ,9018
+ ,0
+ ,9260
+ ,9395
+ ,8209
+ ,8170
+ ,8501
+ ,0
+ ,9018
+ ,9260
+ ,9395
+ ,8209
+ ,8500
+ ,0
+ ,8501
+ ,9018
+ ,9260
+ ,9395
+ ,9649
+ ,0
+ ,8500
+ ,8501
+ ,9018
+ ,9260
+ ,9319
+ ,0
+ ,9649
+ ,8500
+ ,8501
+ ,9018
+ ,8830
+ ,0
+ ,9319
+ ,9649
+ ,8500
+ ,8501
+ ,8436
+ ,0
+ ,8830
+ ,9319
+ ,9649
+ ,8500
+ ,8169
+ ,0
+ ,8436
+ ,8830
+ ,9319
+ ,9649
+ ,8269
+ ,0
+ ,8169
+ ,8436
+ ,8830
+ ,9319
+ ,7945
+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+ ,1
+ ,8221
+ ,7371
+ ,6917
+ ,6773
+ ,8027
+ ,1
+ ,7953
+ ,8221
+ ,7371
+ ,6917
+ ,7287
+ ,1
+ ,8027
+ ,7953
+ ,8221
+ ,7371
+ ,8076
+ ,1
+ ,7287
+ ,8027
+ ,7953
+ ,8221
+ ,8933
+ ,1
+ ,8076
+ ,7287
+ ,8027
+ ,7953
+ ,9433
+ ,1
+ ,8933
+ ,8076
+ ,7287
+ ,8027
+ ,9479
+ ,1
+ ,9433
+ ,8933
+ ,8076
+ ,7287
+ ,9199
+ ,1
+ ,9479
+ ,9433
+ ,8933
+ ,8076
+ ,9469
+ ,1
+ ,9199
+ ,9479
+ ,9433
+ ,8933
+ ,10015
+ ,1
+ ,9469
+ ,9199
+ ,9479
+ ,9433
+ ,10999
+ ,1
+ ,10015
+ ,9469
+ ,9199
+ ,9479
+ ,13009
+ ,1
+ ,10999
+ ,10015
+ ,9469
+ ,9199
+ ,13699
+ ,1
+ ,13009
+ ,10999
+ ,10015
+ ,9469
+ ,13895
+ ,1
+ ,13699
+ ,13009
+ ,10999
+ ,10015
+ ,13248
+ ,1
+ ,13895
+ ,13699
+ ,13009
+ ,10999
+ ,13973
+ ,1
+ ,13248
+ ,13895
+ ,13699
+ ,13009
+ ,15095
+ ,1
+ ,13973
+ ,13248
+ ,13895
+ ,13699
+ ,15201
+ ,1
+ ,15095
+ ,13973
+ ,13248
+ ,13895
+ ,14823
+ ,1
+ ,15201
+ ,15095
+ ,13973
+ ,13248
+ ,14538
+ ,1
+ ,14823
+ ,15201
+ ,15095
+ ,13973
+ ,14547
+ ,1
+ ,14538
+ ,14823
+ ,15201
+ ,15095
+ ,14407
+ ,1
+ ,14547
+ ,14538
+ ,14823
+ ,15201)
+ ,dim=c(6
+ ,91)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:91))
> y <- array(NA,dim=c(6,91),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:91))
> 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 = '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.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
Y X Y1 Y2 Y3 Y4 t
1 7969 0 8255 8776 8823 9051 1
2 8758 0 7969 8255 8776 8823 2
3 8693 0 8758 7969 8255 8776 3
4 8271 0 8693 8758 7969 8255 4
5 7790 0 8271 8693 8758 7969 5
6 7769 0 7790 8271 8693 8758 6
7 8170 0 7769 7790 8271 8693 7
8 8209 0 8170 7769 7790 8271 8
9 9395 0 8209 8170 7769 7790 9
10 9260 0 9395 8209 8170 7769 10
11 9018 0 9260 9395 8209 8170 11
12 8501 0 9018 9260 9395 8209 12
13 8500 0 8501 9018 9260 9395 13
14 9649 0 8500 8501 9018 9260 14
15 9319 0 9649 8500 8501 9018 15
16 8830 0 9319 9649 8500 8501 16
17 8436 0 8830 9319 9649 8500 17
18 8169 0 8436 8830 9319 9649 18
19 8269 0 8169 8436 8830 9319 19
20 7945 0 8269 8169 8436 8830 20
21 9144 0 7945 8269 8169 8436 21
22 8770 0 9144 7945 8269 8169 22
23 8834 0 8770 9144 7945 8269 23
24 7837 0 8834 8770 9144 7945 24
25 7792 0 7837 8834 8770 9144 25
26 8616 0 7792 7837 8834 8770 26
27 8518 0 8616 7792 7837 8834 27
28 7940 0 8518 8616 7792 7837 28
29 7545 0 7940 8518 8616 7792 29
30 7531 0 7545 7940 8518 8616 30
31 7665 0 7531 7545 7940 8518 31
32 7599 0 7665 7531 7545 7940 32
33 8444 0 7599 7665 7531 7545 33
34 8549 0 8444 7599 7665 7531 34
35 7986 0 8549 8444 7599 7665 35
36 7335 0 7986 8549 8444 7599 36
37 7287 0 7335 7986 8549 8444 37
38 7870 0 7287 7335 7986 8549 38
39 7839 0 7870 7287 7335 7986 39
40 7327 0 7839 7870 7287 7335 40
41 7259 0 7327 7839 7870 7287 41
42 6964 0 7259 7327 7839 7870 42
43 7271 0 6964 7259 7327 7839 43
44 6956 0 7271 6964 7259 7327 44
45 7608 0 6956 7271 6964 7259 45
46 7692 0 7608 6956 7271 6964 46
47 7255 0 7692 7608 6956 7271 47
48 6804 0 7255 7692 7608 6956 48
49 6655 0 6804 7255 7692 7608 49
50 7341 0 6655 6804 7255 7692 50
51 7602 0 7341 6655 6804 7255 51
52 7086 0 7602 7341 6655 6804 52
53 6625 0 7086 7602 7341 6655 53
54 6272 0 6625 7086 7602 7341 54
55 6576 0 6272 6625 7086 7602 55
56 6491 0 6576 6272 6625 7086 56
57 7649 0 6491 6576 6272 6625 57
58 7400 0 7649 6491 6576 6272 58
59 6913 0 7400 7649 6491 6576 59
60 6532 0 6913 7400 7649 6491 60
61 6486 0 6532 6913 7400 7649 61
62 7295 0 6486 6532 6913 7400 62
63 7556 0 7295 6486 6532 6913 63
64 7088 1 7556 7295 6486 6532 64
65 6952 1 7088 7556 7295 6486 65
66 6773 1 6952 7088 7556 7295 66
67 6917 1 6773 6952 7088 7556 67
68 7371 1 6917 6773 6952 7088 68
69 8221 1 7371 6917 6773 6952 69
70 7953 1 8221 7371 6917 6773 70
71 8027 1 7953 8221 7371 6917 71
72 7287 1 8027 7953 8221 7371 72
73 8076 1 7287 8027 7953 8221 73
74 8933 1 8076 7287 8027 7953 74
75 9433 1 8933 8076 7287 8027 75
76 9479 1 9433 8933 8076 7287 76
77 9199 1 9479 9433 8933 8076 77
78 9469 1 9199 9479 9433 8933 78
79 10015 1 9469 9199 9479 9433 79
80 10999 1 10015 9469 9199 9479 80
81 13009 1 10999 10015 9469 9199 81
82 13699 1 13009 10999 10015 9469 82
83 13895 1 13699 13009 10999 10015 83
84 13248 1 13895 13699 13009 10999 84
85 13973 1 13248 13895 13699 13009 85
86 15095 1 13973 13248 13895 13699 86
87 15201 1 15095 13973 13248 13895 87
88 14823 1 15201 15095 13973 13248 88
89 14538 1 14823 15201 15095 13973 89
90 14547 1 14538 14823 15201 15095 90
91 14407 1 14547 14538 14823 15201 91
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
-53.6519 389.3134 1.0648 -0.2535 -0.2026 0.3902
t
0.9382
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-858.00 -317.83 -98.75 168.83 1753.18
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -53.6519 278.5856 -0.193 0.847747
X 389.3134 203.3308 1.915 0.058937 .
Y1 1.0648 0.1008 10.563 < 2e-16 ***
Y2 -0.2535 0.1517 -1.671 0.098412 .
Y3 -0.2026 0.1520 -1.333 0.186207
Y4 0.3902 0.1049 3.722 0.000357 ***
t 0.9382 3.2853 0.286 0.775916
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 493.4 on 84 degrees of freedom
Multiple R-squared: 0.9551, Adjusted R-squared: 0.9519
F-statistic: 297.8 on 6 and 84 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.89397314 0.21205372 0.1060269
[2,] 0.84936587 0.30126826 0.1506341
[3,] 0.75530629 0.48938741 0.2446937
[4,] 0.65213701 0.69572599 0.3478630
[5,] 0.77444569 0.45110861 0.2255543
[6,] 0.73823516 0.52352968 0.2617648
[7,] 0.66478217 0.67043567 0.3352178
[8,] 0.59692119 0.80615762 0.4030788
[9,] 0.61819285 0.76361430 0.3818072
[10,] 0.57077265 0.85845469 0.4292273
[11,] 0.62771591 0.74456817 0.3722841
[12,] 0.75187794 0.49624412 0.2481221
[13,] 0.73621062 0.52757876 0.2637894
[14,] 0.68034147 0.63931705 0.3196585
[15,] 0.72168743 0.55662513 0.2783126
[16,] 0.68840416 0.62319169 0.3115958
[17,] 0.70594436 0.58811128 0.2940556
[18,] 0.69015443 0.61969113 0.3098456
[19,] 0.69432536 0.61134927 0.3056746
[20,] 0.65374175 0.69251650 0.3462583
[21,] 0.60799399 0.78401201 0.3920060
[22,] 0.55408374 0.89183252 0.4459163
[23,] 0.50246966 0.99506067 0.4975303
[24,] 0.62224118 0.75551764 0.3777588
[25,] 0.56824202 0.86351596 0.4317580
[26,] 0.52534079 0.94931842 0.4746592
[27,] 0.48129295 0.96258590 0.5187070
[28,] 0.42760313 0.85520626 0.5723969
[29,] 0.39969467 0.79938933 0.6003053
[30,] 0.34867666 0.69735332 0.6513233
[31,] 0.32080019 0.64160038 0.6791998
[32,] 0.28747697 0.57495394 0.7125230
[33,] 0.26249201 0.52498403 0.7375080
[34,] 0.22602404 0.45204808 0.7739760
[35,] 0.20287430 0.40574861 0.7971257
[36,] 0.25969355 0.51938709 0.7403065
[37,] 0.22815559 0.45631117 0.7718444
[38,] 0.19388996 0.38777993 0.8061100
[39,] 0.16107588 0.32215175 0.8389241
[40,] 0.13386803 0.26773606 0.8661320
[41,] 0.16989208 0.33978416 0.8301079
[42,] 0.15109272 0.30218543 0.8489073
[43,] 0.12322360 0.24644719 0.8767764
[44,] 0.09976259 0.19952517 0.9002374
[45,] 0.08292249 0.16584498 0.9170775
[46,] 0.06893520 0.13787041 0.9310648
[47,] 0.05524226 0.11048452 0.9447577
[48,] 0.20881755 0.41763510 0.7911824
[49,] 0.16565200 0.33130400 0.8343480
[50,] 0.12956311 0.25912621 0.8704369
[51,] 0.09764660 0.19529320 0.9023534
[52,] 0.07396989 0.14793977 0.9260301
[53,] 0.08032351 0.16064702 0.9196765
[54,] 0.06023771 0.12047541 0.9397623
[55,] 0.04391085 0.08782170 0.9560891
[56,] 0.03719720 0.07439440 0.9628028
[57,] 0.02474037 0.04948073 0.9752596
[58,] 0.01583007 0.03166014 0.9841699
[59,] 0.01175524 0.02351049 0.9882448
[60,] 0.01992187 0.03984374 0.9800781
[61,] 0.01519107 0.03038213 0.9848089
[62,] 0.01198080 0.02396160 0.9880192
[63,] 0.02448534 0.04897069 0.9755147
[64,] 0.02888427 0.05776854 0.9711157
[65,] 0.02566301 0.05132602 0.9743370
[66,] 0.01878293 0.03756586 0.9812171
[67,] 0.01741069 0.03482138 0.9825893
[68,] 0.02751493 0.05502986 0.9724851
[69,] 0.02866314 0.05732628 0.9713369
[70,] 0.09568509 0.19137018 0.9043149
[71,] 0.57271480 0.85457039 0.4272852
[72,] 0.52067898 0.95864203 0.4793210
> postscript(file="/var/www/html/rcomp/tmp/1e8i61260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2mnz91260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3aa1l1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4tz4y1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5hgzj1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 91
Frequency = 1
1 2 3 4 5 6
-287.823881 752.149125 -313.658872 -322.009839 -99.597157 -37.397836
7 8 9 10 11 12
202.947420 -124.091613 1304.542653 5.063508 57.952446 -11.430435
13 14 15 16 17 18
-14.371443 1007.339528 -557.649129 -203.374953 71.931017 -415.671291
19 20 21 22 23 24
-102.490933 -490.608173 1177.455026 -431.882121 228.700604 -562.816949
25 26 27 28 29 30
-74.572825 702.575541 -512.170681 -397.928734 -18.723437 -100.989755
31 32 33 34 35 36
-132.028534 -199.685226 899.927953 120.101830 -407.094890 -235.950580
37 38 39 40 41 42
-42.883134 270.207640 -306.896602 -394.719154 210.531392 -376.578232
43 44 45 46 47 48
134.720636 -396.881622 634.185490 120.454903 -425.269818 -135.555467
49 50 51 52 53 54
-153.451000 454.612642 25.583989 -449.565308 -98.748874 -307.426524
55 56 57 58 59 60
48.247205 -342.933911 1090.072360 -215.124833 -280.217814 61.095224
61 62 63 64 65 66
-205.942283 553.005495 52.810237 -738.917300 -129.483062 -546.056604
67 68 69 70 71 72
-443.546407 -34.125252 384.815310 -575.098605 34.611249 -857.996780
73 74 75 76 77 78
350.792117 298.694651 -93.596020 84.949271 -252.460865 93.296650
79 80 81 82 83 84
94.082486 489.514673 1753.181194 556.677179 512.874524 -145.562464
85 86 87 88 89 90
672.573328 628.080745 -485.375012 -293.371876 -205.509954 -406.158500
91
-746.884677
> postscript(file="/var/www/html/rcomp/tmp/6373u1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 91
Frequency = 1
lag(myerror, k = 1) myerror
0 -287.823881 NA
1 752.149125 -287.823881
2 -313.658872 752.149125
3 -322.009839 -313.658872
4 -99.597157 -322.009839
5 -37.397836 -99.597157
6 202.947420 -37.397836
7 -124.091613 202.947420
8 1304.542653 -124.091613
9 5.063508 1304.542653
10 57.952446 5.063508
11 -11.430435 57.952446
12 -14.371443 -11.430435
13 1007.339528 -14.371443
14 -557.649129 1007.339528
15 -203.374953 -557.649129
16 71.931017 -203.374953
17 -415.671291 71.931017
18 -102.490933 -415.671291
19 -490.608173 -102.490933
20 1177.455026 -490.608173
21 -431.882121 1177.455026
22 228.700604 -431.882121
23 -562.816949 228.700604
24 -74.572825 -562.816949
25 702.575541 -74.572825
26 -512.170681 702.575541
27 -397.928734 -512.170681
28 -18.723437 -397.928734
29 -100.989755 -18.723437
30 -132.028534 -100.989755
31 -199.685226 -132.028534
32 899.927953 -199.685226
33 120.101830 899.927953
34 -407.094890 120.101830
35 -235.950580 -407.094890
36 -42.883134 -235.950580
37 270.207640 -42.883134
38 -306.896602 270.207640
39 -394.719154 -306.896602
40 210.531392 -394.719154
41 -376.578232 210.531392
42 134.720636 -376.578232
43 -396.881622 134.720636
44 634.185490 -396.881622
45 120.454903 634.185490
46 -425.269818 120.454903
47 -135.555467 -425.269818
48 -153.451000 -135.555467
49 454.612642 -153.451000
50 25.583989 454.612642
51 -449.565308 25.583989
52 -98.748874 -449.565308
53 -307.426524 -98.748874
54 48.247205 -307.426524
55 -342.933911 48.247205
56 1090.072360 -342.933911
57 -215.124833 1090.072360
58 -280.217814 -215.124833
59 61.095224 -280.217814
60 -205.942283 61.095224
61 553.005495 -205.942283
62 52.810237 553.005495
63 -738.917300 52.810237
64 -129.483062 -738.917300
65 -546.056604 -129.483062
66 -443.546407 -546.056604
67 -34.125252 -443.546407
68 384.815310 -34.125252
69 -575.098605 384.815310
70 34.611249 -575.098605
71 -857.996780 34.611249
72 350.792117 -857.996780
73 298.694651 350.792117
74 -93.596020 298.694651
75 84.949271 -93.596020
76 -252.460865 84.949271
77 93.296650 -252.460865
78 94.082486 93.296650
79 489.514673 94.082486
80 1753.181194 489.514673
81 556.677179 1753.181194
82 512.874524 556.677179
83 -145.562464 512.874524
84 672.573328 -145.562464
85 628.080745 672.573328
86 -485.375012 628.080745
87 -293.371876 -485.375012
88 -205.509954 -293.371876
89 -406.158500 -205.509954
90 -746.884677 -406.158500
91 NA -746.884677
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 752.149125 -287.823881
[2,] -313.658872 752.149125
[3,] -322.009839 -313.658872
[4,] -99.597157 -322.009839
[5,] -37.397836 -99.597157
[6,] 202.947420 -37.397836
[7,] -124.091613 202.947420
[8,] 1304.542653 -124.091613
[9,] 5.063508 1304.542653
[10,] 57.952446 5.063508
[11,] -11.430435 57.952446
[12,] -14.371443 -11.430435
[13,] 1007.339528 -14.371443
[14,] -557.649129 1007.339528
[15,] -203.374953 -557.649129
[16,] 71.931017 -203.374953
[17,] -415.671291 71.931017
[18,] -102.490933 -415.671291
[19,] -490.608173 -102.490933
[20,] 1177.455026 -490.608173
[21,] -431.882121 1177.455026
[22,] 228.700604 -431.882121
[23,] -562.816949 228.700604
[24,] -74.572825 -562.816949
[25,] 702.575541 -74.572825
[26,] -512.170681 702.575541
[27,] -397.928734 -512.170681
[28,] -18.723437 -397.928734
[29,] -100.989755 -18.723437
[30,] -132.028534 -100.989755
[31,] -199.685226 -132.028534
[32,] 899.927953 -199.685226
[33,] 120.101830 899.927953
[34,] -407.094890 120.101830
[35,] -235.950580 -407.094890
[36,] -42.883134 -235.950580
[37,] 270.207640 -42.883134
[38,] -306.896602 270.207640
[39,] -394.719154 -306.896602
[40,] 210.531392 -394.719154
[41,] -376.578232 210.531392
[42,] 134.720636 -376.578232
[43,] -396.881622 134.720636
[44,] 634.185490 -396.881622
[45,] 120.454903 634.185490
[46,] -425.269818 120.454903
[47,] -135.555467 -425.269818
[48,] -153.451000 -135.555467
[49,] 454.612642 -153.451000
[50,] 25.583989 454.612642
[51,] -449.565308 25.583989
[52,] -98.748874 -449.565308
[53,] -307.426524 -98.748874
[54,] 48.247205 -307.426524
[55,] -342.933911 48.247205
[56,] 1090.072360 -342.933911
[57,] -215.124833 1090.072360
[58,] -280.217814 -215.124833
[59,] 61.095224 -280.217814
[60,] -205.942283 61.095224
[61,] 553.005495 -205.942283
[62,] 52.810237 553.005495
[63,] -738.917300 52.810237
[64,] -129.483062 -738.917300
[65,] -546.056604 -129.483062
[66,] -443.546407 -546.056604
[67,] -34.125252 -443.546407
[68,] 384.815310 -34.125252
[69,] -575.098605 384.815310
[70,] 34.611249 -575.098605
[71,] -857.996780 34.611249
[72,] 350.792117 -857.996780
[73,] 298.694651 350.792117
[74,] -93.596020 298.694651
[75,] 84.949271 -93.596020
[76,] -252.460865 84.949271
[77,] 93.296650 -252.460865
[78,] 94.082486 93.296650
[79,] 489.514673 94.082486
[80,] 1753.181194 489.514673
[81,] 556.677179 1753.181194
[82,] 512.874524 556.677179
[83,] -145.562464 512.874524
[84,] 672.573328 -145.562464
[85,] 628.080745 672.573328
[86,] -485.375012 628.080745
[87,] -293.371876 -485.375012
[88,] -205.509954 -293.371876
[89,] -406.158500 -205.509954
[90,] -746.884677 -406.158500
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 752.149125 -287.823881
2 -313.658872 752.149125
3 -322.009839 -313.658872
4 -99.597157 -322.009839
5 -37.397836 -99.597157
6 202.947420 -37.397836
7 -124.091613 202.947420
8 1304.542653 -124.091613
9 5.063508 1304.542653
10 57.952446 5.063508
11 -11.430435 57.952446
12 -14.371443 -11.430435
13 1007.339528 -14.371443
14 -557.649129 1007.339528
15 -203.374953 -557.649129
16 71.931017 -203.374953
17 -415.671291 71.931017
18 -102.490933 -415.671291
19 -490.608173 -102.490933
20 1177.455026 -490.608173
21 -431.882121 1177.455026
22 228.700604 -431.882121
23 -562.816949 228.700604
24 -74.572825 -562.816949
25 702.575541 -74.572825
26 -512.170681 702.575541
27 -397.928734 -512.170681
28 -18.723437 -397.928734
29 -100.989755 -18.723437
30 -132.028534 -100.989755
31 -199.685226 -132.028534
32 899.927953 -199.685226
33 120.101830 899.927953
34 -407.094890 120.101830
35 -235.950580 -407.094890
36 -42.883134 -235.950580
37 270.207640 -42.883134
38 -306.896602 270.207640
39 -394.719154 -306.896602
40 210.531392 -394.719154
41 -376.578232 210.531392
42 134.720636 -376.578232
43 -396.881622 134.720636
44 634.185490 -396.881622
45 120.454903 634.185490
46 -425.269818 120.454903
47 -135.555467 -425.269818
48 -153.451000 -135.555467
49 454.612642 -153.451000
50 25.583989 454.612642
51 -449.565308 25.583989
52 -98.748874 -449.565308
53 -307.426524 -98.748874
54 48.247205 -307.426524
55 -342.933911 48.247205
56 1090.072360 -342.933911
57 -215.124833 1090.072360
58 -280.217814 -215.124833
59 61.095224 -280.217814
60 -205.942283 61.095224
61 553.005495 -205.942283
62 52.810237 553.005495
63 -738.917300 52.810237
64 -129.483062 -738.917300
65 -546.056604 -129.483062
66 -443.546407 -546.056604
67 -34.125252 -443.546407
68 384.815310 -34.125252
69 -575.098605 384.815310
70 34.611249 -575.098605
71 -857.996780 34.611249
72 350.792117 -857.996780
73 298.694651 350.792117
74 -93.596020 298.694651
75 84.949271 -93.596020
76 -252.460865 84.949271
77 93.296650 -252.460865
78 94.082486 93.296650
79 489.514673 94.082486
80 1753.181194 489.514673
81 556.677179 1753.181194
82 512.874524 556.677179
83 -145.562464 512.874524
84 672.573328 -145.562464
85 628.080745 672.573328
86 -485.375012 628.080745
87 -293.371876 -485.375012
88 -205.509954 -293.371876
89 -406.158500 -205.509954
90 -746.884677 -406.158500
> 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/7wumi1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8pmyj1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9xgdl1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10sedt1260038780.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11wgoi1260038780.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/12r3o01260038780.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/13unvv1260038780.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/141hri1260038780.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/15w0m01260038780.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/166b591260038780.tab")
+ }
>
> system("convert tmp/1e8i61260038780.ps tmp/1e8i61260038780.png")
> system("convert tmp/2mnz91260038780.ps tmp/2mnz91260038780.png")
> system("convert tmp/3aa1l1260038780.ps tmp/3aa1l1260038780.png")
> system("convert tmp/4tz4y1260038780.ps tmp/4tz4y1260038780.png")
> system("convert tmp/5hgzj1260038780.ps tmp/5hgzj1260038780.png")
> system("convert tmp/6373u1260038780.ps tmp/6373u1260038780.png")
> system("convert tmp/7wumi1260038780.ps tmp/7wumi1260038780.png")
> system("convert tmp/8pmyj1260038780.ps tmp/8pmyj1260038780.png")
> system("convert tmp/9xgdl1260038780.ps tmp/9xgdl1260038780.png")
> system("convert tmp/10sedt1260038780.ps tmp/10sedt1260038780.png")
>
>
> proc.time()
user system elapsed
2.882 1.586 3.360