R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
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(98.5,0,97.0,0,103.3,0,99.6,0,100.1,0,102.9,0,95.9,0,94.5,0,107.4,0,116.0,0,102.8,0,99.8,0,109.6,0,103.0,0,111.6,0,106.3,0,97.9,0,108.8,0,103.9,0,101.2,0,122.9,0,123.9,0,111.7,0,120.9,0,99.6,0,103.3,0,119.4,0,106.5,0,101.9,0,124.6,0,106.5,0,107.8,0,127.4,0,120.1,0,118.5,0,127.7,0,107.7,0,104.5,0,118.8,0,110.3,0,109.6,0,119.1,0,96.5,0,106.7,0,126.3,0,116.2,0,118.8,0,115.2,0,110.0,0,111.4,0,129.6,0,108.1,0,117.8,0,122.9,0,100.6,0,111.8,0,127.0,0,128.6,0,124.8,0,118.5,0,114.7,0,112.6,0,128.7,0,111.0,0,115.8,0,126.0,0,111.1,1,113.2,1,120.1,1,130.6,1,124.0,1,119.4,1,116.7,1,116.5,1,119.6,1,126.5,1,111.3,1,123.5,1,114.2,1,103.7,1,129.5,1),dim=c(2,81),dimnames=list(c('Y','X'),1:81))
> y <- array(NA,dim=c(2,81),dimnames=list(c('Y','X'),1:81))
> 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'
> #'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.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
Y X
1 98.5 0
2 97.0 0
3 103.3 0
4 99.6 0
5 100.1 0
6 102.9 0
7 95.9 0
8 94.5 0
9 107.4 0
10 116.0 0
11 102.8 0
12 99.8 0
13 109.6 0
14 103.0 0
15 111.6 0
16 106.3 0
17 97.9 0
18 108.8 0
19 103.9 0
20 101.2 0
21 122.9 0
22 123.9 0
23 111.7 0
24 120.9 0
25 99.6 0
26 103.3 0
27 119.4 0
28 106.5 0
29 101.9 0
30 124.6 0
31 106.5 0
32 107.8 0
33 127.4 0
34 120.1 0
35 118.5 0
36 127.7 0
37 107.7 0
38 104.5 0
39 118.8 0
40 110.3 0
41 109.6 0
42 119.1 0
43 96.5 0
44 106.7 0
45 126.3 0
46 116.2 0
47 118.8 0
48 115.2 0
49 110.0 0
50 111.4 0
51 129.6 0
52 108.1 0
53 117.8 0
54 122.9 0
55 100.6 0
56 111.8 0
57 127.0 0
58 128.6 0
59 124.8 0
60 118.5 0
61 114.7 0
62 112.6 0
63 128.7 0
64 111.0 0
65 115.8 0
66 126.0 0
67 111.1 1
68 113.2 1
69 120.1 1
70 130.6 1
71 124.0 1
72 119.4 1
73 116.7 1
74 116.5 1
75 119.6 1
76 126.5 1
77 111.3 1
78 123.5 1
79 114.2 1
80 103.7 1
81 129.5 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X
111.703 6.957
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-17.203 -7.560 -0.703 7.097 17.897
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 111.703 1.164 95.926 <2e-16 ***
X 6.957 2.706 2.571 0.0120 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 9.46 on 79 degrees of freedom
Multiple R-squared: 0.07721, Adjusted R-squared: 0.06553
F-statistic: 6.61 on 1 and 79 DF, p-value: 0.01202
> 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.03251213 0.06502427 0.96748787
[2,] 0.01464555 0.02929110 0.98535445
[3,] 0.01104599 0.02209197 0.98895401
[4,] 0.01122138 0.02244277 0.98877862
[5,] 0.02665933 0.05331867 0.97334067
[6,] 0.20499689 0.40999379 0.79500311
[7,] 0.14243626 0.28487252 0.85756374
[8,] 0.10249515 0.20499030 0.89750485
[9,] 0.10477284 0.20954569 0.89522716
[10,] 0.07224854 0.14449707 0.92775146
[11,] 0.08646256 0.17292512 0.91353744
[12,] 0.06337018 0.12674037 0.93662982
[13,] 0.06163006 0.12326013 0.93836994
[14,] 0.05312339 0.10624678 0.94687661
[15,] 0.03839128 0.07678255 0.96160872
[16,] 0.03085372 0.06170744 0.96914628
[17,] 0.19038695 0.38077390 0.80961305
[18,] 0.43296522 0.86593044 0.56703478
[19,] 0.39740826 0.79481653 0.60259174
[20,] 0.50399912 0.99200176 0.49600088
[21,] 0.52570365 0.94859270 0.47429635
[22,] 0.50317604 0.99364792 0.49682396
[23,] 0.55872210 0.88255581 0.44127790
[24,] 0.51709259 0.96581482 0.48290741
[25,] 0.52533246 0.94933507 0.47466754
[26,] 0.67388600 0.65222800 0.32611400
[27,] 0.64340021 0.71319959 0.35659979
[28,] 0.60734820 0.78530360 0.39265180
[29,] 0.77482477 0.45035045 0.22517523
[30,] 0.78481662 0.43036677 0.21518338
[31,] 0.77505793 0.44988413 0.22494207
[32,] 0.86790411 0.26419178 0.13209589
[33,] 0.84701167 0.30597667 0.15298833
[34,] 0.84710987 0.30578025 0.15289013
[35,] 0.83311016 0.33377968 0.16688984
[36,] 0.80179911 0.39640177 0.19820089
[37,] 0.77119883 0.45760234 0.22880117
[38,] 0.75192409 0.49615182 0.24807591
[39,] 0.88118775 0.23762451 0.11881225
[40,] 0.88345779 0.23308442 0.11654221
[41,] 0.91503468 0.16993064 0.08496532
[42,] 0.89381452 0.21237097 0.10618548
[43,] 0.87455902 0.25088196 0.12544098
[44,] 0.84459016 0.31081969 0.15540984
[45,] 0.82652184 0.34695633 0.17347816
[46,] 0.80206587 0.39586825 0.19793413
[47,] 0.87289614 0.25420772 0.12710386
[48,] 0.87289238 0.25421524 0.12710762
[49,] 0.84218000 0.31563999 0.15782000
[50,] 0.83012243 0.33975514 0.16987757
[51,] 0.92850926 0.14298148 0.07149074
[52,] 0.92442197 0.15115606 0.07557803
[53,] 0.93109725 0.13780550 0.06890275
[54,] 0.94805282 0.10389437 0.05194718
[55,] 0.94551547 0.10896907 0.05448453
[56,] 0.92330936 0.15338129 0.07669064
[57,] 0.89677079 0.20645841 0.10322921
[58,] 0.87913444 0.24173112 0.12086556
[59,] 0.90300196 0.19399609 0.09699804
[60,] 0.89400352 0.21199296 0.10599648
[61,] 0.87895347 0.24209305 0.12104653
[62,] 0.84361015 0.31277971 0.15638985
[63,] 0.82632122 0.34735756 0.17367878
[64,] 0.78967763 0.42064474 0.21032237
[65,] 0.71405955 0.57188090 0.28594045
[66,] 0.77328784 0.45342432 0.22671216
[67,] 0.71841777 0.56316445 0.28158223
[68,] 0.61379291 0.77241418 0.38620709
[69,] 0.49450193 0.98900386 0.50549807
[70,] 0.36963946 0.73927893 0.63036054
[71,] 0.24758340 0.49516680 0.75241660
[72,] 0.21041666 0.42083332 0.78958334
> postscript(file="/var/www/html/freestat/rcomp/tmp/1rqwy1229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/2vxa81229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/3ukbf1229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/4snfi1229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/5wzkh1229783002.ps",horizontal=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 = 81
Frequency = 1
1 2 3 4 5
-13.203030303 -14.703030303 -8.403030303 -12.103030303 -11.603030303
6 7 8 9 10
-8.803030303 -15.803030303 -17.203030303 -4.303030303 4.296969697
11 12 13 14 15
-8.903030303 -11.903030303 -2.103030303 -8.703030303 -0.103030303
16 17 18 19 20
-5.403030303 -13.803030303 -2.903030303 -7.803030303 -10.503030303
21 22 23 24 25
11.196969697 12.196969697 -0.003030303 9.196969697 -12.103030303
26 27 28 29 30
-8.403030303 7.696969697 -5.203030303 -9.803030303 12.896969697
31 32 33 34 35
-5.203030303 -3.903030303 15.696969697 8.396969697 6.796969697
36 37 38 39 40
15.996969697 -4.003030303 -7.203030303 7.096969697 -1.403030303
41 42 43 44 45
-2.103030303 7.396969697 -15.203030303 -5.003030303 14.596969697
46 47 48 49 50
4.496969697 7.096969697 3.496969697 -1.703030303 -0.303030303
51 52 53 54 55
17.896969697 -3.603030303 6.096969697 11.196969697 -11.103030303
56 57 58 59 60
0.096969697 15.296969697 16.896969697 13.096969697 6.796969697
61 62 63 64 65
2.996969697 0.896969697 16.996969697 -0.703030303 4.096969697
66 67 68 69 70
14.296969697 -7.560000000 -5.460000000 1.440000000 11.940000000
71 72 73 74 75
5.340000000 0.740000000 -1.960000000 -2.160000000 0.940000000
76 77 78 79 80
7.840000000 -7.360000000 4.840000000 -4.460000000 -14.960000000
81
10.840000000
> postscript(file="/var/www/html/freestat/rcomp/tmp/6i6h91229783002.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 81
Frequency = 1
lag(myerror, k = 1) myerror
0 -13.203030303 NA
1 -14.703030303 -13.203030303
2 -8.403030303 -14.703030303
3 -12.103030303 -8.403030303
4 -11.603030303 -12.103030303
5 -8.803030303 -11.603030303
6 -15.803030303 -8.803030303
7 -17.203030303 -15.803030303
8 -4.303030303 -17.203030303
9 4.296969697 -4.303030303
10 -8.903030303 4.296969697
11 -11.903030303 -8.903030303
12 -2.103030303 -11.903030303
13 -8.703030303 -2.103030303
14 -0.103030303 -8.703030303
15 -5.403030303 -0.103030303
16 -13.803030303 -5.403030303
17 -2.903030303 -13.803030303
18 -7.803030303 -2.903030303
19 -10.503030303 -7.803030303
20 11.196969697 -10.503030303
21 12.196969697 11.196969697
22 -0.003030303 12.196969697
23 9.196969697 -0.003030303
24 -12.103030303 9.196969697
25 -8.403030303 -12.103030303
26 7.696969697 -8.403030303
27 -5.203030303 7.696969697
28 -9.803030303 -5.203030303
29 12.896969697 -9.803030303
30 -5.203030303 12.896969697
31 -3.903030303 -5.203030303
32 15.696969697 -3.903030303
33 8.396969697 15.696969697
34 6.796969697 8.396969697
35 15.996969697 6.796969697
36 -4.003030303 15.996969697
37 -7.203030303 -4.003030303
38 7.096969697 -7.203030303
39 -1.403030303 7.096969697
40 -2.103030303 -1.403030303
41 7.396969697 -2.103030303
42 -15.203030303 7.396969697
43 -5.003030303 -15.203030303
44 14.596969697 -5.003030303
45 4.496969697 14.596969697
46 7.096969697 4.496969697
47 3.496969697 7.096969697
48 -1.703030303 3.496969697
49 -0.303030303 -1.703030303
50 17.896969697 -0.303030303
51 -3.603030303 17.896969697
52 6.096969697 -3.603030303
53 11.196969697 6.096969697
54 -11.103030303 11.196969697
55 0.096969697 -11.103030303
56 15.296969697 0.096969697
57 16.896969697 15.296969697
58 13.096969697 16.896969697
59 6.796969697 13.096969697
60 2.996969697 6.796969697
61 0.896969697 2.996969697
62 16.996969697 0.896969697
63 -0.703030303 16.996969697
64 4.096969697 -0.703030303
65 14.296969697 4.096969697
66 -7.560000000 14.296969697
67 -5.460000000 -7.560000000
68 1.440000000 -5.460000000
69 11.940000000 1.440000000
70 5.340000000 11.940000000
71 0.740000000 5.340000000
72 -1.960000000 0.740000000
73 -2.160000000 -1.960000000
74 0.940000000 -2.160000000
75 7.840000000 0.940000000
76 -7.360000000 7.840000000
77 4.840000000 -7.360000000
78 -4.460000000 4.840000000
79 -14.960000000 -4.460000000
80 10.840000000 -14.960000000
81 NA 10.840000000
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -14.703030303 -13.203030303
[2,] -8.403030303 -14.703030303
[3,] -12.103030303 -8.403030303
[4,] -11.603030303 -12.103030303
[5,] -8.803030303 -11.603030303
[6,] -15.803030303 -8.803030303
[7,] -17.203030303 -15.803030303
[8,] -4.303030303 -17.203030303
[9,] 4.296969697 -4.303030303
[10,] -8.903030303 4.296969697
[11,] -11.903030303 -8.903030303
[12,] -2.103030303 -11.903030303
[13,] -8.703030303 -2.103030303
[14,] -0.103030303 -8.703030303
[15,] -5.403030303 -0.103030303
[16,] -13.803030303 -5.403030303
[17,] -2.903030303 -13.803030303
[18,] -7.803030303 -2.903030303
[19,] -10.503030303 -7.803030303
[20,] 11.196969697 -10.503030303
[21,] 12.196969697 11.196969697
[22,] -0.003030303 12.196969697
[23,] 9.196969697 -0.003030303
[24,] -12.103030303 9.196969697
[25,] -8.403030303 -12.103030303
[26,] 7.696969697 -8.403030303
[27,] -5.203030303 7.696969697
[28,] -9.803030303 -5.203030303
[29,] 12.896969697 -9.803030303
[30,] -5.203030303 12.896969697
[31,] -3.903030303 -5.203030303
[32,] 15.696969697 -3.903030303
[33,] 8.396969697 15.696969697
[34,] 6.796969697 8.396969697
[35,] 15.996969697 6.796969697
[36,] -4.003030303 15.996969697
[37,] -7.203030303 -4.003030303
[38,] 7.096969697 -7.203030303
[39,] -1.403030303 7.096969697
[40,] -2.103030303 -1.403030303
[41,] 7.396969697 -2.103030303
[42,] -15.203030303 7.396969697
[43,] -5.003030303 -15.203030303
[44,] 14.596969697 -5.003030303
[45,] 4.496969697 14.596969697
[46,] 7.096969697 4.496969697
[47,] 3.496969697 7.096969697
[48,] -1.703030303 3.496969697
[49,] -0.303030303 -1.703030303
[50,] 17.896969697 -0.303030303
[51,] -3.603030303 17.896969697
[52,] 6.096969697 -3.603030303
[53,] 11.196969697 6.096969697
[54,] -11.103030303 11.196969697
[55,] 0.096969697 -11.103030303
[56,] 15.296969697 0.096969697
[57,] 16.896969697 15.296969697
[58,] 13.096969697 16.896969697
[59,] 6.796969697 13.096969697
[60,] 2.996969697 6.796969697
[61,] 0.896969697 2.996969697
[62,] 16.996969697 0.896969697
[63,] -0.703030303 16.996969697
[64,] 4.096969697 -0.703030303
[65,] 14.296969697 4.096969697
[66,] -7.560000000 14.296969697
[67,] -5.460000000 -7.560000000
[68,] 1.440000000 -5.460000000
[69,] 11.940000000 1.440000000
[70,] 5.340000000 11.940000000
[71,] 0.740000000 5.340000000
[72,] -1.960000000 0.740000000
[73,] -2.160000000 -1.960000000
[74,] 0.940000000 -2.160000000
[75,] 7.840000000 0.940000000
[76,] -7.360000000 7.840000000
[77,] 4.840000000 -7.360000000
[78,] -4.460000000 4.840000000
[79,] -14.960000000 -4.460000000
[80,] 10.840000000 -14.960000000
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -14.703030303 -13.203030303
2 -8.403030303 -14.703030303
3 -12.103030303 -8.403030303
4 -11.603030303 -12.103030303
5 -8.803030303 -11.603030303
6 -15.803030303 -8.803030303
7 -17.203030303 -15.803030303
8 -4.303030303 -17.203030303
9 4.296969697 -4.303030303
10 -8.903030303 4.296969697
11 -11.903030303 -8.903030303
12 -2.103030303 -11.903030303
13 -8.703030303 -2.103030303
14 -0.103030303 -8.703030303
15 -5.403030303 -0.103030303
16 -13.803030303 -5.403030303
17 -2.903030303 -13.803030303
18 -7.803030303 -2.903030303
19 -10.503030303 -7.803030303
20 11.196969697 -10.503030303
21 12.196969697 11.196969697
22 -0.003030303 12.196969697
23 9.196969697 -0.003030303
24 -12.103030303 9.196969697
25 -8.403030303 -12.103030303
26 7.696969697 -8.403030303
27 -5.203030303 7.696969697
28 -9.803030303 -5.203030303
29 12.896969697 -9.803030303
30 -5.203030303 12.896969697
31 -3.903030303 -5.203030303
32 15.696969697 -3.903030303
33 8.396969697 15.696969697
34 6.796969697 8.396969697
35 15.996969697 6.796969697
36 -4.003030303 15.996969697
37 -7.203030303 -4.003030303
38 7.096969697 -7.203030303
39 -1.403030303 7.096969697
40 -2.103030303 -1.403030303
41 7.396969697 -2.103030303
42 -15.203030303 7.396969697
43 -5.003030303 -15.203030303
44 14.596969697 -5.003030303
45 4.496969697 14.596969697
46 7.096969697 4.496969697
47 3.496969697 7.096969697
48 -1.703030303 3.496969697
49 -0.303030303 -1.703030303
50 17.896969697 -0.303030303
51 -3.603030303 17.896969697
52 6.096969697 -3.603030303
53 11.196969697 6.096969697
54 -11.103030303 11.196969697
55 0.096969697 -11.103030303
56 15.296969697 0.096969697
57 16.896969697 15.296969697
58 13.096969697 16.896969697
59 6.796969697 13.096969697
60 2.996969697 6.796969697
61 0.896969697 2.996969697
62 16.996969697 0.896969697
63 -0.703030303 16.996969697
64 4.096969697 -0.703030303
65 14.296969697 4.096969697
66 -7.560000000 14.296969697
67 -5.460000000 -7.560000000
68 1.440000000 -5.460000000
69 11.940000000 1.440000000
70 5.340000000 11.940000000
71 0.740000000 5.340000000
72 -1.960000000 0.740000000
73 -2.160000000 -1.960000000
74 0.940000000 -2.160000000
75 7.840000000 0.940000000
76 -7.360000000 7.840000000
77 4.840000000 -7.360000000
78 -4.460000000 4.840000000
79 -14.960000000 -4.460000000
80 10.840000000 -14.960000000
> 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/www/html/freestat/rcomp/tmp/76yqy1229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/84iso1229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/9lsla1229783002.ps",horizontal=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/www/html/freestat/rcomp/tmp/10e1pi1229783002.ps",horizontal=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/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/www/html/freestat/rcomp/tmp/112wyg1229783002.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/www/html/freestat/rcomp/tmp/12coh51229783002.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/www/html/freestat/rcomp/tmp/13mmhb1229783002.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/www/html/freestat/rcomp/tmp/14tgqy1229783002.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/www/html/freestat/rcomp/tmp/150h7n1229783002.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/www/html/freestat/rcomp/tmp/16nh9l1229783002.tab")
+ }
>
> system("convert tmp/1rqwy1229783002.ps tmp/1rqwy1229783002.png")
> system("convert tmp/2vxa81229783002.ps tmp/2vxa81229783002.png")
> system("convert tmp/3ukbf1229783002.ps tmp/3ukbf1229783002.png")
> system("convert tmp/4snfi1229783002.ps tmp/4snfi1229783002.png")
> system("convert tmp/5wzkh1229783002.ps tmp/5wzkh1229783002.png")
> system("convert tmp/6i6h91229783002.ps tmp/6i6h91229783002.png")
> system("convert tmp/76yqy1229783002.ps tmp/76yqy1229783002.png")
> system("convert tmp/84iso1229783002.ps tmp/84iso1229783002.png")
> system("convert tmp/9lsla1229783002.ps tmp/9lsla1229783002.png")
> system("convert tmp/10e1pi1229783002.ps tmp/10e1pi1229783002.png")
>
>
> proc.time()
user system elapsed
3.956 2.542 4.378