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(2172 + ,2155 + ,3016 + ,0 + ,2150 + ,2172 + ,2155 + ,0 + ,2533 + ,2150 + ,2172 + ,0 + ,2058 + ,2533 + ,2150 + ,0 + ,2160 + ,2058 + ,2533 + ,0 + ,2260 + ,2160 + ,2058 + ,0 + ,2498 + ,2260 + ,2160 + ,0 + ,2695 + ,2498 + ,2260 + ,0 + ,2799 + ,2695 + ,2498 + ,0 + ,2946 + ,2799 + ,2695 + ,0 + ,2930 + ,2946 + ,2799 + ,0 + ,2318 + ,2930 + ,2946 + ,0 + ,2540 + ,2318 + ,2930 + ,0 + ,2570 + ,2540 + ,2318 + ,0 + ,2669 + ,2570 + ,2540 + ,0 + ,2450 + ,2669 + ,2570 + ,0 + ,2842 + ,2450 + ,2669 + ,0 + ,3440 + ,2842 + ,2450 + ,0 + ,2678 + ,3440 + ,2842 + ,0 + ,2981 + ,2678 + ,3440 + ,0 + ,2260 + ,2981 + ,2678 + ,0 + ,2844 + ,2260 + ,2981 + ,0 + ,2546 + ,2844 + ,2260 + ,0 + ,2456 + ,2546 + ,2844 + ,0 + ,2295 + ,2456 + ,2546 + ,0 + ,2379 + ,2295 + ,2456 + ,0 + ,2479 + ,2379 + ,2295 + ,0 + ,2057 + ,2479 + ,2379 + ,0 + ,2280 + ,2057 + ,2479 + ,0 + ,2351 + ,2280 + ,2057 + ,0 + ,2276 + ,2351 + ,2280 + ,0 + ,2548 + ,2276 + ,2351 + ,0 + ,2311 + ,2548 + ,2276 + ,0 + ,2201 + ,2311 + ,2548 + ,1 + ,2725 + ,2201 + ,2311 + ,1 + ,2408 + ,2725 + ,2201 + ,1 + ,2139 + ,2408 + ,2725 + ,1 + ,1898 + ,2139 + ,2408 + ,1 + ,2537 + ,1898 + ,2139 + ,1 + ,2068 + ,2537 + ,1898 + ,1 + ,2063 + ,2068 + ,2537 + ,1 + ,2520 + ,2063 + ,2068 + ,1 + ,2434 + ,2520 + ,2063 + ,1 + ,2190 + ,2434 + ,2520 + ,1 + ,2794 + ,2190 + ,2434 + ,1 + ,2070 + ,2794 + ,2190 + ,1 + ,2615 + ,2070 + ,2794 + ,1 + ,2265 + ,2615 + ,2070 + ,1 + ,2139 + ,2265 + ,2615 + ,1 + ,2428 + ,2139 + ,2265 + ,1 + ,2137 + ,2428 + ,2139 + ,1 + ,1823 + ,2137 + ,2428 + ,1 + ,2063 + ,1823 + ,2137 + ,1 + ,1806 + ,2063 + ,1823 + ,1 + ,1758 + ,1806 + ,2063 + ,1 + ,2243 + ,1758 + ,1806 + ,1 + ,1993 + ,2243 + ,1758 + ,1 + ,1932 + ,1993 + ,2243 + ,1 + ,2465 + ,1932 + ,1993 + ,1) + ,dim=c(4 + ,59) + ,dimnames=list(c('y' + ,'y(t-1)' + ,'y(t-2)' + ,'x') + ,1:59)) > y <- array(NA,dim=c(4,59),dimnames=list(c('y','y(t-1)','y(t-2)','x'),1:59)) > 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 y y(t-1) y(t-2) x M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 2172 2155 3016 0 1 0 0 0 0 0 0 0 0 0 0 1 2 2150 2172 2155 0 0 1 0 0 0 0 0 0 0 0 0 2 3 2533 2150 2172 0 0 0 1 0 0 0 0 0 0 0 0 3 4 2058 2533 2150 0 0 0 0 1 0 0 0 0 0 0 0 4 5 2160 2058 2533 0 0 0 0 0 1 0 0 0 0 0 0 5 6 2260 2160 2058 0 0 0 0 0 0 1 0 0 0 0 0 6 7 2498 2260 2160 0 0 0 0 0 0 0 1 0 0 0 0 7 8 2695 2498 2260 0 0 0 0 0 0 0 0 1 0 0 0 8 9 2799 2695 2498 0 0 0 0 0 0 0 0 0 1 0 0 9 10 2946 2799 2695 0 0 0 0 0 0 0 0 0 0 1 0 10 11 2930 2946 2799 0 0 0 0 0 0 0 0 0 0 0 1 11 12 2318 2930 2946 0 0 0 0 0 0 0 0 0 0 0 0 12 13 2540 2318 2930 0 1 0 0 0 0 0 0 0 0 0 0 13 14 2570 2540 2318 0 0 1 0 0 0 0 0 0 0 0 0 14 15 2669 2570 2540 0 0 0 1 0 0 0 0 0 0 0 0 15 16 2450 2669 2570 0 0 0 0 1 0 0 0 0 0 0 0 16 17 2842 2450 2669 0 0 0 0 0 1 0 0 0 0 0 0 17 18 3440 2842 2450 0 0 0 0 0 0 1 0 0 0 0 0 18 19 2678 3440 2842 0 0 0 0 0 0 0 1 0 0 0 0 19 20 2981 2678 3440 0 0 0 0 0 0 0 0 1 0 0 0 20 21 2260 2981 2678 0 0 0 0 0 0 0 0 0 1 0 0 21 22 2844 2260 2981 0 0 0 0 0 0 0 0 0 0 1 0 22 23 2546 2844 2260 0 0 0 0 0 0 0 0 0 0 0 1 23 24 2456 2546 2844 0 0 0 0 0 0 0 0 0 0 0 0 24 25 2295 2456 2546 0 1 0 0 0 0 0 0 0 0 0 0 25 26 2379 2295 2456 0 0 1 0 0 0 0 0 0 0 0 0 26 27 2479 2379 2295 0 0 0 1 0 0 0 0 0 0 0 0 27 28 2057 2479 2379 0 0 0 0 1 0 0 0 0 0 0 0 28 29 2280 2057 2479 0 0 0 0 0 1 0 0 0 0 0 0 29 30 2351 2280 2057 0 0 0 0 0 0 1 0 0 0 0 0 30 31 2276 2351 2280 0 0 0 0 0 0 0 1 0 0 0 0 31 32 2548 2276 2351 0 0 0 0 0 0 0 0 1 0 0 0 32 33 2311 2548 2276 0 0 0 0 0 0 0 0 0 1 0 0 33 34 2201 2311 2548 1 0 0 0 0 0 0 0 0 0 1 0 34 35 2725 2201 2311 1 0 0 0 0 0 0 0 0 0 0 1 35 36 2408 2725 2201 1 0 0 0 0 0 0 0 0 0 0 0 36 37 2139 2408 2725 1 1 0 0 0 0 0 0 0 0 0 0 37 38 1898 2139 2408 1 0 1 0 0 0 0 0 0 0 0 0 38 39 2537 1898 2139 1 0 0 1 0 0 0 0 0 0 0 0 39 40 2068 2537 1898 1 0 0 0 1 0 0 0 0 0 0 0 40 41 2063 2068 2537 1 0 0 0 0 1 0 0 0 0 0 0 41 42 2520 2063 2068 1 0 0 0 0 0 1 0 0 0 0 0 42 43 2434 2520 2063 1 0 0 0 0 0 0 1 0 0 0 0 43 44 2190 2434 2520 1 0 0 0 0 0 0 0 1 0 0 0 44 45 2794 2190 2434 1 0 0 0 0 0 0 0 0 1 0 0 45 46 2070 2794 2190 1 0 0 0 0 0 0 0 0 0 1 0 46 47 2615 2070 2794 1 0 0 0 0 0 0 0 0 0 0 1 47 48 2265 2615 2070 1 0 0 0 0 0 0 0 0 0 0 0 48 49 2139 2265 2615 1 1 0 0 0 0 0 0 0 0 0 0 49 50 2428 2139 2265 1 0 1 0 0 0 0 0 0 0 0 0 50 51 2137 2428 2139 1 0 0 1 0 0 0 0 0 0 0 0 51 52 1823 2137 2428 1 0 0 0 1 0 0 0 0 0 0 0 52 53 2063 1823 2137 1 0 0 0 0 1 0 0 0 0 0 0 53 54 1806 2063 1823 1 0 0 0 0 0 1 0 0 0 0 0 54 55 1758 1806 2063 1 0 0 0 0 0 0 1 0 0 0 0 55 56 2243 1758 1806 1 0 0 0 0 0 0 0 1 0 0 0 56 57 1993 2243 1758 1 0 0 0 0 0 0 0 0 1 0 0 57 58 1932 1993 2243 1 0 0 0 0 0 0 0 0 0 1 0 58 59 2465 1932 1993 1 0 0 0 0 0 0 0 0 0 0 1 59 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `y(t-1)` `y(t-2)` x M1 M2 1134.9678 0.2183 0.3114 -16.8622 -123.9439 61.3838 M3 M4 M5 M6 M7 M8 265.6233 -158.8935 61.1246 336.2265 92.6392 271.5135 M9 M10 M11 t 177.5387 111.4711 411.9815 -4.6115 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -440.378 -166.145 -9.719 161.825 668.441 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1134.9678 498.0723 2.279 0.0277 * `y(t-1)` 0.2183 0.1413 1.545 0.1297 `y(t-2)` 0.3114 0.1432 2.174 0.0352 * x -16.8622 138.6594 -0.122 0.9038 M1 -123.9439 187.1136 -0.662 0.5113 M2 61.3838 183.6629 0.334 0.7398 M3 265.6233 183.0331 1.451 0.1540 M4 -158.8935 176.7008 -0.899 0.3735 M5 61.1246 192.3702 0.318 0.7522 M6 336.2265 186.9913 1.798 0.0792 . M7 92.6392 176.8106 0.524 0.6030 M8 271.5135 180.1541 1.507 0.1391 M9 177.5387 175.6276 1.011 0.3177 M10 111.4711 175.0873 0.637 0.5277 M11 411.9815 175.1653 2.352 0.0233 * t -4.6115 4.0345 -1.143 0.2593 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 255.1 on 43 degrees of freedom Multiple R-squared: 0.5531, Adjusted R-squared: 0.3972 F-statistic: 3.548 on 15 and 43 DF, p-value: 0.0005644 > 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.9131395 0.17372108 0.08686054 [2,] 0.8548410 0.29031803 0.14515902 [3,] 0.9808386 0.03832288 0.01916144 [4,] 0.9780333 0.04393340 0.02196670 [5,] 0.9757813 0.04843736 0.02421868 [6,] 0.9573503 0.08529938 0.04264969 [7,] 0.9286754 0.14264929 0.07132464 [8,] 0.8844126 0.23117479 0.11558739 [9,] 0.8294567 0.34108661 0.17054331 [10,] 0.7632859 0.47342818 0.23671409 [11,] 0.6757831 0.64843375 0.32421687 [12,] 0.6174289 0.76514213 0.38257107 [13,] 0.5076567 0.98468651 0.49234326 [14,] 0.4418888 0.88377756 0.55811122 [15,] 0.3328151 0.66563021 0.66718489 [16,] 0.2414376 0.48287521 0.75856239 [17,] 0.2620872 0.52417438 0.73791281 [18,] 0.1932843 0.38656864 0.80671568 [19,] 0.1379808 0.27596151 0.86201925 [20,] 0.4135169 0.82703372 0.58648314 [21,] 0.3654741 0.73094828 0.63452586 [22,] 0.3504471 0.70089430 0.64955285 > postscript(file="/var/www/html/rcomp/tmp/1lr8e1261272031.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/2o0h01261272031.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/3szi21261272031.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/4qbdh1261272031.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/5kx3v1261272031.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 = 59 Frequency = 1 1 2 3 4 5 6 -244.0294021 -182.3621447 0.5198127 -122.1228277 -251.0787305 -295.9351329 7 8 9 10 11 12 136.6701000 76.3066094 161.7739386 295.4054143 -80.9714956 -318.6574126 13 14 15 16 17 18 170.4993673 161.8758076 -14.4276578 164.7444966 358.3264080 668.4413116 19 20 21 22 23 24 -97.9820554 10.9213131 -440.3782608 277.3714438 -219.5312043 -9.7188731 25 26 27 28 29 30 70.2765859 36.7358461 -31.1004322 -71.9609311 -3.3689463 -120.1464975 31 32 33 34 35 36 -31.8861634 60.1182582 -114.3285453 -169.7367430 156.1770633 175.6154368 37 38 39 40 41 42 -58.7790127 -323.0574439 252.6929062 148.3486194 -168.6296141 165.0072779 43 44 45 46 47 48 228.9851581 -312.8000238 469.8377609 -239.3799400 -20.2776057 152.7608489 49 50 51 52 53 54 62.0324615 306.8079349 -207.6846288 -119.0093572 64.7508830 -417.3669590 55 56 57 58 59 -235.7870393 165.4538431 -76.9048934 -163.6601752 164.6032422 > postscript(file="/var/www/html/rcomp/tmp/665ax1261272031.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 = 59 Frequency = 1 lag(myerror, k = 1) myerror 0 -244.0294021 NA 1 -182.3621447 -244.0294021 2 0.5198127 -182.3621447 3 -122.1228277 0.5198127 4 -251.0787305 -122.1228277 5 -295.9351329 -251.0787305 6 136.6701000 -295.9351329 7 76.3066094 136.6701000 8 161.7739386 76.3066094 9 295.4054143 161.7739386 10 -80.9714956 295.4054143 11 -318.6574126 -80.9714956 12 170.4993673 -318.6574126 13 161.8758076 170.4993673 14 -14.4276578 161.8758076 15 164.7444966 -14.4276578 16 358.3264080 164.7444966 17 668.4413116 358.3264080 18 -97.9820554 668.4413116 19 10.9213131 -97.9820554 20 -440.3782608 10.9213131 21 277.3714438 -440.3782608 22 -219.5312043 277.3714438 23 -9.7188731 -219.5312043 24 70.2765859 -9.7188731 25 36.7358461 70.2765859 26 -31.1004322 36.7358461 27 -71.9609311 -31.1004322 28 -3.3689463 -71.9609311 29 -120.1464975 -3.3689463 30 -31.8861634 -120.1464975 31 60.1182582 -31.8861634 32 -114.3285453 60.1182582 33 -169.7367430 -114.3285453 34 156.1770633 -169.7367430 35 175.6154368 156.1770633 36 -58.7790127 175.6154368 37 -323.0574439 -58.7790127 38 252.6929062 -323.0574439 39 148.3486194 252.6929062 40 -168.6296141 148.3486194 41 165.0072779 -168.6296141 42 228.9851581 165.0072779 43 -312.8000238 228.9851581 44 469.8377609 -312.8000238 45 -239.3799400 469.8377609 46 -20.2776057 -239.3799400 47 152.7608489 -20.2776057 48 62.0324615 152.7608489 49 306.8079349 62.0324615 50 -207.6846288 306.8079349 51 -119.0093572 -207.6846288 52 64.7508830 -119.0093572 53 -417.3669590 64.7508830 54 -235.7870393 -417.3669590 55 165.4538431 -235.7870393 56 -76.9048934 165.4538431 57 -163.6601752 -76.9048934 58 164.6032422 -163.6601752 59 NA 164.6032422 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -182.3621447 -244.0294021 [2,] 0.5198127 -182.3621447 [3,] -122.1228277 0.5198127 [4,] -251.0787305 -122.1228277 [5,] -295.9351329 -251.0787305 [6,] 136.6701000 -295.9351329 [7,] 76.3066094 136.6701000 [8,] 161.7739386 76.3066094 [9,] 295.4054143 161.7739386 [10,] -80.9714956 295.4054143 [11,] -318.6574126 -80.9714956 [12,] 170.4993673 -318.6574126 [13,] 161.8758076 170.4993673 [14,] -14.4276578 161.8758076 [15,] 164.7444966 -14.4276578 [16,] 358.3264080 164.7444966 [17,] 668.4413116 358.3264080 [18,] -97.9820554 668.4413116 [19,] 10.9213131 -97.9820554 [20,] -440.3782608 10.9213131 [21,] 277.3714438 -440.3782608 [22,] -219.5312043 277.3714438 [23,] -9.7188731 -219.5312043 [24,] 70.2765859 -9.7188731 [25,] 36.7358461 70.2765859 [26,] -31.1004322 36.7358461 [27,] -71.9609311 -31.1004322 [28,] -3.3689463 -71.9609311 [29,] -120.1464975 -3.3689463 [30,] -31.8861634 -120.1464975 [31,] 60.1182582 -31.8861634 [32,] -114.3285453 60.1182582 [33,] -169.7367430 -114.3285453 [34,] 156.1770633 -169.7367430 [35,] 175.6154368 156.1770633 [36,] -58.7790127 175.6154368 [37,] -323.0574439 -58.7790127 [38,] 252.6929062 -323.0574439 [39,] 148.3486194 252.6929062 [40,] -168.6296141 148.3486194 [41,] 165.0072779 -168.6296141 [42,] 228.9851581 165.0072779 [43,] -312.8000238 228.9851581 [44,] 469.8377609 -312.8000238 [45,] -239.3799400 469.8377609 [46,] -20.2776057 -239.3799400 [47,] 152.7608489 -20.2776057 [48,] 62.0324615 152.7608489 [49,] 306.8079349 62.0324615 [50,] -207.6846288 306.8079349 [51,] -119.0093572 -207.6846288 [52,] 64.7508830 -119.0093572 [53,] -417.3669590 64.7508830 [54,] -235.7870393 -417.3669590 [55,] 165.4538431 -235.7870393 [56,] -76.9048934 165.4538431 [57,] -163.6601752 -76.9048934 [58,] 164.6032422 -163.6601752 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -182.3621447 -244.0294021 2 0.5198127 -182.3621447 3 -122.1228277 0.5198127 4 -251.0787305 -122.1228277 5 -295.9351329 -251.0787305 6 136.6701000 -295.9351329 7 76.3066094 136.6701000 8 161.7739386 76.3066094 9 295.4054143 161.7739386 10 -80.9714956 295.4054143 11 -318.6574126 -80.9714956 12 170.4993673 -318.6574126 13 161.8758076 170.4993673 14 -14.4276578 161.8758076 15 164.7444966 -14.4276578 16 358.3264080 164.7444966 17 668.4413116 358.3264080 18 -97.9820554 668.4413116 19 10.9213131 -97.9820554 20 -440.3782608 10.9213131 21 277.3714438 -440.3782608 22 -219.5312043 277.3714438 23 -9.7188731 -219.5312043 24 70.2765859 -9.7188731 25 36.7358461 70.2765859 26 -31.1004322 36.7358461 27 -71.9609311 -31.1004322 28 -3.3689463 -71.9609311 29 -120.1464975 -3.3689463 30 -31.8861634 -120.1464975 31 60.1182582 -31.8861634 32 -114.3285453 60.1182582 33 -169.7367430 -114.3285453 34 156.1770633 -169.7367430 35 175.6154368 156.1770633 36 -58.7790127 175.6154368 37 -323.0574439 -58.7790127 38 252.6929062 -323.0574439 39 148.3486194 252.6929062 40 -168.6296141 148.3486194 41 165.0072779 -168.6296141 42 228.9851581 165.0072779 43 -312.8000238 228.9851581 44 469.8377609 -312.8000238 45 -239.3799400 469.8377609 46 -20.2776057 -239.3799400 47 152.7608489 -20.2776057 48 62.0324615 152.7608489 49 306.8079349 62.0324615 50 -207.6846288 306.8079349 51 -119.0093572 -207.6846288 52 64.7508830 -119.0093572 53 -417.3669590 64.7508830 54 -235.7870393 -417.3669590 55 165.4538431 -235.7870393 56 -76.9048934 165.4538431 57 -163.6601752 -76.9048934 58 164.6032422 -163.6601752 > 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/70nsq1261272031.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/8f3ym1261272031.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/9peaq1261272031.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/10s1v71261272031.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/11zwhc1261272031.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/12lev81261272031.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/130u7p1261272031.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/14didv1261272031.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/15jsqv1261272031.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/16xunq1261272032.tab") + } > > try(system("convert tmp/1lr8e1261272031.ps tmp/1lr8e1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/2o0h01261272031.ps tmp/2o0h01261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/3szi21261272031.ps tmp/3szi21261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/4qbdh1261272031.ps tmp/4qbdh1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/5kx3v1261272031.ps tmp/5kx3v1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/665ax1261272031.ps tmp/665ax1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/70nsq1261272031.ps tmp/70nsq1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/8f3ym1261272031.ps tmp/8f3ym1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/9peaq1261272031.ps tmp/9peaq1261272031.png",intern=TRUE)) character(0) > try(system("convert tmp/10s1v71261272031.ps tmp/10s1v71261272031.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.400 1.563 4.008