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(97.7,0,101.5,0,119.6,0,108.1,0,117.8,0,125.5,0,89.2,0,92.3,0,104.6,0,122.8,0,96.0,0,94.6,0,93.3,0,101.1,0,114.2,0,104.7,0,113.3,0,118.2,0,83.6,0,73.9,0,99.5,0,97.7,0,103.0,0,106.3,0,92.2,0,101.8,0,122.8,0,111.8,0,106.3,0,121.5,0,81.9,0,85.4,0,110.9,0,117.3,0,106.3,0,105.5,0,101.3,0,105.9,0,126.3,0,111.9,0,108.9,0,127.2,0,94.2,0,85.7,0,116.2,0,107.2,0,110.6,0,112.0,0,104.5,0,112.0,0,132.8,0,110.8,0,128.7,0,136.8,0,94.9,0,88.8,0,123.2,0,125.3,0,122.7,0,125.7,0,116.3,0,118.7,0,142.0,0,127.9,0,131.9,0,152.3,0,110.8,1,99.1,1,135.0,1,133.2,1,131.0,1,133.9,1,119.9,1,136.9,1,148.9,1,145.1,1,142.4,1,159.6,1,120.7,1,109.0,1,142.0,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 97.7 0
2 101.5 0
3 119.6 0
4 108.1 0
5 117.8 0
6 125.5 0
7 89.2 0
8 92.3 0
9 104.6 0
10 122.8 0
11 96.0 0
12 94.6 0
13 93.3 0
14 101.1 0
15 114.2 0
16 104.7 0
17 113.3 0
18 118.2 0
19 83.6 0
20 73.9 0
21 99.5 0
22 97.7 0
23 103.0 0
24 106.3 0
25 92.2 0
26 101.8 0
27 122.8 0
28 111.8 0
29 106.3 0
30 121.5 0
31 81.9 0
32 85.4 0
33 110.9 0
34 117.3 0
35 106.3 0
36 105.5 0
37 101.3 0
38 105.9 0
39 126.3 0
40 111.9 0
41 108.9 0
42 127.2 0
43 94.2 0
44 85.7 0
45 116.2 0
46 107.2 0
47 110.6 0
48 112.0 0
49 104.5 0
50 112.0 0
51 132.8 0
52 110.8 0
53 128.7 0
54 136.8 0
55 94.9 0
56 88.8 0
57 123.2 0
58 125.3 0
59 122.7 0
60 125.7 0
61 116.3 0
62 118.7 0
63 142.0 0
64 127.9 0
65 131.9 0
66 152.3 0
67 110.8 1
68 99.1 1
69 135.0 1
70 133.2 1
71 131.0 1
72 133.9 1
73 119.9 1
74 136.9 1
75 148.9 1
76 145.1 1
77 142.4 1
78 159.6 1
79 120.7 1
80 109.0 1
81 142.0 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X
109.77 21.40
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-35.871 -10.467 1.029 11.233 42.529
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 109.771 1.917 57.262 < 2e-16 ***
X 21.395 4.455 4.803 7.3e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 15.57 on 79 degrees of freedom
Multiple R-squared: 0.226, Adjusted R-squared: 0.2162
F-statistic: 23.07 on 1 and 79 DF, p-value: 7.295e-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.31099550 0.6219910 0.6890045
[2,] 0.33181801 0.6636360 0.6681820
[3,] 0.46366337 0.9273267 0.5363366
[4,] 0.45822953 0.9164591 0.5417705
[5,] 0.34019769 0.6803954 0.6598023
[6,] 0.34626050 0.6925210 0.6537395
[7,] 0.30587250 0.6117450 0.6941275
[8,] 0.27541821 0.5508364 0.7245818
[9,] 0.25329104 0.5065821 0.7467090
[10,] 0.18868273 0.3773655 0.8113173
[11,] 0.15148891 0.3029778 0.8485111
[12,] 0.10471969 0.2094394 0.8952803
[13,] 0.07829864 0.1565973 0.9217014
[14,] 0.06909954 0.1381991 0.9309005
[15,] 0.12637500 0.2527500 0.8736250
[16,] 0.34255535 0.6851107 0.6574447
[17,] 0.28791541 0.5758308 0.7120846
[18,] 0.24558011 0.4911602 0.7544199
[19,] 0.19515078 0.3903016 0.8048492
[20,] 0.15138106 0.3027621 0.8486189
[21,] 0.14830138 0.2966028 0.8516986
[22,] 0.11599145 0.2319829 0.8840086
[23,] 0.13539087 0.2707817 0.8646091
[24,] 0.10827275 0.2165455 0.8917272
[25,] 0.08145748 0.1629150 0.9185425
[26,] 0.08511072 0.1702214 0.9148893
[27,] 0.15635755 0.3127151 0.8436425
[28,] 0.22096443 0.4419289 0.7790356
[29,] 0.18422971 0.3684594 0.8157703
[30,] 0.16668260 0.3333652 0.8333174
[31,] 0.13468815 0.2693763 0.8653118
[32,] 0.10824988 0.2164998 0.8917501
[33,] 0.09194739 0.1838948 0.9080526
[34,] 0.07304148 0.1460830 0.9269585
[35,] 0.08896327 0.1779265 0.9110367
[36,] 0.06997889 0.1399578 0.9300211
[37,] 0.05390460 0.1078092 0.9460954
[38,] 0.06498340 0.1299668 0.9350166
[39,] 0.07401036 0.1480207 0.9259896
[40,] 0.14361333 0.2872267 0.8563867
[41,] 0.12173660 0.2434732 0.8782634
[42,] 0.10351025 0.2070205 0.8964897
[43,] 0.08524686 0.1704937 0.9147531
[44,] 0.06950593 0.1390119 0.9304941
[45,] 0.06446724 0.1289345 0.9355328
[46,] 0.05331872 0.1066374 0.9466813
[47,] 0.07292765 0.1458553 0.9270724
[48,] 0.06100476 0.1220095 0.9389952
[49,] 0.06393787 0.1278757 0.9360621
[50,] 0.09429314 0.1885863 0.9057069
[51,] 0.14133385 0.2826677 0.8586661
[52,] 0.34391883 0.6878377 0.6560812
[53,] 0.31433226 0.6286645 0.6856677
[54,] 0.28687399 0.5737480 0.7131260
[55,] 0.25790623 0.5158125 0.7420938
[56,] 0.23130362 0.4626072 0.7686964
[57,] 0.23000343 0.4600069 0.7699966
[58,] 0.24017628 0.4803526 0.7598237
[59,] 0.26066336 0.5213267 0.7393366
[60,] 0.24779320 0.4955864 0.7522068
[61,] 0.25725669 0.5145134 0.7427433
[62,] 0.29038076 0.5807615 0.7096192
[63,] 0.31656327 0.6331265 0.6834367
[64,] 0.61069778 0.7786044 0.3893022
[65,] 0.54502918 0.9099416 0.4549708
[66,] 0.45752484 0.9150497 0.5424752
[67,] 0.36731509 0.7346302 0.6326849
[68,] 0.27526359 0.5505272 0.7247364
[69,] 0.26954746 0.5390949 0.7304525
[70,] 0.18169930 0.3633986 0.8183007
[71,] 0.14188708 0.2837742 0.8581129
[72,] 0.09032617 0.1806523 0.9096738
> postscript(file="/var/www/html/freestat/rcomp/tmp/1p66i1229782432.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/2dwgx1229782432.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/33t361229782432.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/4hqs91229782432.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/5tr131229782432.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 6
-12.0712121 -8.2712121 9.8287879 -1.6712121 8.0287879 15.7287879
7 8 9 10 11 12
-20.5712121 -17.4712121 -5.1712121 13.0287879 -13.7712121 -15.1712121
13 14 15 16 17 18
-16.4712121 -8.6712121 4.4287879 -5.0712121 3.5287879 8.4287879
19 20 21 22 23 24
-26.1712121 -35.8712121 -10.2712121 -12.0712121 -6.7712121 -3.4712121
25 26 27 28 29 30
-17.5712121 -7.9712121 13.0287879 2.0287879 -3.4712121 11.7287879
31 32 33 34 35 36
-27.8712121 -24.3712121 1.1287879 7.5287879 -3.4712121 -4.2712121
37 38 39 40 41 42
-8.4712121 -3.8712121 16.5287879 2.1287879 -0.8712121 17.4287879
43 44 45 46 47 48
-15.5712121 -24.0712121 6.4287879 -2.5712121 0.8287879 2.2287879
49 50 51 52 53 54
-5.2712121 2.2287879 23.0287879 1.0287879 18.9287879 27.0287879
55 56 57 58 59 60
-14.8712121 -20.9712121 13.4287879 15.5287879 12.9287879 15.9287879
61 62 63 64 65 66
6.5287879 8.9287879 32.2287879 18.1287879 22.1287879 42.5287879
67 68 69 70 71 72
-20.3666667 -32.0666667 3.8333333 2.0333333 -0.1666667 2.7333333
73 74 75 76 77 78
-11.2666667 5.7333333 17.7333333 13.9333333 11.2333333 28.4333333
79 80 81
-10.4666667 -22.1666667 10.8333333
> postscript(file="/var/www/html/freestat/rcomp/tmp/6yto11229782432.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 -12.0712121 NA
1 -8.2712121 -12.0712121
2 9.8287879 -8.2712121
3 -1.6712121 9.8287879
4 8.0287879 -1.6712121
5 15.7287879 8.0287879
6 -20.5712121 15.7287879
7 -17.4712121 -20.5712121
8 -5.1712121 -17.4712121
9 13.0287879 -5.1712121
10 -13.7712121 13.0287879
11 -15.1712121 -13.7712121
12 -16.4712121 -15.1712121
13 -8.6712121 -16.4712121
14 4.4287879 -8.6712121
15 -5.0712121 4.4287879
16 3.5287879 -5.0712121
17 8.4287879 3.5287879
18 -26.1712121 8.4287879
19 -35.8712121 -26.1712121
20 -10.2712121 -35.8712121
21 -12.0712121 -10.2712121
22 -6.7712121 -12.0712121
23 -3.4712121 -6.7712121
24 -17.5712121 -3.4712121
25 -7.9712121 -17.5712121
26 13.0287879 -7.9712121
27 2.0287879 13.0287879
28 -3.4712121 2.0287879
29 11.7287879 -3.4712121
30 -27.8712121 11.7287879
31 -24.3712121 -27.8712121
32 1.1287879 -24.3712121
33 7.5287879 1.1287879
34 -3.4712121 7.5287879
35 -4.2712121 -3.4712121
36 -8.4712121 -4.2712121
37 -3.8712121 -8.4712121
38 16.5287879 -3.8712121
39 2.1287879 16.5287879
40 -0.8712121 2.1287879
41 17.4287879 -0.8712121
42 -15.5712121 17.4287879
43 -24.0712121 -15.5712121
44 6.4287879 -24.0712121
45 -2.5712121 6.4287879
46 0.8287879 -2.5712121
47 2.2287879 0.8287879
48 -5.2712121 2.2287879
49 2.2287879 -5.2712121
50 23.0287879 2.2287879
51 1.0287879 23.0287879
52 18.9287879 1.0287879
53 27.0287879 18.9287879
54 -14.8712121 27.0287879
55 -20.9712121 -14.8712121
56 13.4287879 -20.9712121
57 15.5287879 13.4287879
58 12.9287879 15.5287879
59 15.9287879 12.9287879
60 6.5287879 15.9287879
61 8.9287879 6.5287879
62 32.2287879 8.9287879
63 18.1287879 32.2287879
64 22.1287879 18.1287879
65 42.5287879 22.1287879
66 -20.3666667 42.5287879
67 -32.0666667 -20.3666667
68 3.8333333 -32.0666667
69 2.0333333 3.8333333
70 -0.1666667 2.0333333
71 2.7333333 -0.1666667
72 -11.2666667 2.7333333
73 5.7333333 -11.2666667
74 17.7333333 5.7333333
75 13.9333333 17.7333333
76 11.2333333 13.9333333
77 28.4333333 11.2333333
78 -10.4666667 28.4333333
79 -22.1666667 -10.4666667
80 10.8333333 -22.1666667
81 NA 10.8333333
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -8.2712121 -12.0712121
[2,] 9.8287879 -8.2712121
[3,] -1.6712121 9.8287879
[4,] 8.0287879 -1.6712121
[5,] 15.7287879 8.0287879
[6,] -20.5712121 15.7287879
[7,] -17.4712121 -20.5712121
[8,] -5.1712121 -17.4712121
[9,] 13.0287879 -5.1712121
[10,] -13.7712121 13.0287879
[11,] -15.1712121 -13.7712121
[12,] -16.4712121 -15.1712121
[13,] -8.6712121 -16.4712121
[14,] 4.4287879 -8.6712121
[15,] -5.0712121 4.4287879
[16,] 3.5287879 -5.0712121
[17,] 8.4287879 3.5287879
[18,] -26.1712121 8.4287879
[19,] -35.8712121 -26.1712121
[20,] -10.2712121 -35.8712121
[21,] -12.0712121 -10.2712121
[22,] -6.7712121 -12.0712121
[23,] -3.4712121 -6.7712121
[24,] -17.5712121 -3.4712121
[25,] -7.9712121 -17.5712121
[26,] 13.0287879 -7.9712121
[27,] 2.0287879 13.0287879
[28,] -3.4712121 2.0287879
[29,] 11.7287879 -3.4712121
[30,] -27.8712121 11.7287879
[31,] -24.3712121 -27.8712121
[32,] 1.1287879 -24.3712121
[33,] 7.5287879 1.1287879
[34,] -3.4712121 7.5287879
[35,] -4.2712121 -3.4712121
[36,] -8.4712121 -4.2712121
[37,] -3.8712121 -8.4712121
[38,] 16.5287879 -3.8712121
[39,] 2.1287879 16.5287879
[40,] -0.8712121 2.1287879
[41,] 17.4287879 -0.8712121
[42,] -15.5712121 17.4287879
[43,] -24.0712121 -15.5712121
[44,] 6.4287879 -24.0712121
[45,] -2.5712121 6.4287879
[46,] 0.8287879 -2.5712121
[47,] 2.2287879 0.8287879
[48,] -5.2712121 2.2287879
[49,] 2.2287879 -5.2712121
[50,] 23.0287879 2.2287879
[51,] 1.0287879 23.0287879
[52,] 18.9287879 1.0287879
[53,] 27.0287879 18.9287879
[54,] -14.8712121 27.0287879
[55,] -20.9712121 -14.8712121
[56,] 13.4287879 -20.9712121
[57,] 15.5287879 13.4287879
[58,] 12.9287879 15.5287879
[59,] 15.9287879 12.9287879
[60,] 6.5287879 15.9287879
[61,] 8.9287879 6.5287879
[62,] 32.2287879 8.9287879
[63,] 18.1287879 32.2287879
[64,] 22.1287879 18.1287879
[65,] 42.5287879 22.1287879
[66,] -20.3666667 42.5287879
[67,] -32.0666667 -20.3666667
[68,] 3.8333333 -32.0666667
[69,] 2.0333333 3.8333333
[70,] -0.1666667 2.0333333
[71,] 2.7333333 -0.1666667
[72,] -11.2666667 2.7333333
[73,] 5.7333333 -11.2666667
[74,] 17.7333333 5.7333333
[75,] 13.9333333 17.7333333
[76,] 11.2333333 13.9333333
[77,] 28.4333333 11.2333333
[78,] -10.4666667 28.4333333
[79,] -22.1666667 -10.4666667
[80,] 10.8333333 -22.1666667
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -8.2712121 -12.0712121
2 9.8287879 -8.2712121
3 -1.6712121 9.8287879
4 8.0287879 -1.6712121
5 15.7287879 8.0287879
6 -20.5712121 15.7287879
7 -17.4712121 -20.5712121
8 -5.1712121 -17.4712121
9 13.0287879 -5.1712121
10 -13.7712121 13.0287879
11 -15.1712121 -13.7712121
12 -16.4712121 -15.1712121
13 -8.6712121 -16.4712121
14 4.4287879 -8.6712121
15 -5.0712121 4.4287879
16 3.5287879 -5.0712121
17 8.4287879 3.5287879
18 -26.1712121 8.4287879
19 -35.8712121 -26.1712121
20 -10.2712121 -35.8712121
21 -12.0712121 -10.2712121
22 -6.7712121 -12.0712121
23 -3.4712121 -6.7712121
24 -17.5712121 -3.4712121
25 -7.9712121 -17.5712121
26 13.0287879 -7.9712121
27 2.0287879 13.0287879
28 -3.4712121 2.0287879
29 11.7287879 -3.4712121
30 -27.8712121 11.7287879
31 -24.3712121 -27.8712121
32 1.1287879 -24.3712121
33 7.5287879 1.1287879
34 -3.4712121 7.5287879
35 -4.2712121 -3.4712121
36 -8.4712121 -4.2712121
37 -3.8712121 -8.4712121
38 16.5287879 -3.8712121
39 2.1287879 16.5287879
40 -0.8712121 2.1287879
41 17.4287879 -0.8712121
42 -15.5712121 17.4287879
43 -24.0712121 -15.5712121
44 6.4287879 -24.0712121
45 -2.5712121 6.4287879
46 0.8287879 -2.5712121
47 2.2287879 0.8287879
48 -5.2712121 2.2287879
49 2.2287879 -5.2712121
50 23.0287879 2.2287879
51 1.0287879 23.0287879
52 18.9287879 1.0287879
53 27.0287879 18.9287879
54 -14.8712121 27.0287879
55 -20.9712121 -14.8712121
56 13.4287879 -20.9712121
57 15.5287879 13.4287879
58 12.9287879 15.5287879
59 15.9287879 12.9287879
60 6.5287879 15.9287879
61 8.9287879 6.5287879
62 32.2287879 8.9287879
63 18.1287879 32.2287879
64 22.1287879 18.1287879
65 42.5287879 22.1287879
66 -20.3666667 42.5287879
67 -32.0666667 -20.3666667
68 3.8333333 -32.0666667
69 2.0333333 3.8333333
70 -0.1666667 2.0333333
71 2.7333333 -0.1666667
72 -11.2666667 2.7333333
73 5.7333333 -11.2666667
74 17.7333333 5.7333333
75 13.9333333 17.7333333
76 11.2333333 13.9333333
77 28.4333333 11.2333333
78 -10.4666667 28.4333333
79 -22.1666667 -10.4666667
80 10.8333333 -22.1666667
> 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/7lpbb1229782432.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/8f4q01229782432.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/9p3go1229782432.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/10j1gh1229782432.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/11o6n81229782433.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/1202md1229782433.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/13lsr11229782433.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/140ie11229782433.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/15njd21229782433.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/1606tz1229782433.tab")
+ }
>
> system("convert tmp/1p66i1229782432.ps tmp/1p66i1229782432.png")
> system("convert tmp/2dwgx1229782432.ps tmp/2dwgx1229782432.png")
> system("convert tmp/33t361229782432.ps tmp/33t361229782432.png")
> system("convert tmp/4hqs91229782432.ps tmp/4hqs91229782432.png")
> system("convert tmp/5tr131229782432.ps tmp/5tr131229782432.png")
> system("convert tmp/6yto11229782432.ps tmp/6yto11229782432.png")
> system("convert tmp/7lpbb1229782432.ps tmp/7lpbb1229782432.png")
> system("convert tmp/8f4q01229782432.ps tmp/8f4q01229782432.png")
> system("convert tmp/9p3go1229782432.ps tmp/9p3go1229782432.png")
> system("convert tmp/10j1gh1229782432.ps tmp/10j1gh1229782432.png")
>
>
> proc.time()
user system elapsed
3.989 2.517 4.797