R version 2.7.0 (2008-04-22)
Copyright (C) 2008 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(46,0,48,0,48,0,48,0,45,0,44,0,45,0,45,0,45,0,42,0,43,0,50,0,46,0,46,0,45,0,49,0,46,0,45,0,49,0,47,0,45,0,48,0,51,0,48,0,49,0,51,0,54,0,52,0,52,0,53,0,51,0,55,0,53,0,51,0,52,0,54,0,58,0,57,0,52,0,50,0,53,0,50,0,50,0,51,0,53,0,49,0,54,0,57,0,58,0,56,0,60,0,55,0,54,0,52,0,55,0,56,0,54,0,53,0,59,1,62,1,63,1,64,1,75,1,77,1,79,1,77,1,82,1,83,1,81,1,78,1,79,1,79,1,73,1),dim=c(2,73),dimnames=list(c('Y','d'),1:73))
> y <- array(NA,dim=c(2,73),dimnames=list(c('Y','d'),1:73))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No Linear Trend'
> par2 = '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
Y d M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 46 0 1 0 0 0 0 0 0 0 0 0 0
2 48 0 0 1 0 0 0 0 0 0 0 0 0
3 48 0 0 0 1 0 0 0 0 0 0 0 0
4 48 0 0 0 0 1 0 0 0 0 0 0 0
5 45 0 0 0 0 0 1 0 0 0 0 0 0
6 44 0 0 0 0 0 0 1 0 0 0 0 0
7 45 0 0 0 0 0 0 0 1 0 0 0 0
8 45 0 0 0 0 0 0 0 0 1 0 0 0
9 45 0 0 0 0 0 0 0 0 0 1 0 0
10 42 0 0 0 0 0 0 0 0 0 0 1 0
11 43 0 0 0 0 0 0 0 0 0 0 0 1
12 50 0 0 0 0 0 0 0 0 0 0 0 0
13 46 0 1 0 0 0 0 0 0 0 0 0 0
14 46 0 0 1 0 0 0 0 0 0 0 0 0
15 45 0 0 0 1 0 0 0 0 0 0 0 0
16 49 0 0 0 0 1 0 0 0 0 0 0 0
17 46 0 0 0 0 0 1 0 0 0 0 0 0
18 45 0 0 0 0 0 0 1 0 0 0 0 0
19 49 0 0 0 0 0 0 0 1 0 0 0 0
20 47 0 0 0 0 0 0 0 0 1 0 0 0
21 45 0 0 0 0 0 0 0 0 0 1 0 0
22 48 0 0 0 0 0 0 0 0 0 0 1 0
23 51 0 0 0 0 0 0 0 0 0 0 0 1
24 48 0 0 0 0 0 0 0 0 0 0 0 0
25 49 0 1 0 0 0 0 0 0 0 0 0 0
26 51 0 0 1 0 0 0 0 0 0 0 0 0
27 54 0 0 0 1 0 0 0 0 0 0 0 0
28 52 0 0 0 0 1 0 0 0 0 0 0 0
29 52 0 0 0 0 0 1 0 0 0 0 0 0
30 53 0 0 0 0 0 0 1 0 0 0 0 0
31 51 0 0 0 0 0 0 0 1 0 0 0 0
32 55 0 0 0 0 0 0 0 0 1 0 0 0
33 53 0 0 0 0 0 0 0 0 0 1 0 0
34 51 0 0 0 0 0 0 0 0 0 0 1 0
35 52 0 0 0 0 0 0 0 0 0 0 0 1
36 54 0 0 0 0 0 0 0 0 0 0 0 0
37 58 0 1 0 0 0 0 0 0 0 0 0 0
38 57 0 0 1 0 0 0 0 0 0 0 0 0
39 52 0 0 0 1 0 0 0 0 0 0 0 0
40 50 0 0 0 0 1 0 0 0 0 0 0 0
41 53 0 0 0 0 0 1 0 0 0 0 0 0
42 50 0 0 0 0 0 0 1 0 0 0 0 0
43 50 0 0 0 0 0 0 0 1 0 0 0 0
44 51 0 0 0 0 0 0 0 0 1 0 0 0
45 53 0 0 0 0 0 0 0 0 0 1 0 0
46 49 0 0 0 0 0 0 0 0 0 0 1 0
47 54 0 0 0 0 0 0 0 0 0 0 0 1
48 57 0 0 0 0 0 0 0 0 0 0 0 0
49 58 0 1 0 0 0 0 0 0 0 0 0 0
50 56 0 0 1 0 0 0 0 0 0 0 0 0
51 60 0 0 0 1 0 0 0 0 0 0 0 0
52 55 0 0 0 0 1 0 0 0 0 0 0 0
53 54 0 0 0 0 0 1 0 0 0 0 0 0
54 52 0 0 0 0 0 0 1 0 0 0 0 0
55 55 0 0 0 0 0 0 0 1 0 0 0 0
56 56 0 0 0 0 0 0 0 0 1 0 0 0
57 54 0 0 0 0 0 0 0 0 0 1 0 0
58 53 0 0 0 0 0 0 0 0 0 0 1 0
59 59 1 0 0 0 0 0 0 0 0 0 0 1
60 62 1 0 0 0 0 0 0 0 0 0 0 0
61 63 1 1 0 0 0 0 0 0 0 0 0 0
62 64 1 0 1 0 0 0 0 0 0 0 0 0
63 75 1 0 0 1 0 0 0 0 0 0 0 0
64 77 1 0 0 0 1 0 0 0 0 0 0 0
65 79 1 0 0 0 0 1 0 0 0 0 0 0
66 77 1 0 0 0 0 0 1 0 0 0 0 0
67 82 1 0 0 0 0 0 0 1 0 0 0 0
68 83 1 0 0 0 0 0 0 0 1 0 0 0
69 81 1 0 0 0 0 0 0 0 0 1 0 0
70 78 1 0 0 0 0 0 0 0 0 0 1 0
71 79 1 0 0 0 0 0 0 0 0 0 0 1
72 79 1 0 0 0 0 0 0 0 0 0 0 0
73 73 1 1 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) d M1 M2 M3 M4
50.3881 23.8357 -1.0554 -0.6940 1.3060 0.8060
M5 M6 M7 M8 M9 M10
0.4726 -0.8607 0.9726 1.8060 0.8060 -0.8607
M11
-2.0000
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.2238 -3.3326 0.4726 3.6119 8.6674
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 50.3881 2.3237 21.685 <2e-16 ***
d 23.8357 1.6254 14.664 <2e-16 ***
M1 -1.0554 3.0803 -0.343 0.733
M2 -0.6940 3.2070 -0.216 0.829
M3 1.3060 3.2070 0.407 0.685
M4 0.8060 3.2070 0.251 0.802
M5 0.4726 3.2070 0.147 0.883
M6 -0.8607 3.2070 -0.268 0.789
M7 0.9726 3.2070 0.303 0.763
M8 1.8060 3.2070 0.563 0.575
M9 0.8060 3.2070 0.251 0.802
M10 -0.8607 3.2070 -0.268 0.789
M11 -2.0000 3.1956 -0.626 0.534
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.535 on 60 degrees of freedom
Multiple R-squared: 0.7851, Adjusted R-squared: 0.7421
F-statistic: 18.27 on 12 and 60 DF, p-value: 9.363e-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.0286930733 0.057386147 0.9713069
[2,] 0.0078536394 0.015707279 0.9921464
[3,] 0.0021055243 0.004211049 0.9978945
[4,] 0.0031728351 0.006345670 0.9968272
[5,] 0.0014566515 0.002913303 0.9985433
[6,] 0.0005055214 0.001011043 0.9994945
[7,] 0.0022770204 0.004554041 0.9977230
[8,] 0.0107016448 0.021403290 0.9892984
[9,] 0.0056881835 0.011376367 0.9943118
[10,] 0.0037274602 0.007454920 0.9962725
[11,] 0.0030662330 0.006132466 0.9969338
[12,] 0.0083829854 0.016765971 0.9916170
[13,] 0.0057699051 0.011539810 0.9942301
[14,] 0.0082058241 0.016411648 0.9917942
[15,] 0.0168842401 0.033768480 0.9831158
[16,] 0.0131190802 0.026238160 0.9868809
[17,] 0.0235756184 0.047151237 0.9764244
[18,] 0.0300840232 0.060168046 0.9699160
[19,] 0.0269014683 0.053802937 0.9730985
[20,] 0.0210512372 0.042102474 0.9789488
[21,] 0.0162400771 0.032480154 0.9837599
[22,] 0.0398343259 0.079668652 0.9601657
[23,] 0.0555764012 0.111152802 0.9444236
[24,] 0.0416079526 0.083215905 0.9583920
[25,] 0.0294126338 0.058825268 0.9705874
[26,] 0.0233093801 0.046618760 0.9766906
[27,] 0.0158845968 0.031769194 0.9841154
[28,] 0.0132247582 0.026449516 0.9867752
[29,] 0.0114684009 0.022936802 0.9885316
[30,] 0.0092325200 0.018465040 0.9907675
[31,] 0.0069044138 0.013808828 0.9930956
[32,] 0.0054122536 0.010824507 0.9945877
[33,] 0.0053996265 0.010799253 0.9946004
[34,] 0.0122302328 0.024460466 0.9877698
[35,] 0.0293318478 0.058663696 0.9706682
[36,] 0.0496477977 0.099295595 0.9503522
[37,] 0.0351958397 0.070391679 0.9648042
[38,] 0.0216573050 0.043314610 0.9783427
[39,] 0.0118873083 0.023774617 0.9881127
[40,] 0.0066234120 0.013246824 0.9933766
[41,] 0.0033620405 0.006724081 0.9966380
[42,] 0.0013536817 0.002707363 0.9986463
> postscript(file="/var/www/html/rcomp/tmp/194pc1227863047.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/2cgzm1227863047.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/3vyek1227863047.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/4kvtz1227863047.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/5rkck1227863047.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 = 73
Frequency = 1
1 2 3 4 5 6
-3.3326489 -1.6940452 -3.6940452 -3.1940452 -5.8607118 -5.5273785
7 8 9 10 11 12
-6.3607118 -7.1940452 -6.1940452 -7.5273785 -5.3880903 -0.3880903
13 14 15 16 17 18
-3.3326489 -3.6940452 -6.6940452 -2.1940452 -4.8607118 -4.5273785
19 20 21 22 23 24
-2.3607118 -5.1940452 -6.1940452 -1.5273785 2.6119097 -2.3880903
25 26 27 28 29 30
-0.3326489 1.3059548 2.3059548 0.8059548 1.1392882 3.4726215
31 32 33 34 35 36
-0.3607118 2.8059548 1.8059548 1.4726215 3.6119097 3.6119097
37 38 39 40 41 42
8.6673511 7.3059548 0.3059548 -1.1940452 2.1392882 0.4726215
43 44 45 46 47 48
-1.3607118 -1.1940452 1.8059548 -0.5273785 5.6119097 6.6119097
49 50 51 52 53 54
8.6673511 6.3059548 8.3059548 3.8059548 3.1392882 2.4726215
55 56 57 58 59 60
3.6392882 3.8059548 2.8059548 3.4726215 -13.2238193 -12.2238193
61 62 63 64 65 66
-10.1683778 -9.5297741 -0.5297741 1.9702259 4.3035592 3.6368925
67 68 69 70 71 72
6.8035592 6.9702259 5.9702259 4.6368925 6.7761807 4.7761807
73
-0.1683778
> postscript(file="/var/www/html/rcomp/tmp/6mz8m1227863047.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 = 73
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.3326489 NA
1 -1.6940452 -3.3326489
2 -3.6940452 -1.6940452
3 -3.1940452 -3.6940452
4 -5.8607118 -3.1940452
5 -5.5273785 -5.8607118
6 -6.3607118 -5.5273785
7 -7.1940452 -6.3607118
8 -6.1940452 -7.1940452
9 -7.5273785 -6.1940452
10 -5.3880903 -7.5273785
11 -0.3880903 -5.3880903
12 -3.3326489 -0.3880903
13 -3.6940452 -3.3326489
14 -6.6940452 -3.6940452
15 -2.1940452 -6.6940452
16 -4.8607118 -2.1940452
17 -4.5273785 -4.8607118
18 -2.3607118 -4.5273785
19 -5.1940452 -2.3607118
20 -6.1940452 -5.1940452
21 -1.5273785 -6.1940452
22 2.6119097 -1.5273785
23 -2.3880903 2.6119097
24 -0.3326489 -2.3880903
25 1.3059548 -0.3326489
26 2.3059548 1.3059548
27 0.8059548 2.3059548
28 1.1392882 0.8059548
29 3.4726215 1.1392882
30 -0.3607118 3.4726215
31 2.8059548 -0.3607118
32 1.8059548 2.8059548
33 1.4726215 1.8059548
34 3.6119097 1.4726215
35 3.6119097 3.6119097
36 8.6673511 3.6119097
37 7.3059548 8.6673511
38 0.3059548 7.3059548
39 -1.1940452 0.3059548
40 2.1392882 -1.1940452
41 0.4726215 2.1392882
42 -1.3607118 0.4726215
43 -1.1940452 -1.3607118
44 1.8059548 -1.1940452
45 -0.5273785 1.8059548
46 5.6119097 -0.5273785
47 6.6119097 5.6119097
48 8.6673511 6.6119097
49 6.3059548 8.6673511
50 8.3059548 6.3059548
51 3.8059548 8.3059548
52 3.1392882 3.8059548
53 2.4726215 3.1392882
54 3.6392882 2.4726215
55 3.8059548 3.6392882
56 2.8059548 3.8059548
57 3.4726215 2.8059548
58 -13.2238193 3.4726215
59 -12.2238193 -13.2238193
60 -10.1683778 -12.2238193
61 -9.5297741 -10.1683778
62 -0.5297741 -9.5297741
63 1.9702259 -0.5297741
64 4.3035592 1.9702259
65 3.6368925 4.3035592
66 6.8035592 3.6368925
67 6.9702259 6.8035592
68 5.9702259 6.9702259
69 4.6368925 5.9702259
70 6.7761807 4.6368925
71 4.7761807 6.7761807
72 -0.1683778 4.7761807
73 NA -0.1683778
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.6940452 -3.3326489
[2,] -3.6940452 -1.6940452
[3,] -3.1940452 -3.6940452
[4,] -5.8607118 -3.1940452
[5,] -5.5273785 -5.8607118
[6,] -6.3607118 -5.5273785
[7,] -7.1940452 -6.3607118
[8,] -6.1940452 -7.1940452
[9,] -7.5273785 -6.1940452
[10,] -5.3880903 -7.5273785
[11,] -0.3880903 -5.3880903
[12,] -3.3326489 -0.3880903
[13,] -3.6940452 -3.3326489
[14,] -6.6940452 -3.6940452
[15,] -2.1940452 -6.6940452
[16,] -4.8607118 -2.1940452
[17,] -4.5273785 -4.8607118
[18,] -2.3607118 -4.5273785
[19,] -5.1940452 -2.3607118
[20,] -6.1940452 -5.1940452
[21,] -1.5273785 -6.1940452
[22,] 2.6119097 -1.5273785
[23,] -2.3880903 2.6119097
[24,] -0.3326489 -2.3880903
[25,] 1.3059548 -0.3326489
[26,] 2.3059548 1.3059548
[27,] 0.8059548 2.3059548
[28,] 1.1392882 0.8059548
[29,] 3.4726215 1.1392882
[30,] -0.3607118 3.4726215
[31,] 2.8059548 -0.3607118
[32,] 1.8059548 2.8059548
[33,] 1.4726215 1.8059548
[34,] 3.6119097 1.4726215
[35,] 3.6119097 3.6119097
[36,] 8.6673511 3.6119097
[37,] 7.3059548 8.6673511
[38,] 0.3059548 7.3059548
[39,] -1.1940452 0.3059548
[40,] 2.1392882 -1.1940452
[41,] 0.4726215 2.1392882
[42,] -1.3607118 0.4726215
[43,] -1.1940452 -1.3607118
[44,] 1.8059548 -1.1940452
[45,] -0.5273785 1.8059548
[46,] 5.6119097 -0.5273785
[47,] 6.6119097 5.6119097
[48,] 8.6673511 6.6119097
[49,] 6.3059548 8.6673511
[50,] 8.3059548 6.3059548
[51,] 3.8059548 8.3059548
[52,] 3.1392882 3.8059548
[53,] 2.4726215 3.1392882
[54,] 3.6392882 2.4726215
[55,] 3.8059548 3.6392882
[56,] 2.8059548 3.8059548
[57,] 3.4726215 2.8059548
[58,] -13.2238193 3.4726215
[59,] -12.2238193 -13.2238193
[60,] -10.1683778 -12.2238193
[61,] -9.5297741 -10.1683778
[62,] -0.5297741 -9.5297741
[63,] 1.9702259 -0.5297741
[64,] 4.3035592 1.9702259
[65,] 3.6368925 4.3035592
[66,] 6.8035592 3.6368925
[67,] 6.9702259 6.8035592
[68,] 5.9702259 6.9702259
[69,] 4.6368925 5.9702259
[70,] 6.7761807 4.6368925
[71,] 4.7761807 6.7761807
[72,] -0.1683778 4.7761807
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.6940452 -3.3326489
2 -3.6940452 -1.6940452
3 -3.1940452 -3.6940452
4 -5.8607118 -3.1940452
5 -5.5273785 -5.8607118
6 -6.3607118 -5.5273785
7 -7.1940452 -6.3607118
8 -6.1940452 -7.1940452
9 -7.5273785 -6.1940452
10 -5.3880903 -7.5273785
11 -0.3880903 -5.3880903
12 -3.3326489 -0.3880903
13 -3.6940452 -3.3326489
14 -6.6940452 -3.6940452
15 -2.1940452 -6.6940452
16 -4.8607118 -2.1940452
17 -4.5273785 -4.8607118
18 -2.3607118 -4.5273785
19 -5.1940452 -2.3607118
20 -6.1940452 -5.1940452
21 -1.5273785 -6.1940452
22 2.6119097 -1.5273785
23 -2.3880903 2.6119097
24 -0.3326489 -2.3880903
25 1.3059548 -0.3326489
26 2.3059548 1.3059548
27 0.8059548 2.3059548
28 1.1392882 0.8059548
29 3.4726215 1.1392882
30 -0.3607118 3.4726215
31 2.8059548 -0.3607118
32 1.8059548 2.8059548
33 1.4726215 1.8059548
34 3.6119097 1.4726215
35 3.6119097 3.6119097
36 8.6673511 3.6119097
37 7.3059548 8.6673511
38 0.3059548 7.3059548
39 -1.1940452 0.3059548
40 2.1392882 -1.1940452
41 0.4726215 2.1392882
42 -1.3607118 0.4726215
43 -1.1940452 -1.3607118
44 1.8059548 -1.1940452
45 -0.5273785 1.8059548
46 5.6119097 -0.5273785
47 6.6119097 5.6119097
48 8.6673511 6.6119097
49 6.3059548 8.6673511
50 8.3059548 6.3059548
51 3.8059548 8.3059548
52 3.1392882 3.8059548
53 2.4726215 3.1392882
54 3.6392882 2.4726215
55 3.8059548 3.6392882
56 2.8059548 3.8059548
57 3.4726215 2.8059548
58 -13.2238193 3.4726215
59 -12.2238193 -13.2238193
60 -10.1683778 -12.2238193
61 -9.5297741 -10.1683778
62 -0.5297741 -9.5297741
63 1.9702259 -0.5297741
64 4.3035592 1.9702259
65 3.6368925 4.3035592
66 6.8035592 3.6368925
67 6.9702259 6.8035592
68 5.9702259 6.9702259
69 4.6368925 5.9702259
70 6.7761807 4.6368925
71 4.7761807 6.7761807
72 -0.1683778 4.7761807
> 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/783ri1227863047.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/83yh41227863047.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/9d8jp1227863047.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/10bwcd1227863047.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/11eqeb1227863047.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/12lerz1227863047.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/134d7f1227863047.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/14vyid1227863047.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/15o1x61227863047.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/16sa871227863047.tab")
+ }
>
> system("convert tmp/194pc1227863047.ps tmp/194pc1227863047.png")
> system("convert tmp/2cgzm1227863047.ps tmp/2cgzm1227863047.png")
> system("convert tmp/3vyek1227863047.ps tmp/3vyek1227863047.png")
> system("convert tmp/4kvtz1227863047.ps tmp/4kvtz1227863047.png")
> system("convert tmp/5rkck1227863047.ps tmp/5rkck1227863047.png")
> system("convert tmp/6mz8m1227863047.ps tmp/6mz8m1227863047.png")
> system("convert tmp/783ri1227863047.ps tmp/783ri1227863047.png")
> system("convert tmp/83yh41227863047.ps tmp/83yh41227863047.png")
> system("convert tmp/9d8jp1227863047.ps tmp/9d8jp1227863047.png")
> system("convert tmp/10bwcd1227863047.ps tmp/10bwcd1227863047.png")
>
>
> proc.time()
user system elapsed
5.261 2.744 5.637