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,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0),dim=c(2,86),dimnames=list(c('T40','CorrectAnalysis
'),1:86))
> y <- array(NA,dim=c(2,86),dimnames=list(c('T40','CorrectAnalysis
'),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 = '1'
> par3 <- 'No Linear Trend'
> par2 <- 'Do not include Seasonal Dummies'
> par1 <- '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
T40 CorrectAnalysis\r
1 1 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
7 0 0
8 1 0
9 0 0
10 0 0
11 1 0
12 0 0
13 0 0
14 1 0
15 0 0
16 1 0
17 1 1
18 1 0
19 0 0
20 1 1
21 0 0
22 0 0
23 0 0
24 0 0
25 1 0
26 0 0
27 0 0
28 0 0
29 0 0
30 0 0
31 0 0
32 0 0
33 0 0
34 1 0
35 0 0
36 0 0
37 1 0
38 0 0
39 0 0
40 1 0
41 0 1
42 0 0
43 0 0
44 1 0
45 0 0
46 0 0
47 0 0
48 0 0
49 0 0
50 0 0
51 1 0
52 1 1
53 0 0
54 0 1
55 0 0
56 1 0
57 0 0
58 0 0
59 0 0
60 1 1
61 1 0
62 0 0
63 0 0
64 1 0
65 0 0
66 0 0
67 1 1
68 0 0
69 0 0
70 0 0
71 0 0
72 0 0
73 0 0
74 0 0
75 0 0
76 1 0
77 0 0
78 0 0
79 1 1
80 1 0
81 0 0
82 0 0
83 0 0
84 0 1
85 0 0
86 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `CorrectAnalysis\\r`
0.2208 0.4459
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.6667 -0.2208 -0.2208 0.3333 0.7792
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.22078 0.04855 4.547 1.81e-05 ***
`CorrectAnalysis\\r` 0.44589 0.15008 2.971 0.00387 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.426 on 84 degrees of freedom
Multiple R-squared: 0.09509, Adjusted R-squared: 0.08431
F-statistic: 8.826 on 1 and 84 DF, p-value: 0.003871
> 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.7677316 0.4645367 0.2322684
[2,] 0.6509337 0.6981325 0.3490663
[3,] 0.5274861 0.9450279 0.4725139
[4,] 0.7676046 0.4647908 0.2323954
[5,] 0.6960205 0.6079590 0.3039795
[6,] 0.6167799 0.7664401 0.3832201
[7,] 0.7769279 0.4461442 0.2230721
[8,] 0.7234350 0.5531301 0.2765650
[9,] 0.6636179 0.6727642 0.3363821
[10,] 0.7902924 0.4194153 0.2097076
[11,] 0.7467351 0.5065298 0.2532649
[12,] 0.8383644 0.3232712 0.1616356
[13,] 0.7921624 0.4156752 0.2078376
[14,] 0.8636472 0.2727056 0.1363528
[15,] 0.8402533 0.3194934 0.1597467
[16,] 0.8019180 0.3961641 0.1980820
[17,] 0.7717464 0.4565072 0.2282536
[18,] 0.7375173 0.5249655 0.2624827
[19,] 0.6994727 0.6010545 0.3005273
[20,] 0.6579913 0.6840174 0.3420087
[21,] 0.7695794 0.4608411 0.2304206
[22,] 0.7353241 0.5293518 0.2646759
[23,] 0.6977116 0.6045767 0.3022884
[24,] 0.6570721 0.6858558 0.3429279
[25,] 0.6138587 0.7722826 0.3861413
[26,] 0.5686367 0.8627267 0.4313633
[27,] 0.5220626 0.9558749 0.4779374
[28,] 0.4748558 0.9497115 0.5251442
[29,] 0.4277644 0.8555288 0.5722356
[30,] 0.5715064 0.8569873 0.4284936
[31,] 0.5257962 0.9484076 0.4742038
[32,] 0.4794825 0.9589651 0.5205175
[33,] 0.6198213 0.7603573 0.3801787
[34,] 0.5756005 0.8487989 0.4243995
[35,] 0.5301292 0.9397416 0.4698708
[36,] 0.6682770 0.6634460 0.3317230
[37,] 0.7641014 0.4717973 0.2358986
[38,] 0.7268165 0.5463670 0.2731835
[39,] 0.6865857 0.6268287 0.3134143
[40,] 0.8039055 0.3921891 0.1960945
[41,] 0.7694252 0.4611496 0.2305748
[42,] 0.7315475 0.5369050 0.2684525
[43,] 0.6905542 0.6188915 0.3094458
[44,] 0.6468588 0.7062824 0.3531412
[45,] 0.6009972 0.7980056 0.3990028
[46,] 0.5536102 0.8927795 0.4463898
[47,] 0.6979112 0.6041777 0.3020888
[48,] 0.6765923 0.6468153 0.3234077
[49,] 0.6299823 0.7400353 0.3700177
[50,] 0.7162036 0.5675928 0.2837964
[51,] 0.6711793 0.6576414 0.3288207
[52,] 0.8126208 0.3747584 0.1873792
[53,] 0.7738282 0.4523436 0.2261718
[54,] 0.7306265 0.5387470 0.2693735
[55,] 0.6834315 0.6331371 0.3165685
[56,] 0.6537865 0.6924270 0.3462135
[57,] 0.8164535 0.3670930 0.1835465
[58,] 0.7735745 0.4528510 0.2264255
[59,] 0.7251314 0.5497372 0.2748686
[60,] 0.8893293 0.2213413 0.1106707
[61,] 0.8539372 0.2921257 0.1460628
[62,] 0.8110392 0.3779216 0.1889608
[63,] 0.8078629 0.3842743 0.1921371
[64,] 0.7553558 0.4892884 0.2446442
[65,] 0.6950887 0.6098226 0.3049113
[66,] 0.6280670 0.7438660 0.3719330
[67,] 0.5559711 0.8880579 0.4440289
[68,] 0.4810868 0.9621737 0.5189132
[69,] 0.4061325 0.8122650 0.5938675
[70,] 0.3339949 0.6679897 0.6660051
[71,] 0.2674158 0.5348315 0.7325842
[72,] 0.4994244 0.9988489 0.5005756
[73,] 0.4003165 0.8006330 0.5996835
[74,] 0.3045531 0.6091061 0.6954469
[75,] 0.4704029 0.9408057 0.5295971
[76,] 1.0000000 0.0000000 0.0000000
[77,] 1.0000000 0.0000000 0.0000000
> postscript(file="/var/wessaorg/rcomp/tmp/120e51355917371.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/2fc2c1355917371.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/3t6et1355917371.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/4kl7q1355917371.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/5nzbe1355917371.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.7792208 -0.2207792 -0.2207792 -0.2207792 -0.2207792 -0.2207792 -0.2207792
8 9 10 11 12 13 14
0.7792208 -0.2207792 -0.2207792 0.7792208 -0.2207792 -0.2207792 0.7792208
15 16 17 18 19 20 21
-0.2207792 0.7792208 0.3333333 0.7792208 -0.2207792 0.3333333 -0.2207792
22 23 24 25 26 27 28
-0.2207792 -0.2207792 -0.2207792 0.7792208 -0.2207792 -0.2207792 -0.2207792
29 30 31 32 33 34 35
-0.2207792 -0.2207792 -0.2207792 -0.2207792 -0.2207792 0.7792208 -0.2207792
36 37 38 39 40 41 42
-0.2207792 0.7792208 -0.2207792 -0.2207792 0.7792208 -0.6666667 -0.2207792
43 44 45 46 47 48 49
-0.2207792 0.7792208 -0.2207792 -0.2207792 -0.2207792 -0.2207792 -0.2207792
50 51 52 53 54 55 56
-0.2207792 0.7792208 0.3333333 -0.2207792 -0.6666667 -0.2207792 0.7792208
57 58 59 60 61 62 63
-0.2207792 -0.2207792 -0.2207792 0.3333333 0.7792208 -0.2207792 -0.2207792
64 65 66 67 68 69 70
0.7792208 -0.2207792 -0.2207792 0.3333333 -0.2207792 -0.2207792 -0.2207792
71 72 73 74 75 76 77
-0.2207792 -0.2207792 -0.2207792 -0.2207792 -0.2207792 0.7792208 -0.2207792
78 79 80 81 82 83 84
-0.2207792 0.3333333 0.7792208 -0.2207792 -0.2207792 -0.2207792 -0.6666667
85 86
-0.2207792 -0.2207792
> postscript(file="/var/wessaorg/rcomp/tmp/6egh31355917371.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.7792208 NA
1 -0.2207792 0.7792208
2 -0.2207792 -0.2207792
3 -0.2207792 -0.2207792
4 -0.2207792 -0.2207792
5 -0.2207792 -0.2207792
6 -0.2207792 -0.2207792
7 0.7792208 -0.2207792
8 -0.2207792 0.7792208
9 -0.2207792 -0.2207792
10 0.7792208 -0.2207792
11 -0.2207792 0.7792208
12 -0.2207792 -0.2207792
13 0.7792208 -0.2207792
14 -0.2207792 0.7792208
15 0.7792208 -0.2207792
16 0.3333333 0.7792208
17 0.7792208 0.3333333
18 -0.2207792 0.7792208
19 0.3333333 -0.2207792
20 -0.2207792 0.3333333
21 -0.2207792 -0.2207792
22 -0.2207792 -0.2207792
23 -0.2207792 -0.2207792
24 0.7792208 -0.2207792
25 -0.2207792 0.7792208
26 -0.2207792 -0.2207792
27 -0.2207792 -0.2207792
28 -0.2207792 -0.2207792
29 -0.2207792 -0.2207792
30 -0.2207792 -0.2207792
31 -0.2207792 -0.2207792
32 -0.2207792 -0.2207792
33 0.7792208 -0.2207792
34 -0.2207792 0.7792208
35 -0.2207792 -0.2207792
36 0.7792208 -0.2207792
37 -0.2207792 0.7792208
38 -0.2207792 -0.2207792
39 0.7792208 -0.2207792
40 -0.6666667 0.7792208
41 -0.2207792 -0.6666667
42 -0.2207792 -0.2207792
43 0.7792208 -0.2207792
44 -0.2207792 0.7792208
45 -0.2207792 -0.2207792
46 -0.2207792 -0.2207792
47 -0.2207792 -0.2207792
48 -0.2207792 -0.2207792
49 -0.2207792 -0.2207792
50 0.7792208 -0.2207792
51 0.3333333 0.7792208
52 -0.2207792 0.3333333
53 -0.6666667 -0.2207792
54 -0.2207792 -0.6666667
55 0.7792208 -0.2207792
56 -0.2207792 0.7792208
57 -0.2207792 -0.2207792
58 -0.2207792 -0.2207792
59 0.3333333 -0.2207792
60 0.7792208 0.3333333
61 -0.2207792 0.7792208
62 -0.2207792 -0.2207792
63 0.7792208 -0.2207792
64 -0.2207792 0.7792208
65 -0.2207792 -0.2207792
66 0.3333333 -0.2207792
67 -0.2207792 0.3333333
68 -0.2207792 -0.2207792
69 -0.2207792 -0.2207792
70 -0.2207792 -0.2207792
71 -0.2207792 -0.2207792
72 -0.2207792 -0.2207792
73 -0.2207792 -0.2207792
74 -0.2207792 -0.2207792
75 0.7792208 -0.2207792
76 -0.2207792 0.7792208
77 -0.2207792 -0.2207792
78 0.3333333 -0.2207792
79 0.7792208 0.3333333
80 -0.2207792 0.7792208
81 -0.2207792 -0.2207792
82 -0.2207792 -0.2207792
83 -0.6666667 -0.2207792
84 -0.2207792 -0.6666667
85 -0.2207792 -0.2207792
86 NA -0.2207792
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.2207792 0.7792208
[2,] -0.2207792 -0.2207792
[3,] -0.2207792 -0.2207792
[4,] -0.2207792 -0.2207792
[5,] -0.2207792 -0.2207792
[6,] -0.2207792 -0.2207792
[7,] 0.7792208 -0.2207792
[8,] -0.2207792 0.7792208
[9,] -0.2207792 -0.2207792
[10,] 0.7792208 -0.2207792
[11,] -0.2207792 0.7792208
[12,] -0.2207792 -0.2207792
[13,] 0.7792208 -0.2207792
[14,] -0.2207792 0.7792208
[15,] 0.7792208 -0.2207792
[16,] 0.3333333 0.7792208
[17,] 0.7792208 0.3333333
[18,] -0.2207792 0.7792208
[19,] 0.3333333 -0.2207792
[20,] -0.2207792 0.3333333
[21,] -0.2207792 -0.2207792
[22,] -0.2207792 -0.2207792
[23,] -0.2207792 -0.2207792
[24,] 0.7792208 -0.2207792
[25,] -0.2207792 0.7792208
[26,] -0.2207792 -0.2207792
[27,] -0.2207792 -0.2207792
[28,] -0.2207792 -0.2207792
[29,] -0.2207792 -0.2207792
[30,] -0.2207792 -0.2207792
[31,] -0.2207792 -0.2207792
[32,] -0.2207792 -0.2207792
[33,] 0.7792208 -0.2207792
[34,] -0.2207792 0.7792208
[35,] -0.2207792 -0.2207792
[36,] 0.7792208 -0.2207792
[37,] -0.2207792 0.7792208
[38,] -0.2207792 -0.2207792
[39,] 0.7792208 -0.2207792
[40,] -0.6666667 0.7792208
[41,] -0.2207792 -0.6666667
[42,] -0.2207792 -0.2207792
[43,] 0.7792208 -0.2207792
[44,] -0.2207792 0.7792208
[45,] -0.2207792 -0.2207792
[46,] -0.2207792 -0.2207792
[47,] -0.2207792 -0.2207792
[48,] -0.2207792 -0.2207792
[49,] -0.2207792 -0.2207792
[50,] 0.7792208 -0.2207792
[51,] 0.3333333 0.7792208
[52,] -0.2207792 0.3333333
[53,] -0.6666667 -0.2207792
[54,] -0.2207792 -0.6666667
[55,] 0.7792208 -0.2207792
[56,] -0.2207792 0.7792208
[57,] -0.2207792 -0.2207792
[58,] -0.2207792 -0.2207792
[59,] 0.3333333 -0.2207792
[60,] 0.7792208 0.3333333
[61,] -0.2207792 0.7792208
[62,] -0.2207792 -0.2207792
[63,] 0.7792208 -0.2207792
[64,] -0.2207792 0.7792208
[65,] -0.2207792 -0.2207792
[66,] 0.3333333 -0.2207792
[67,] -0.2207792 0.3333333
[68,] -0.2207792 -0.2207792
[69,] -0.2207792 -0.2207792
[70,] -0.2207792 -0.2207792
[71,] -0.2207792 -0.2207792
[72,] -0.2207792 -0.2207792
[73,] -0.2207792 -0.2207792
[74,] -0.2207792 -0.2207792
[75,] 0.7792208 -0.2207792
[76,] -0.2207792 0.7792208
[77,] -0.2207792 -0.2207792
[78,] 0.3333333 -0.2207792
[79,] 0.7792208 0.3333333
[80,] -0.2207792 0.7792208
[81,] -0.2207792 -0.2207792
[82,] -0.2207792 -0.2207792
[83,] -0.6666667 -0.2207792
[84,] -0.2207792 -0.6666667
[85,] -0.2207792 -0.2207792
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.2207792 0.7792208
2 -0.2207792 -0.2207792
3 -0.2207792 -0.2207792
4 -0.2207792 -0.2207792
5 -0.2207792 -0.2207792
6 -0.2207792 -0.2207792
7 0.7792208 -0.2207792
8 -0.2207792 0.7792208
9 -0.2207792 -0.2207792
10 0.7792208 -0.2207792
11 -0.2207792 0.7792208
12 -0.2207792 -0.2207792
13 0.7792208 -0.2207792
14 -0.2207792 0.7792208
15 0.7792208 -0.2207792
16 0.3333333 0.7792208
17 0.7792208 0.3333333
18 -0.2207792 0.7792208
19 0.3333333 -0.2207792
20 -0.2207792 0.3333333
21 -0.2207792 -0.2207792
22 -0.2207792 -0.2207792
23 -0.2207792 -0.2207792
24 0.7792208 -0.2207792
25 -0.2207792 0.7792208
26 -0.2207792 -0.2207792
27 -0.2207792 -0.2207792
28 -0.2207792 -0.2207792
29 -0.2207792 -0.2207792
30 -0.2207792 -0.2207792
31 -0.2207792 -0.2207792
32 -0.2207792 -0.2207792
33 0.7792208 -0.2207792
34 -0.2207792 0.7792208
35 -0.2207792 -0.2207792
36 0.7792208 -0.2207792
37 -0.2207792 0.7792208
38 -0.2207792 -0.2207792
39 0.7792208 -0.2207792
40 -0.6666667 0.7792208
41 -0.2207792 -0.6666667
42 -0.2207792 -0.2207792
43 0.7792208 -0.2207792
44 -0.2207792 0.7792208
45 -0.2207792 -0.2207792
46 -0.2207792 -0.2207792
47 -0.2207792 -0.2207792
48 -0.2207792 -0.2207792
49 -0.2207792 -0.2207792
50 0.7792208 -0.2207792
51 0.3333333 0.7792208
52 -0.2207792 0.3333333
53 -0.6666667 -0.2207792
54 -0.2207792 -0.6666667
55 0.7792208 -0.2207792
56 -0.2207792 0.7792208
57 -0.2207792 -0.2207792
58 -0.2207792 -0.2207792
59 0.3333333 -0.2207792
60 0.7792208 0.3333333
61 -0.2207792 0.7792208
62 -0.2207792 -0.2207792
63 0.7792208 -0.2207792
64 -0.2207792 0.7792208
65 -0.2207792 -0.2207792
66 0.3333333 -0.2207792
67 -0.2207792 0.3333333
68 -0.2207792 -0.2207792
69 -0.2207792 -0.2207792
70 -0.2207792 -0.2207792
71 -0.2207792 -0.2207792
72 -0.2207792 -0.2207792
73 -0.2207792 -0.2207792
74 -0.2207792 -0.2207792
75 0.7792208 -0.2207792
76 -0.2207792 0.7792208
77 -0.2207792 -0.2207792
78 0.3333333 -0.2207792
79 0.7792208 0.3333333
80 -0.2207792 0.7792208
81 -0.2207792 -0.2207792
82 -0.2207792 -0.2207792
83 -0.6666667 -0.2207792
84 -0.2207792 -0.6666667
85 -0.2207792 -0.2207792
> 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/74de21355917371.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/8rr5s1355917371.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/9jmmc1355917371.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/10800p1355917371.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/11mbln1355917371.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/12fvhk1355917371.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/13yw4o1355917371.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/14wurz1355917371.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/15c1ft1355917371.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/16lvop1355917371.tab")
+ }
>
> try(system("convert tmp/120e51355917371.ps tmp/120e51355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/2fc2c1355917371.ps tmp/2fc2c1355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/3t6et1355917371.ps tmp/3t6et1355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/4kl7q1355917371.ps tmp/4kl7q1355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/5nzbe1355917371.ps tmp/5nzbe1355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/6egh31355917371.ps tmp/6egh31355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/74de21355917371.ps tmp/74de21355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/8rr5s1355917371.ps tmp/8rr5s1355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/9jmmc1355917371.ps tmp/9jmmc1355917371.png",intern=TRUE))
character(0)
> try(system("convert tmp/10800p1355917371.ps tmp/10800p1355917371.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.429 0.986 9.092