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,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,1,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,1,0,1,0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0),dim=c(3,86),dimnames=list(c('T40','Used','Outcome
'),1:86))
> y <- array(NA,dim=c(3,86),dimnames=list(c('T40','Used','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
Outcome\r T40 Used
1 1 1 0
2 0 0 0
3 0 0 0
4 0 0 0
5 0 0 0
6 1 0 0
7 0 0 0
8 0 1 0
9 1 0 0
10 0 0 0
11 0 1 0
12 0 0 0
13 0 0 1
14 0 1 0
15 1 0 1
16 1 1 1
17 0 1 1
18 0 1 0
19 1 0 0
20 1 1 1
21 0 0 0
22 1 0 1
23 1 0 0
24 1 0 0
25 1 1 1
26 0 0 1
27 1 0 0
28 0 0 1
29 1 0 0
30 0 0 0
31 0 0 0
32 0 0 0
33 0 0 0
34 1 1 0
35 0 0 0
36 0 0 0
37 0 1 1
38 1 0 1
39 1 0 0
40 0 1 0
41 1 0 1
42 1 0 1
43 1 0 0
44 0 1 0
45 0 0 0
46 1 0 0
47 0 0 0
48 1 0 0
49 1 0 0
50 0 0 0
51 0 1 1
52 0 1 1
53 1 0 0
54 0 0 1
55 0 0 0
56 1 1 1
57 1 0 1
58 1 0 0
59 1 0 0
60 1 1 1
61 1 1 0
62 0 0 1
63 0 0 0
64 1 1 0
65 0 0 0
66 0 0 0
67 0 1 1
68 0 0 0
69 1 0 0
70 0 0 1
71 0 0 0
72 1 0 0
73 1 0 1
74 0 0 1
75 1 0 0
76 1 1 0
77 1 0 0
78 1 0 1
79 1 1 1
80 0 1 0
81 0 0 0
82 1 0 1
83 0 0 0
84 0 0 1
85 1 0 0
86 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) T40 Used
0.43187 -0.00403 0.10543
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.5373 -0.4319 -0.4278 0.5681 0.5722
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.43187 0.07125 6.062 3.81e-08 ***
T40 -0.00403 0.12555 -0.032 0.974
Used 0.10543 0.11859 0.889 0.377
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5053 on 83 degrees of freedom
Multiple R-squared: 0.009684, Adjusted R-squared: -0.01418
F-statistic: 0.4058 on 2 and 83 DF, p-value: 0.6678
> 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.6200321 0.7599359 0.3799679
[2,] 0.4774377 0.9548755 0.5225623
[3,] 0.5952209 0.8095582 0.4047791
[4,] 0.7073894 0.5852211 0.2926106
[5,] 0.6310984 0.7378032 0.3689016
[6,] 0.5886566 0.8226867 0.4113434
[7,] 0.5122831 0.9754337 0.4877169
[8,] 0.4241704 0.8483407 0.5758296
[9,] 0.3676141 0.7352283 0.6323859
[10,] 0.4467387 0.8934775 0.5532613
[11,] 0.4051788 0.8103576 0.5948212
[12,] 0.4436994 0.8873988 0.5563006
[13,] 0.3894327 0.7788654 0.6105673
[14,] 0.4683255 0.9366510 0.5316745
[15,] 0.4551470 0.9102940 0.5448530
[16,] 0.4094992 0.8189985 0.5905008
[17,] 0.3792122 0.7584244 0.6207878
[18,] 0.4349094 0.8698189 0.5650906
[19,] 0.4723380 0.9446761 0.5276620
[20,] 0.4436952 0.8873904 0.5563048
[21,] 0.4872709 0.9745417 0.5127291
[22,] 0.5150944 0.9698113 0.4849056
[23,] 0.5318749 0.9362502 0.4681251
[24,] 0.5516322 0.8967355 0.4483678
[25,] 0.5274610 0.9450780 0.4725390
[26,] 0.5020630 0.9958740 0.4979370
[27,] 0.4762059 0.9524119 0.5237941
[28,] 0.4505884 0.9011767 0.5494116
[29,] 0.4701695 0.9403389 0.5298305
[30,] 0.4459273 0.8918547 0.5540727
[31,] 0.4230092 0.8460183 0.5769908
[32,] 0.4320341 0.8640682 0.5679659
[33,] 0.4242059 0.8484118 0.5757941
[34,] 0.4452388 0.8904776 0.5547612
[35,] 0.4262363 0.8524725 0.5737637
[36,] 0.4139160 0.8278321 0.5860840
[37,] 0.4026008 0.8052016 0.5973992
[38,] 0.4186191 0.8372382 0.5813809
[39,] 0.4108597 0.8217193 0.5891403
[40,] 0.3962307 0.7924615 0.6037693
[41,] 0.4094663 0.8189326 0.5905337
[42,] 0.3961817 0.7923634 0.6038183
[43,] 0.4071317 0.8142633 0.5928683
[44,] 0.4178729 0.8357458 0.5821271
[45,] 0.4039695 0.8079390 0.5960305
[46,] 0.4182337 0.8364673 0.5817663
[47,] 0.4455321 0.8910643 0.5544679
[48,] 0.4593099 0.9186199 0.5406901
[49,] 0.4620080 0.9240160 0.5379920
[50,] 0.4463611 0.8927222 0.5536389
[51,] 0.4194849 0.8389697 0.5805151
[52,] 0.4167585 0.8335170 0.5832415
[53,] 0.4292512 0.8585025 0.5707488
[54,] 0.4478486 0.8956972 0.5521514
[55,] 0.4177115 0.8354230 0.5822885
[56,] 0.4063758 0.8127516 0.5936242
[57,] 0.3965671 0.7931341 0.6034329
[58,] 0.3727823 0.7455646 0.6272177
[59,] 0.3681165 0.7362330 0.6318835
[60,] 0.3460903 0.6921806 0.6539097
[61,] 0.3300326 0.6600652 0.6699674
[62,] 0.3453777 0.6907554 0.6546223
[63,] 0.3321529 0.6643059 0.6678471
[64,] 0.3299818 0.6599637 0.6700182
[65,] 0.3449977 0.6899954 0.6550023
[66,] 0.3325921 0.6651841 0.6674079
[67,] 0.3266849 0.6533699 0.6733151
[68,] 0.2914450 0.5828900 0.7085550
[69,] 0.3202187 0.6404373 0.6797813
[70,] 0.3326189 0.6652378 0.6673811
[71,] 0.3411678 0.6823356 0.6588322
[72,] 0.4330981 0.8661962 0.5669019
[73,] 0.3538312 0.7076625 0.6461688
[74,] 0.3126662 0.6253324 0.6873338
[75,] 0.1913460 0.3826921 0.8086540
> postscript(file="/var/wessaorg/rcomp/tmp/1qmhx1356127087.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/2w8aa1356127087.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/3vbbp1356127087.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/400xk1356127087.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/5eu5s1356127087.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.5721618 -0.4318683 -0.4318683 -0.4318683 -0.4318683 0.5681317 -0.4318683
8 9 10 11 12 13 14
-0.4278382 0.5681317 -0.4318683 -0.4278382 -0.4318683 -0.5372975 -0.4278382
15 16 17 18 19 20 21
0.4627025 0.4667326 -0.5332674 -0.4278382 0.5681317 0.4667326 -0.4318683
22 23 24 25 26 27 28
0.4627025 0.5681317 0.5681317 0.4667326 -0.5372975 0.5681317 -0.5372975
29 30 31 32 33 34 35
0.5681317 -0.4318683 -0.4318683 -0.4318683 -0.4318683 0.5721618 -0.4318683
36 37 38 39 40 41 42
-0.4318683 -0.5332674 0.4627025 0.5681317 -0.4278382 0.4627025 0.4627025
43 44 45 46 47 48 49
0.5681317 -0.4278382 -0.4318683 0.5681317 -0.4318683 0.5681317 0.5681317
50 51 52 53 54 55 56
-0.4318683 -0.5332674 -0.5332674 0.5681317 -0.5372975 -0.4318683 0.4667326
57 58 59 60 61 62 63
0.4627025 0.5681317 0.5681317 0.4667326 0.5721618 -0.5372975 -0.4318683
64 65 66 67 68 69 70
0.5721618 -0.4318683 -0.4318683 -0.5332674 -0.4318683 0.5681317 -0.5372975
71 72 73 74 75 76 77
-0.4318683 0.5681317 0.4627025 -0.5372975 0.5681317 0.5721618 0.5681317
78 79 80 81 82 83 84
0.4627025 0.4667326 -0.4278382 -0.4318683 0.4627025 -0.4318683 -0.5372975
85 86
0.5681317 -0.4318683
> postscript(file="/var/wessaorg/rcomp/tmp/6m9hj1356127087.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.5721618 NA
1 -0.4318683 0.5721618
2 -0.4318683 -0.4318683
3 -0.4318683 -0.4318683
4 -0.4318683 -0.4318683
5 0.5681317 -0.4318683
6 -0.4318683 0.5681317
7 -0.4278382 -0.4318683
8 0.5681317 -0.4278382
9 -0.4318683 0.5681317
10 -0.4278382 -0.4318683
11 -0.4318683 -0.4278382
12 -0.5372975 -0.4318683
13 -0.4278382 -0.5372975
14 0.4627025 -0.4278382
15 0.4667326 0.4627025
16 -0.5332674 0.4667326
17 -0.4278382 -0.5332674
18 0.5681317 -0.4278382
19 0.4667326 0.5681317
20 -0.4318683 0.4667326
21 0.4627025 -0.4318683
22 0.5681317 0.4627025
23 0.5681317 0.5681317
24 0.4667326 0.5681317
25 -0.5372975 0.4667326
26 0.5681317 -0.5372975
27 -0.5372975 0.5681317
28 0.5681317 -0.5372975
29 -0.4318683 0.5681317
30 -0.4318683 -0.4318683
31 -0.4318683 -0.4318683
32 -0.4318683 -0.4318683
33 0.5721618 -0.4318683
34 -0.4318683 0.5721618
35 -0.4318683 -0.4318683
36 -0.5332674 -0.4318683
37 0.4627025 -0.5332674
38 0.5681317 0.4627025
39 -0.4278382 0.5681317
40 0.4627025 -0.4278382
41 0.4627025 0.4627025
42 0.5681317 0.4627025
43 -0.4278382 0.5681317
44 -0.4318683 -0.4278382
45 0.5681317 -0.4318683
46 -0.4318683 0.5681317
47 0.5681317 -0.4318683
48 0.5681317 0.5681317
49 -0.4318683 0.5681317
50 -0.5332674 -0.4318683
51 -0.5332674 -0.5332674
52 0.5681317 -0.5332674
53 -0.5372975 0.5681317
54 -0.4318683 -0.5372975
55 0.4667326 -0.4318683
56 0.4627025 0.4667326
57 0.5681317 0.4627025
58 0.5681317 0.5681317
59 0.4667326 0.5681317
60 0.5721618 0.4667326
61 -0.5372975 0.5721618
62 -0.4318683 -0.5372975
63 0.5721618 -0.4318683
64 -0.4318683 0.5721618
65 -0.4318683 -0.4318683
66 -0.5332674 -0.4318683
67 -0.4318683 -0.5332674
68 0.5681317 -0.4318683
69 -0.5372975 0.5681317
70 -0.4318683 -0.5372975
71 0.5681317 -0.4318683
72 0.4627025 0.5681317
73 -0.5372975 0.4627025
74 0.5681317 -0.5372975
75 0.5721618 0.5681317
76 0.5681317 0.5721618
77 0.4627025 0.5681317
78 0.4667326 0.4627025
79 -0.4278382 0.4667326
80 -0.4318683 -0.4278382
81 0.4627025 -0.4318683
82 -0.4318683 0.4627025
83 -0.5372975 -0.4318683
84 0.5681317 -0.5372975
85 -0.4318683 0.5681317
86 NA -0.4318683
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.4318683 0.5721618
[2,] -0.4318683 -0.4318683
[3,] -0.4318683 -0.4318683
[4,] -0.4318683 -0.4318683
[5,] 0.5681317 -0.4318683
[6,] -0.4318683 0.5681317
[7,] -0.4278382 -0.4318683
[8,] 0.5681317 -0.4278382
[9,] -0.4318683 0.5681317
[10,] -0.4278382 -0.4318683
[11,] -0.4318683 -0.4278382
[12,] -0.5372975 -0.4318683
[13,] -0.4278382 -0.5372975
[14,] 0.4627025 -0.4278382
[15,] 0.4667326 0.4627025
[16,] -0.5332674 0.4667326
[17,] -0.4278382 -0.5332674
[18,] 0.5681317 -0.4278382
[19,] 0.4667326 0.5681317
[20,] -0.4318683 0.4667326
[21,] 0.4627025 -0.4318683
[22,] 0.5681317 0.4627025
[23,] 0.5681317 0.5681317
[24,] 0.4667326 0.5681317
[25,] -0.5372975 0.4667326
[26,] 0.5681317 -0.5372975
[27,] -0.5372975 0.5681317
[28,] 0.5681317 -0.5372975
[29,] -0.4318683 0.5681317
[30,] -0.4318683 -0.4318683
[31,] -0.4318683 -0.4318683
[32,] -0.4318683 -0.4318683
[33,] 0.5721618 -0.4318683
[34,] -0.4318683 0.5721618
[35,] -0.4318683 -0.4318683
[36,] -0.5332674 -0.4318683
[37,] 0.4627025 -0.5332674
[38,] 0.5681317 0.4627025
[39,] -0.4278382 0.5681317
[40,] 0.4627025 -0.4278382
[41,] 0.4627025 0.4627025
[42,] 0.5681317 0.4627025
[43,] -0.4278382 0.5681317
[44,] -0.4318683 -0.4278382
[45,] 0.5681317 -0.4318683
[46,] -0.4318683 0.5681317
[47,] 0.5681317 -0.4318683
[48,] 0.5681317 0.5681317
[49,] -0.4318683 0.5681317
[50,] -0.5332674 -0.4318683
[51,] -0.5332674 -0.5332674
[52,] 0.5681317 -0.5332674
[53,] -0.5372975 0.5681317
[54,] -0.4318683 -0.5372975
[55,] 0.4667326 -0.4318683
[56,] 0.4627025 0.4667326
[57,] 0.5681317 0.4627025
[58,] 0.5681317 0.5681317
[59,] 0.4667326 0.5681317
[60,] 0.5721618 0.4667326
[61,] -0.5372975 0.5721618
[62,] -0.4318683 -0.5372975
[63,] 0.5721618 -0.4318683
[64,] -0.4318683 0.5721618
[65,] -0.4318683 -0.4318683
[66,] -0.5332674 -0.4318683
[67,] -0.4318683 -0.5332674
[68,] 0.5681317 -0.4318683
[69,] -0.5372975 0.5681317
[70,] -0.4318683 -0.5372975
[71,] 0.5681317 -0.4318683
[72,] 0.4627025 0.5681317
[73,] -0.5372975 0.4627025
[74,] 0.5681317 -0.5372975
[75,] 0.5721618 0.5681317
[76,] 0.5681317 0.5721618
[77,] 0.4627025 0.5681317
[78,] 0.4667326 0.4627025
[79,] -0.4278382 0.4667326
[80,] -0.4318683 -0.4278382
[81,] 0.4627025 -0.4318683
[82,] -0.4318683 0.4627025
[83,] -0.5372975 -0.4318683
[84,] 0.5681317 -0.5372975
[85,] -0.4318683 0.5681317
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.4318683 0.5721618
2 -0.4318683 -0.4318683
3 -0.4318683 -0.4318683
4 -0.4318683 -0.4318683
5 0.5681317 -0.4318683
6 -0.4318683 0.5681317
7 -0.4278382 -0.4318683
8 0.5681317 -0.4278382
9 -0.4318683 0.5681317
10 -0.4278382 -0.4318683
11 -0.4318683 -0.4278382
12 -0.5372975 -0.4318683
13 -0.4278382 -0.5372975
14 0.4627025 -0.4278382
15 0.4667326 0.4627025
16 -0.5332674 0.4667326
17 -0.4278382 -0.5332674
18 0.5681317 -0.4278382
19 0.4667326 0.5681317
20 -0.4318683 0.4667326
21 0.4627025 -0.4318683
22 0.5681317 0.4627025
23 0.5681317 0.5681317
24 0.4667326 0.5681317
25 -0.5372975 0.4667326
26 0.5681317 -0.5372975
27 -0.5372975 0.5681317
28 0.5681317 -0.5372975
29 -0.4318683 0.5681317
30 -0.4318683 -0.4318683
31 -0.4318683 -0.4318683
32 -0.4318683 -0.4318683
33 0.5721618 -0.4318683
34 -0.4318683 0.5721618
35 -0.4318683 -0.4318683
36 -0.5332674 -0.4318683
37 0.4627025 -0.5332674
38 0.5681317 0.4627025
39 -0.4278382 0.5681317
40 0.4627025 -0.4278382
41 0.4627025 0.4627025
42 0.5681317 0.4627025
43 -0.4278382 0.5681317
44 -0.4318683 -0.4278382
45 0.5681317 -0.4318683
46 -0.4318683 0.5681317
47 0.5681317 -0.4318683
48 0.5681317 0.5681317
49 -0.4318683 0.5681317
50 -0.5332674 -0.4318683
51 -0.5332674 -0.5332674
52 0.5681317 -0.5332674
53 -0.5372975 0.5681317
54 -0.4318683 -0.5372975
55 0.4667326 -0.4318683
56 0.4627025 0.4667326
57 0.5681317 0.4627025
58 0.5681317 0.5681317
59 0.4667326 0.5681317
60 0.5721618 0.4667326
61 -0.5372975 0.5721618
62 -0.4318683 -0.5372975
63 0.5721618 -0.4318683
64 -0.4318683 0.5721618
65 -0.4318683 -0.4318683
66 -0.5332674 -0.4318683
67 -0.4318683 -0.5332674
68 0.5681317 -0.4318683
69 -0.5372975 0.5681317
70 -0.4318683 -0.5372975
71 0.5681317 -0.4318683
72 0.4627025 0.5681317
73 -0.5372975 0.4627025
74 0.5681317 -0.5372975
75 0.5721618 0.5681317
76 0.5681317 0.5721618
77 0.4627025 0.5681317
78 0.4667326 0.4627025
79 -0.4278382 0.4667326
80 -0.4318683 -0.4278382
81 0.4627025 -0.4318683
82 -0.4318683 0.4627025
83 -0.5372975 -0.4318683
84 0.5681317 -0.5372975
85 -0.4318683 0.5681317
> 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/7oqgm1356127087.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/8mk3t1356127087.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/9snhj1356127087.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/1066r51356127087.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/11gz2e1356127087.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/127tj81356127087.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/13qcwi1356127088.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/14pkdm1356127088.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/15ikj21356127088.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/16l16l1356127088.tab")
+ }
>
> try(system("convert tmp/1qmhx1356127087.ps tmp/1qmhx1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/2w8aa1356127087.ps tmp/2w8aa1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/3vbbp1356127087.ps tmp/3vbbp1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/400xk1356127087.ps tmp/400xk1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/5eu5s1356127087.ps tmp/5eu5s1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/6m9hj1356127087.ps tmp/6m9hj1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/7oqgm1356127087.ps tmp/7oqgm1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/8mk3t1356127087.ps tmp/8mk3t1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/9snhj1356127087.ps tmp/9snhj1356127087.png",intern=TRUE))
character(0)
> try(system("convert tmp/1066r51356127087.ps tmp/1066r51356127087.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.444 0.999 7.448