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
+ ,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
+ ,1
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,1
+ ,1
+ ,1
+ ,1
+ ,1
+ ,1
+ ,1
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,1
+ ,1
+ ,1
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,1
+ ,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+ ,1
+ ,0
+ ,1
+ ,1
+ ,1
+ ,0
+ ,1
+ ,0
+ ,1
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,0
+ ,1
+ ,0
+ ,0
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0
+ ,1
+ ,1
+ ,1
+ ,0
+ ,0
+ ,0
+ ,0
+ ,0)
+ ,dim=c(6
+ ,86)
+ ,dimnames=list(c('UseLimit'
+ ,'T40'
+ ,'Used'
+ ,'CorrectAnalysis'
+ ,'Useful'
+ ,'Outcome')
+ ,1:86))
> y <- array(NA,dim=c(6,86),dimnames=list(c('UseLimit','T40','Used','CorrectAnalysis','Useful','Outcome'),1:86))
> 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 = 'Do not include Seasonal Dummies'
> par1 = '5'
> par3 <- 'No 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
Useful UseLimit T40 Used CorrectAnalysis Outcome
1 0 1 1 0 0 1
2 0 0 0 0 0 0
3 0 0 0 0 0 0
4 0 0 0 0 0 0
5 0 0 0 0 0 0
6 1 1 0 0 0 1
7 0 0 0 0 0 0
8 0 0 1 0 0 0
9 0 0 0 0 0 1
10 0 1 0 0 0 0
11 0 1 1 0 0 0
12 0 0 0 0 0 0
13 1 0 0 1 0 0
14 0 1 1 0 0 0
15 1 0 0 1 0 1
16 1 0 1 1 0 1
17 1 1 1 1 1 0
18 0 1 1 0 0 0
19 0 0 0 0 0 1
20 1 0 1 1 1 1
21 1 1 0 0 0 0
22 1 1 0 1 0 1
23 1 0 0 0 0 1
24 1 1 0 0 0 1
25 0 0 1 1 0 1
26 1 0 0 1 0 0
27 0 1 0 0 0 1
28 0 0 0 1 0 0
29 0 0 0 0 0 1
30 1 0 0 0 0 0
31 0 0 0 0 0 0
32 0 1 0 0 0 0
33 1 1 0 0 0 0
34 0 0 1 0 0 1
35 0 0 0 0 0 0
36 0 0 0 0 0 0
37 1 1 1 1 0 0
38 0 0 0 1 0 1
39 1 0 0 0 0 1
40 1 0 1 0 0 0
41 1 0 0 1 1 1
42 0 0 0 1 0 1
43 1 1 0 0 0 1
44 0 1 1 0 0 0
45 1 0 0 0 0 0
46 1 0 0 0 0 1
47 0 0 0 0 0 0
48 0 0 0 0 0 1
49 1 0 0 0 0 1
50 0 0 0 0 0 0
51 0 0 1 1 0 0
52 1 1 1 1 1 0
53 0 0 0 0 0 1
54 0 0 0 1 1 0
55 0 0 0 0 0 0
56 0 0 1 1 0 1
57 1 0 0 1 0 1
58 0 0 0 0 0 1
59 0 0 0 0 0 1
60 1 1 1 1 1 1
61 0 1 1 0 0 1
62 1 0 0 1 0 0
63 0 0 0 0 0 0
64 0 1 1 0 0 1
65 0 0 0 0 0 0
66 0 0 0 0 0 0
67 1 0 1 1 1 0
68 0 1 0 0 0 0
69 0 0 0 0 0 1
70 0 0 0 1 0 0
71 0 0 0 0 0 0
72 0 0 0 0 0 1
73 0 0 0 1 0 1
74 0 1 0 1 0 0
75 0 0 0 0 0 1
76 1 0 1 0 0 1
77 0 0 0 0 0 1
78 1 0 0 1 0 1
79 0 0 1 1 1 1
80 1 0 1 0 0 0
81 0 0 0 0 0 0
82 0 1 0 1 0 1
83 0 0 0 0 0 0
84 0 0 0 1 1 0
85 1 0 0 0 0 1
86 0 1 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) UseLimit T40 Used
0.170633 0.106578 0.001388 0.204411
CorrectAnalysis Outcome
0.196952 0.130991
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.7044 -0.3016 -0.1706 0.4936 0.8294
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.170633 0.084294 2.024 0.0463 *
UseLimit 0.106578 0.116964 0.911 0.3649
T40 0.001388 0.124175 0.011 0.9911
Used 0.204411 0.124560 1.641 0.1047
CorrectAnalysis 0.196952 0.194909 1.010 0.3153
Outcome 0.130991 0.101547 1.290 0.2008
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4654 on 80 degrees of freedom
Multiple R-squared: 0.113, Adjusted R-squared: 0.05761
F-statistic: 2.039 on 5 and 80 DF, p-value: 0.08191
> 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.2813299409 0.562659882 0.7186701
[2,] 0.2888104973 0.577620995 0.7111895
[3,] 0.1695719988 0.339143998 0.8304280
[4,] 0.0920932808 0.184186562 0.9079067
[5,] 0.0496130691 0.099226138 0.9503869
[6,] 0.0244697267 0.048939453 0.9755303
[7,] 0.0143045244 0.028609049 0.9856955
[8,] 0.0075118043 0.015023609 0.9924882
[9,] 0.0033260622 0.006652124 0.9966739
[10,] 0.0014630251 0.002926050 0.9985370
[11,] 0.0008496271 0.001699254 0.9991504
[12,] 0.0003657240 0.000731448 0.9996343
[13,] 0.0047616333 0.009523267 0.9952384
[14,] 0.0065819770 0.013163954 0.9934180
[15,] 0.0330358527 0.066071705 0.9669641
[16,] 0.0358052926 0.071610585 0.9641947
[17,] 0.0612092279 0.122418456 0.9387908
[18,] 0.0573635294 0.114727059 0.9426365
[19,] 0.0838347214 0.167669443 0.9161653
[20,] 0.1337236058 0.267447212 0.8662764
[21,] 0.1127872530 0.225574506 0.8872127
[22,] 0.2450556722 0.490111344 0.7549443
[23,] 0.1988295417 0.397659083 0.8011705
[24,] 0.1804550583 0.360910117 0.8195449
[25,] 0.2429971692 0.485994338 0.7570028
[26,] 0.2140437595 0.428087519 0.7859562
[27,] 0.1727050559 0.345410112 0.8272949
[28,] 0.1368849245 0.273769849 0.8631151
[29,] 0.1432111447 0.286422289 0.8567889
[30,] 0.2004563005 0.400912601 0.7995437
[31,] 0.2796532463 0.559306493 0.7203468
[32,] 0.4664742080 0.932948416 0.5335258
[33,] 0.4297762883 0.859552577 0.5702237
[34,] 0.4539639403 0.907927881 0.5460361
[35,] 0.5269953419 0.946009316 0.4730047
[36,] 0.4808203247 0.961640649 0.5191797
[37,] 0.6263642814 0.747271437 0.3736357
[38,] 0.7215508845 0.556898231 0.2784491
[39,] 0.6718362015 0.656327597 0.3281638
[40,] 0.6315876679 0.736824664 0.3684123
[41,] 0.7427882110 0.514423578 0.2572118
[42,] 0.6926913260 0.614617348 0.3073087
[43,] 0.7335624675 0.532875065 0.2664375
[44,] 0.7319980782 0.536003844 0.2680019
[45,] 0.6898540284 0.620291943 0.3101460
[46,] 0.7092730093 0.581453981 0.2907270
[47,] 0.6530639145 0.693872171 0.3469361
[48,] 0.7967661916 0.406467617 0.2032338
[49,] 0.8124128440 0.375174312 0.1875872
[50,] 0.7697110654 0.460577869 0.2302889
[51,] 0.7205256739 0.558948652 0.2794743
[52,] 0.8084950231 0.383009954 0.1915050
[53,] 0.7838161357 0.432367729 0.2161839
[54,] 0.8252511001 0.349497800 0.1747489
[55,] 0.7765495674 0.446900865 0.2234504
[56,] 0.8080989028 0.383802194 0.1919011
[57,] 0.7519155002 0.496169000 0.2480845
[58,] 0.6882506591 0.623498682 0.3117493
[59,] 0.7348834240 0.530233152 0.2651166
[60,] 0.6683476476 0.663304705 0.3316524
[61,] 0.6070139535 0.785972093 0.3929860
[62,] 0.5719293601 0.856141280 0.4280706
[63,] 0.4945314880 0.989062976 0.5054685
[64,] 0.4256153691 0.851230738 0.5743846
[65,] 0.4977589634 0.995517927 0.5022410
[66,] 0.4163521014 0.832704203 0.5836479
[67,] 0.3587936951 0.717587390 0.6412063
[68,] 0.2697594763 0.539518953 0.7302405
[69,] 0.2707385922 0.541477184 0.7292614
> postscript(file="/var/wessaorg/rcomp/tmp/1z4kk1356127532.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/wessaorg/rcomp/tmp/2mj9r1356127532.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/wessaorg/rcomp/tmp/3hvd41356127532.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/wessaorg/rcomp/tmp/40spx1356127532.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/wessaorg/rcomp/tmp/5ynik1356127532.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 = 86
Frequency = 1
1 2 3 4 5 6 7
-0.4095911 -0.1706333 -0.1706333 -0.1706333 -0.1706333 0.5917974 -0.1706333
8 9 10 11 12 13 14
-0.1720218 -0.3016241 -0.2772118 -0.2786003 -0.1706333 0.6249555 -0.2786003
15 16 17 18 19 20 21
0.4939647 0.4925763 0.3200363 -0.2786003 -0.3016241 0.2956240 0.7227882
22 23 24 25 26 27 28
0.3873862 0.6983759 0.5917974 -0.5074237 0.6249555 -0.4082026 -0.3750445
29 30 31 32 33 34 35
-0.3016241 0.8293667 -0.1706333 -0.2772118 0.7227882 -0.3030126 -0.1706333
36 37 38 39 40 41 42
-0.1706333 0.5169886 -0.5060353 0.6983759 0.8279782 0.2970125 -0.5060353
43 44 45 46 47 48 49
0.5917974 -0.2786003 0.8293667 0.6983759 -0.1706333 -0.3016241 0.6983759
50 51 52 53 54 55 56
-0.1706333 -0.3764329 0.3200363 -0.3016241 -0.5719967 -0.1706333 -0.5074237
57 58 59 60 61 62 63
0.4939647 -0.3016241 -0.3016241 0.1890455 -0.4095911 0.6249555 -0.1706333
64 65 66 67 68 69 70
-0.4095911 -0.1706333 -0.1706333 0.4266148 -0.2772118 -0.3016241 -0.3750445
71 72 73 74 75 76 77
-0.1706333 -0.3016241 -0.5060353 -0.4816230 -0.3016241 0.6969874 -0.3016241
78 79 80 81 82 83 84
0.4939647 -0.7043760 0.8279782 -0.1706333 -0.6126138 -0.1706333 -0.5719967
85 86
0.6983759 -0.2772118
> postscript(file="/var/wessaorg/rcomp/tmp/65gfm1356127532.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 = 86
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.4095911 NA
1 -0.1706333 -0.4095911
2 -0.1706333 -0.1706333
3 -0.1706333 -0.1706333
4 -0.1706333 -0.1706333
5 0.5917974 -0.1706333
6 -0.1706333 0.5917974
7 -0.1720218 -0.1706333
8 -0.3016241 -0.1720218
9 -0.2772118 -0.3016241
10 -0.2786003 -0.2772118
11 -0.1706333 -0.2786003
12 0.6249555 -0.1706333
13 -0.2786003 0.6249555
14 0.4939647 -0.2786003
15 0.4925763 0.4939647
16 0.3200363 0.4925763
17 -0.2786003 0.3200363
18 -0.3016241 -0.2786003
19 0.2956240 -0.3016241
20 0.7227882 0.2956240
21 0.3873862 0.7227882
22 0.6983759 0.3873862
23 0.5917974 0.6983759
24 -0.5074237 0.5917974
25 0.6249555 -0.5074237
26 -0.4082026 0.6249555
27 -0.3750445 -0.4082026
28 -0.3016241 -0.3750445
29 0.8293667 -0.3016241
30 -0.1706333 0.8293667
31 -0.2772118 -0.1706333
32 0.7227882 -0.2772118
33 -0.3030126 0.7227882
34 -0.1706333 -0.3030126
35 -0.1706333 -0.1706333
36 0.5169886 -0.1706333
37 -0.5060353 0.5169886
38 0.6983759 -0.5060353
39 0.8279782 0.6983759
40 0.2970125 0.8279782
41 -0.5060353 0.2970125
42 0.5917974 -0.5060353
43 -0.2786003 0.5917974
44 0.8293667 -0.2786003
45 0.6983759 0.8293667
46 -0.1706333 0.6983759
47 -0.3016241 -0.1706333
48 0.6983759 -0.3016241
49 -0.1706333 0.6983759
50 -0.3764329 -0.1706333
51 0.3200363 -0.3764329
52 -0.3016241 0.3200363
53 -0.5719967 -0.3016241
54 -0.1706333 -0.5719967
55 -0.5074237 -0.1706333
56 0.4939647 -0.5074237
57 -0.3016241 0.4939647
58 -0.3016241 -0.3016241
59 0.1890455 -0.3016241
60 -0.4095911 0.1890455
61 0.6249555 -0.4095911
62 -0.1706333 0.6249555
63 -0.4095911 -0.1706333
64 -0.1706333 -0.4095911
65 -0.1706333 -0.1706333
66 0.4266148 -0.1706333
67 -0.2772118 0.4266148
68 -0.3016241 -0.2772118
69 -0.3750445 -0.3016241
70 -0.1706333 -0.3750445
71 -0.3016241 -0.1706333
72 -0.5060353 -0.3016241
73 -0.4816230 -0.5060353
74 -0.3016241 -0.4816230
75 0.6969874 -0.3016241
76 -0.3016241 0.6969874
77 0.4939647 -0.3016241
78 -0.7043760 0.4939647
79 0.8279782 -0.7043760
80 -0.1706333 0.8279782
81 -0.6126138 -0.1706333
82 -0.1706333 -0.6126138
83 -0.5719967 -0.1706333
84 0.6983759 -0.5719967
85 -0.2772118 0.6983759
86 NA -0.2772118
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.1706333 -0.4095911
[2,] -0.1706333 -0.1706333
[3,] -0.1706333 -0.1706333
[4,] -0.1706333 -0.1706333
[5,] 0.5917974 -0.1706333
[6,] -0.1706333 0.5917974
[7,] -0.1720218 -0.1706333
[8,] -0.3016241 -0.1720218
[9,] -0.2772118 -0.3016241
[10,] -0.2786003 -0.2772118
[11,] -0.1706333 -0.2786003
[12,] 0.6249555 -0.1706333
[13,] -0.2786003 0.6249555
[14,] 0.4939647 -0.2786003
[15,] 0.4925763 0.4939647
[16,] 0.3200363 0.4925763
[17,] -0.2786003 0.3200363
[18,] -0.3016241 -0.2786003
[19,] 0.2956240 -0.3016241
[20,] 0.7227882 0.2956240
[21,] 0.3873862 0.7227882
[22,] 0.6983759 0.3873862
[23,] 0.5917974 0.6983759
[24,] -0.5074237 0.5917974
[25,] 0.6249555 -0.5074237
[26,] -0.4082026 0.6249555
[27,] -0.3750445 -0.4082026
[28,] -0.3016241 -0.3750445
[29,] 0.8293667 -0.3016241
[30,] -0.1706333 0.8293667
[31,] -0.2772118 -0.1706333
[32,] 0.7227882 -0.2772118
[33,] -0.3030126 0.7227882
[34,] -0.1706333 -0.3030126
[35,] -0.1706333 -0.1706333
[36,] 0.5169886 -0.1706333
[37,] -0.5060353 0.5169886
[38,] 0.6983759 -0.5060353
[39,] 0.8279782 0.6983759
[40,] 0.2970125 0.8279782
[41,] -0.5060353 0.2970125
[42,] 0.5917974 -0.5060353
[43,] -0.2786003 0.5917974
[44,] 0.8293667 -0.2786003
[45,] 0.6983759 0.8293667
[46,] -0.1706333 0.6983759
[47,] -0.3016241 -0.1706333
[48,] 0.6983759 -0.3016241
[49,] -0.1706333 0.6983759
[50,] -0.3764329 -0.1706333
[51,] 0.3200363 -0.3764329
[52,] -0.3016241 0.3200363
[53,] -0.5719967 -0.3016241
[54,] -0.1706333 -0.5719967
[55,] -0.5074237 -0.1706333
[56,] 0.4939647 -0.5074237
[57,] -0.3016241 0.4939647
[58,] -0.3016241 -0.3016241
[59,] 0.1890455 -0.3016241
[60,] -0.4095911 0.1890455
[61,] 0.6249555 -0.4095911
[62,] -0.1706333 0.6249555
[63,] -0.4095911 -0.1706333
[64,] -0.1706333 -0.4095911
[65,] -0.1706333 -0.1706333
[66,] 0.4266148 -0.1706333
[67,] -0.2772118 0.4266148
[68,] -0.3016241 -0.2772118
[69,] -0.3750445 -0.3016241
[70,] -0.1706333 -0.3750445
[71,] -0.3016241 -0.1706333
[72,] -0.5060353 -0.3016241
[73,] -0.4816230 -0.5060353
[74,] -0.3016241 -0.4816230
[75,] 0.6969874 -0.3016241
[76,] -0.3016241 0.6969874
[77,] 0.4939647 -0.3016241
[78,] -0.7043760 0.4939647
[79,] 0.8279782 -0.7043760
[80,] -0.1706333 0.8279782
[81,] -0.6126138 -0.1706333
[82,] -0.1706333 -0.6126138
[83,] -0.5719967 -0.1706333
[84,] 0.6983759 -0.5719967
[85,] -0.2772118 0.6983759
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.1706333 -0.4095911
2 -0.1706333 -0.1706333
3 -0.1706333 -0.1706333
4 -0.1706333 -0.1706333
5 0.5917974 -0.1706333
6 -0.1706333 0.5917974
7 -0.1720218 -0.1706333
8 -0.3016241 -0.1720218
9 -0.2772118 -0.3016241
10 -0.2786003 -0.2772118
11 -0.1706333 -0.2786003
12 0.6249555 -0.1706333
13 -0.2786003 0.6249555
14 0.4939647 -0.2786003
15 0.4925763 0.4939647
16 0.3200363 0.4925763
17 -0.2786003 0.3200363
18 -0.3016241 -0.2786003
19 0.2956240 -0.3016241
20 0.7227882 0.2956240
21 0.3873862 0.7227882
22 0.6983759 0.3873862
23 0.5917974 0.6983759
24 -0.5074237 0.5917974
25 0.6249555 -0.5074237
26 -0.4082026 0.6249555
27 -0.3750445 -0.4082026
28 -0.3016241 -0.3750445
29 0.8293667 -0.3016241
30 -0.1706333 0.8293667
31 -0.2772118 -0.1706333
32 0.7227882 -0.2772118
33 -0.3030126 0.7227882
34 -0.1706333 -0.3030126
35 -0.1706333 -0.1706333
36 0.5169886 -0.1706333
37 -0.5060353 0.5169886
38 0.6983759 -0.5060353
39 0.8279782 0.6983759
40 0.2970125 0.8279782
41 -0.5060353 0.2970125
42 0.5917974 -0.5060353
43 -0.2786003 0.5917974
44 0.8293667 -0.2786003
45 0.6983759 0.8293667
46 -0.1706333 0.6983759
47 -0.3016241 -0.1706333
48 0.6983759 -0.3016241
49 -0.1706333 0.6983759
50 -0.3764329 -0.1706333
51 0.3200363 -0.3764329
52 -0.3016241 0.3200363
53 -0.5719967 -0.3016241
54 -0.1706333 -0.5719967
55 -0.5074237 -0.1706333
56 0.4939647 -0.5074237
57 -0.3016241 0.4939647
58 -0.3016241 -0.3016241
59 0.1890455 -0.3016241
60 -0.4095911 0.1890455
61 0.6249555 -0.4095911
62 -0.1706333 0.6249555
63 -0.4095911 -0.1706333
64 -0.1706333 -0.4095911
65 -0.1706333 -0.1706333
66 0.4266148 -0.1706333
67 -0.2772118 0.4266148
68 -0.3016241 -0.2772118
69 -0.3750445 -0.3016241
70 -0.1706333 -0.3750445
71 -0.3016241 -0.1706333
72 -0.5060353 -0.3016241
73 -0.4816230 -0.5060353
74 -0.3016241 -0.4816230
75 0.6969874 -0.3016241
76 -0.3016241 0.6969874
77 0.4939647 -0.3016241
78 -0.7043760 0.4939647
79 0.8279782 -0.7043760
80 -0.1706333 0.8279782
81 -0.6126138 -0.1706333
82 -0.1706333 -0.6126138
83 -0.5719967 -0.1706333
84 0.6983759 -0.5719967
85 -0.2772118 0.6983759
> 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/wessaorg/rcomp/tmp/7h5d41356127532.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/wessaorg/rcomp/tmp/8qt4q1356127532.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/wessaorg/rcomp/tmp/9fouq1356127532.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/wessaorg/rcomp/tmp/105sk11356127532.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11kmu61356127532.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/wessaorg/rcomp/tmp/12g0451356127532.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/wessaorg/rcomp/tmp/13gkve1356127532.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/wessaorg/rcomp/tmp/14rer21356127532.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/wessaorg/rcomp/tmp/15pk9i1356127532.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/wessaorg/rcomp/tmp/160pji1356127532.tab")
+ }
>
> try(system("convert tmp/1z4kk1356127532.ps tmp/1z4kk1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/2mj9r1356127532.ps tmp/2mj9r1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/3hvd41356127532.ps tmp/3hvd41356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/40spx1356127532.ps tmp/40spx1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ynik1356127532.ps tmp/5ynik1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/65gfm1356127532.ps tmp/65gfm1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/7h5d41356127532.ps tmp/7h5d41356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/8qt4q1356127532.ps tmp/8qt4q1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/9fouq1356127532.ps tmp/9fouq1356127532.png",intern=TRUE))
character(0)
> try(system("convert tmp/105sk11356127532.ps tmp/105sk11356127532.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
7.661 1.216 8.920