R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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(1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,0
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,1
+ ,0
+ ,1
+ ,0
+ ,1
+ ,1
+ ,1
+ ,1
+ ,0
+ ,1
+ ,1
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,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+ ,1
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0)
+ ,dim=c(7
+ ,68)
+ ,dimnames=list(c('UseLimit'
+ ,'T40'
+ ,'T20'
+ ,'Used'
+ ,'CorrectAnalysis'
+ ,'Useful'
+ ,'Outcome
')
+ ,1:68))
> y <- array(NA,dim=c(7,68),dimnames=list(c('UseLimit','T40','T20','Used','CorrectAnalysis','Useful','Outcome
'),1:68))
> 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 = '5'
> par3 <- 'Linear Trend'
> par2 <- 'Do not include Seasonal Dummies'
> par1 <- '5'
> #'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, 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
CorrectAnalysis UseLimit T40 T20 Used Useful Outcome\r\r t
1 0 1 1 0 0 0 1 1
2 0 0 0 1 0 0 0 2
3 0 0 0 0 0 0 0 3
4 0 0 0 0 0 0 0 4
5 0 0 0 0 0 0 0 5
6 0 1 0 1 0 1 1 6
7 0 0 0 0 0 0 0 7
8 0 0 1 0 0 0 0 8
9 0 0 0 1 0 0 1 9
10 0 1 0 0 0 0 0 10
11 0 1 1 1 0 0 0 11
12 0 0 0 0 0 0 0 12
13 0 0 0 0 1 1 0 13
14 0 1 1 0 0 0 0 14
15 0 0 0 0 1 1 1 15
16 0 0 1 0 1 1 1 16
17 1 1 1 0 1 1 0 17
18 0 1 1 0 0 0 0 18
19 0 0 0 1 0 0 1 19
20 1 0 1 0 1 1 1 20
21 0 1 0 0 0 1 0 21
22 0 1 0 1 1 1 1 22
23 0 0 0 0 0 1 1 23
24 0 1 0 0 0 1 1 24
25 0 0 1 1 1 0 1 25
26 0 0 0 1 1 1 0 26
27 0 1 0 0 0 0 1 27
28 0 0 0 1 1 0 0 28
29 0 0 0 0 0 0 1 29
30 0 0 0 0 0 1 0 30
31 0 0 0 0 0 0 0 31
32 0 1 0 0 0 0 0 32
33 0 1 0 0 0 1 0 33
34 0 0 1 0 0 0 1 34
35 0 0 0 0 0 0 0 35
36 0 0 0 0 0 0 0 36
37 0 1 1 1 1 1 0 37
38 0 0 0 0 1 0 1 38
39 0 0 0 0 0 1 1 39
40 0 0 1 1 0 1 0 40
41 1 0 0 0 1 1 1 41
42 0 0 0 0 1 0 1 42
43 0 1 0 0 0 1 1 43
44 0 1 1 0 0 0 0 44
45 0 0 0 0 0 1 0 45
46 0 0 0 0 0 1 1 46
47 0 0 0 0 0 0 0 47
48 0 0 0 0 0 0 1 48
49 0 0 0 0 0 1 1 49
50 0 0 0 0 0 0 0 50
51 0 0 1 0 1 0 0 51
52 1 1 1 1 1 1 0 52
53 0 0 0 1 0 0 1 53
54 1 0 0 0 1 0 0 54
55 0 0 0 0 0 0 0 55
56 0 0 1 1 1 0 1 56
57 0 0 0 0 1 1 1 57
58 0 0 0 0 0 0 1 58
59 0 0 0 0 0 0 1 59
60 1 1 1 1 1 1 1 60
61 0 1 1 1 0 0 1 61
62 0 0 0 1 1 1 0 62
63 0 0 0 0 0 0 0 63
64 0 1 1 0 0 0 1 64
65 0 0 0 0 0 0 0 65
66 0 0 0 0 0 0 0 66
67 1 0 1 0 1 1 0 67
68 0 1 0 0 0 0 0 68
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) UseLimit T40 T20
-0.098769 0.045694 0.136487 -0.105813
Used Useful `Outcome\\r\\r` t
0.279608 0.110973 -0.047806 0.001919
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.43920 -0.12005 -0.02695 0.07785 0.71551
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.098769 0.076434 -1.292 0.20123
UseLimit 0.045694 0.076609 0.596 0.55312
T40 0.136487 0.078846 1.731 0.08858 .
T20 -0.105813 0.077196 -1.371 0.17558
Used 0.279608 0.082984 3.369 0.00132 **
Useful 0.110973 0.073063 1.519 0.13405
`Outcome\\r\\r` -0.047806 0.064379 -0.743 0.46064
t 0.001919 0.001621 1.184 0.24110
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2584 on 60 degrees of freedom
Multiple R-squared: 0.3619, Adjusted R-squared: 0.2875
F-statistic: 4.861 on 7 and 60 DF, p-value: 0.0002177
> 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.000000000 0.000000000 1.0000000
[2,] 0.000000000 0.000000000 1.0000000
[3,] 0.000000000 0.000000000 1.0000000
[4,] 0.000000000 0.000000000 1.0000000
[5,] 0.000000000 0.000000000 1.0000000
[6,] 0.000000000 0.000000000 1.0000000
[7,] 0.344900459 0.689800917 0.6550995
[8,] 0.261793640 0.523587280 0.7382064
[9,] 0.258120296 0.516240592 0.7418797
[10,] 0.731450589 0.537098821 0.2685494
[11,] 0.653913264 0.692173472 0.3460867
[12,] 0.630865698 0.738268605 0.3691343
[13,] 0.545844652 0.908310696 0.4541553
[14,] 0.460007507 0.920015013 0.5399925
[15,] 0.419439776 0.838879552 0.5805602
[16,] 0.377790228 0.755580456 0.6222098
[17,] 0.318835107 0.637670215 0.6811649
[18,] 0.251033017 0.502066034 0.7489670
[19,] 0.203315032 0.406630064 0.7966850
[20,] 0.152110126 0.304220252 0.8478899
[21,] 0.114063630 0.228127259 0.8859364
[22,] 0.081096915 0.162193831 0.9189031
[23,] 0.056781063 0.113562126 0.9432189
[24,] 0.040130075 0.080260150 0.9598699
[25,] 0.027591380 0.055182760 0.9724086
[26,] 0.018911158 0.037822315 0.9810888
[27,] 0.031163687 0.062327375 0.9688363
[28,] 0.023920816 0.047841633 0.9760792
[29,] 0.014665849 0.029331698 0.9853342
[30,] 0.008771044 0.017542089 0.9912290
[31,] 0.126078344 0.252156689 0.8739217
[32,] 0.104708252 0.209416504 0.8952917
[33,] 0.079461983 0.158923967 0.9205380
[34,] 0.065585820 0.131171640 0.9344142
[35,] 0.047109108 0.094218215 0.9528909
[36,] 0.030346981 0.060693962 0.9696530
[37,] 0.018775763 0.037551525 0.9812242
[38,] 0.011315639 0.022631277 0.9886844
[39,] 0.006485154 0.012970309 0.9935148
[40,] 0.003522519 0.007045039 0.9964775
[41,] 0.029483206 0.058966412 0.9705168
[42,] 0.058017860 0.116035721 0.9419821
[43,] 0.064982958 0.129965916 0.9350170
[44,] 0.318713487 0.637426974 0.6812865
[45,] 0.214765711 0.429531423 0.7852343
[46,] 0.134458115 0.268916229 0.8655419
[47,] 0.252536903 0.505073806 0.7474631
> postscript(file="/var/fisher/rcomp/tmp/1h2pe1356024407.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/fisher/rcomp/tmp/2caoe1356024407.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/fisher/rcomp/tmp/36z5w1356024407.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/fisher/rcomp/tmp/42o5m1356024407.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/fisher/rcomp/tmp/5yt2x1356024407.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 = 68
Frequency = 1
1 2 3 4 5 6
-0.037524330 0.200743486 0.093011145 0.091091726 0.089172307 0.084205500
7 8 9 10 11 12
0.085333469 -0.053072927 0.235113727 0.033881706 0.001288233 0.075736375
13 14 15 16 17 18
-0.316763973 -0.110282946 -0.272796638 -0.411203034 0.493377868 -0.117960622
19 20 21 22 23 24
0.215919539 0.581119290 -0.098204877 -0.226113154 -0.008544036 -0.056156961
25 26 27 28 29 30
-0.211691904 -0.235903495 0.049057758 -0.128769356 0.090912428 -0.069786140
31 32 33 34 35 36
0.039267418 -0.008345508 -0.121237903 -0.055171644 0.031589742 0.029670324
37 38 39 40 41 42
-0.439197585 -0.205970295 -0.039254737 -0.119654382 0.677298472 -0.213647970
43 44 45 46 47 48
-0.092625919 -0.167865511 -0.098577422 -0.052690669 0.008556717 0.054443470
49 50 51 52 53 54
-0.058448925 0.002798460 -0.415215889 0.532011132 0.150659299 0.715512832
55 56 57 58 59 60
-0.006798634 -0.271193888 -0.353412229 0.035249282 0.033329863 0.564461954
61 62 63 64 65 66
-0.046876535 -0.305002572 -0.022153984 -0.158447715 -0.025992822 -0.027912241
67 68
0.443100434 -0.077444585
> postscript(file="/var/fisher/rcomp/tmp/6t9dm1356024407.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 = 68
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.037524330 NA
1 0.200743486 -0.037524330
2 0.093011145 0.200743486
3 0.091091726 0.093011145
4 0.089172307 0.091091726
5 0.084205500 0.089172307
6 0.085333469 0.084205500
7 -0.053072927 0.085333469
8 0.235113727 -0.053072927
9 0.033881706 0.235113727
10 0.001288233 0.033881706
11 0.075736375 0.001288233
12 -0.316763973 0.075736375
13 -0.110282946 -0.316763973
14 -0.272796638 -0.110282946
15 -0.411203034 -0.272796638
16 0.493377868 -0.411203034
17 -0.117960622 0.493377868
18 0.215919539 -0.117960622
19 0.581119290 0.215919539
20 -0.098204877 0.581119290
21 -0.226113154 -0.098204877
22 -0.008544036 -0.226113154
23 -0.056156961 -0.008544036
24 -0.211691904 -0.056156961
25 -0.235903495 -0.211691904
26 0.049057758 -0.235903495
27 -0.128769356 0.049057758
28 0.090912428 -0.128769356
29 -0.069786140 0.090912428
30 0.039267418 -0.069786140
31 -0.008345508 0.039267418
32 -0.121237903 -0.008345508
33 -0.055171644 -0.121237903
34 0.031589742 -0.055171644
35 0.029670324 0.031589742
36 -0.439197585 0.029670324
37 -0.205970295 -0.439197585
38 -0.039254737 -0.205970295
39 -0.119654382 -0.039254737
40 0.677298472 -0.119654382
41 -0.213647970 0.677298472
42 -0.092625919 -0.213647970
43 -0.167865511 -0.092625919
44 -0.098577422 -0.167865511
45 -0.052690669 -0.098577422
46 0.008556717 -0.052690669
47 0.054443470 0.008556717
48 -0.058448925 0.054443470
49 0.002798460 -0.058448925
50 -0.415215889 0.002798460
51 0.532011132 -0.415215889
52 0.150659299 0.532011132
53 0.715512832 0.150659299
54 -0.006798634 0.715512832
55 -0.271193888 -0.006798634
56 -0.353412229 -0.271193888
57 0.035249282 -0.353412229
58 0.033329863 0.035249282
59 0.564461954 0.033329863
60 -0.046876535 0.564461954
61 -0.305002572 -0.046876535
62 -0.022153984 -0.305002572
63 -0.158447715 -0.022153984
64 -0.025992822 -0.158447715
65 -0.027912241 -0.025992822
66 0.443100434 -0.027912241
67 -0.077444585 0.443100434
68 NA -0.077444585
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.200743486 -0.037524330
[2,] 0.093011145 0.200743486
[3,] 0.091091726 0.093011145
[4,] 0.089172307 0.091091726
[5,] 0.084205500 0.089172307
[6,] 0.085333469 0.084205500
[7,] -0.053072927 0.085333469
[8,] 0.235113727 -0.053072927
[9,] 0.033881706 0.235113727
[10,] 0.001288233 0.033881706
[11,] 0.075736375 0.001288233
[12,] -0.316763973 0.075736375
[13,] -0.110282946 -0.316763973
[14,] -0.272796638 -0.110282946
[15,] -0.411203034 -0.272796638
[16,] 0.493377868 -0.411203034
[17,] -0.117960622 0.493377868
[18,] 0.215919539 -0.117960622
[19,] 0.581119290 0.215919539
[20,] -0.098204877 0.581119290
[21,] -0.226113154 -0.098204877
[22,] -0.008544036 -0.226113154
[23,] -0.056156961 -0.008544036
[24,] -0.211691904 -0.056156961
[25,] -0.235903495 -0.211691904
[26,] 0.049057758 -0.235903495
[27,] -0.128769356 0.049057758
[28,] 0.090912428 -0.128769356
[29,] -0.069786140 0.090912428
[30,] 0.039267418 -0.069786140
[31,] -0.008345508 0.039267418
[32,] -0.121237903 -0.008345508
[33,] -0.055171644 -0.121237903
[34,] 0.031589742 -0.055171644
[35,] 0.029670324 0.031589742
[36,] -0.439197585 0.029670324
[37,] -0.205970295 -0.439197585
[38,] -0.039254737 -0.205970295
[39,] -0.119654382 -0.039254737
[40,] 0.677298472 -0.119654382
[41,] -0.213647970 0.677298472
[42,] -0.092625919 -0.213647970
[43,] -0.167865511 -0.092625919
[44,] -0.098577422 -0.167865511
[45,] -0.052690669 -0.098577422
[46,] 0.008556717 -0.052690669
[47,] 0.054443470 0.008556717
[48,] -0.058448925 0.054443470
[49,] 0.002798460 -0.058448925
[50,] -0.415215889 0.002798460
[51,] 0.532011132 -0.415215889
[52,] 0.150659299 0.532011132
[53,] 0.715512832 0.150659299
[54,] -0.006798634 0.715512832
[55,] -0.271193888 -0.006798634
[56,] -0.353412229 -0.271193888
[57,] 0.035249282 -0.353412229
[58,] 0.033329863 0.035249282
[59,] 0.564461954 0.033329863
[60,] -0.046876535 0.564461954
[61,] -0.305002572 -0.046876535
[62,] -0.022153984 -0.305002572
[63,] -0.158447715 -0.022153984
[64,] -0.025992822 -0.158447715
[65,] -0.027912241 -0.025992822
[66,] 0.443100434 -0.027912241
[67,] -0.077444585 0.443100434
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.200743486 -0.037524330
2 0.093011145 0.200743486
3 0.091091726 0.093011145
4 0.089172307 0.091091726
5 0.084205500 0.089172307
6 0.085333469 0.084205500
7 -0.053072927 0.085333469
8 0.235113727 -0.053072927
9 0.033881706 0.235113727
10 0.001288233 0.033881706
11 0.075736375 0.001288233
12 -0.316763973 0.075736375
13 -0.110282946 -0.316763973
14 -0.272796638 -0.110282946
15 -0.411203034 -0.272796638
16 0.493377868 -0.411203034
17 -0.117960622 0.493377868
18 0.215919539 -0.117960622
19 0.581119290 0.215919539
20 -0.098204877 0.581119290
21 -0.226113154 -0.098204877
22 -0.008544036 -0.226113154
23 -0.056156961 -0.008544036
24 -0.211691904 -0.056156961
25 -0.235903495 -0.211691904
26 0.049057758 -0.235903495
27 -0.128769356 0.049057758
28 0.090912428 -0.128769356
29 -0.069786140 0.090912428
30 0.039267418 -0.069786140
31 -0.008345508 0.039267418
32 -0.121237903 -0.008345508
33 -0.055171644 -0.121237903
34 0.031589742 -0.055171644
35 0.029670324 0.031589742
36 -0.439197585 0.029670324
37 -0.205970295 -0.439197585
38 -0.039254737 -0.205970295
39 -0.119654382 -0.039254737
40 0.677298472 -0.119654382
41 -0.213647970 0.677298472
42 -0.092625919 -0.213647970
43 -0.167865511 -0.092625919
44 -0.098577422 -0.167865511
45 -0.052690669 -0.098577422
46 0.008556717 -0.052690669
47 0.054443470 0.008556717
48 -0.058448925 0.054443470
49 0.002798460 -0.058448925
50 -0.415215889 0.002798460
51 0.532011132 -0.415215889
52 0.150659299 0.532011132
53 0.715512832 0.150659299
54 -0.006798634 0.715512832
55 -0.271193888 -0.006798634
56 -0.353412229 -0.271193888
57 0.035249282 -0.353412229
58 0.033329863 0.035249282
59 0.564461954 0.033329863
60 -0.046876535 0.564461954
61 -0.305002572 -0.046876535
62 -0.022153984 -0.305002572
63 -0.158447715 -0.022153984
64 -0.025992822 -0.158447715
65 -0.027912241 -0.025992822
66 0.443100434 -0.027912241
67 -0.077444585 0.443100434
> 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/fisher/rcomp/tmp/7blws1356024407.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/fisher/rcomp/tmp/8w6mt1356024407.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/fisher/rcomp/tmp/9q8ai1356024407.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/fisher/rcomp/tmp/10uezc1356024407.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/11iwtz1356024407.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/fisher/rcomp/tmp/129qvg1356024407.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/fisher/rcomp/tmp/13ts1u1356024407.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/fisher/rcomp/tmp/1455a61356024407.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/fisher/rcomp/tmp/15jnmj1356024408.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/fisher/rcomp/tmp/166fsd1356024408.tab")
+ }
>
> try(system("convert tmp/1h2pe1356024407.ps tmp/1h2pe1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/2caoe1356024407.ps tmp/2caoe1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/36z5w1356024407.ps tmp/36z5w1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/42o5m1356024407.ps tmp/42o5m1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/5yt2x1356024407.ps tmp/5yt2x1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/6t9dm1356024407.ps tmp/6t9dm1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/7blws1356024407.ps tmp/7blws1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/8w6mt1356024407.ps tmp/8w6mt1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/9q8ai1356024407.ps tmp/9q8ai1356024407.png",intern=TRUE))
character(0)
> try(system("convert tmp/10uezc1356024407.ps tmp/10uezc1356024407.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.697 1.857 8.601