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(2360 + ,2 + ,2267 + ,1746 + ,2069 + ,2299 + ,2214 + ,2 + ,2360 + ,2267 + ,1746 + ,2069 + ,2825 + ,2 + ,2214 + ,2360 + ,2267 + ,1746 + ,2355 + ,2 + ,2825 + ,2214 + ,2360 + ,2267 + ,2333 + ,2 + ,2355 + ,2825 + ,2214 + ,2360 + ,3016 + ,2 + ,2333 + ,2355 + ,2825 + ,2214 + ,2155 + ,2 + ,3016 + ,2333 + ,2355 + ,2825 + ,2172 + ,2 + ,2155 + ,3016 + ,2333 + ,2355 + ,2150 + ,2 + ,2172 + ,2155 + ,3016 + ,2333 + ,2533 + ,2 + ,2150 + ,2172 + ,2155 + ,3016 + ,2058 + ,2 + ,2533 + ,2150 + ,2172 + ,2155 + ,2160 + ,2 + ,2058 + ,2533 + ,2150 + ,2172 + ,2260 + ,2 + ,2160 + ,2058 + ,2533 + ,2150 + ,2498 + ,2 + ,2260 + ,2160 + ,2058 + ,2533 + ,2695 + ,2 + ,2498 + ,2260 + ,2160 + ,2058 + ,2799 + ,2 + ,2695 + ,2498 + ,2260 + ,2160 + ,2947 + ,2 + ,2799 + ,2695 + ,2498 + ,2260 + ,2930 + ,2 + ,2947 + ,2799 + ,2695 + ,2498 + ,2318 + ,2 + ,2930 + ,2947 + ,2799 + ,2695 + ,2540 + ,2 + ,2318 + ,2930 + ,2947 + ,2799 + ,2570 + ,2 + ,2540 + ,2318 + ,2930 + ,2947 + ,2669 + ,2 + ,2570 + ,2540 + ,2318 + ,2930 + ,2450 + ,2 + ,2669 + ,2570 + ,2540 + ,2318 + ,2842 + ,2 + ,2450 + ,2669 + ,2570 + ,2540 + ,3440 + ,2 + ,2842 + ,2450 + ,2669 + ,2570 + ,2678 + ,2 + ,3440 + ,2842 + ,2450 + ,2669 + ,2981 + ,2 + ,2678 + ,3440 + ,2842 + ,2450 + ,2260 + ,2.21 + ,2981 + ,2678 + ,3440 + ,2842 + ,2844 + ,2.25 + ,2260 + ,2981 + ,2678 + ,3440 + ,2546 + ,2.25 + ,2844 + ,2260 + ,2981 + ,2678 + ,2456 + ,2.45 + ,2546 + ,2844 + ,2260 + ,2981 + ,2295 + ,2.5 + ,2456 + ,2546 + ,2844 + ,2260 + ,2379 + ,2.5 + ,2295 + ,2456 + ,2546 + ,2844 + ,2479 + ,2.64 + ,2379 + ,2295 + ,2456 + ,2546 + ,2057 + ,2.75 + ,2479 + ,2379 + ,2295 + ,2456 + ,2280 + ,2.93 + ,2057 + ,2479 + ,2379 + ,2295 + ,2351 + ,3 + ,2280 + ,2057 + ,2479 + ,2379 + ,2276 + ,3.17 + ,2351 + ,2280 + ,2057 + ,2479 + ,2548 + ,3.25 + ,2276 + ,2351 + ,2280 + ,2057 + ,2311 + ,3.39 + ,2548 + ,2276 + ,2351 + ,2280 + ,2201 + ,3.5 + ,2311 + ,2548 + ,2276 + ,2351 + ,2725 + ,3.5 + ,2201 + ,2311 + ,2548 + ,2276 + ,2408 + ,3.65 + ,2725 + ,2201 + ,2311 + ,2548 + ,2139 + ,3.75 + ,2408 + ,2725 + ,2201 + ,2311 + ,1898 + ,3.75 + ,2139 + ,2408 + ,2725 + ,2201 + ,2537 + ,3.9 + ,1898 + ,2139 + ,2408 + ,2725 + ,2069 + ,4 + ,2537 + ,1898 + ,2139 + ,2408 + ,2063 + ,4 + ,2069 + ,2537 + ,1898 + ,2139 + ,2524 + ,4 + ,2063 + ,2069 + ,2537 + ,1898 + ,2437 + ,4 + ,2524 + ,2063 + ,2069 + ,2537 + ,2189 + ,4 + ,2437 + ,2524 + ,2063 + ,2069 + ,2793 + ,4 + ,2189 + ,2437 + ,2524 + ,2063 + ,2074 + ,4 + ,2793 + ,2189 + ,2437 + ,2524 + ,2622 + ,4 + ,2074 + ,2793 + ,2189 + ,2437 + ,2278 + ,4 + ,2622 + ,2074 + ,2793 + ,2189 + ,2144 + ,4 + ,2278 + ,2622 + ,2074 + ,2793 + ,2427 + ,4 + ,2144 + ,2278 + ,2622 + ,2074 + ,2139 + ,4 + ,2427 + ,2144 + ,2278 + ,2622 + ,1828 + ,4.18 + ,2139 + ,2427 + ,2144 + ,2278 + ,2072 + ,4.25 + ,1828 + ,2139 + ,2427 + ,2144 + ,1800 + ,4.25 + ,2072 + ,1828 + ,2139 + ,2427) + ,dim=c(6 + ,61) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:61)) > y <- array(NA,dim=c(6,61),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:61)) > 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 X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 2360 2.00 2267 1746 2069 2299 1 0 0 0 0 0 0 0 0 0 0 1 2 2214 2.00 2360 2267 1746 2069 0 1 0 0 0 0 0 0 0 0 0 2 3 2825 2.00 2214 2360 2267 1746 0 0 1 0 0 0 0 0 0 0 0 3 4 2355 2.00 2825 2214 2360 2267 0 0 0 1 0 0 0 0 0 0 0 4 5 2333 2.00 2355 2825 2214 2360 0 0 0 0 1 0 0 0 0 0 0 5 6 3016 2.00 2333 2355 2825 2214 0 0 0 0 0 1 0 0 0 0 0 6 7 2155 2.00 3016 2333 2355 2825 0 0 0 0 0 0 1 0 0 0 0 7 8 2172 2.00 2155 3016 2333 2355 0 0 0 0 0 0 0 1 0 0 0 8 9 2150 2.00 2172 2155 3016 2333 0 0 0 0 0 0 0 0 1 0 0 9 10 2533 2.00 2150 2172 2155 3016 0 0 0 0 0 0 0 0 0 1 0 10 11 2058 2.00 2533 2150 2172 2155 0 0 0 0 0 0 0 0 0 0 1 11 12 2160 2.00 2058 2533 2150 2172 0 0 0 0 0 0 0 0 0 0 0 12 13 2260 2.00 2160 2058 2533 2150 1 0 0 0 0 0 0 0 0 0 0 13 14 2498 2.00 2260 2160 2058 2533 0 1 0 0 0 0 0 0 0 0 0 14 15 2695 2.00 2498 2260 2160 2058 0 0 1 0 0 0 0 0 0 0 0 15 16 2799 2.00 2695 2498 2260 2160 0 0 0 1 0 0 0 0 0 0 0 16 17 2947 2.00 2799 2695 2498 2260 0 0 0 0 1 0 0 0 0 0 0 17 18 2930 2.00 2947 2799 2695 2498 0 0 0 0 0 1 0 0 0 0 0 18 19 2318 2.00 2930 2947 2799 2695 0 0 0 0 0 0 1 0 0 0 0 19 20 2540 2.00 2318 2930 2947 2799 0 0 0 0 0 0 0 1 0 0 0 20 21 2570 2.00 2540 2318 2930 2947 0 0 0 0 0 0 0 0 1 0 0 21 22 2669 2.00 2570 2540 2318 2930 0 0 0 0 0 0 0 0 0 1 0 22 23 2450 2.00 2669 2570 2540 2318 0 0 0 0 0 0 0 0 0 0 1 23 24 2842 2.00 2450 2669 2570 2540 0 0 0 0 0 0 0 0 0 0 0 24 25 3440 2.00 2842 2450 2669 2570 1 0 0 0 0 0 0 0 0 0 0 25 26 2678 2.00 3440 2842 2450 2669 0 1 0 0 0 0 0 0 0 0 0 26 27 2981 2.00 2678 3440 2842 2450 0 0 1 0 0 0 0 0 0 0 0 27 28 2260 2.21 2981 2678 3440 2842 0 0 0 1 0 0 0 0 0 0 0 28 29 2844 2.25 2260 2981 2678 3440 0 0 0 0 1 0 0 0 0 0 0 29 30 2546 2.25 2844 2260 2981 2678 0 0 0 0 0 1 0 0 0 0 0 30 31 2456 2.45 2546 2844 2260 2981 0 0 0 0 0 0 1 0 0 0 0 31 32 2295 2.50 2456 2546 2844 2260 0 0 0 0 0 0 0 1 0 0 0 32 33 2379 2.50 2295 2456 2546 2844 0 0 0 0 0 0 0 0 1 0 0 33 34 2479 2.64 2379 2295 2456 2546 0 0 0 0 0 0 0 0 0 1 0 34 35 2057 2.75 2479 2379 2295 2456 0 0 0 0 0 0 0 0 0 0 1 35 36 2280 2.93 2057 2479 2379 2295 0 0 0 0 0 0 0 0 0 0 0 36 37 2351 3.00 2280 2057 2479 2379 1 0 0 0 0 0 0 0 0 0 0 37 38 2276 3.17 2351 2280 2057 2479 0 1 0 0 0 0 0 0 0 0 0 38 39 2548 3.25 2276 2351 2280 2057 0 0 1 0 0 0 0 0 0 0 0 39 40 2311 3.39 2548 2276 2351 2280 0 0 0 1 0 0 0 0 0 0 0 40 41 2201 3.50 2311 2548 2276 2351 0 0 0 0 1 0 0 0 0 0 0 41 42 2725 3.50 2201 2311 2548 2276 0 0 0 0 0 1 0 0 0 0 0 42 43 2408 3.65 2725 2201 2311 2548 0 0 0 0 0 0 1 0 0 0 0 43 44 2139 3.75 2408 2725 2201 2311 0 0 0 0 0 0 0 1 0 0 0 44 45 1898 3.75 2139 2408 2725 2201 0 0 0 0 0 0 0 0 1 0 0 45 46 2537 3.90 1898 2139 2408 2725 0 0 0 0 0 0 0 0 0 1 0 46 47 2069 4.00 2537 1898 2139 2408 0 0 0 0 0 0 0 0 0 0 1 47 48 2063 4.00 2069 2537 1898 2139 0 0 0 0 0 0 0 0 0 0 0 48 49 2524 4.00 2063 2069 2537 1898 1 0 0 0 0 0 0 0 0 0 0 49 50 2437 4.00 2524 2063 2069 2537 0 1 0 0 0 0 0 0 0 0 0 50 51 2189 4.00 2437 2524 2063 2069 0 0 1 0 0 0 0 0 0 0 0 51 52 2793 4.00 2189 2437 2524 2063 0 0 0 1 0 0 0 0 0 0 0 52 53 2074 4.00 2793 2189 2437 2524 0 0 0 0 1 0 0 0 0 0 0 53 54 2622 4.00 2074 2793 2189 2437 0 0 0 0 0 1 0 0 0 0 0 54 55 2278 4.00 2622 2074 2793 2189 0 0 0 0 0 0 1 0 0 0 0 55 56 2144 4.00 2278 2622 2074 2793 0 0 0 0 0 0 0 1 0 0 0 56 57 2427 4.00 2144 2278 2622 2074 0 0 0 0 0 0 0 0 1 0 0 57 58 2139 4.00 2427 2144 2278 2622 0 0 0 0 0 0 0 0 0 1 0 58 59 1828 4.18 2139 2427 2144 2278 0 0 0 0 0 0 0 0 0 0 1 59 60 2072 4.25 1828 2139 2427 2144 0 0 0 0 0 0 0 0 0 0 0 60 61 1800 4.25 2072 1828 2139 2427 1 0 0 0 0 0 0 0 0 0 0 61 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 2.544e+03 -3.329e+02 -8.973e-03 1.895e-01 5.896e-02 -1.040e-01 M1 M2 M3 M4 M5 M6 2.549e+02 1.804e+02 2.958e+02 2.076e+02 1.756e+02 4.489e+02 M7 M8 M9 M10 M11 t 5.544e+01 -8.282e+01 -2.929e+00 2.606e+02 -1.494e+02 1.113e+01 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -464.74 -149.33 -26.69 105.08 699.87 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.544e+03 1.052e+03 2.418 0.0199 * X -3.329e+02 1.915e+02 -1.738 0.0893 . Y1 -8.973e-03 1.659e-01 -0.054 0.9571 Y2 1.895e-01 1.671e-01 1.134 0.2632 Y3 5.896e-02 1.669e-01 0.353 0.7255 Y4 -1.040e-01 1.641e-01 -0.634 0.5297 M1 2.549e+02 1.715e+02 1.486 0.1446 M2 1.804e+02 1.883e+02 0.958 0.3434 M3 2.958e+02 1.725e+02 1.715 0.0935 . M4 2.076e+02 1.908e+02 1.088 0.2827 M5 1.756e+02 1.877e+02 0.936 0.3546 M6 4.489e+02 1.821e+02 2.465 0.0178 * M7 5.544e+01 2.082e+02 0.266 0.7913 M8 -8.282e+01 1.795e+02 -0.461 0.6468 M9 -2.929e+00 1.834e+02 -0.016 0.9873 M10 2.606e+02 1.860e+02 1.401 0.1684 M11 -1.494e+02 1.739e+02 -0.859 0.3950 t 1.113e+01 8.574e+00 1.299 0.2010 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 252.4 on 43 degrees of freedom Multiple R-squared: 0.5502, Adjusted R-squared: 0.3724 F-statistic: 3.095 on 17 and 43 DF, p-value: 0.001396 > 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.6087574 0.7824852 0.3912426 [2,] 0.4323827 0.8647655 0.5676173 [3,] 0.3247432 0.6494864 0.6752568 [4,] 0.3129030 0.6258061 0.6870970 [5,] 0.7602063 0.4795875 0.2397937 [6,] 0.8068330 0.3863340 0.1931670 [7,] 0.8111059 0.3777882 0.1888941 [8,] 0.7969711 0.4060578 0.2030289 [9,] 0.8268692 0.3462616 0.1731308 [10,] 0.7762323 0.4475355 0.2237677 [11,] 0.8149783 0.3700434 0.1850217 [12,] 0.7583416 0.4833168 0.2416584 [13,] 0.7022344 0.5955311 0.2977656 [14,] 0.5998461 0.8003079 0.4001539 [15,] 0.4814746 0.9629491 0.5185254 [16,] 0.3867794 0.7735588 0.6132206 [17,] 0.4109129 0.8218258 0.5890871 [18,] 0.2996265 0.5992530 0.7003735 [19,] 0.2929591 0.5859182 0.7070409 [20,] 0.1770051 0.3540101 0.8229949 > postscript(file="/var/www/html/rcomp/tmp/1fv591258654864.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/2pidr1258654864.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/3hjmx1258654864.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/4hmq91258654864.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/5uoyk1258654864.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 = 61 Frequency = 1 1 2 3 4 5 6 22.5316173 -162.8523334 238.3944775 -72.6614526 -175.5628181 260.6934927 7 8 9 10 11 12 -116.4636894 -157.0116663 -149.3291970 77.3936773 -81.6607038 -213.9718240 13 14 15 16 17 18 -314.0024484 36.7415486 35.0129124 177.5242507 306.2922262 -0.3439045 19 20 21 22 23 24 -243.8697382 105.0774492 178.3717952 -4.7242025 93.6178793 325.6521775 25 26 27 28 29 30 699.8748254 -44.4709085 -34.0076796 -455.4115573 205.9173781 -331.7092223 31 32 33 34 35 36 -12.1234494 -83.0813967 3.7734815 -118.6674847 -120.0876247 -42.1480270 37 38 39 40 41 42 -129.1287687 -90.5270425 10.4330178 -67.1966118 -161.6424282 98.0509953 43 44 45 46 47 48 281.0889754 52.2397148 -264.4787685 271.7860318 270.2169798 -35.3481752 49 50 51 52 53 54 185.4660278 261.1087359 -249.8327281 417.7453710 -175.0043580 -26.6913611 55 56 57 58 59 60 91.3679016 82.7758990 231.6626888 -225.7880219 -162.0865307 -34.1841513 61 -464.7412534 > postscript(file="/var/www/html/rcomp/tmp/6ofzy1258654864.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 22.5316173 NA 1 -162.8523334 22.5316173 2 238.3944775 -162.8523334 3 -72.6614526 238.3944775 4 -175.5628181 -72.6614526 5 260.6934927 -175.5628181 6 -116.4636894 260.6934927 7 -157.0116663 -116.4636894 8 -149.3291970 -157.0116663 9 77.3936773 -149.3291970 10 -81.6607038 77.3936773 11 -213.9718240 -81.6607038 12 -314.0024484 -213.9718240 13 36.7415486 -314.0024484 14 35.0129124 36.7415486 15 177.5242507 35.0129124 16 306.2922262 177.5242507 17 -0.3439045 306.2922262 18 -243.8697382 -0.3439045 19 105.0774492 -243.8697382 20 178.3717952 105.0774492 21 -4.7242025 178.3717952 22 93.6178793 -4.7242025 23 325.6521775 93.6178793 24 699.8748254 325.6521775 25 -44.4709085 699.8748254 26 -34.0076796 -44.4709085 27 -455.4115573 -34.0076796 28 205.9173781 -455.4115573 29 -331.7092223 205.9173781 30 -12.1234494 -331.7092223 31 -83.0813967 -12.1234494 32 3.7734815 -83.0813967 33 -118.6674847 3.7734815 34 -120.0876247 -118.6674847 35 -42.1480270 -120.0876247 36 -129.1287687 -42.1480270 37 -90.5270425 -129.1287687 38 10.4330178 -90.5270425 39 -67.1966118 10.4330178 40 -161.6424282 -67.1966118 41 98.0509953 -161.6424282 42 281.0889754 98.0509953 43 52.2397148 281.0889754 44 -264.4787685 52.2397148 45 271.7860318 -264.4787685 46 270.2169798 271.7860318 47 -35.3481752 270.2169798 48 185.4660278 -35.3481752 49 261.1087359 185.4660278 50 -249.8327281 261.1087359 51 417.7453710 -249.8327281 52 -175.0043580 417.7453710 53 -26.6913611 -175.0043580 54 91.3679016 -26.6913611 55 82.7758990 91.3679016 56 231.6626888 82.7758990 57 -225.7880219 231.6626888 58 -162.0865307 -225.7880219 59 -34.1841513 -162.0865307 60 -464.7412534 -34.1841513 61 NA -464.7412534 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -162.8523334 22.5316173 [2,] 238.3944775 -162.8523334 [3,] -72.6614526 238.3944775 [4,] -175.5628181 -72.6614526 [5,] 260.6934927 -175.5628181 [6,] -116.4636894 260.6934927 [7,] -157.0116663 -116.4636894 [8,] -149.3291970 -157.0116663 [9,] 77.3936773 -149.3291970 [10,] -81.6607038 77.3936773 [11,] -213.9718240 -81.6607038 [12,] -314.0024484 -213.9718240 [13,] 36.7415486 -314.0024484 [14,] 35.0129124 36.7415486 [15,] 177.5242507 35.0129124 [16,] 306.2922262 177.5242507 [17,] -0.3439045 306.2922262 [18,] -243.8697382 -0.3439045 [19,] 105.0774492 -243.8697382 [20,] 178.3717952 105.0774492 [21,] -4.7242025 178.3717952 [22,] 93.6178793 -4.7242025 [23,] 325.6521775 93.6178793 [24,] 699.8748254 325.6521775 [25,] -44.4709085 699.8748254 [26,] -34.0076796 -44.4709085 [27,] -455.4115573 -34.0076796 [28,] 205.9173781 -455.4115573 [29,] -331.7092223 205.9173781 [30,] -12.1234494 -331.7092223 [31,] -83.0813967 -12.1234494 [32,] 3.7734815 -83.0813967 [33,] -118.6674847 3.7734815 [34,] -120.0876247 -118.6674847 [35,] -42.1480270 -120.0876247 [36,] -129.1287687 -42.1480270 [37,] -90.5270425 -129.1287687 [38,] 10.4330178 -90.5270425 [39,] -67.1966118 10.4330178 [40,] -161.6424282 -67.1966118 [41,] 98.0509953 -161.6424282 [42,] 281.0889754 98.0509953 [43,] 52.2397148 281.0889754 [44,] -264.4787685 52.2397148 [45,] 271.7860318 -264.4787685 [46,] 270.2169798 271.7860318 [47,] -35.3481752 270.2169798 [48,] 185.4660278 -35.3481752 [49,] 261.1087359 185.4660278 [50,] -249.8327281 261.1087359 [51,] 417.7453710 -249.8327281 [52,] -175.0043580 417.7453710 [53,] -26.6913611 -175.0043580 [54,] 91.3679016 -26.6913611 [55,] 82.7758990 91.3679016 [56,] 231.6626888 82.7758990 [57,] -225.7880219 231.6626888 [58,] -162.0865307 -225.7880219 [59,] -34.1841513 -162.0865307 [60,] -464.7412534 -34.1841513 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -162.8523334 22.5316173 2 238.3944775 -162.8523334 3 -72.6614526 238.3944775 4 -175.5628181 -72.6614526 5 260.6934927 -175.5628181 6 -116.4636894 260.6934927 7 -157.0116663 -116.4636894 8 -149.3291970 -157.0116663 9 77.3936773 -149.3291970 10 -81.6607038 77.3936773 11 -213.9718240 -81.6607038 12 -314.0024484 -213.9718240 13 36.7415486 -314.0024484 14 35.0129124 36.7415486 15 177.5242507 35.0129124 16 306.2922262 177.5242507 17 -0.3439045 306.2922262 18 -243.8697382 -0.3439045 19 105.0774492 -243.8697382 20 178.3717952 105.0774492 21 -4.7242025 178.3717952 22 93.6178793 -4.7242025 23 325.6521775 93.6178793 24 699.8748254 325.6521775 25 -44.4709085 699.8748254 26 -34.0076796 -44.4709085 27 -455.4115573 -34.0076796 28 205.9173781 -455.4115573 29 -331.7092223 205.9173781 30 -12.1234494 -331.7092223 31 -83.0813967 -12.1234494 32 3.7734815 -83.0813967 33 -118.6674847 3.7734815 34 -120.0876247 -118.6674847 35 -42.1480270 -120.0876247 36 -129.1287687 -42.1480270 37 -90.5270425 -129.1287687 38 10.4330178 -90.5270425 39 -67.1966118 10.4330178 40 -161.6424282 -67.1966118 41 98.0509953 -161.6424282 42 281.0889754 98.0509953 43 52.2397148 281.0889754 44 -264.4787685 52.2397148 45 271.7860318 -264.4787685 46 270.2169798 271.7860318 47 -35.3481752 270.2169798 48 185.4660278 -35.3481752 49 261.1087359 185.4660278 50 -249.8327281 261.1087359 51 417.7453710 -249.8327281 52 -175.0043580 417.7453710 53 -26.6913611 -175.0043580 54 91.3679016 -26.6913611 55 82.7758990 91.3679016 56 231.6626888 82.7758990 57 -225.7880219 231.6626888 58 -162.0865307 -225.7880219 59 -34.1841513 -162.0865307 60 -464.7412534 -34.1841513 > 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/7y1lo1258654864.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/85i2a1258654864.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/9t7se1258654864.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/10ngtj1258654864.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/11hpg31258654864.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/12f3qp1258654864.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/13fzid1258654864.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/14rrm81258654865.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/15iwhl1258654865.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/16jxvo1258654865.tab") + } > system("convert tmp/1fv591258654864.ps tmp/1fv591258654864.png") > system("convert tmp/2pidr1258654864.ps tmp/2pidr1258654864.png") > system("convert tmp/3hjmx1258654864.ps tmp/3hjmx1258654864.png") > system("convert tmp/4hmq91258654864.ps tmp/4hmq91258654864.png") > system("convert tmp/5uoyk1258654864.ps tmp/5uoyk1258654864.png") > system("convert tmp/6ofzy1258654864.ps tmp/6ofzy1258654864.png") > system("convert tmp/7y1lo1258654864.ps tmp/7y1lo1258654864.png") > system("convert tmp/85i2a1258654864.ps tmp/85i2a1258654864.png") > system("convert tmp/9t7se1258654864.ps tmp/9t7se1258654864.png") > system("convert tmp/10ngtj1258654864.ps tmp/10ngtj1258654864.png") > > > proc.time() user system elapsed 2.407 1.550 2.809