R version 2.9.0 (2009-04-17)
Copyright (C) 2009 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(109.8,8.4,111.7,8.4,98.6,8.4,96.9,8.6,95.1,8.9,97,8.8,112.7,8.3,102.9,7.5,97.4,7.2,111.4,7.4,87.4,8.8,96.8,9.3,114.1,9.3,110.3,8.7,103.9,8.2,101.6,8.3,94.6,8.5,95.9,8.6,104.7,8.5,102.8,8.2,98.1,8.1,113.9,7.9,80.9,8.6,95.7,8.7,113.2,8.7,105.9,8.5,108.8,8.4,102.3,8.5,99,8.7,100.7,8.7,115.5,8.6,100.7,8.5,109.9,8.3,114.6,8,85.4,8.2,100.5,8.1,114.8,8.1,116.5,8,112.9,7.9,102,7.9,106,8,105.3,8,118.8,7.9,106.1,8,109.3,7.7,117.2,7.2,92.5,7.5,104.2,7.3,112.5,7,122.4,7,113.3,7,100,7.2,110.7,7.3,112.8,7.1,109.8,6.8,117.3,6.4,109.1,6.1,115.9,6.5,96,7.7,99.8,7.9,116.8,7.5,115.7,6.9),dim=c(2,62),dimnames=list(c('Y','X'),1:62))
> y <- array(NA,dim=c(2,62),dimnames=list(c('Y','X'),1:62))
> 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 = 'Include Monthly Dummies'
> par1 = '2'
> #'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
X Y M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 8.4 109.8 1 0 0 0 0 0 0 0 0 0 0
2 8.4 111.7 0 1 0 0 0 0 0 0 0 0 0
3 8.4 98.6 0 0 1 0 0 0 0 0 0 0 0
4 8.6 96.9 0 0 0 1 0 0 0 0 0 0 0
5 8.9 95.1 0 0 0 0 1 0 0 0 0 0 0
6 8.8 97.0 0 0 0 0 0 1 0 0 0 0 0
7 8.3 112.7 0 0 0 0 0 0 1 0 0 0 0
8 7.5 102.9 0 0 0 0 0 0 0 1 0 0 0
9 7.2 97.4 0 0 0 0 0 0 0 0 1 0 0
10 7.4 111.4 0 0 0 0 0 0 0 0 0 1 0
11 8.8 87.4 0 0 0 0 0 0 0 0 0 0 1
12 9.3 96.8 0 0 0 0 0 0 0 0 0 0 0
13 9.3 114.1 1 0 0 0 0 0 0 0 0 0 0
14 8.7 110.3 0 1 0 0 0 0 0 0 0 0 0
15 8.2 103.9 0 0 1 0 0 0 0 0 0 0 0
16 8.3 101.6 0 0 0 1 0 0 0 0 0 0 0
17 8.5 94.6 0 0 0 0 1 0 0 0 0 0 0
18 8.6 95.9 0 0 0 0 0 1 0 0 0 0 0
19 8.5 104.7 0 0 0 0 0 0 1 0 0 0 0
20 8.2 102.8 0 0 0 0 0 0 0 1 0 0 0
21 8.1 98.1 0 0 0 0 0 0 0 0 1 0 0
22 7.9 113.9 0 0 0 0 0 0 0 0 0 1 0
23 8.6 80.9 0 0 0 0 0 0 0 0 0 0 1
24 8.7 95.7 0 0 0 0 0 0 0 0 0 0 0
25 8.7 113.2 1 0 0 0 0 0 0 0 0 0 0
26 8.5 105.9 0 1 0 0 0 0 0 0 0 0 0
27 8.4 108.8 0 0 1 0 0 0 0 0 0 0 0
28 8.5 102.3 0 0 0 1 0 0 0 0 0 0 0
29 8.7 99.0 0 0 0 0 1 0 0 0 0 0 0
30 8.7 100.7 0 0 0 0 0 1 0 0 0 0 0
31 8.6 115.5 0 0 0 0 0 0 1 0 0 0 0
32 8.5 100.7 0 0 0 0 0 0 0 1 0 0 0
33 8.3 109.9 0 0 0 0 0 0 0 0 1 0 0
34 8.0 114.6 0 0 0 0 0 0 0 0 0 1 0
35 8.2 85.4 0 0 0 0 0 0 0 0 0 0 1
36 8.1 100.5 0 0 0 0 0 0 0 0 0 0 0
37 8.1 114.8 1 0 0 0 0 0 0 0 0 0 0
38 8.0 116.5 0 1 0 0 0 0 0 0 0 0 0
39 7.9 112.9 0 0 1 0 0 0 0 0 0 0 0
40 7.9 102.0 0 0 0 1 0 0 0 0 0 0 0
41 8.0 106.0 0 0 0 0 1 0 0 0 0 0 0
42 8.0 105.3 0 0 0 0 0 1 0 0 0 0 0
43 7.9 118.8 0 0 0 0 0 0 1 0 0 0 0
44 8.0 106.1 0 0 0 0 0 0 0 1 0 0 0
45 7.7 109.3 0 0 0 0 0 0 0 0 1 0 0
46 7.2 117.2 0 0 0 0 0 0 0 0 0 1 0
47 7.5 92.5 0 0 0 0 0 0 0 0 0 0 1
48 7.3 104.2 0 0 0 0 0 0 0 0 0 0 0
49 7.0 112.5 1 0 0 0 0 0 0 0 0 0 0
50 7.0 122.4 0 1 0 0 0 0 0 0 0 0 0
51 7.0 113.3 0 0 1 0 0 0 0 0 0 0 0
52 7.2 100.0 0 0 0 1 0 0 0 0 0 0 0
53 7.3 110.7 0 0 0 0 1 0 0 0 0 0 0
54 7.1 112.8 0 0 0 0 0 1 0 0 0 0 0
55 6.8 109.8 0 0 0 0 0 0 1 0 0 0 0
56 6.4 117.3 0 0 0 0 0 0 0 1 0 0 0
57 6.1 109.1 0 0 0 0 0 0 0 0 1 0 0
58 6.5 115.9 0 0 0 0 0 0 0 0 0 1 0
59 7.7 96.0 0 0 0 0 0 0 0 0 0 0 1
60 7.9 99.8 0 0 0 0 0 0 0 0 0 0 0
61 7.5 116.8 1 0 0 0 0 0 0 0 0 0 0
62 6.9 115.7 0 1 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Y M1 M2 M3 M4
15.92338 -0.07710 0.99630 0.76300 0.34448 -0.07057
M5 M6 M7 M8 M9 M10
0.14952 0.20666 0.75454 -0.03425 -0.36676 0.31187
M11
-0.94498
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.41274 -0.27623 0.01572 0.33149 1.21628
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 15.92338 1.59468 9.985 2.11e-13 ***
Y -0.07710 0.01582 -4.874 1.19e-05 ***
M1 0.99630 0.42449 2.347 0.0230 *
M2 0.76300 0.42630 1.790 0.0797 .
M3 0.34448 0.39808 0.865 0.3911
M4 -0.07057 0.37734 -0.187 0.8524
M5 0.14952 0.37783 0.396 0.6940
M6 0.20666 0.37975 0.544 0.5888
M7 0.75454 0.42858 1.761 0.0846 .
M8 -0.03425 0.39092 -0.088 0.9305
M9 -0.36676 0.38631 -0.949 0.3471
M10 0.31187 0.44705 0.698 0.4887
M11 -0.94498 0.41485 -2.278 0.0271 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5959 on 49 degrees of freedom
Multiple R-squared: 0.4343, Adjusted R-squared: 0.2958
F-statistic: 3.135 on 12 and 49 DF, p-value: 0.002289
> 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.2886562563 0.577312513 0.7113437
[2,] 0.1855379901 0.371075980 0.8144620
[3,] 0.0975842354 0.195168471 0.9024158
[4,] 0.0512089367 0.102417873 0.9487911
[5,] 0.0540480843 0.108096169 0.9459519
[6,] 0.0764995145 0.152999029 0.9235005
[7,] 0.0550627287 0.110125457 0.9449373
[8,] 0.0291282623 0.058256525 0.9708717
[9,] 0.0229918614 0.045983723 0.9770081
[10,] 0.0160172664 0.032034533 0.9839827
[11,] 0.0078185506 0.015637101 0.9921814
[12,] 0.0040130744 0.008026149 0.9959869
[13,] 0.0026053727 0.005210745 0.9973946
[14,] 0.0011774915 0.002354983 0.9988225
[15,] 0.0005551156 0.001110231 0.9994449
[16,] 0.0005355629 0.001071126 0.9994644
[17,] 0.0008314777 0.001662955 0.9991685
[18,] 0.0017705082 0.003541016 0.9982295
[19,] 0.0019963133 0.003992627 0.9980037
[20,] 0.0016081423 0.003216285 0.9983919
[21,] 0.0041264120 0.008252824 0.9958736
[22,] 0.0073339015 0.014667803 0.9926661
[23,] 0.0109233369 0.021846674 0.9890767
[24,] 0.0109605827 0.021921165 0.9890394
[25,] 0.0114011620 0.022802324 0.9885988
[26,] 0.0095906891 0.019181378 0.9904093
[27,] 0.0086699221 0.017339844 0.9913301
[28,] 0.0270958803 0.054191761 0.9729041
[29,] 0.0527791089 0.105558218 0.9472209
[30,] 0.4336712028 0.867342406 0.5663288
[31,] 0.5260568309 0.947886338 0.4739432
> postscript(file="/var/www/html/rcomp/tmp/1dwca1258664162.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/rcomp/tmp/2gxzn1258664162.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/rcomp/tmp/3d6ca1258664162.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/rcomp/tmp/47a6i1258664162.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/rcomp/tmp/5nlgu1258664162.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 = 62
Frequency = 1
1 2 3 4 5
-0.0544931895 0.3252857338 -0.2661578713 0.2178272125 0.1589635876
6 7 8 9 10
0.1483052772 0.3108385560 -0.4559149535 -0.8474294307 -0.2467084481
11 12 13 14 15
0.5598197544 0.8395493859 1.1770212877 0.5173507877 -0.0575470041
16 17 18 19 20
0.2801802456 -0.2795846074 -0.1365007518 -0.1059325643 0.2363754075
21 22 23 24 25
0.1065380423 0.4460325270 -0.1413067809 0.1547433569 0.5076345367
26 27 28 29 30
-0.0218733285 0.5202253070 0.5341477187 0.2596395087 0.3335619203
31 32 33 34 35
0.8267084481 0.3744729884 1.2162754448 0.6000000000 -0.1943730257
36 37 38 39 40
-0.0751939710 0.0309887607 0.2953484059 0.3363205062 -0.0889811983
41 42 43 44 45
0.0993142390 -0.0117946855 0.3811265352 0.2907934946 0.5700176108
46 47 48 49 50
0.0004506141 -0.3469886564 -0.5899373278 -1.2463329364 -0.2497828928
51 52 53 54 55
-0.5328409378 -0.9431739784 -0.2383327278 -0.3335717602 -1.4127409751
56 57 58 59 60
-0.4457269370 -1.0454016672 -0.7997746930 0.1228487087 -0.3291614440
61 62
-0.4148184592 -0.8663287061
> postscript(file="/var/www/html/rcomp/tmp/6wl0z1258664162.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 = 62
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.0544931895 NA
1 0.3252857338 -0.0544931895
2 -0.2661578713 0.3252857338
3 0.2178272125 -0.2661578713
4 0.1589635876 0.2178272125
5 0.1483052772 0.1589635876
6 0.3108385560 0.1483052772
7 -0.4559149535 0.3108385560
8 -0.8474294307 -0.4559149535
9 -0.2467084481 -0.8474294307
10 0.5598197544 -0.2467084481
11 0.8395493859 0.5598197544
12 1.1770212877 0.8395493859
13 0.5173507877 1.1770212877
14 -0.0575470041 0.5173507877
15 0.2801802456 -0.0575470041
16 -0.2795846074 0.2801802456
17 -0.1365007518 -0.2795846074
18 -0.1059325643 -0.1365007518
19 0.2363754075 -0.1059325643
20 0.1065380423 0.2363754075
21 0.4460325270 0.1065380423
22 -0.1413067809 0.4460325270
23 0.1547433569 -0.1413067809
24 0.5076345367 0.1547433569
25 -0.0218733285 0.5076345367
26 0.5202253070 -0.0218733285
27 0.5341477187 0.5202253070
28 0.2596395087 0.5341477187
29 0.3335619203 0.2596395087
30 0.8267084481 0.3335619203
31 0.3744729884 0.8267084481
32 1.2162754448 0.3744729884
33 0.6000000000 1.2162754448
34 -0.1943730257 0.6000000000
35 -0.0751939710 -0.1943730257
36 0.0309887607 -0.0751939710
37 0.2953484059 0.0309887607
38 0.3363205062 0.2953484059
39 -0.0889811983 0.3363205062
40 0.0993142390 -0.0889811983
41 -0.0117946855 0.0993142390
42 0.3811265352 -0.0117946855
43 0.2907934946 0.3811265352
44 0.5700176108 0.2907934946
45 0.0004506141 0.5700176108
46 -0.3469886564 0.0004506141
47 -0.5899373278 -0.3469886564
48 -1.2463329364 -0.5899373278
49 -0.2497828928 -1.2463329364
50 -0.5328409378 -0.2497828928
51 -0.9431739784 -0.5328409378
52 -0.2383327278 -0.9431739784
53 -0.3335717602 -0.2383327278
54 -1.4127409751 -0.3335717602
55 -0.4457269370 -1.4127409751
56 -1.0454016672 -0.4457269370
57 -0.7997746930 -1.0454016672
58 0.1228487087 -0.7997746930
59 -0.3291614440 0.1228487087
60 -0.4148184592 -0.3291614440
61 -0.8663287061 -0.4148184592
62 NA -0.8663287061
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.3252857338 -0.0544931895
[2,] -0.2661578713 0.3252857338
[3,] 0.2178272125 -0.2661578713
[4,] 0.1589635876 0.2178272125
[5,] 0.1483052772 0.1589635876
[6,] 0.3108385560 0.1483052772
[7,] -0.4559149535 0.3108385560
[8,] -0.8474294307 -0.4559149535
[9,] -0.2467084481 -0.8474294307
[10,] 0.5598197544 -0.2467084481
[11,] 0.8395493859 0.5598197544
[12,] 1.1770212877 0.8395493859
[13,] 0.5173507877 1.1770212877
[14,] -0.0575470041 0.5173507877
[15,] 0.2801802456 -0.0575470041
[16,] -0.2795846074 0.2801802456
[17,] -0.1365007518 -0.2795846074
[18,] -0.1059325643 -0.1365007518
[19,] 0.2363754075 -0.1059325643
[20,] 0.1065380423 0.2363754075
[21,] 0.4460325270 0.1065380423
[22,] -0.1413067809 0.4460325270
[23,] 0.1547433569 -0.1413067809
[24,] 0.5076345367 0.1547433569
[25,] -0.0218733285 0.5076345367
[26,] 0.5202253070 -0.0218733285
[27,] 0.5341477187 0.5202253070
[28,] 0.2596395087 0.5341477187
[29,] 0.3335619203 0.2596395087
[30,] 0.8267084481 0.3335619203
[31,] 0.3744729884 0.8267084481
[32,] 1.2162754448 0.3744729884
[33,] 0.6000000000 1.2162754448
[34,] -0.1943730257 0.6000000000
[35,] -0.0751939710 -0.1943730257
[36,] 0.0309887607 -0.0751939710
[37,] 0.2953484059 0.0309887607
[38,] 0.3363205062 0.2953484059
[39,] -0.0889811983 0.3363205062
[40,] 0.0993142390 -0.0889811983
[41,] -0.0117946855 0.0993142390
[42,] 0.3811265352 -0.0117946855
[43,] 0.2907934946 0.3811265352
[44,] 0.5700176108 0.2907934946
[45,] 0.0004506141 0.5700176108
[46,] -0.3469886564 0.0004506141
[47,] -0.5899373278 -0.3469886564
[48,] -1.2463329364 -0.5899373278
[49,] -0.2497828928 -1.2463329364
[50,] -0.5328409378 -0.2497828928
[51,] -0.9431739784 -0.5328409378
[52,] -0.2383327278 -0.9431739784
[53,] -0.3335717602 -0.2383327278
[54,] -1.4127409751 -0.3335717602
[55,] -0.4457269370 -1.4127409751
[56,] -1.0454016672 -0.4457269370
[57,] -0.7997746930 -1.0454016672
[58,] 0.1228487087 -0.7997746930
[59,] -0.3291614440 0.1228487087
[60,] -0.4148184592 -0.3291614440
[61,] -0.8663287061 -0.4148184592
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.3252857338 -0.0544931895
2 -0.2661578713 0.3252857338
3 0.2178272125 -0.2661578713
4 0.1589635876 0.2178272125
5 0.1483052772 0.1589635876
6 0.3108385560 0.1483052772
7 -0.4559149535 0.3108385560
8 -0.8474294307 -0.4559149535
9 -0.2467084481 -0.8474294307
10 0.5598197544 -0.2467084481
11 0.8395493859 0.5598197544
12 1.1770212877 0.8395493859
13 0.5173507877 1.1770212877
14 -0.0575470041 0.5173507877
15 0.2801802456 -0.0575470041
16 -0.2795846074 0.2801802456
17 -0.1365007518 -0.2795846074
18 -0.1059325643 -0.1365007518
19 0.2363754075 -0.1059325643
20 0.1065380423 0.2363754075
21 0.4460325270 0.1065380423
22 -0.1413067809 0.4460325270
23 0.1547433569 -0.1413067809
24 0.5076345367 0.1547433569
25 -0.0218733285 0.5076345367
26 0.5202253070 -0.0218733285
27 0.5341477187 0.5202253070
28 0.2596395087 0.5341477187
29 0.3335619203 0.2596395087
30 0.8267084481 0.3335619203
31 0.3744729884 0.8267084481
32 1.2162754448 0.3744729884
33 0.6000000000 1.2162754448
34 -0.1943730257 0.6000000000
35 -0.0751939710 -0.1943730257
36 0.0309887607 -0.0751939710
37 0.2953484059 0.0309887607
38 0.3363205062 0.2953484059
39 -0.0889811983 0.3363205062
40 0.0993142390 -0.0889811983
41 -0.0117946855 0.0993142390
42 0.3811265352 -0.0117946855
43 0.2907934946 0.3811265352
44 0.5700176108 0.2907934946
45 0.0004506141 0.5700176108
46 -0.3469886564 0.0004506141
47 -0.5899373278 -0.3469886564
48 -1.2463329364 -0.5899373278
49 -0.2497828928 -1.2463329364
50 -0.5328409378 -0.2497828928
51 -0.9431739784 -0.5328409378
52 -0.2383327278 -0.9431739784
53 -0.3335717602 -0.2383327278
54 -1.4127409751 -0.3335717602
55 -0.4457269370 -1.4127409751
56 -1.0454016672 -0.4457269370
57 -0.7997746930 -1.0454016672
58 0.1228487087 -0.7997746930
59 -0.3291614440 0.1228487087
60 -0.4148184592 -0.3291614440
61 -0.8663287061 -0.4148184592
> 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/rcomp/tmp/7tr541258664162.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/rcomp/tmp/83u1w1258664162.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/rcomp/tmp/9nl6i1258664162.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/rcomp/tmp/104ee21258664162.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/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/rcomp/tmp/11be0e1258664162.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/rcomp/tmp/12hasp1258664162.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/rcomp/tmp/13btoe1258664163.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/rcomp/tmp/14j8501258664163.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/rcomp/tmp/157hzt1258664163.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/rcomp/tmp/16jfnw1258664163.tab")
+ }
> system("convert tmp/1dwca1258664162.ps tmp/1dwca1258664162.png")
> system("convert tmp/2gxzn1258664162.ps tmp/2gxzn1258664162.png")
> system("convert tmp/3d6ca1258664162.ps tmp/3d6ca1258664162.png")
> system("convert tmp/47a6i1258664162.ps tmp/47a6i1258664162.png")
> system("convert tmp/5nlgu1258664162.ps tmp/5nlgu1258664162.png")
> system("convert tmp/6wl0z1258664162.ps tmp/6wl0z1258664162.png")
> system("convert tmp/7tr541258664162.ps tmp/7tr541258664162.png")
> system("convert tmp/83u1w1258664162.ps tmp/83u1w1258664162.png")
> system("convert tmp/9nl6i1258664162.ps tmp/9nl6i1258664162.png")
> system("convert tmp/104ee21258664162.ps tmp/104ee21258664162.png")
>
>
> proc.time()
user system elapsed
2.394 1.542 3.051