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(277128,0,277915,277103,0,277128,275037,0,277103,270150,0,275037,267140,0,270150,264993,0,267140,287259,0,264993,291186,0,287259,292300,0,291186,288186,0,292300,281477,0,288186,282656,0,281477,280190,0,282656,280408,0,280190,276836,0,280408,275216,0,276836,274352,0,275216,271311,0,274352,289802,0,271311,290726,0,289802,292300,0,290726,278506,0,292300,269826,0,278506,265861,0,269826,269034,0,265861,264176,0,269034,255198,0,264176,253353,0,255198,246057,0,253353,235372,0,246057,258556,0,235372,260993,0,258556,254663,0,260993,250643,0,254663,243422,0,250643,247105,0,243422,248541,0,247105,245039,0,248541,237080,0,245039,237085,0,237080,225554,0,237085,226839,1,225554,247934,1,226839,248333,1,247934,246969,1,248333,245098,1,246969,246263,1,245098,255765,1,246263,264319,1,255765,268347,1,264319,273046,1,268347,273963,1,273046,267430,1,273963,271993,1,267430,292710,1,271993,295881,1,292710),dim=c(3,56),dimnames=list(c('nwwmb','dummy_variable','y[t-1]'),1:56))
> y <- array(NA,dim=c(3,56),dimnames=list(c('nwwmb','dummy_variable','y[t-1]'),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 = '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
nwwmb dummy_variable y[t-1] M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 277128 0 277915 1 0 0 0 0 0 0 0 0 0 0 1
2 277103 0 277128 0 1 0 0 0 0 0 0 0 0 0 2
3 275037 0 277103 0 0 1 0 0 0 0 0 0 0 0 3
4 270150 0 275037 0 0 0 1 0 0 0 0 0 0 0 4
5 267140 0 270150 0 0 0 0 1 0 0 0 0 0 0 5
6 264993 0 267140 0 0 0 0 0 1 0 0 0 0 0 6
7 287259 0 264993 0 0 0 0 0 0 1 0 0 0 0 7
8 291186 0 287259 0 0 0 0 0 0 0 1 0 0 0 8
9 292300 0 291186 0 0 0 0 0 0 0 0 1 0 0 9
10 288186 0 292300 0 0 0 0 0 0 0 0 0 1 0 10
11 281477 0 288186 0 0 0 0 0 0 0 0 0 0 1 11
12 282656 0 281477 0 0 0 0 0 0 0 0 0 0 0 12
13 280190 0 282656 1 0 0 0 0 0 0 0 0 0 0 13
14 280408 0 280190 0 1 0 0 0 0 0 0 0 0 0 14
15 276836 0 280408 0 0 1 0 0 0 0 0 0 0 0 15
16 275216 0 276836 0 0 0 1 0 0 0 0 0 0 0 16
17 274352 0 275216 0 0 0 0 1 0 0 0 0 0 0 17
18 271311 0 274352 0 0 0 0 0 1 0 0 0 0 0 18
19 289802 0 271311 0 0 0 0 0 0 1 0 0 0 0 19
20 290726 0 289802 0 0 0 0 0 0 0 1 0 0 0 20
21 292300 0 290726 0 0 0 0 0 0 0 0 1 0 0 21
22 278506 0 292300 0 0 0 0 0 0 0 0 0 1 0 22
23 269826 0 278506 0 0 0 0 0 0 0 0 0 0 1 23
24 265861 0 269826 0 0 0 0 0 0 0 0 0 0 0 24
25 269034 0 265861 1 0 0 0 0 0 0 0 0 0 0 25
26 264176 0 269034 0 1 0 0 0 0 0 0 0 0 0 26
27 255198 0 264176 0 0 1 0 0 0 0 0 0 0 0 27
28 253353 0 255198 0 0 0 1 0 0 0 0 0 0 0 28
29 246057 0 253353 0 0 0 0 1 0 0 0 0 0 0 29
30 235372 0 246057 0 0 0 0 0 1 0 0 0 0 0 30
31 258556 0 235372 0 0 0 0 0 0 1 0 0 0 0 31
32 260993 0 258556 0 0 0 0 0 0 0 1 0 0 0 32
33 254663 0 260993 0 0 0 0 0 0 0 0 1 0 0 33
34 250643 0 254663 0 0 0 0 0 0 0 0 0 1 0 34
35 243422 0 250643 0 0 0 0 0 0 0 0 0 0 1 35
36 247105 0 243422 0 0 0 0 0 0 0 0 0 0 0 36
37 248541 0 247105 1 0 0 0 0 0 0 0 0 0 0 37
38 245039 0 248541 0 1 0 0 0 0 0 0 0 0 0 38
39 237080 0 245039 0 0 1 0 0 0 0 0 0 0 0 39
40 237085 0 237080 0 0 0 1 0 0 0 0 0 0 0 40
41 225554 0 237085 0 0 0 0 1 0 0 0 0 0 0 41
42 226839 1 225554 0 0 0 0 0 1 0 0 0 0 0 42
43 247934 1 226839 0 0 0 0 0 0 1 0 0 0 0 43
44 248333 1 247934 0 0 0 0 0 0 0 1 0 0 0 44
45 246969 1 248333 0 0 0 0 0 0 0 0 1 0 0 45
46 245098 1 246969 0 0 0 0 0 0 0 0 0 1 0 46
47 246263 1 245098 0 0 0 0 0 0 0 0 0 0 1 47
48 255765 1 246263 0 0 0 0 0 0 0 0 0 0 0 48
49 264319 1 255765 1 0 0 0 0 0 0 0 0 0 0 49
50 268347 1 264319 0 1 0 0 0 0 0 0 0 0 0 50
51 273046 1 268347 0 0 1 0 0 0 0 0 0 0 0 51
52 273963 1 273046 0 0 0 1 0 0 0 0 0 0 0 52
53 267430 1 273963 0 0 0 0 1 0 0 0 0 0 0 53
54 271993 1 267430 0 0 0 0 0 1 0 0 0 0 0 54
55 292710 1 271993 0 0 0 0 0 0 1 0 0 0 0 55
56 295881 1 292710 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) dummy_variable `y[t-1]` M1 M2
6488.0927 6674.2030 0.9881 -628.6559 -3332.6772
M3 M4 M5 M6 M7
-6007.6535 -3878.6440 -8174.8338 -5655.0309 17559.0183
M8 M9 M10 M11 t
-1086.6535 -3948.8727 -8579.7287 -7979.6074 -82.2505
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6423.0 -2412.4 323.4 2542.8 5488.1
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.488e+03 1.036e+04 0.626 0.534654
dummy_variable 6.674e+03 1.763e+03 3.785 0.000492 ***
`y[t-1]` 9.881e-01 3.595e-02 27.490 < 2e-16 ***
M1 -6.287e+02 2.380e+03 -0.264 0.792995
M2 -3.333e+03 2.383e+03 -1.399 0.169400
M3 -6.008e+03 2.381e+03 -2.523 0.015594 *
M4 -3.879e+03 2.375e+03 -1.633 0.110043
M5 -8.175e+03 2.374e+03 -3.444 0.001336 **
M6 -5.655e+03 2.396e+03 -2.360 0.023125 *
M7 1.756e+04 2.397e+03 7.325 5.76e-09 ***
M8 -1.087e+03 2.438e+03 -0.446 0.658180
M9 -3.949e+03 2.530e+03 -1.561 0.126312
M10 -8.580e+03 2.526e+03 -3.396 0.001529 **
M11 -7.980e+03 2.507e+03 -3.184 0.002777 **
t -8.225e+01 5.523e+01 -1.489 0.144095
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3537 on 41 degrees of freedom
Multiple R-squared: 0.9716, Adjusted R-squared: 0.9619
F-statistic: 100.3 on 14 and 41 DF, p-value: < 2.2e-16
> 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.09936178 0.19872355 0.9006382
[2,] 0.06014490 0.12028980 0.9398551
[3,] 0.05801130 0.11602261 0.9419887
[4,] 0.04774038 0.09548076 0.9522596
[5,] 0.31319123 0.62638246 0.6868088
[6,] 0.21442634 0.42885267 0.7855737
[7,] 0.19018569 0.38037139 0.8098143
[8,] 0.32592795 0.65185590 0.6740720
[9,] 0.29066923 0.58133846 0.7093308
[10,] 0.30687401 0.61374803 0.6931260
[11,] 0.25482082 0.50964165 0.7451792
[12,] 0.22794374 0.45588748 0.7720563
[13,] 0.49782988 0.99565975 0.5021701
[14,] 0.66945307 0.66109387 0.3305469
[15,] 0.79879848 0.40240304 0.2012015
[16,] 0.76416135 0.47167731 0.2358387
[17,] 0.86497536 0.27004928 0.1350246
[18,] 0.77620971 0.44758059 0.2237903
[19,] 0.76291187 0.47417627 0.2370881
[20,] 0.73000336 0.53999329 0.2699966
[21,] 0.87044998 0.25910004 0.1295500
> postscript(file="/var/www/html/rcomp/tmp/1hsr31258995183.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/2litt1258995183.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/3ht6u1258995183.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/4vpie1258995183.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/5b07g1258995183.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
-3265.07172 273.85762 989.78762 -3902.49674 2294.93016 684.64627
7 8 9 10 11 12
1940.36060 2593.60146 2771.68834 2270.01907 -891.68884 -980.68791
13 14 15 16 17 18
-3900.78563 1540.21240 510.02703 372.86502 5488.07431 863.26548
19 20 21 22 23 24
-772.63282 607.79521 4213.23364 -6422.97500 -1990.59368 -5275.99039
25 26 27 28 29 30
2525.84773 -2681.21397 -4101.65627 878.00738 -216.45429 -6129.61707
31 32 33 34 35 36
4480.74310 2736.88149 -3056.71933 3891.24406 124.65202 3045.57502
37 38 39 40 41 42
1553.20216 -581.47938 -2322.82467 3499.93547 -3657.56495 -90.20422
43 44 45 46 47 48
-3396.74880 -5114.40883 -3928.20264 261.71187 2757.63050 3211.10328
49 50 51 52 53 54
3086.80746 1448.62333 4924.66628 -848.31112 -3908.98523 4671.90953
55 56
-2251.72208 -823.86933
> postscript(file="/var/www/html/rcomp/tmp/6bpzf1258995183.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 -3265.07172 NA
1 273.85762 -3265.07172
2 989.78762 273.85762
3 -3902.49674 989.78762
4 2294.93016 -3902.49674
5 684.64627 2294.93016
6 1940.36060 684.64627
7 2593.60146 1940.36060
8 2771.68834 2593.60146
9 2270.01907 2771.68834
10 -891.68884 2270.01907
11 -980.68791 -891.68884
12 -3900.78563 -980.68791
13 1540.21240 -3900.78563
14 510.02703 1540.21240
15 372.86502 510.02703
16 5488.07431 372.86502
17 863.26548 5488.07431
18 -772.63282 863.26548
19 607.79521 -772.63282
20 4213.23364 607.79521
21 -6422.97500 4213.23364
22 -1990.59368 -6422.97500
23 -5275.99039 -1990.59368
24 2525.84773 -5275.99039
25 -2681.21397 2525.84773
26 -4101.65627 -2681.21397
27 878.00738 -4101.65627
28 -216.45429 878.00738
29 -6129.61707 -216.45429
30 4480.74310 -6129.61707
31 2736.88149 4480.74310
32 -3056.71933 2736.88149
33 3891.24406 -3056.71933
34 124.65202 3891.24406
35 3045.57502 124.65202
36 1553.20216 3045.57502
37 -581.47938 1553.20216
38 -2322.82467 -581.47938
39 3499.93547 -2322.82467
40 -3657.56495 3499.93547
41 -90.20422 -3657.56495
42 -3396.74880 -90.20422
43 -5114.40883 -3396.74880
44 -3928.20264 -5114.40883
45 261.71187 -3928.20264
46 2757.63050 261.71187
47 3211.10328 2757.63050
48 3086.80746 3211.10328
49 1448.62333 3086.80746
50 4924.66628 1448.62333
51 -848.31112 4924.66628
52 -3908.98523 -848.31112
53 4671.90953 -3908.98523
54 -2251.72208 4671.90953
55 -823.86933 -2251.72208
56 NA -823.86933
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 273.85762 -3265.07172
[2,] 989.78762 273.85762
[3,] -3902.49674 989.78762
[4,] 2294.93016 -3902.49674
[5,] 684.64627 2294.93016
[6,] 1940.36060 684.64627
[7,] 2593.60146 1940.36060
[8,] 2771.68834 2593.60146
[9,] 2270.01907 2771.68834
[10,] -891.68884 2270.01907
[11,] -980.68791 -891.68884
[12,] -3900.78563 -980.68791
[13,] 1540.21240 -3900.78563
[14,] 510.02703 1540.21240
[15,] 372.86502 510.02703
[16,] 5488.07431 372.86502
[17,] 863.26548 5488.07431
[18,] -772.63282 863.26548
[19,] 607.79521 -772.63282
[20,] 4213.23364 607.79521
[21,] -6422.97500 4213.23364
[22,] -1990.59368 -6422.97500
[23,] -5275.99039 -1990.59368
[24,] 2525.84773 -5275.99039
[25,] -2681.21397 2525.84773
[26,] -4101.65627 -2681.21397
[27,] 878.00738 -4101.65627
[28,] -216.45429 878.00738
[29,] -6129.61707 -216.45429
[30,] 4480.74310 -6129.61707
[31,] 2736.88149 4480.74310
[32,] -3056.71933 2736.88149
[33,] 3891.24406 -3056.71933
[34,] 124.65202 3891.24406
[35,] 3045.57502 124.65202
[36,] 1553.20216 3045.57502
[37,] -581.47938 1553.20216
[38,] -2322.82467 -581.47938
[39,] 3499.93547 -2322.82467
[40,] -3657.56495 3499.93547
[41,] -90.20422 -3657.56495
[42,] -3396.74880 -90.20422
[43,] -5114.40883 -3396.74880
[44,] -3928.20264 -5114.40883
[45,] 261.71187 -3928.20264
[46,] 2757.63050 261.71187
[47,] 3211.10328 2757.63050
[48,] 3086.80746 3211.10328
[49,] 1448.62333 3086.80746
[50,] 4924.66628 1448.62333
[51,] -848.31112 4924.66628
[52,] -3908.98523 -848.31112
[53,] 4671.90953 -3908.98523
[54,] -2251.72208 4671.90953
[55,] -823.86933 -2251.72208
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 273.85762 -3265.07172
2 989.78762 273.85762
3 -3902.49674 989.78762
4 2294.93016 -3902.49674
5 684.64627 2294.93016
6 1940.36060 684.64627
7 2593.60146 1940.36060
8 2771.68834 2593.60146
9 2270.01907 2771.68834
10 -891.68884 2270.01907
11 -980.68791 -891.68884
12 -3900.78563 -980.68791
13 1540.21240 -3900.78563
14 510.02703 1540.21240
15 372.86502 510.02703
16 5488.07431 372.86502
17 863.26548 5488.07431
18 -772.63282 863.26548
19 607.79521 -772.63282
20 4213.23364 607.79521
21 -6422.97500 4213.23364
22 -1990.59368 -6422.97500
23 -5275.99039 -1990.59368
24 2525.84773 -5275.99039
25 -2681.21397 2525.84773
26 -4101.65627 -2681.21397
27 878.00738 -4101.65627
28 -216.45429 878.00738
29 -6129.61707 -216.45429
30 4480.74310 -6129.61707
31 2736.88149 4480.74310
32 -3056.71933 2736.88149
33 3891.24406 -3056.71933
34 124.65202 3891.24406
35 3045.57502 124.65202
36 1553.20216 3045.57502
37 -581.47938 1553.20216
38 -2322.82467 -581.47938
39 3499.93547 -2322.82467
40 -3657.56495 3499.93547
41 -90.20422 -3657.56495
42 -3396.74880 -90.20422
43 -5114.40883 -3396.74880
44 -3928.20264 -5114.40883
45 261.71187 -3928.20264
46 2757.63050 261.71187
47 3211.10328 2757.63050
48 3086.80746 3211.10328
49 1448.62333 3086.80746
50 4924.66628 1448.62333
51 -848.31112 4924.66628
52 -3908.98523 -848.31112
53 4671.90953 -3908.98523
54 -2251.72208 4671.90953
55 -823.86933 -2251.72208
> 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/796o61258995183.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/8mb4p1258995183.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/988uc1258995183.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/101gje1258995183.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/11vfe91258995183.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/120ok11258995183.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/13stdg1258995183.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/14ycgz1258995183.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/152jly1258995183.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/16rasd1258995183.tab")
+ }
>
> system("convert tmp/1hsr31258995183.ps tmp/1hsr31258995183.png")
> system("convert tmp/2litt1258995183.ps tmp/2litt1258995183.png")
> system("convert tmp/3ht6u1258995183.ps tmp/3ht6u1258995183.png")
> system("convert tmp/4vpie1258995183.ps tmp/4vpie1258995183.png")
> system("convert tmp/5b07g1258995183.ps tmp/5b07g1258995183.png")
> system("convert tmp/6bpzf1258995183.ps tmp/6bpzf1258995183.png")
> system("convert tmp/796o61258995183.ps tmp/796o61258995183.png")
> system("convert tmp/8mb4p1258995183.ps tmp/8mb4p1258995183.png")
> system("convert tmp/988uc1258995183.ps tmp/988uc1258995183.png")
> system("convert tmp/101gje1258995183.ps tmp/101gje1258995183.png")
>
>
> proc.time()
user system elapsed
2.339 1.537 3.586