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.4,99,8.4,98.6,8.4,98.6,8.6,98.5,8.9,98.9,8.8,99.4,8.3,99.8,7.5,99.9,7.2,100,7.4,100.1,8.8,100.1,9.3,100.2,9.3,100.3,8.7,100,8.2,99.9,8.3,99.4,8.5,99.8,8.6,99.6,8.5,100,8.2,99.9,8.1,100.3,7.9,100.6,8.6,100.7,8.7,100.8,8.7,100.8,8.5,100.6,8.4,101.1,8.5,101.1,8.7,100.9,8.7,101.1,8.6,101.2,8.5,101.4,8.3,101.9,8,102.1,8.2,102.1,8.1,103,8.1,103.4,8,103.2,7.9,103.1,7.9,103,8,103.7,8,103.4,7.9,103.5,8,103.8,7.7,104,7.2,104.2,7.5,104.4,7.3,104.4,7,104.9,7,105.3,7,105.2,7.2,105.4,7.3,105.4,7.1,105.5,6.8,105.7,6.4,105.6,6.1,105.8,6.5,105.4,7.7,105.5,7.9,105.8,7.5,106.1,6.9,106,6.6,105.5,6.9,105.4,7.7,106,8,106.1,8,106.4,7.7,106,7.3,106,7.4,106,8.1,106,8.3,106.1,8.2,106.1),dim=c(2,73),dimnames=list(c('werkl','afzetp'),1:73))
> y <- array(NA,dim=c(2,73),dimnames=list(c('werkl','afzetp'),1:73))
> 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
werkl afzetp M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 8.4 99.0 1 0 0 0 0 0 0 0 0 0 0
2 8.4 98.6 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 98.5 0 0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 0 0 0 0 0 1 0 0 0
69 7.3 106.0 0 0 0 0 0 0 0 0 1 0 0
70 7.4 106.0 0 0 0 0 0 0 0 0 0 1 0
71 8.1 106.0 0 0 0 0 0 0 0 0 0 0 1
72 8.3 106.1 0 0 0 0 0 0 0 0 0 0 0
73 8.2 106.1 1 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) afzetp M1 M2 M3 M4
27.8625 -0.1895 -0.1787 -0.5585 -0.7346 -0.6036
M5 M6 M7 M8 M9 M10
-0.2602 -0.2309 -0.3669 -0.6669 -0.8893 -0.9267
M11
-0.1641
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.81927 -0.23933 0.01132 0.31427 0.67201
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 27.86246 2.11395 13.180 < 2e-16 ***
afzetp -0.18954 0.02037 -9.304 3.05e-13 ***
M1 -0.17873 0.24758 -0.722 0.473153
M2 -0.55850 0.25773 -2.167 0.034215 *
M3 -0.73464 0.25782 -2.849 0.005993 **
M4 -0.60360 0.25801 -2.339 0.022661 *
M5 -0.26024 0.25746 -1.011 0.316161
M6 -0.23094 0.25736 -0.897 0.373124
M7 -0.36689 0.25706 -1.427 0.158695
M8 -0.66689 0.25706 -2.594 0.011895 *
M9 -0.88933 0.25687 -3.462 0.000994 ***
M10 -0.92669 0.25683 -3.608 0.000630 ***
M11 -0.16405 0.25680 -0.639 0.525367
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4447 on 60 degrees of freedom
Multiple R-squared: 0.6588, Adjusted R-squared: 0.5905
F-statistic: 9.653 on 12 and 60 DF, p-value: 4.303e-10
> 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.455070841 0.91014168 0.5449292
[2,] 0.407600088 0.81520018 0.5923999
[3,] 0.285990130 0.57198026 0.7140099
[4,] 0.187834774 0.37566955 0.8121652
[5,] 0.238518006 0.47703601 0.7614820
[6,] 0.333649669 0.66729934 0.6663503
[7,] 0.280598060 0.56119612 0.7194019
[8,] 0.213678043 0.42735609 0.7863220
[9,] 0.219912813 0.43982563 0.7800872
[10,] 0.162045409 0.32409082 0.8379546
[11,] 0.110119988 0.22023998 0.8898800
[12,] 0.073895203 0.14779041 0.9261048
[13,] 0.047569424 0.09513885 0.9524306
[14,] 0.028457742 0.05691548 0.9715423
[15,] 0.016373176 0.03274635 0.9836268
[16,] 0.009548809 0.01909762 0.9904512
[17,] 0.010747158 0.02149432 0.9892528
[18,] 0.011471793 0.02294359 0.9885282
[19,] 0.007275779 0.01455156 0.9927242
[20,] 0.009001583 0.01800317 0.9909984
[21,] 0.022902321 0.04580464 0.9770977
[22,] 0.023866233 0.04773247 0.9761338
[23,] 0.020548597 0.04109719 0.9794514
[24,] 0.018458506 0.03691701 0.9815415
[25,] 0.015460004 0.03092001 0.9845400
[26,] 0.011409705 0.02281941 0.9885903
[27,] 0.008266812 0.01653362 0.9917332
[28,] 0.005965023 0.01193005 0.9940350
[29,] 0.011750253 0.02350051 0.9882497
[30,] 0.074654560 0.14930912 0.9253454
[31,] 0.160198428 0.32039686 0.8398016
[32,] 0.198597880 0.39719576 0.8014021
[33,] 0.296482073 0.59296415 0.7035179
[34,] 0.363679357 0.72735871 0.6363206
[35,] 0.522944172 0.95411166 0.4770558
[36,] 0.629651513 0.74069697 0.3703485
[37,] 0.550661878 0.89867624 0.4493381
[38,] 0.550801337 0.89839733 0.4491987
[39,] 0.451564363 0.90312873 0.5484356
[40,] 0.346067125 0.69213425 0.6539329
[41,] 0.374453598 0.74890720 0.6255464
[42,] 0.649561993 0.70087601 0.3504380
> postscript(file="/var/www/html/rcomp/tmp/1j7ak1258201126.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/23wgc1258201126.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/3o3lv1258201126.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/4u1qm1258201126.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/5ut0e1258201126.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 = 73
Frequency = 1
1 2 3 4 5 6
-0.518777319 -0.214823981 -0.038680065 0.011319935 0.043782016 0.009251503
7 8 9 10 11 12
-0.278983417 -0.760028920 -0.818634916 -0.562316751 0.075046918 0.429948505
13 14 15 16 17 18
0.627631145 0.350538980 0.007728398 -0.118089591 -0.185627510 -0.152839502
19 20 21 22 23 24
-0.041074423 -0.060028920 0.138228575 0.032455735 -0.011226099 -0.056324511
25 26 27 28 29 30
0.122403631 0.264265964 0.435182365 0.404136862 0.222871960 0.231477956
31 32 33 34 35 36
0.286379544 0.524288538 0.641500531 0.416773194 -0.145863138 -0.239325573
37 38 39 40 41 42
0.015220559 0.257082891 0.314272309 0.164272309 0.053597882 -0.032568608
43 44 45 46 47 48
0.022332980 0.479196471 0.439544972 0.014817635 -0.409909702 -0.773962612
49 50 51 52 53 54
-0.800461983 -0.344872667 -0.187683249 -0.080819758 -0.324175665 -0.534524166
55 56 57 58 59 60
-0.660668082 -0.779622579 -0.819274078 -0.457728398 -0.001410233 0.091400349
61 62 63 64 65 66
-0.073008017 -0.312191187 -0.530819758 -0.380819758 0.189551318 0.479202817
67 68 69 70 71 72
0.672013399 0.596195410 0.418634916 0.555998585 0.493362253 0.548263841
73
0.626991983
> postscript(file="/var/www/html/rcomp/tmp/6wnt41258201126.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 = 73
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.518777319 NA
1 -0.214823981 -0.518777319
2 -0.038680065 -0.214823981
3 0.011319935 -0.038680065
4 0.043782016 0.011319935
5 0.009251503 0.043782016
6 -0.278983417 0.009251503
7 -0.760028920 -0.278983417
8 -0.818634916 -0.760028920
9 -0.562316751 -0.818634916
10 0.075046918 -0.562316751
11 0.429948505 0.075046918
12 0.627631145 0.429948505
13 0.350538980 0.627631145
14 0.007728398 0.350538980
15 -0.118089591 0.007728398
16 -0.185627510 -0.118089591
17 -0.152839502 -0.185627510
18 -0.041074423 -0.152839502
19 -0.060028920 -0.041074423
20 0.138228575 -0.060028920
21 0.032455735 0.138228575
22 -0.011226099 0.032455735
23 -0.056324511 -0.011226099
24 0.122403631 -0.056324511
25 0.264265964 0.122403631
26 0.435182365 0.264265964
27 0.404136862 0.435182365
28 0.222871960 0.404136862
29 0.231477956 0.222871960
30 0.286379544 0.231477956
31 0.524288538 0.286379544
32 0.641500531 0.524288538
33 0.416773194 0.641500531
34 -0.145863138 0.416773194
35 -0.239325573 -0.145863138
36 0.015220559 -0.239325573
37 0.257082891 0.015220559
38 0.314272309 0.257082891
39 0.164272309 0.314272309
40 0.053597882 0.164272309
41 -0.032568608 0.053597882
42 0.022332980 -0.032568608
43 0.479196471 0.022332980
44 0.439544972 0.479196471
45 0.014817635 0.439544972
46 -0.409909702 0.014817635
47 -0.773962612 -0.409909702
48 -0.800461983 -0.773962612
49 -0.344872667 -0.800461983
50 -0.187683249 -0.344872667
51 -0.080819758 -0.187683249
52 -0.324175665 -0.080819758
53 -0.534524166 -0.324175665
54 -0.660668082 -0.534524166
55 -0.779622579 -0.660668082
56 -0.819274078 -0.779622579
57 -0.457728398 -0.819274078
58 -0.001410233 -0.457728398
59 0.091400349 -0.001410233
60 -0.073008017 0.091400349
61 -0.312191187 -0.073008017
62 -0.530819758 -0.312191187
63 -0.380819758 -0.530819758
64 0.189551318 -0.380819758
65 0.479202817 0.189551318
66 0.672013399 0.479202817
67 0.596195410 0.672013399
68 0.418634916 0.596195410
69 0.555998585 0.418634916
70 0.493362253 0.555998585
71 0.548263841 0.493362253
72 0.626991983 0.548263841
73 NA 0.626991983
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.214823981 -0.518777319
[2,] -0.038680065 -0.214823981
[3,] 0.011319935 -0.038680065
[4,] 0.043782016 0.011319935
[5,] 0.009251503 0.043782016
[6,] -0.278983417 0.009251503
[7,] -0.760028920 -0.278983417
[8,] -0.818634916 -0.760028920
[9,] -0.562316751 -0.818634916
[10,] 0.075046918 -0.562316751
[11,] 0.429948505 0.075046918
[12,] 0.627631145 0.429948505
[13,] 0.350538980 0.627631145
[14,] 0.007728398 0.350538980
[15,] -0.118089591 0.007728398
[16,] -0.185627510 -0.118089591
[17,] -0.152839502 -0.185627510
[18,] -0.041074423 -0.152839502
[19,] -0.060028920 -0.041074423
[20,] 0.138228575 -0.060028920
[21,] 0.032455735 0.138228575
[22,] -0.011226099 0.032455735
[23,] -0.056324511 -0.011226099
[24,] 0.122403631 -0.056324511
[25,] 0.264265964 0.122403631
[26,] 0.435182365 0.264265964
[27,] 0.404136862 0.435182365
[28,] 0.222871960 0.404136862
[29,] 0.231477956 0.222871960
[30,] 0.286379544 0.231477956
[31,] 0.524288538 0.286379544
[32,] 0.641500531 0.524288538
[33,] 0.416773194 0.641500531
[34,] -0.145863138 0.416773194
[35,] -0.239325573 -0.145863138
[36,] 0.015220559 -0.239325573
[37,] 0.257082891 0.015220559
[38,] 0.314272309 0.257082891
[39,] 0.164272309 0.314272309
[40,] 0.053597882 0.164272309
[41,] -0.032568608 0.053597882
[42,] 0.022332980 -0.032568608
[43,] 0.479196471 0.022332980
[44,] 0.439544972 0.479196471
[45,] 0.014817635 0.439544972
[46,] -0.409909702 0.014817635
[47,] -0.773962612 -0.409909702
[48,] -0.800461983 -0.773962612
[49,] -0.344872667 -0.800461983
[50,] -0.187683249 -0.344872667
[51,] -0.080819758 -0.187683249
[52,] -0.324175665 -0.080819758
[53,] -0.534524166 -0.324175665
[54,] -0.660668082 -0.534524166
[55,] -0.779622579 -0.660668082
[56,] -0.819274078 -0.779622579
[57,] -0.457728398 -0.819274078
[58,] -0.001410233 -0.457728398
[59,] 0.091400349 -0.001410233
[60,] -0.073008017 0.091400349
[61,] -0.312191187 -0.073008017
[62,] -0.530819758 -0.312191187
[63,] -0.380819758 -0.530819758
[64,] 0.189551318 -0.380819758
[65,] 0.479202817 0.189551318
[66,] 0.672013399 0.479202817
[67,] 0.596195410 0.672013399
[68,] 0.418634916 0.596195410
[69,] 0.555998585 0.418634916
[70,] 0.493362253 0.555998585
[71,] 0.548263841 0.493362253
[72,] 0.626991983 0.548263841
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.214823981 -0.518777319
2 -0.038680065 -0.214823981
3 0.011319935 -0.038680065
4 0.043782016 0.011319935
5 0.009251503 0.043782016
6 -0.278983417 0.009251503
7 -0.760028920 -0.278983417
8 -0.818634916 -0.760028920
9 -0.562316751 -0.818634916
10 0.075046918 -0.562316751
11 0.429948505 0.075046918
12 0.627631145 0.429948505
13 0.350538980 0.627631145
14 0.007728398 0.350538980
15 -0.118089591 0.007728398
16 -0.185627510 -0.118089591
17 -0.152839502 -0.185627510
18 -0.041074423 -0.152839502
19 -0.060028920 -0.041074423
20 0.138228575 -0.060028920
21 0.032455735 0.138228575
22 -0.011226099 0.032455735
23 -0.056324511 -0.011226099
24 0.122403631 -0.056324511
25 0.264265964 0.122403631
26 0.435182365 0.264265964
27 0.404136862 0.435182365
28 0.222871960 0.404136862
29 0.231477956 0.222871960
30 0.286379544 0.231477956
31 0.524288538 0.286379544
32 0.641500531 0.524288538
33 0.416773194 0.641500531
34 -0.145863138 0.416773194
35 -0.239325573 -0.145863138
36 0.015220559 -0.239325573
37 0.257082891 0.015220559
38 0.314272309 0.257082891
39 0.164272309 0.314272309
40 0.053597882 0.164272309
41 -0.032568608 0.053597882
42 0.022332980 -0.032568608
43 0.479196471 0.022332980
44 0.439544972 0.479196471
45 0.014817635 0.439544972
46 -0.409909702 0.014817635
47 -0.773962612 -0.409909702
48 -0.800461983 -0.773962612
49 -0.344872667 -0.800461983
50 -0.187683249 -0.344872667
51 -0.080819758 -0.187683249
52 -0.324175665 -0.080819758
53 -0.534524166 -0.324175665
54 -0.660668082 -0.534524166
55 -0.779622579 -0.660668082
56 -0.819274078 -0.779622579
57 -0.457728398 -0.819274078
58 -0.001410233 -0.457728398
59 0.091400349 -0.001410233
60 -0.073008017 0.091400349
61 -0.312191187 -0.073008017
62 -0.530819758 -0.312191187
63 -0.380819758 -0.530819758
64 0.189551318 -0.380819758
65 0.479202817 0.189551318
66 0.672013399 0.479202817
67 0.596195410 0.672013399
68 0.418634916 0.596195410
69 0.555998585 0.418634916
70 0.493362253 0.555998585
71 0.548263841 0.493362253
72 0.626991983 0.548263841
> 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/7fusw1258201126.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/8z1vn1258201126.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/9gmtx1258201126.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/109k4h1258201126.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/11q8o61258201126.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/12nip61258201126.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/13i6kx1258201126.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/14p40r1258201126.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/15ai6p1258201126.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/16471w1258201126.tab")
+ }
>
> system("convert tmp/1j7ak1258201126.ps tmp/1j7ak1258201126.png")
> system("convert tmp/23wgc1258201126.ps tmp/23wgc1258201126.png")
> system("convert tmp/3o3lv1258201126.ps tmp/3o3lv1258201126.png")
> system("convert tmp/4u1qm1258201126.ps tmp/4u1qm1258201126.png")
> system("convert tmp/5ut0e1258201126.ps tmp/5ut0e1258201126.png")
> system("convert tmp/6wnt41258201126.ps tmp/6wnt41258201126.png")
> system("convert tmp/7fusw1258201126.ps tmp/7fusw1258201126.png")
> system("convert tmp/8z1vn1258201126.ps tmp/8z1vn1258201126.png")
> system("convert tmp/9gmtx1258201126.ps tmp/9gmtx1258201126.png")
> system("convert tmp/109k4h1258201126.ps tmp/109k4h1258201126.png")
>
>
> proc.time()
user system elapsed
2.562 1.552 3.498