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(100,0,95.84395716,0,105.5073942,1,118.1540031,1,101.8612953,1,109.8419174,1,105.6348802,1,112.927078,1,133.0698623,1,125.6756757,1,146.736359,1,142.5803162,1,106.1448241,1,126.5170831,1,132.7893932,1,121.2391637,1,114.5079041,1,146.1499235,1,146.1244263,1,128.5058644,1,155.5838858,1,125.0382458,1,136.8944416,1,142.2233554,1,117.7715451,1,120.627231,1,127.7664457,1,135.1096379,1,105.7113717,1,117.9245283,1,120.754717,1,107.572667,1,130.4436512,1,107.2157063,1,105.0739419,1,130.1121877,1,109.6379398,1,116.7261601,1,97.11881693,0,140.8975013,1,108.2865885,1,97.65425803,0,112.0346762,1,123.0494646,1,112.4171341,1,116.4966854,1,104.6914839,1,122.2335543,1,99.79602244,0,96.71086181,0,112.3151453,1,102.5497195,1,104.5385008,1,122.0805711,1,80.64762876,0,91.40744518,0,99.51555329,0,106.527282,1,98.49566548,0,106.7567568,1),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 100.00000 0 1 0 0 0 0 0 0 0 0 0 0
2 95.84396 0 0 1 0 0 0 0 0 0 0 0 0
3 105.50739 1 0 0 1 0 0 0 0 0 0 0 0
4 118.15400 1 0 0 0 1 0 0 0 0 0 0 0
5 101.86130 1 0 0 0 0 1 0 0 0 0 0 0
6 109.84192 1 0 0 0 0 0 1 0 0 0 0 0
7 105.63488 1 0 0 0 0 0 0 1 0 0 0 0
8 112.92708 1 0 0 0 0 0 0 0 1 0 0 0
9 133.06986 1 0 0 0 0 0 0 0 0 1 0 0
10 125.67568 1 0 0 0 0 0 0 0 0 0 1 0
11 146.73636 1 0 0 0 0 0 0 0 0 0 0 1
12 142.58032 1 0 0 0 0 0 0 0 0 0 0 0
13 106.14482 1 1 0 0 0 0 0 0 0 0 0 0
14 126.51708 1 0 1 0 0 0 0 0 0 0 0 0
15 132.78939 1 0 0 1 0 0 0 0 0 0 0 0
16 121.23916 1 0 0 0 1 0 0 0 0 0 0 0
17 114.50790 1 0 0 0 0 1 0 0 0 0 0 0
18 146.14992 1 0 0 0 0 0 1 0 0 0 0 0
19 146.12443 1 0 0 0 0 0 0 1 0 0 0 0
20 128.50586 1 0 0 0 0 0 0 0 1 0 0 0
21 155.58389 1 0 0 0 0 0 0 0 0 1 0 0
22 125.03825 1 0 0 0 0 0 0 0 0 0 1 0
23 136.89444 1 0 0 0 0 0 0 0 0 0 0 1
24 142.22336 1 0 0 0 0 0 0 0 0 0 0 0
25 117.77155 1 1 0 0 0 0 0 0 0 0 0 0
26 120.62723 1 0 1 0 0 0 0 0 0 0 0 0
27 127.76645 1 0 0 1 0 0 0 0 0 0 0 0
28 135.10964 1 0 0 0 1 0 0 0 0 0 0 0
29 105.71137 1 0 0 0 0 1 0 0 0 0 0 0
30 117.92453 1 0 0 0 0 0 1 0 0 0 0 0
31 120.75472 1 0 0 0 0 0 0 1 0 0 0 0
32 107.57267 1 0 0 0 0 0 0 0 1 0 0 0
33 130.44365 1 0 0 0 0 0 0 0 0 1 0 0
34 107.21571 1 0 0 0 0 0 0 0 0 0 1 0
35 105.07394 1 0 0 0 0 0 0 0 0 0 0 1
36 130.11219 1 0 0 0 0 0 0 0 0 0 0 0
37 109.63794 1 1 0 0 0 0 0 0 0 0 0 0
38 116.72616 1 0 1 0 0 0 0 0 0 0 0 0
39 97.11882 0 0 0 1 0 0 0 0 0 0 0 0
40 140.89750 1 0 0 0 1 0 0 0 0 0 0 0
41 108.28659 1 0 0 0 0 1 0 0 0 0 0 0
42 97.65426 0 0 0 0 0 0 1 0 0 0 0 0
43 112.03468 1 0 0 0 0 0 0 1 0 0 0 0
44 123.04946 1 0 0 0 0 0 0 0 1 0 0 0
45 112.41713 1 0 0 0 0 0 0 0 0 1 0 0
46 116.49669 1 0 0 0 0 0 0 0 0 0 1 0
47 104.69148 1 0 0 0 0 0 0 0 0 0 0 1
48 122.23355 1 0 0 0 0 0 0 0 0 0 0 0
49 99.79602 0 1 0 0 0 0 0 0 0 0 0 0
50 96.71086 0 0 1 0 0 0 0 0 0 0 0 0
51 112.31515 1 0 0 1 0 0 0 0 0 0 0 0
52 102.54972 1 0 0 0 1 0 0 0 0 0 0 0
53 104.53850 1 0 0 0 0 1 0 0 0 0 0 0
54 122.08057 1 0 0 0 0 0 1 0 0 0 0 0
55 80.64763 0 0 0 0 0 0 0 1 0 0 0 0
56 91.40745 0 0 0 0 0 0 0 0 1 0 0 0
57 99.51555 0 0 0 0 0 0 0 0 0 1 0 0
58 106.52728 1 0 0 0 0 0 0 0 0 0 1 0
59 98.49567 0 0 0 0 0 0 0 0 0 0 0 1
60 106.75676 1 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
103.383 25.398 -11.952 -7.337 -8.602 -5.191
M5 M6 M7 M8 M9 M10
-21.800 -4.971 -10.662 -11.009 2.504 -12.591
M11
-5.323
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-22.0245 -6.7086 -0.7873 7.7817 28.0056
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 103.383 7.423 13.928 < 2e-16 ***
X 25.398 4.752 5.345 2.6e-06 ***
M1 -11.952 8.285 -1.443 0.15577
M2 -7.337 8.285 -0.886 0.38037
M3 -8.602 8.120 -1.059 0.29484
M4 -5.191 8.064 -0.644 0.52287
M5 -21.800 8.064 -2.703 0.00953 **
M6 -4.971 8.120 -0.612 0.54333
M7 -10.662 8.120 -1.313 0.19553
M8 -11.009 8.120 -1.356 0.18164
M9 2.504 8.120 0.308 0.75912
M10 -12.591 8.064 -1.561 0.12517
M11 -5.323 8.120 -0.656 0.51530
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 12.75 on 47 degrees of freedom
Multiple R-squared: 0.4912, Adjusted R-squared: 0.3614
F-statistic: 3.782 on 12 and 47 DF, p-value: 0.0004901
> 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.5949498 0.81010030 0.40505015
[2,] 0.4924964 0.98499271 0.50750364
[3,] 0.7766626 0.44667475 0.22333737
[4,] 0.9443016 0.11139672 0.05569836
[5,] 0.9272174 0.14556521 0.07278260
[6,] 0.9670818 0.06583642 0.03291821
[7,] 0.9530876 0.09382485 0.04691243
[8,] 0.9680445 0.06391102 0.03195551
[9,] 0.9737944 0.05241112 0.02620556
[10,] 0.9556953 0.08860930 0.04430465
[11,] 0.9276312 0.14473752 0.07236876
[12,] 0.9133021 0.17339572 0.08669786
[13,] 0.9135786 0.17284286 0.08642143
[14,] 0.8680540 0.26389201 0.13194600
[15,] 0.8211162 0.35776761 0.17888380
[16,] 0.8022445 0.39551106 0.19775553
[17,] 0.7727111 0.45457775 0.22728887
[18,] 0.7793191 0.44136180 0.22068090
[19,] 0.7455667 0.50886652 0.25443326
[20,] 0.8102644 0.37947126 0.18973563
[21,] 0.8084651 0.38306989 0.19153494
[22,] 0.7480630 0.50387398 0.25193699
[23,] 0.6502233 0.69955346 0.34977673
[24,] 0.5483230 0.90335407 0.45167704
[25,] 0.9115536 0.17689276 0.08844638
[26,] 0.8451931 0.30961379 0.15480689
[27,] 0.7463711 0.50725788 0.25362894
[28,] 0.6990431 0.60191381 0.30095691
[29,] 0.7558521 0.48829580 0.24414790
> postscript(file="/var/www/html/rcomp/tmp/1u2xv1258718684.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/2e4ej1258718684.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/315ba1258718684.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/449nb1258718684.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/585221258718684.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
8.5687574 -0.2022777 -14.6716528 -5.4360020 -5.1198368 -13.9679302
7 8 9 10 11 12
-12.4839934 -4.8450337 1.7842371 9.4849567 23.2783727 13.7990821
13 14 15 16 17 18
-10.6844580 5.0728086 12.6103462 -2.3508414 7.5267720 22.3400759
19 20 21 22 23 24
28.0055527 10.7337527 24.2982606 8.8475268 13.4364553 13.4421213
25 26 27 28 29 30
0.9422630 -0.8170435 7.5873987 11.5196328 -1.2697604 -5.8853193
31 32 33 34 35 36
2.6358434 -10.1994447 -0.8419740 -8.9750127 -18.3840444 1.3309536
37 38 39 40 41 42
-7.1913423 -4.7181144 2.3378095 17.3074962 1.3054564 -0.7575500
43 44 45 46 47 48
-6.0841974 5.2773529 -18.8684911 0.3059664 -18.7665024 -6.5476798
49 50 51 52 53 54
8.3647799 0.6646269 -7.8639017 -21.0402856 -2.4426313 -1.7292765
55 56 57 58 59 60
-12.0732053 -0.9666270 -6.3720324 -9.6634370 0.4357187 -22.0244773
> postscript(file="/var/www/html/rcomp/tmp/6d3sm1258718684.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 8.5687574 NA
1 -0.2022777 8.5687574
2 -14.6716528 -0.2022777
3 -5.4360020 -14.6716528
4 -5.1198368 -5.4360020
5 -13.9679302 -5.1198368
6 -12.4839934 -13.9679302
7 -4.8450337 -12.4839934
8 1.7842371 -4.8450337
9 9.4849567 1.7842371
10 23.2783727 9.4849567
11 13.7990821 23.2783727
12 -10.6844580 13.7990821
13 5.0728086 -10.6844580
14 12.6103462 5.0728086
15 -2.3508414 12.6103462
16 7.5267720 -2.3508414
17 22.3400759 7.5267720
18 28.0055527 22.3400759
19 10.7337527 28.0055527
20 24.2982606 10.7337527
21 8.8475268 24.2982606
22 13.4364553 8.8475268
23 13.4421213 13.4364553
24 0.9422630 13.4421213
25 -0.8170435 0.9422630
26 7.5873987 -0.8170435
27 11.5196328 7.5873987
28 -1.2697604 11.5196328
29 -5.8853193 -1.2697604
30 2.6358434 -5.8853193
31 -10.1994447 2.6358434
32 -0.8419740 -10.1994447
33 -8.9750127 -0.8419740
34 -18.3840444 -8.9750127
35 1.3309536 -18.3840444
36 -7.1913423 1.3309536
37 -4.7181144 -7.1913423
38 2.3378095 -4.7181144
39 17.3074962 2.3378095
40 1.3054564 17.3074962
41 -0.7575500 1.3054564
42 -6.0841974 -0.7575500
43 5.2773529 -6.0841974
44 -18.8684911 5.2773529
45 0.3059664 -18.8684911
46 -18.7665024 0.3059664
47 -6.5476798 -18.7665024
48 8.3647799 -6.5476798
49 0.6646269 8.3647799
50 -7.8639017 0.6646269
51 -21.0402856 -7.8639017
52 -2.4426313 -21.0402856
53 -1.7292765 -2.4426313
54 -12.0732053 -1.7292765
55 -0.9666270 -12.0732053
56 -6.3720324 -0.9666270
57 -9.6634370 -6.3720324
58 0.4357187 -9.6634370
59 -22.0244773 0.4357187
60 NA -22.0244773
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.2022777 8.5687574
[2,] -14.6716528 -0.2022777
[3,] -5.4360020 -14.6716528
[4,] -5.1198368 -5.4360020
[5,] -13.9679302 -5.1198368
[6,] -12.4839934 -13.9679302
[7,] -4.8450337 -12.4839934
[8,] 1.7842371 -4.8450337
[9,] 9.4849567 1.7842371
[10,] 23.2783727 9.4849567
[11,] 13.7990821 23.2783727
[12,] -10.6844580 13.7990821
[13,] 5.0728086 -10.6844580
[14,] 12.6103462 5.0728086
[15,] -2.3508414 12.6103462
[16,] 7.5267720 -2.3508414
[17,] 22.3400759 7.5267720
[18,] 28.0055527 22.3400759
[19,] 10.7337527 28.0055527
[20,] 24.2982606 10.7337527
[21,] 8.8475268 24.2982606
[22,] 13.4364553 8.8475268
[23,] 13.4421213 13.4364553
[24,] 0.9422630 13.4421213
[25,] -0.8170435 0.9422630
[26,] 7.5873987 -0.8170435
[27,] 11.5196328 7.5873987
[28,] -1.2697604 11.5196328
[29,] -5.8853193 -1.2697604
[30,] 2.6358434 -5.8853193
[31,] -10.1994447 2.6358434
[32,] -0.8419740 -10.1994447
[33,] -8.9750127 -0.8419740
[34,] -18.3840444 -8.9750127
[35,] 1.3309536 -18.3840444
[36,] -7.1913423 1.3309536
[37,] -4.7181144 -7.1913423
[38,] 2.3378095 -4.7181144
[39,] 17.3074962 2.3378095
[40,] 1.3054564 17.3074962
[41,] -0.7575500 1.3054564
[42,] -6.0841974 -0.7575500
[43,] 5.2773529 -6.0841974
[44,] -18.8684911 5.2773529
[45,] 0.3059664 -18.8684911
[46,] -18.7665024 0.3059664
[47,] -6.5476798 -18.7665024
[48,] 8.3647799 -6.5476798
[49,] 0.6646269 8.3647799
[50,] -7.8639017 0.6646269
[51,] -21.0402856 -7.8639017
[52,] -2.4426313 -21.0402856
[53,] -1.7292765 -2.4426313
[54,] -12.0732053 -1.7292765
[55,] -0.9666270 -12.0732053
[56,] -6.3720324 -0.9666270
[57,] -9.6634370 -6.3720324
[58,] 0.4357187 -9.6634370
[59,] -22.0244773 0.4357187
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.2022777 8.5687574
2 -14.6716528 -0.2022777
3 -5.4360020 -14.6716528
4 -5.1198368 -5.4360020
5 -13.9679302 -5.1198368
6 -12.4839934 -13.9679302
7 -4.8450337 -12.4839934
8 1.7842371 -4.8450337
9 9.4849567 1.7842371
10 23.2783727 9.4849567
11 13.7990821 23.2783727
12 -10.6844580 13.7990821
13 5.0728086 -10.6844580
14 12.6103462 5.0728086
15 -2.3508414 12.6103462
16 7.5267720 -2.3508414
17 22.3400759 7.5267720
18 28.0055527 22.3400759
19 10.7337527 28.0055527
20 24.2982606 10.7337527
21 8.8475268 24.2982606
22 13.4364553 8.8475268
23 13.4421213 13.4364553
24 0.9422630 13.4421213
25 -0.8170435 0.9422630
26 7.5873987 -0.8170435
27 11.5196328 7.5873987
28 -1.2697604 11.5196328
29 -5.8853193 -1.2697604
30 2.6358434 -5.8853193
31 -10.1994447 2.6358434
32 -0.8419740 -10.1994447
33 -8.9750127 -0.8419740
34 -18.3840444 -8.9750127
35 1.3309536 -18.3840444
36 -7.1913423 1.3309536
37 -4.7181144 -7.1913423
38 2.3378095 -4.7181144
39 17.3074962 2.3378095
40 1.3054564 17.3074962
41 -0.7575500 1.3054564
42 -6.0841974 -0.7575500
43 5.2773529 -6.0841974
44 -18.8684911 5.2773529
45 0.3059664 -18.8684911
46 -18.7665024 0.3059664
47 -6.5476798 -18.7665024
48 8.3647799 -6.5476798
49 0.6646269 8.3647799
50 -7.8639017 0.6646269
51 -21.0402856 -7.8639017
52 -2.4426313 -21.0402856
53 -1.7292765 -2.4426313
54 -12.0732053 -1.7292765
55 -0.9666270 -12.0732053
56 -6.3720324 -0.9666270
57 -9.6634370 -6.3720324
58 0.4357187 -9.6634370
59 -22.0244773 0.4357187
> 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/7e87e1258718684.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/8alwc1258718684.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/9ta1h1258718684.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/1065cq1258718684.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/11afgm1258718684.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/12e09v1258718684.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/1389711258718684.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/14jckw1258718684.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/150awo1258718684.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/16d1oq1258718684.tab")
+ }
>
> system("convert tmp/1u2xv1258718684.ps tmp/1u2xv1258718684.png")
> system("convert tmp/2e4ej1258718684.ps tmp/2e4ej1258718684.png")
> system("convert tmp/315ba1258718684.ps tmp/315ba1258718684.png")
> system("convert tmp/449nb1258718684.ps tmp/449nb1258718684.png")
> system("convert tmp/585221258718684.ps tmp/585221258718684.png")
> system("convert tmp/6d3sm1258718684.ps tmp/6d3sm1258718684.png")
> system("convert tmp/7e87e1258718684.ps tmp/7e87e1258718684.png")
> system("convert tmp/8alwc1258718684.ps tmp/8alwc1258718684.png")
> system("convert tmp/9ta1h1258718684.ps tmp/9ta1h1258718684.png")
> system("convert tmp/1065cq1258718684.ps tmp/1065cq1258718684.png")
>
>
> proc.time()
user system elapsed
2.378 1.548 3.540