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(8.5,104.1,8.6,90.2,8.5,99.2,8.2,116.5,8.1,98.4,7.9,90.6,8.6,130.5,8.7,107.4,8.7,106,8.5,196.5,8.4,107.8,8.5,90.5,8.7,123.8,8.7,114.7,8.6,115.3,8.5,197,8.3,88.4,8,93.8,8.2,111.3,8.1,105.9,8.1,123.6,8,171,7.9,97,7.9,99.2,8,126.6,8,103.4,7.9,121.3,8,129.6,7.7,110.8,7.2,98.9,7.5,122.8,7.3,120.9,7,133.1,7,203.1,7,110.2,7.2,119.5,7.3,135.1,7.1,113.9,6.8,137.4,6.4,157.1,6.1,126.4,6.5,112.2,7.7,128.8,7.9,136.8,7.5,156.5,6.9,215.2,6.6,146.7,6.9,130.8,7.7,133.1,8,153.4,8,159.9,7.7,174.6,7.3,145,7.4,112.9,8.1,137.8,8.3,150.6),dim=c(2,56),dimnames=list(c('X','Yt-4'),1:56))
> y <- array(NA,dim=c(2,56),dimnames=list(c('X','Yt-4'),1:56))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = '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
Yt-4 X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 104.1 8.5 1 0 0 0 0 0 0 0 0 0 0 1
2 90.2 8.6 0 1 0 0 0 0 0 0 0 0 0 2
3 99.2 8.5 0 0 1 0 0 0 0 0 0 0 0 3
4 116.5 8.2 0 0 0 1 0 0 0 0 0 0 0 4
5 98.4 8.1 0 0 0 0 1 0 0 0 0 0 0 5
6 90.6 7.9 0 0 0 0 0 1 0 0 0 0 0 6
7 130.5 8.6 0 0 0 0 0 0 1 0 0 0 0 7
8 107.4 8.7 0 0 0 0 0 0 0 1 0 0 0 8
9 106.0 8.7 0 0 0 0 0 0 0 0 1 0 0 9
10 196.5 8.5 0 0 0 0 0 0 0 0 0 1 0 10
11 107.8 8.4 0 0 0 0 0 0 0 0 0 0 1 11
12 90.5 8.5 0 0 0 0 0 0 0 0 0 0 0 12
13 123.8 8.7 1 0 0 0 0 0 0 0 0 0 0 13
14 114.7 8.7 0 1 0 0 0 0 0 0 0 0 0 14
15 115.3 8.6 0 0 1 0 0 0 0 0 0 0 0 15
16 197.0 8.5 0 0 0 1 0 0 0 0 0 0 0 16
17 88.4 8.3 0 0 0 0 1 0 0 0 0 0 0 17
18 93.8 8.0 0 0 0 0 0 1 0 0 0 0 0 18
19 111.3 8.2 0 0 0 0 0 0 1 0 0 0 0 19
20 105.9 8.1 0 0 0 0 0 0 0 1 0 0 0 20
21 123.6 8.1 0 0 0 0 0 0 0 0 1 0 0 21
22 171.0 8.0 0 0 0 0 0 0 0 0 0 1 0 22
23 97.0 7.9 0 0 0 0 0 0 0 0 0 0 1 23
24 99.2 7.9 0 0 0 0 0 0 0 0 0 0 0 24
25 126.6 8.0 1 0 0 0 0 0 0 0 0 0 0 25
26 103.4 8.0 0 1 0 0 0 0 0 0 0 0 0 26
27 121.3 7.9 0 0 1 0 0 0 0 0 0 0 0 27
28 129.6 8.0 0 0 0 1 0 0 0 0 0 0 0 28
29 110.8 7.7 0 0 0 0 1 0 0 0 0 0 0 29
30 98.9 7.2 0 0 0 0 0 1 0 0 0 0 0 30
31 122.8 7.5 0 0 0 0 0 0 1 0 0 0 0 31
32 120.9 7.3 0 0 0 0 0 0 0 1 0 0 0 32
33 133.1 7.0 0 0 0 0 0 0 0 0 1 0 0 33
34 203.1 7.0 0 0 0 0 0 0 0 0 0 1 0 34
35 110.2 7.0 0 0 0 0 0 0 0 0 0 0 1 35
36 119.5 7.2 0 0 0 0 0 0 0 0 0 0 0 36
37 135.1 7.3 1 0 0 0 0 0 0 0 0 0 0 37
38 113.9 7.1 0 1 0 0 0 0 0 0 0 0 0 38
39 137.4 6.8 0 0 1 0 0 0 0 0 0 0 0 39
40 157.1 6.4 0 0 0 1 0 0 0 0 0 0 0 40
41 126.4 6.1 0 0 0 0 1 0 0 0 0 0 0 41
42 112.2 6.5 0 0 0 0 0 1 0 0 0 0 0 42
43 128.8 7.7 0 0 0 0 0 0 1 0 0 0 0 43
44 136.8 7.9 0 0 0 0 0 0 0 1 0 0 0 44
45 156.5 7.5 0 0 0 0 0 0 0 0 1 0 0 45
46 215.2 6.9 0 0 0 0 0 0 0 0 0 1 0 46
47 146.7 6.6 0 0 0 0 0 0 0 0 0 0 1 47
48 130.8 6.9 0 0 0 0 0 0 0 0 0 0 0 48
49 133.1 7.7 1 0 0 0 0 0 0 0 0 0 0 49
50 153.4 8.0 0 1 0 0 0 0 0 0 0 0 0 50
51 159.9 8.0 0 0 1 0 0 0 0 0 0 0 0 51
52 174.6 7.7 0 0 0 1 0 0 0 0 0 0 0 52
53 145.0 7.3 0 0 0 0 1 0 0 0 0 0 0 53
54 112.9 7.4 0 0 0 0 0 1 0 0 0 0 0 54
55 137.8 8.1 0 0 0 0 0 0 1 0 0 0 0 55
56 150.6 8.3 0 0 0 0 0 0 0 1 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
52.0823 3.8564 17.6917 7.1670 18.1794 46.3402
M5 M6 M7 M8 M9 M10
5.2325 -7.4523 13.7663 10.7416 21.8800 88.4473
M11 t
6.9539 0.9504
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-26.28554 -6.81157 0.05351 5.55619 50.59131
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 52.0823 35.5351 1.466 0.1502
X 3.8564 4.1236 0.935 0.3550
M1 17.6917 9.2532 1.912 0.0627 .
M2 7.1670 9.2854 0.772 0.4445
M3 18.1794 9.2285 1.970 0.0555 .
M4 46.3402 9.1707 5.053 8.96e-06 ***
M5 5.2325 9.1836 0.570 0.5719
M6 -7.4523 9.2085 -0.809 0.4229
M7 13.7663 9.3256 1.476 0.1474
M8 10.7416 9.3826 1.145 0.2588
M9 21.8800 9.6761 2.261 0.0290 *
M10 88.4473 9.6652 9.151 1.48e-11 ***
M11 6.9539 9.6852 0.718 0.4767
t 0.9504 0.1574 6.037 3.51e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 13.66 on 42 degrees of freedom
Multiple R-squared: 0.8372, Adjusted R-squared: 0.7869
F-statistic: 16.62 on 13 and 42 DF, p-value: 1.555e-12
> 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.9976533 0.004693371 0.002346686
[2,] 0.9963767 0.007246592 0.003623296
[3,] 0.9985139 0.002972239 0.001486119
[4,] 0.9986375 0.002724920 0.001362460
[5,] 0.9987129 0.002574160 0.001287080
[6,] 0.9986307 0.002738552 0.001369276
[7,] 0.9970571 0.005885854 0.002942927
[8,] 0.9950446 0.009910749 0.004955375
[9,] 0.9954779 0.009044170 0.004522085
[10,] 0.9908394 0.018321251 0.009160625
[11,] 0.9836783 0.032643422 0.016321711
[12,] 0.9938241 0.012351768 0.006175884
[13,] 0.9894247 0.021150565 0.010575283
[14,] 0.9806520 0.038696079 0.019348039
[15,] 0.9753428 0.049314491 0.024657246
[16,] 0.9613378 0.077324346 0.038662173
[17,] 0.9462023 0.107595385 0.053797692
[18,] 0.9123462 0.175307634 0.087653817
[19,] 0.9485726 0.102854811 0.051427406
[20,] 0.9202100 0.159580008 0.079790004
[21,] 0.8855797 0.228840575 0.114420288
[22,] 0.9712921 0.057415707 0.028707854
[23,] 0.9383016 0.123396895 0.061698448
> postscript(file="/var/www/html/rcomp/tmp/1rqxl1258809362.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/2990b1258809362.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/3eq1v1258809362.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/4pp3k1258809362.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/50bmf1258809362.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 = 56
Frequency = 1
1 2 3 4 5 6
0.5961574 -4.1152267 -6.6923547 -17.3467146 5.0962612 9.8019014
7 8 9 10 11 12
24.8333893 3.4220052 -10.0667746 13.6868154 5.9154054 -5.7667746
13 14 15 16 17 18
8.1198262 8.5940822 -2.3830458 50.5913141 -17.0800700 1.2112103
19 20 21 22 23 24
-4.2291012 -7.1692051 -1.5579848 -21.2900350 -14.3614450 -6.1579848
25 26 27 28 29 30
2.2142560 -11.4114879 -5.0886159 -26.2855363 -3.7712802 -2.0087198
31 32 33 34 35 36
-1.4346714 -0.4891351 0.7790055 3.2613152 -9.0957349 5.4364450
37 38 39 40 41 42
2.0086859 -8.8457778 3.8483744 -4.0203454 6.5939107 2.5857101
43 44 45 46 47 48
-7.6110026 1.6919732 10.8457539 4.3419044 17.5417746 6.4883144
49 50 51 52 53 54
-12.9389255 15.7784102 10.3156420 -2.9387179 9.1611783 -11.5901019
55 56
-11.5586140 2.5443618
> postscript(file="/var/www/html/rcomp/tmp/6oaoo1258809362.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 0.5961574 NA
1 -4.1152267 0.5961574
2 -6.6923547 -4.1152267
3 -17.3467146 -6.6923547
4 5.0962612 -17.3467146
5 9.8019014 5.0962612
6 24.8333893 9.8019014
7 3.4220052 24.8333893
8 -10.0667746 3.4220052
9 13.6868154 -10.0667746
10 5.9154054 13.6868154
11 -5.7667746 5.9154054
12 8.1198262 -5.7667746
13 8.5940822 8.1198262
14 -2.3830458 8.5940822
15 50.5913141 -2.3830458
16 -17.0800700 50.5913141
17 1.2112103 -17.0800700
18 -4.2291012 1.2112103
19 -7.1692051 -4.2291012
20 -1.5579848 -7.1692051
21 -21.2900350 -1.5579848
22 -14.3614450 -21.2900350
23 -6.1579848 -14.3614450
24 2.2142560 -6.1579848
25 -11.4114879 2.2142560
26 -5.0886159 -11.4114879
27 -26.2855363 -5.0886159
28 -3.7712802 -26.2855363
29 -2.0087198 -3.7712802
30 -1.4346714 -2.0087198
31 -0.4891351 -1.4346714
32 0.7790055 -0.4891351
33 3.2613152 0.7790055
34 -9.0957349 3.2613152
35 5.4364450 -9.0957349
36 2.0086859 5.4364450
37 -8.8457778 2.0086859
38 3.8483744 -8.8457778
39 -4.0203454 3.8483744
40 6.5939107 -4.0203454
41 2.5857101 6.5939107
42 -7.6110026 2.5857101
43 1.6919732 -7.6110026
44 10.8457539 1.6919732
45 4.3419044 10.8457539
46 17.5417746 4.3419044
47 6.4883144 17.5417746
48 -12.9389255 6.4883144
49 15.7784102 -12.9389255
50 10.3156420 15.7784102
51 -2.9387179 10.3156420
52 9.1611783 -2.9387179
53 -11.5901019 9.1611783
54 -11.5586140 -11.5901019
55 2.5443618 -11.5586140
56 NA 2.5443618
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.1152267 0.5961574
[2,] -6.6923547 -4.1152267
[3,] -17.3467146 -6.6923547
[4,] 5.0962612 -17.3467146
[5,] 9.8019014 5.0962612
[6,] 24.8333893 9.8019014
[7,] 3.4220052 24.8333893
[8,] -10.0667746 3.4220052
[9,] 13.6868154 -10.0667746
[10,] 5.9154054 13.6868154
[11,] -5.7667746 5.9154054
[12,] 8.1198262 -5.7667746
[13,] 8.5940822 8.1198262
[14,] -2.3830458 8.5940822
[15,] 50.5913141 -2.3830458
[16,] -17.0800700 50.5913141
[17,] 1.2112103 -17.0800700
[18,] -4.2291012 1.2112103
[19,] -7.1692051 -4.2291012
[20,] -1.5579848 -7.1692051
[21,] -21.2900350 -1.5579848
[22,] -14.3614450 -21.2900350
[23,] -6.1579848 -14.3614450
[24,] 2.2142560 -6.1579848
[25,] -11.4114879 2.2142560
[26,] -5.0886159 -11.4114879
[27,] -26.2855363 -5.0886159
[28,] -3.7712802 -26.2855363
[29,] -2.0087198 -3.7712802
[30,] -1.4346714 -2.0087198
[31,] -0.4891351 -1.4346714
[32,] 0.7790055 -0.4891351
[33,] 3.2613152 0.7790055
[34,] -9.0957349 3.2613152
[35,] 5.4364450 -9.0957349
[36,] 2.0086859 5.4364450
[37,] -8.8457778 2.0086859
[38,] 3.8483744 -8.8457778
[39,] -4.0203454 3.8483744
[40,] 6.5939107 -4.0203454
[41,] 2.5857101 6.5939107
[42,] -7.6110026 2.5857101
[43,] 1.6919732 -7.6110026
[44,] 10.8457539 1.6919732
[45,] 4.3419044 10.8457539
[46,] 17.5417746 4.3419044
[47,] 6.4883144 17.5417746
[48,] -12.9389255 6.4883144
[49,] 15.7784102 -12.9389255
[50,] 10.3156420 15.7784102
[51,] -2.9387179 10.3156420
[52,] 9.1611783 -2.9387179
[53,] -11.5901019 9.1611783
[54,] -11.5586140 -11.5901019
[55,] 2.5443618 -11.5586140
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.1152267 0.5961574
2 -6.6923547 -4.1152267
3 -17.3467146 -6.6923547
4 5.0962612 -17.3467146
5 9.8019014 5.0962612
6 24.8333893 9.8019014
7 3.4220052 24.8333893
8 -10.0667746 3.4220052
9 13.6868154 -10.0667746
10 5.9154054 13.6868154
11 -5.7667746 5.9154054
12 8.1198262 -5.7667746
13 8.5940822 8.1198262
14 -2.3830458 8.5940822
15 50.5913141 -2.3830458
16 -17.0800700 50.5913141
17 1.2112103 -17.0800700
18 -4.2291012 1.2112103
19 -7.1692051 -4.2291012
20 -1.5579848 -7.1692051
21 -21.2900350 -1.5579848
22 -14.3614450 -21.2900350
23 -6.1579848 -14.3614450
24 2.2142560 -6.1579848
25 -11.4114879 2.2142560
26 -5.0886159 -11.4114879
27 -26.2855363 -5.0886159
28 -3.7712802 -26.2855363
29 -2.0087198 -3.7712802
30 -1.4346714 -2.0087198
31 -0.4891351 -1.4346714
32 0.7790055 -0.4891351
33 3.2613152 0.7790055
34 -9.0957349 3.2613152
35 5.4364450 -9.0957349
36 2.0086859 5.4364450
37 -8.8457778 2.0086859
38 3.8483744 -8.8457778
39 -4.0203454 3.8483744
40 6.5939107 -4.0203454
41 2.5857101 6.5939107
42 -7.6110026 2.5857101
43 1.6919732 -7.6110026
44 10.8457539 1.6919732
45 4.3419044 10.8457539
46 17.5417746 4.3419044
47 6.4883144 17.5417746
48 -12.9389255 6.4883144
49 15.7784102 -12.9389255
50 10.3156420 15.7784102
51 -2.9387179 10.3156420
52 9.1611783 -2.9387179
53 -11.5901019 9.1611783
54 -11.5586140 -11.5901019
55 2.5443618 -11.5586140
> 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/7od071258809362.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/86gmj1258809362.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/9gwka1258809362.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/10j6651258809362.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/11da801258809362.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/12v9q21258809362.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/131fws1258809362.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/14h75t1258809362.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/15eczz1258809362.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/168dlc1258809362.tab")
+ }
>
> system("convert tmp/1rqxl1258809362.ps tmp/1rqxl1258809362.png")
> system("convert tmp/2990b1258809362.ps tmp/2990b1258809362.png")
> system("convert tmp/3eq1v1258809362.ps tmp/3eq1v1258809362.png")
> system("convert tmp/4pp3k1258809362.ps tmp/4pp3k1258809362.png")
> system("convert tmp/50bmf1258809362.ps tmp/50bmf1258809362.png")
> system("convert tmp/6oaoo1258809362.ps tmp/6oaoo1258809362.png")
> system("convert tmp/7od071258809362.ps tmp/7od071258809362.png")
> system("convert tmp/86gmj1258809362.ps tmp/86gmj1258809362.png")
> system("convert tmp/9gwka1258809362.ps tmp/9gwka1258809362.png")
> system("convert tmp/10j6651258809362.ps tmp/10j6651258809362.png")
>
>
> proc.time()
user system elapsed
2.340 1.538 2.806