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(17823.2,0,17872,0,17420.4,0,16704.4,0,15991.2,0,15583.6,0,19123.5,0,17838.7,0,17209.4,0,18586.5,0,16258.1,0,15141.6,0,19202.1,0,17746.5,0,19090.1,1,18040.3,1,17515.5,1,17751.8,1,21072.4,1,17170,1,19439.5,1,19795.4,1,17574.9,1,16165.4,1,19464.6,1,19932.1,1,19961.2,1,17343.4,1,18924.2,1,18574.1,1,21350.6,1,18594.6,1,19832.1,1,20844.4,1,19640.2,1,17735.4,1,19813.6,1,22160,1,20664.3,1,17877.4,1,20906.5,1,21164.1,1,21374.4,1,22952.3,1,21343.5,1,23899.3,1,22392.9,1,18274.1,1,22786.7,1,22321.5,1,17842.2,1,16373.5,1,15933.8,0,16446.1,0,17729,0,16643,0,16196.7,0,18252.1,0,17570.4,0,15836.8,0),dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> 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 = '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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 17823.2 0 1 0 0 0 0 0 0 0 0 0 0
2 17872.0 0 0 1 0 0 0 0 0 0 0 0 0
3 17420.4 0 0 0 1 0 0 0 0 0 0 0 0
4 16704.4 0 0 0 0 1 0 0 0 0 0 0 0
5 15991.2 0 0 0 0 0 1 0 0 0 0 0 0
6 15583.6 0 0 0 0 0 0 1 0 0 0 0 0
7 19123.5 0 0 0 0 0 0 0 1 0 0 0 0
8 17838.7 0 0 0 0 0 0 0 0 1 0 0 0
9 17209.4 0 0 0 0 0 0 0 0 0 1 0 0
10 18586.5 0 0 0 0 0 0 0 0 0 0 1 0
11 16258.1 0 0 0 0 0 0 0 0 0 0 0 1
12 15141.6 0 0 0 0 0 0 0 0 0 0 0 0
13 19202.1 0 1 0 0 0 0 0 0 0 0 0 0
14 17746.5 0 0 1 0 0 0 0 0 0 0 0 0
15 19090.1 1 0 0 1 0 0 0 0 0 0 0 0
16 18040.3 1 0 0 0 1 0 0 0 0 0 0 0
17 17515.5 1 0 0 0 0 1 0 0 0 0 0 0
18 17751.8 1 0 0 0 0 0 1 0 0 0 0 0
19 21072.4 1 0 0 0 0 0 0 1 0 0 0 0
20 17170.0 1 0 0 0 0 0 0 0 1 0 0 0
21 19439.5 1 0 0 0 0 0 0 0 0 1 0 0
22 19795.4 1 0 0 0 0 0 0 0 0 0 1 0
23 17574.9 1 0 0 0 0 0 0 0 0 0 0 1
24 16165.4 1 0 0 0 0 0 0 0 0 0 0 0
25 19464.6 1 1 0 0 0 0 0 0 0 0 0 0
26 19932.1 1 0 1 0 0 0 0 0 0 0 0 0
27 19961.2 1 0 0 1 0 0 0 0 0 0 0 0
28 17343.4 1 0 0 0 1 0 0 0 0 0 0 0
29 18924.2 1 0 0 0 0 1 0 0 0 0 0 0
30 18574.1 1 0 0 0 0 0 1 0 0 0 0 0
31 21350.6 1 0 0 0 0 0 0 1 0 0 0 0
32 18594.6 1 0 0 0 0 0 0 0 1 0 0 0
33 19832.1 1 0 0 0 0 0 0 0 0 1 0 0
34 20844.4 1 0 0 0 0 0 0 0 0 0 1 0
35 19640.2 1 0 0 0 0 0 0 0 0 0 0 1
36 17735.4 1 0 0 0 0 0 0 0 0 0 0 0
37 19813.6 1 1 0 0 0 0 0 0 0 0 0 0
38 22160.0 1 0 1 0 0 0 0 0 0 0 0 0
39 20664.3 1 0 0 1 0 0 0 0 0 0 0 0
40 17877.4 1 0 0 0 1 0 0 0 0 0 0 0
41 20906.5 1 0 0 0 0 1 0 0 0 0 0 0
42 21164.1 1 0 0 0 0 0 1 0 0 0 0 0
43 21374.4 1 0 0 0 0 0 0 1 0 0 0 0
44 22952.3 1 0 0 0 0 0 0 0 1 0 0 0
45 21343.5 1 0 0 0 0 0 0 0 0 1 0 0
46 23899.3 1 0 0 0 0 0 0 0 0 0 1 0
47 22392.9 1 0 0 0 0 0 0 0 0 0 0 1
48 18274.1 1 0 0 0 0 0 0 0 0 0 0 0
49 22786.7 1 1 0 0 0 0 0 0 0 0 0 0
50 22321.5 1 0 1 0 0 0 0 0 0 0 0 0
51 17842.2 1 0 0 1 0 0 0 0 0 0 0 0
52 16373.5 1 0 0 0 1 0 0 0 0 0 0 0
53 15933.8 0 0 0 0 0 1 0 0 0 0 0 0
54 16446.1 0 0 0 0 0 0 1 0 0 0 0 0
55 17729.0 0 0 0 0 0 0 0 1 0 0 0 0
56 16643.0 0 0 0 0 0 0 0 0 1 0 0 0
57 16196.7 0 0 0 0 0 0 0 0 0 1 0 0
58 18252.1 0 0 0 0 0 0 0 0 0 0 1 0
59 17570.4 0 0 0 0 0 0 0 0 0 0 0 1
60 15836.8 0 0 0 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) X M1 M2 M3 M4
15013.5 2695.2 3187.4 3375.8 1825.9 98.1
M5 M6 M7 M8 M9 M10
1223.6 1273.3 3499.3 2009.1 2173.6 3644.9
M11
2056.6
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2547.79 -723.39 -98.55 588.34 3234.51
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 15013.5 636.7 23.580 < 2e-16 ***
X 2695.2 362.8 7.429 1.83e-09 ***
M1 3187.4 846.2 3.767 0.000460 ***
M2 3375.8 846.2 3.989 0.000230 ***
M3 1825.9 849.3 2.150 0.036735 *
M4 98.1 849.3 0.116 0.908531
M5 1223.6 846.2 1.446 0.154814
M6 1273.3 846.2 1.505 0.139085
M7 3499.3 846.2 4.135 0.000145 ***
M8 2009.1 846.2 2.374 0.021720 *
M9 2173.6 846.2 2.569 0.013445 *
M10 3644.9 846.2 4.307 8.35e-05 ***
M11 2056.6 846.2 2.430 0.018950 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1338 on 47 degrees of freedom
Multiple R-squared: 0.6753, Adjusted R-squared: 0.5924
F-statistic: 8.146 on 12 and 47 DF, p-value: 5.56e-08
> 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.062954756 0.125909513 0.9370452
[2,] 0.019792636 0.039585271 0.9802074
[3,] 0.008240889 0.016481778 0.9917591
[4,] 0.002339623 0.004679246 0.9976604
[5,] 0.025589437 0.051178874 0.9744106
[6,] 0.014578058 0.029156115 0.9854219
[7,] 0.007770824 0.015541647 0.9922292
[8,] 0.006165602 0.012331204 0.9938344
[9,] 0.003933461 0.007866922 0.9960665
[10,] 0.002271842 0.004543684 0.9977282
[11,] 0.002181378 0.004362756 0.9978186
[12,] 0.001864160 0.003728320 0.9981358
[13,] 0.001120195 0.002240391 0.9988798
[14,] 0.001966001 0.003932002 0.9980340
[15,] 0.002809039 0.005618077 0.9971910
[16,] 0.001390012 0.002780024 0.9986100
[17,] 0.002705196 0.005410392 0.9972948
[18,] 0.001847928 0.003695857 0.9981521
[19,] 0.003209932 0.006419864 0.9967901
[20,] 0.021383443 0.042766886 0.9786166
[21,] 0.030150360 0.060300721 0.9698496
[22,] 0.079465100 0.158930199 0.9205349
[23,] 0.141234225 0.282468450 0.8587658
[24,] 0.374427782 0.748855563 0.6255722
[25,] 0.393062883 0.786125766 0.6069371
[26,] 0.449408500 0.898817000 0.5505915
[27,] 0.474792213 0.949584426 0.5252078
[28,] 0.397070554 0.794141108 0.6029294
[29,] 0.560929335 0.878141331 0.4390707
> postscript(file="/var/www/html/rcomp/tmp/1bk111258561101.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/25rrf1258561101.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/332lc1258561101.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/4yp551258561101.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/5ya881258561101.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 = 60
Frequency = 1
1 2 3 4 5 6
-377.72971 -517.30971 580.90706 1592.74706 -245.92971 -703.22971
7 8 9 10 11 12
610.63029 816.09029 22.27029 -71.92971 -812.08971 128.05029
13 14 15 16 17 18
1001.17029 -642.80971 -444.57676 233.46324 -1416.81353 -1230.21353
19 20 21 22 23 24
-135.65353 -2547.79353 -442.81353 -1558.21353 -2190.47353 -1543.33353
25 26 27 28 29 30
-1431.51353 -1152.39353 426.52324 -463.43676 -8.11353 -407.91353
31 32 33 34 35 36
142.54647 -1123.19353 -50.21353 -509.21353 -125.17353 26.66647
37 38 39 40 41 42
-1082.51353 1075.50647 1129.62324 70.56324 1974.18647 2182.08647
43 44 45 46 47 48
166.34647 3234.50647 1461.18647 2545.68647 2627.52647 565.36647
49 50 51 52 53 54
1890.58647 1237.00647 -1692.47676 -1433.33676 -303.32971 159.27029
55 56 57 58 59 60
-783.86971 -379.60971 -990.42971 -406.32971 500.21029 823.25029
> postscript(file="/var/www/html/rcomp/tmp/6agiz1258561101.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 -377.72971 NA
1 -517.30971 -377.72971
2 580.90706 -517.30971
3 1592.74706 580.90706
4 -245.92971 1592.74706
5 -703.22971 -245.92971
6 610.63029 -703.22971
7 816.09029 610.63029
8 22.27029 816.09029
9 -71.92971 22.27029
10 -812.08971 -71.92971
11 128.05029 -812.08971
12 1001.17029 128.05029
13 -642.80971 1001.17029
14 -444.57676 -642.80971
15 233.46324 -444.57676
16 -1416.81353 233.46324
17 -1230.21353 -1416.81353
18 -135.65353 -1230.21353
19 -2547.79353 -135.65353
20 -442.81353 -2547.79353
21 -1558.21353 -442.81353
22 -2190.47353 -1558.21353
23 -1543.33353 -2190.47353
24 -1431.51353 -1543.33353
25 -1152.39353 -1431.51353
26 426.52324 -1152.39353
27 -463.43676 426.52324
28 -8.11353 -463.43676
29 -407.91353 -8.11353
30 142.54647 -407.91353
31 -1123.19353 142.54647
32 -50.21353 -1123.19353
33 -509.21353 -50.21353
34 -125.17353 -509.21353
35 26.66647 -125.17353
36 -1082.51353 26.66647
37 1075.50647 -1082.51353
38 1129.62324 1075.50647
39 70.56324 1129.62324
40 1974.18647 70.56324
41 2182.08647 1974.18647
42 166.34647 2182.08647
43 3234.50647 166.34647
44 1461.18647 3234.50647
45 2545.68647 1461.18647
46 2627.52647 2545.68647
47 565.36647 2627.52647
48 1890.58647 565.36647
49 1237.00647 1890.58647
50 -1692.47676 1237.00647
51 -1433.33676 -1692.47676
52 -303.32971 -1433.33676
53 159.27029 -303.32971
54 -783.86971 159.27029
55 -379.60971 -783.86971
56 -990.42971 -379.60971
57 -406.32971 -990.42971
58 500.21029 -406.32971
59 823.25029 500.21029
60 NA 823.25029
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -517.30971 -377.72971
[2,] 580.90706 -517.30971
[3,] 1592.74706 580.90706
[4,] -245.92971 1592.74706
[5,] -703.22971 -245.92971
[6,] 610.63029 -703.22971
[7,] 816.09029 610.63029
[8,] 22.27029 816.09029
[9,] -71.92971 22.27029
[10,] -812.08971 -71.92971
[11,] 128.05029 -812.08971
[12,] 1001.17029 128.05029
[13,] -642.80971 1001.17029
[14,] -444.57676 -642.80971
[15,] 233.46324 -444.57676
[16,] -1416.81353 233.46324
[17,] -1230.21353 -1416.81353
[18,] -135.65353 -1230.21353
[19,] -2547.79353 -135.65353
[20,] -442.81353 -2547.79353
[21,] -1558.21353 -442.81353
[22,] -2190.47353 -1558.21353
[23,] -1543.33353 -2190.47353
[24,] -1431.51353 -1543.33353
[25,] -1152.39353 -1431.51353
[26,] 426.52324 -1152.39353
[27,] -463.43676 426.52324
[28,] -8.11353 -463.43676
[29,] -407.91353 -8.11353
[30,] 142.54647 -407.91353
[31,] -1123.19353 142.54647
[32,] -50.21353 -1123.19353
[33,] -509.21353 -50.21353
[34,] -125.17353 -509.21353
[35,] 26.66647 -125.17353
[36,] -1082.51353 26.66647
[37,] 1075.50647 -1082.51353
[38,] 1129.62324 1075.50647
[39,] 70.56324 1129.62324
[40,] 1974.18647 70.56324
[41,] 2182.08647 1974.18647
[42,] 166.34647 2182.08647
[43,] 3234.50647 166.34647
[44,] 1461.18647 3234.50647
[45,] 2545.68647 1461.18647
[46,] 2627.52647 2545.68647
[47,] 565.36647 2627.52647
[48,] 1890.58647 565.36647
[49,] 1237.00647 1890.58647
[50,] -1692.47676 1237.00647
[51,] -1433.33676 -1692.47676
[52,] -303.32971 -1433.33676
[53,] 159.27029 -303.32971
[54,] -783.86971 159.27029
[55,] -379.60971 -783.86971
[56,] -990.42971 -379.60971
[57,] -406.32971 -990.42971
[58,] 500.21029 -406.32971
[59,] 823.25029 500.21029
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -517.30971 -377.72971
2 580.90706 -517.30971
3 1592.74706 580.90706
4 -245.92971 1592.74706
5 -703.22971 -245.92971
6 610.63029 -703.22971
7 816.09029 610.63029
8 22.27029 816.09029
9 -71.92971 22.27029
10 -812.08971 -71.92971
11 128.05029 -812.08971
12 1001.17029 128.05029
13 -642.80971 1001.17029
14 -444.57676 -642.80971
15 233.46324 -444.57676
16 -1416.81353 233.46324
17 -1230.21353 -1416.81353
18 -135.65353 -1230.21353
19 -2547.79353 -135.65353
20 -442.81353 -2547.79353
21 -1558.21353 -442.81353
22 -2190.47353 -1558.21353
23 -1543.33353 -2190.47353
24 -1431.51353 -1543.33353
25 -1152.39353 -1431.51353
26 426.52324 -1152.39353
27 -463.43676 426.52324
28 -8.11353 -463.43676
29 -407.91353 -8.11353
30 142.54647 -407.91353
31 -1123.19353 142.54647
32 -50.21353 -1123.19353
33 -509.21353 -50.21353
34 -125.17353 -509.21353
35 26.66647 -125.17353
36 -1082.51353 26.66647
37 1075.50647 -1082.51353
38 1129.62324 1075.50647
39 70.56324 1129.62324
40 1974.18647 70.56324
41 2182.08647 1974.18647
42 166.34647 2182.08647
43 3234.50647 166.34647
44 1461.18647 3234.50647
45 2545.68647 1461.18647
46 2627.52647 2545.68647
47 565.36647 2627.52647
48 1890.58647 565.36647
49 1237.00647 1890.58647
50 -1692.47676 1237.00647
51 -1433.33676 -1692.47676
52 -303.32971 -1433.33676
53 159.27029 -303.32971
54 -783.86971 159.27029
55 -379.60971 -783.86971
56 -990.42971 -379.60971
57 -406.32971 -990.42971
58 500.21029 -406.32971
59 823.25029 500.21029
> 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/71zhg1258561101.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/82fgu1258561101.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/9m6lg1258561101.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/107lu71258561101.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/11vrjp1258561101.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/12n6121258561101.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/13giuv1258561101.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/14mhmb1258561101.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/15ghc71258561101.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/16nyjo1258561101.tab")
+ }
> system("convert tmp/1bk111258561101.ps tmp/1bk111258561101.png")
> system("convert tmp/25rrf1258561101.ps tmp/25rrf1258561101.png")
> system("convert tmp/332lc1258561101.ps tmp/332lc1258561101.png")
> system("convert tmp/4yp551258561101.ps tmp/4yp551258561101.png")
> system("convert tmp/5ya881258561101.ps tmp/5ya881258561101.png")
> system("convert tmp/6agiz1258561101.ps tmp/6agiz1258561101.png")
> system("convert tmp/71zhg1258561101.ps tmp/71zhg1258561101.png")
> system("convert tmp/82fgu1258561101.ps tmp/82fgu1258561101.png")
> system("convert tmp/9m6lg1258561101.ps tmp/9m6lg1258561101.png")
> system("convert tmp/107lu71258561101.ps tmp/107lu71258561101.png")
>
>
> proc.time()
user system elapsed
2.463 1.605 5.323