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,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,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,0,0,1,0,1,1,0,0,0,1,1,0,0,0,1,1,1,1,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,1,1,0,0,1,0,0,1,1,1,1,0,1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0),dim=c(5,86),dimnames=list(c('T40','Used','CorrectAnalysis','Useful','Outcome'),1:86))
> y <- array(NA,dim=c(5,86),dimnames=list(c('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 = '3'
> par3 <- 'No Linear Trend'
> par2 <- 'Do not include Seasonal Dummies'
> par1 <- '3'
> #'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 T40 Used Useful Outcome
1 0 1 0 0 1
2 0 0 0 0 0
3 0 0 0 0 0
4 0 0 0 0 0
5 0 0 0 0 0
6 0 0 0 1 1
7 0 0 0 0 0
8 0 1 0 0 0
9 0 0 0 0 1
10 0 0 0 0 0
11 0 1 0 0 0
12 0 0 0 0 0
13 0 0 1 1 0
14 0 1 0 0 0
15 0 0 1 1 1
16 0 1 1 1 1
17 1 1 1 1 0
18 0 1 0 0 0
19 0 0 0 0 1
20 1 1 1 1 1
21 0 0 0 1 0
22 0 0 1 1 1
23 0 0 0 1 1
24 0 0 0 1 1
25 0 1 1 0 1
26 0 0 1 1 0
27 0 0 0 0 1
28 0 0 1 0 0
29 0 0 0 0 1
30 0 0 0 1 0
31 0 0 0 0 0
32 0 0 0 0 0
33 0 0 0 1 0
34 0 1 0 0 1
35 0 0 0 0 0
36 0 0 0 0 0
37 0 1 1 1 0
38 0 0 1 0 1
39 0 0 0 1 1
40 0 1 0 1 0
41 1 0 1 1 1
42 0 0 1 0 1
43 0 0 0 1 1
44 0 1 0 0 0
45 0 0 0 1 0
46 0 0 0 1 1
47 0 0 0 0 0
48 0 0 0 0 1
49 0 0 0 1 1
50 0 0 0 0 0
51 0 1 1 0 0
52 1 1 1 1 0
53 0 0 0 0 1
54 1 0 1 0 0
55 0 0 0 0 0
56 0 1 1 0 1
57 0 0 1 1 1
58 0 0 0 0 1
59 0 0 0 0 1
60 1 1 1 1 1
61 0 1 0 0 1
62 0 0 1 1 0
63 0 0 0 0 0
64 0 1 0 0 1
65 0 0 0 0 0
66 0 0 0 0 0
67 1 1 1 1 0
68 0 0 0 0 0
69 0 0 0 0 1
70 0 0 1 0 0
71 0 0 0 0 0
72 0 0 0 0 1
73 0 0 1 0 1
74 0 0 1 0 0
75 0 0 0 0 1
76 0 1 0 1 1
77 0 0 0 0 1
78 0 0 1 1 1
79 1 1 1 0 1
80 0 1 0 1 0
81 0 0 0 0 0
82 0 0 1 0 1
83 0 0 0 0 0
84 1 0 1 0 0
85 0 0 0 1 1
86 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) T40 Used Useful Outcome
-0.02727 0.14805 0.28116 0.06328 -0.04577
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.46522 -0.13391 0.01851 0.02727 0.74611
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.02727 0.04629 -0.589 0.5575
T40 0.14805 0.06563 2.256 0.0268 *
Used 0.28116 0.06416 4.382 3.5e-05 ***
Useful 0.06328 0.06262 1.011 0.3153
Outcome -0.04577 0.05775 -0.793 0.4303
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2636 on 81 degrees of freedom
Multiple R-squared: 0.3013, Adjusted R-squared: 0.2668
F-statistic: 8.733 on 4 and 81 DF, p-value: 6.519e-06
> 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.00000000 0.00000000 1.0000000
[2,] 0.00000000 0.00000000 1.0000000
[3,] 0.00000000 0.00000000 1.0000000
[4,] 0.00000000 0.00000000 1.0000000
[5,] 0.00000000 0.00000000 1.0000000
[6,] 0.00000000 0.00000000 1.0000000
[7,] 0.00000000 0.00000000 1.0000000
[8,] 0.00000000 0.00000000 1.0000000
[9,] 0.00000000 0.00000000 1.0000000
[10,] 0.18037695 0.36075389 0.8196231
[11,] 0.13766785 0.27533570 0.8623322
[12,] 0.11450807 0.22901614 0.8854919
[13,] 0.45875697 0.91751395 0.5412430
[14,] 0.37966482 0.75932964 0.6203352
[15,] 0.36561687 0.73123375 0.6343831
[16,] 0.29423593 0.58847187 0.7057641
[17,] 0.23059638 0.46119276 0.7694036
[18,] 0.23322899 0.46645797 0.7667710
[19,] 0.23466908 0.46933815 0.7653309
[20,] 0.19323534 0.38647069 0.8067647
[21,] 0.16121529 0.32243058 0.8387847
[22,] 0.12746991 0.25493982 0.8725301
[23,] 0.09608255 0.19216510 0.9039175
[24,] 0.07030176 0.14060352 0.9296982
[25,] 0.05019644 0.10039288 0.9498036
[26,] 0.03536134 0.07072268 0.9646387
[27,] 0.02501571 0.05003141 0.9749843
[28,] 0.01674422 0.03348844 0.9832558
[29,] 0.01093507 0.02187013 0.9890649
[30,] 0.02324715 0.04649430 0.9767528
[31,] 0.01772347 0.03544693 0.9822765
[32,] 0.01157192 0.02314385 0.9884281
[33,] 0.01019295 0.02038589 0.9898071
[34,] 0.16280696 0.32561392 0.8371930
[35,] 0.14175924 0.28351849 0.8582408
[36,] 0.10931276 0.21862552 0.8906872
[37,] 0.08971571 0.17943141 0.9102843
[38,] 0.06662934 0.13325867 0.9333707
[39,] 0.04856068 0.09712137 0.9514393
[40,] 0.03455267 0.06910535 0.9654473
[41,] 0.02448834 0.04897669 0.9755117
[42,] 0.01679220 0.03358439 0.9832078
[43,] 0.01115167 0.02230334 0.9888483
[44,] 0.02765681 0.05531363 0.9723432
[45,] 0.08064716 0.16129431 0.9193528
[46,] 0.06136845 0.12273689 0.9386316
[47,] 0.31479554 0.62959108 0.6852045
[48,] 0.25704987 0.51409974 0.7429501
[49,] 0.41065968 0.82131935 0.5893403
[50,] 0.38457626 0.76915252 0.6154237
[51,] 0.32833322 0.65666645 0.6716668
[52,] 0.27673193 0.55346386 0.7232681
[53,] 0.46881139 0.93762278 0.5311886
[54,] 0.45315148 0.90630295 0.5468485
[55,] 0.43952705 0.87905410 0.5604730
[56,] 0.36619938 0.73239875 0.6338006
[57,] 0.38618132 0.77236264 0.6138187
[58,] 0.31340380 0.62680760 0.6865962
[59,] 0.24622691 0.49245382 0.7537731
[60,] 0.39179784 0.78359568 0.6082022
[61,] 0.31286754 0.62573507 0.6871325
[62,] 0.24137599 0.48275198 0.7586240
[63,] 0.24860546 0.49721092 0.7513945
[64,] 0.18192337 0.36384674 0.8180766
[65,] 0.12693183 0.25386366 0.8730682
[66,] 0.13035024 0.26070047 0.8696498
[67,] 0.23489433 0.46978866 0.7651057
[68,] 0.15988382 0.31976764 0.8401162
[69,] 0.10002800 0.20005600 0.8999720
[70,] 0.05778765 0.11557530 0.9422124
[71,] 0.05074277 0.10148555 0.9492572
> postscript(file="/var/wessaorg/rcomp/tmp/1vyti1355860455.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/2tvpo1355860455.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/3lcc71355860455.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/498nv1355860455.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/5k89w1355860455.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
-0.075010436 0.027265443 0.027265443 0.027265443 0.027265443 0.009762964
7 8 9 10 11 12
0.027265443 -0.120784414 0.073039421 0.027265443 -0.120784414 0.027265443
13 14 15 16 17 18
-0.317166256 -0.120784414 -0.271392279 -0.419442135 0.534783887 -0.120784414
19 20 21 22 23 24
0.073039421 0.580557865 -0.036011014 -0.271392279 0.009762964 0.009762964
25 26 27 28 29 30
-0.356165679 -0.317166256 0.073039421 -0.253889800 0.073039421 -0.036011014
31 32 33 34 35 36
0.027265443 0.027265443 -0.036011014 -0.075010436 0.027265443 0.027265443
37 38 39 40 41 42
-0.465216113 -0.208115822 0.009762964 -0.184060871 0.728607721 -0.208115822
43 44 45 46 47 48
0.009762964 -0.120784414 -0.036011014 0.009762964 0.027265443 0.073039421
49 50 51 52 53 54
0.009762964 0.027265443 -0.401939656 0.534783887 0.073039421 0.746110200
55 56 57 58 59 60
0.027265443 -0.356165679 -0.271392279 0.073039421 0.073039421 0.580557865
61 62 63 64 65 66
-0.075010436 -0.317166256 0.027265443 -0.075010436 0.027265443 0.027265443
67 68 69 70 71 72
0.534783887 0.027265443 0.073039421 -0.253889800 0.027265443 0.073039421
73 74 75 76 77 78
-0.208115822 -0.253889800 0.073039421 -0.138286893 0.073039421 -0.271392279
79 80 81 82 83 84
0.643834321 -0.184060871 0.027265443 -0.208115822 0.027265443 0.746110200
85 86
0.009762964 0.027265443
> postscript(file="/var/wessaorg/rcomp/tmp/66fq01355860455.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.075010436 NA
1 0.027265443 -0.075010436
2 0.027265443 0.027265443
3 0.027265443 0.027265443
4 0.027265443 0.027265443
5 0.009762964 0.027265443
6 0.027265443 0.009762964
7 -0.120784414 0.027265443
8 0.073039421 -0.120784414
9 0.027265443 0.073039421
10 -0.120784414 0.027265443
11 0.027265443 -0.120784414
12 -0.317166256 0.027265443
13 -0.120784414 -0.317166256
14 -0.271392279 -0.120784414
15 -0.419442135 -0.271392279
16 0.534783887 -0.419442135
17 -0.120784414 0.534783887
18 0.073039421 -0.120784414
19 0.580557865 0.073039421
20 -0.036011014 0.580557865
21 -0.271392279 -0.036011014
22 0.009762964 -0.271392279
23 0.009762964 0.009762964
24 -0.356165679 0.009762964
25 -0.317166256 -0.356165679
26 0.073039421 -0.317166256
27 -0.253889800 0.073039421
28 0.073039421 -0.253889800
29 -0.036011014 0.073039421
30 0.027265443 -0.036011014
31 0.027265443 0.027265443
32 -0.036011014 0.027265443
33 -0.075010436 -0.036011014
34 0.027265443 -0.075010436
35 0.027265443 0.027265443
36 -0.465216113 0.027265443
37 -0.208115822 -0.465216113
38 0.009762964 -0.208115822
39 -0.184060871 0.009762964
40 0.728607721 -0.184060871
41 -0.208115822 0.728607721
42 0.009762964 -0.208115822
43 -0.120784414 0.009762964
44 -0.036011014 -0.120784414
45 0.009762964 -0.036011014
46 0.027265443 0.009762964
47 0.073039421 0.027265443
48 0.009762964 0.073039421
49 0.027265443 0.009762964
50 -0.401939656 0.027265443
51 0.534783887 -0.401939656
52 0.073039421 0.534783887
53 0.746110200 0.073039421
54 0.027265443 0.746110200
55 -0.356165679 0.027265443
56 -0.271392279 -0.356165679
57 0.073039421 -0.271392279
58 0.073039421 0.073039421
59 0.580557865 0.073039421
60 -0.075010436 0.580557865
61 -0.317166256 -0.075010436
62 0.027265443 -0.317166256
63 -0.075010436 0.027265443
64 0.027265443 -0.075010436
65 0.027265443 0.027265443
66 0.534783887 0.027265443
67 0.027265443 0.534783887
68 0.073039421 0.027265443
69 -0.253889800 0.073039421
70 0.027265443 -0.253889800
71 0.073039421 0.027265443
72 -0.208115822 0.073039421
73 -0.253889800 -0.208115822
74 0.073039421 -0.253889800
75 -0.138286893 0.073039421
76 0.073039421 -0.138286893
77 -0.271392279 0.073039421
78 0.643834321 -0.271392279
79 -0.184060871 0.643834321
80 0.027265443 -0.184060871
81 -0.208115822 0.027265443
82 0.027265443 -0.208115822
83 0.746110200 0.027265443
84 0.009762964 0.746110200
85 0.027265443 0.009762964
86 NA 0.027265443
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.027265443 -0.075010436
[2,] 0.027265443 0.027265443
[3,] 0.027265443 0.027265443
[4,] 0.027265443 0.027265443
[5,] 0.009762964 0.027265443
[6,] 0.027265443 0.009762964
[7,] -0.120784414 0.027265443
[8,] 0.073039421 -0.120784414
[9,] 0.027265443 0.073039421
[10,] -0.120784414 0.027265443
[11,] 0.027265443 -0.120784414
[12,] -0.317166256 0.027265443
[13,] -0.120784414 -0.317166256
[14,] -0.271392279 -0.120784414
[15,] -0.419442135 -0.271392279
[16,] 0.534783887 -0.419442135
[17,] -0.120784414 0.534783887
[18,] 0.073039421 -0.120784414
[19,] 0.580557865 0.073039421
[20,] -0.036011014 0.580557865
[21,] -0.271392279 -0.036011014
[22,] 0.009762964 -0.271392279
[23,] 0.009762964 0.009762964
[24,] -0.356165679 0.009762964
[25,] -0.317166256 -0.356165679
[26,] 0.073039421 -0.317166256
[27,] -0.253889800 0.073039421
[28,] 0.073039421 -0.253889800
[29,] -0.036011014 0.073039421
[30,] 0.027265443 -0.036011014
[31,] 0.027265443 0.027265443
[32,] -0.036011014 0.027265443
[33,] -0.075010436 -0.036011014
[34,] 0.027265443 -0.075010436
[35,] 0.027265443 0.027265443
[36,] -0.465216113 0.027265443
[37,] -0.208115822 -0.465216113
[38,] 0.009762964 -0.208115822
[39,] -0.184060871 0.009762964
[40,] 0.728607721 -0.184060871
[41,] -0.208115822 0.728607721
[42,] 0.009762964 -0.208115822
[43,] -0.120784414 0.009762964
[44,] -0.036011014 -0.120784414
[45,] 0.009762964 -0.036011014
[46,] 0.027265443 0.009762964
[47,] 0.073039421 0.027265443
[48,] 0.009762964 0.073039421
[49,] 0.027265443 0.009762964
[50,] -0.401939656 0.027265443
[51,] 0.534783887 -0.401939656
[52,] 0.073039421 0.534783887
[53,] 0.746110200 0.073039421
[54,] 0.027265443 0.746110200
[55,] -0.356165679 0.027265443
[56,] -0.271392279 -0.356165679
[57,] 0.073039421 -0.271392279
[58,] 0.073039421 0.073039421
[59,] 0.580557865 0.073039421
[60,] -0.075010436 0.580557865
[61,] -0.317166256 -0.075010436
[62,] 0.027265443 -0.317166256
[63,] -0.075010436 0.027265443
[64,] 0.027265443 -0.075010436
[65,] 0.027265443 0.027265443
[66,] 0.534783887 0.027265443
[67,] 0.027265443 0.534783887
[68,] 0.073039421 0.027265443
[69,] -0.253889800 0.073039421
[70,] 0.027265443 -0.253889800
[71,] 0.073039421 0.027265443
[72,] -0.208115822 0.073039421
[73,] -0.253889800 -0.208115822
[74,] 0.073039421 -0.253889800
[75,] -0.138286893 0.073039421
[76,] 0.073039421 -0.138286893
[77,] -0.271392279 0.073039421
[78,] 0.643834321 -0.271392279
[79,] -0.184060871 0.643834321
[80,] 0.027265443 -0.184060871
[81,] -0.208115822 0.027265443
[82,] 0.027265443 -0.208115822
[83,] 0.746110200 0.027265443
[84,] 0.009762964 0.746110200
[85,] 0.027265443 0.009762964
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.027265443 -0.075010436
2 0.027265443 0.027265443
3 0.027265443 0.027265443
4 0.027265443 0.027265443
5 0.009762964 0.027265443
6 0.027265443 0.009762964
7 -0.120784414 0.027265443
8 0.073039421 -0.120784414
9 0.027265443 0.073039421
10 -0.120784414 0.027265443
11 0.027265443 -0.120784414
12 -0.317166256 0.027265443
13 -0.120784414 -0.317166256
14 -0.271392279 -0.120784414
15 -0.419442135 -0.271392279
16 0.534783887 -0.419442135
17 -0.120784414 0.534783887
18 0.073039421 -0.120784414
19 0.580557865 0.073039421
20 -0.036011014 0.580557865
21 -0.271392279 -0.036011014
22 0.009762964 -0.271392279
23 0.009762964 0.009762964
24 -0.356165679 0.009762964
25 -0.317166256 -0.356165679
26 0.073039421 -0.317166256
27 -0.253889800 0.073039421
28 0.073039421 -0.253889800
29 -0.036011014 0.073039421
30 0.027265443 -0.036011014
31 0.027265443 0.027265443
32 -0.036011014 0.027265443
33 -0.075010436 -0.036011014
34 0.027265443 -0.075010436
35 0.027265443 0.027265443
36 -0.465216113 0.027265443
37 -0.208115822 -0.465216113
38 0.009762964 -0.208115822
39 -0.184060871 0.009762964
40 0.728607721 -0.184060871
41 -0.208115822 0.728607721
42 0.009762964 -0.208115822
43 -0.120784414 0.009762964
44 -0.036011014 -0.120784414
45 0.009762964 -0.036011014
46 0.027265443 0.009762964
47 0.073039421 0.027265443
48 0.009762964 0.073039421
49 0.027265443 0.009762964
50 -0.401939656 0.027265443
51 0.534783887 -0.401939656
52 0.073039421 0.534783887
53 0.746110200 0.073039421
54 0.027265443 0.746110200
55 -0.356165679 0.027265443
56 -0.271392279 -0.356165679
57 0.073039421 -0.271392279
58 0.073039421 0.073039421
59 0.580557865 0.073039421
60 -0.075010436 0.580557865
61 -0.317166256 -0.075010436
62 0.027265443 -0.317166256
63 -0.075010436 0.027265443
64 0.027265443 -0.075010436
65 0.027265443 0.027265443
66 0.534783887 0.027265443
67 0.027265443 0.534783887
68 0.073039421 0.027265443
69 -0.253889800 0.073039421
70 0.027265443 -0.253889800
71 0.073039421 0.027265443
72 -0.208115822 0.073039421
73 -0.253889800 -0.208115822
74 0.073039421 -0.253889800
75 -0.138286893 0.073039421
76 0.073039421 -0.138286893
77 -0.271392279 0.073039421
78 0.643834321 -0.271392279
79 -0.184060871 0.643834321
80 0.027265443 -0.184060871
81 -0.208115822 0.027265443
82 0.027265443 -0.208115822
83 0.746110200 0.027265443
84 0.009762964 0.746110200
85 0.027265443 0.009762964
> 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/7guyi1355860455.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/89gyp1355860455.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/9z0531355860455.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/10pfmm1355860455.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/11xwr81355860455.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/12c4hd1355860455.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/13n5g11355860455.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/14nwin1355860455.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/15123p1355860455.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/166mxd1355860455.tab")
+ }
>
> try(system("convert tmp/1vyti1355860455.ps tmp/1vyti1355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/2tvpo1355860455.ps tmp/2tvpo1355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/3lcc71355860455.ps tmp/3lcc71355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/498nv1355860455.ps tmp/498nv1355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/5k89w1355860455.ps tmp/5k89w1355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/66fq01355860455.ps tmp/66fq01355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/7guyi1355860455.ps tmp/7guyi1355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/89gyp1355860455.ps tmp/89gyp1355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/9z0531355860455.ps tmp/9z0531355860455.png",intern=TRUE))
character(0)
> try(system("convert tmp/10pfmm1355860455.ps tmp/10pfmm1355860455.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
7.274 1.289 9.670