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(1852 + ,18.2 + ,2187 + ,1855 + ,2218 + ,2253 + ,1570 + ,18 + ,1852 + ,2187 + ,1855 + ,2218 + ,1851 + ,19 + ,1570 + ,1852 + ,2187 + ,1855 + ,1954 + ,20.7 + ,1851 + ,1570 + ,1852 + ,2187 + ,1828 + ,21.2 + ,1954 + ,1851 + ,1570 + ,1852 + ,2251 + ,20.7 + ,1828 + ,1954 + ,1851 + ,1570 + ,2277 + ,19.6 + ,2251 + ,1828 + ,1954 + ,1851 + ,2085 + ,18.6 + ,2277 + ,2251 + ,1828 + ,1954 + ,2282 + ,18.7 + ,2085 + ,2277 + ,2251 + ,1828 + ,2266 + ,23.8 + ,2282 + ,2085 + ,2277 + ,2251 + ,1878 + ,24.9 + ,2266 + ,2282 + ,2085 + ,2277 + ,2267 + ,24.8 + ,1878 + ,2266 + ,2282 + ,2085 + ,2069 + ,23.8 + ,2267 + ,1878 + ,2266 + ,2282 + ,1746 + ,22.3 + ,2069 + ,2267 + ,1878 + ,2266 + ,2299 + ,21.7 + ,1746 + ,2069 + ,2267 + ,1878 + ,2360 + ,20.7 + ,2299 + ,1746 + ,2069 + ,2267 + ,2214 + ,19.7 + ,2360 + ,2299 + ,1746 + ,2069 + ,2825 + ,18.4 + ,2214 + ,2360 + ,2299 + ,1746 + ,2355 + ,17.4 + ,2825 + ,2214 + ,2360 + ,2299 + ,2333 + ,17 + ,2355 + ,2825 + ,2214 + ,2360 + ,3016 + ,18 + ,2333 + ,2355 + ,2825 + ,2214 + ,2155 + ,23.8 + ,3016 + ,2333 + ,2355 + ,2825 + ,2172 + ,25.5 + ,2155 + ,3016 + ,2333 + ,2355 + ,2150 + ,25.6 + ,2172 + ,2155 + ,3016 + ,2333 + ,2533 + ,23.7 + ,2150 + ,2172 + ,2155 + ,3016 + ,2058 + ,22 + ,2533 + ,2150 + ,2172 + ,2155 + ,2160 + ,21.3 + ,2058 + ,2533 + ,2150 + ,2172 + ,2260 + ,20.7 + ,2160 + ,2058 + ,2533 + ,2150 + ,2498 + ,20.4 + ,2260 + ,2160 + ,2058 + ,2533 + ,2695 + ,20.3 + ,2498 + ,2260 + ,2160 + ,2058 + ,2799 + ,20.4 + ,2695 + ,2498 + ,2260 + ,2160 + ,2946 + ,19.8 + ,2799 + ,2695 + ,2498 + ,2260 + ,2930 + ,19.5 + ,2946 + ,2799 + ,2695 + ,2498 + ,2318 + ,23.1 + ,2930 + ,2946 + ,2799 + ,2695 + ,2540 + ,23.5 + ,2318 + ,2930 + ,2946 + ,2799 + ,2570 + ,23.5 + ,2540 + ,2318 + ,2930 + ,2946 + ,2669 + ,22.9 + ,2570 + ,2540 + ,2318 + ,2930 + ,2450 + ,21.9 + ,2669 + ,2570 + ,2540 + ,2318 + ,2842 + ,21.5 + ,2450 + ,2669 + ,2570 + ,2540 + ,3440 + ,20.5 + ,2842 + ,2450 + ,2669 + ,2570 + ,2678 + ,20.2 + ,3440 + ,2842 + ,2450 + ,2669 + ,2981 + ,19.4 + ,2678 + ,3440 + ,2842 + ,2450 + ,2260 + ,19.2 + ,2981 + ,2678 + ,3440 + ,2842 + ,2844 + ,18.8 + ,2260 + ,2981 + ,2678 + ,3440 + ,2546 + ,18.8 + ,2844 + ,2260 + ,2981 + ,2678 + ,2456 + ,22.6 + ,2546 + ,2844 + ,2260 + ,2981 + ,2295 + ,23.3 + ,2456 + ,2546 + ,2844 + ,2260 + ,2379 + ,23 + ,2295 + ,2456 + ,2546 + ,2844 + ,2479 + ,21.4 + ,2379 + ,2295 + ,2456 + ,2546 + ,2057 + ,19.9 + ,2479 + ,2379 + ,2295 + ,2456 + ,2280 + ,18.8 + ,2057 + ,2479 + ,2379 + ,2295 + ,2351 + ,18.6 + ,2280 + ,2057 + ,2479 + ,2379 + ,2276 + ,18.4 + ,2351 + ,2280 + ,2057 + ,2479 + ,2548 + ,18.6 + ,2276 + ,2351 + ,2280 + ,2057 + ,2311 + ,19.9 + ,2548 + ,2276 + ,2351 + ,2280 + ,2201 + ,19.2 + ,2311 + ,2548 + ,2276 + ,2351 + ,2725 + ,18.4 + ,2201 + ,2311 + ,2548 + ,2276) + ,dim=c(6 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:57)) > y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57)) > 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 1852 18.2 2187 1855 2218 2253 1 0 0 0 0 0 0 0 0 0 0 1 2 1570 18.0 1852 2187 1855 2218 0 1 0 0 0 0 0 0 0 0 0 2 3 1851 19.0 1570 1852 2187 1855 0 0 1 0 0 0 0 0 0 0 0 3 4 1954 20.7 1851 1570 1852 2187 0 0 0 1 0 0 0 0 0 0 0 4 5 1828 21.2 1954 1851 1570 1852 0 0 0 0 1 0 0 0 0 0 0 5 6 2251 20.7 1828 1954 1851 1570 0 0 0 0 0 1 0 0 0 0 0 6 7 2277 19.6 2251 1828 1954 1851 0 0 0 0 0 0 1 0 0 0 0 7 8 2085 18.6 2277 2251 1828 1954 0 0 0 0 0 0 0 1 0 0 0 8 9 2282 18.7 2085 2277 2251 1828 0 0 0 0 0 0 0 0 1 0 0 9 10 2266 23.8 2282 2085 2277 2251 0 0 0 0 0 0 0 0 0 1 0 10 11 1878 24.9 2266 2282 2085 2277 0 0 0 0 0 0 0 0 0 0 1 11 12 2267 24.8 1878 2266 2282 2085 0 0 0 0 0 0 0 0 0 0 0 12 13 2069 23.8 2267 1878 2266 2282 1 0 0 0 0 0 0 0 0 0 0 13 14 1746 22.3 2069 2267 1878 2266 0 1 0 0 0 0 0 0 0 0 0 14 15 2299 21.7 1746 2069 2267 1878 0 0 1 0 0 0 0 0 0 0 0 15 16 2360 20.7 2299 1746 2069 2267 0 0 0 1 0 0 0 0 0 0 0 16 17 2214 19.7 2360 2299 1746 2069 0 0 0 0 1 0 0 0 0 0 0 17 18 2825 18.4 2214 2360 2299 1746 0 0 0 0 0 1 0 0 0 0 0 18 19 2355 17.4 2825 2214 2360 2299 0 0 0 0 0 0 1 0 0 0 0 19 20 2333 17.0 2355 2825 2214 2360 0 0 0 0 0 0 0 1 0 0 0 20 21 3016 18.0 2333 2355 2825 2214 0 0 0 0 0 0 0 0 1 0 0 21 22 2155 23.8 3016 2333 2355 2825 0 0 0 0 0 0 0 0 0 1 0 22 23 2172 25.5 2155 3016 2333 2355 0 0 0 0 0 0 0 0 0 0 1 23 24 2150 25.6 2172 2155 3016 2333 0 0 0 0 0 0 0 0 0 0 0 24 25 2533 23.7 2150 2172 2155 3016 1 0 0 0 0 0 0 0 0 0 0 25 26 2058 22.0 2533 2150 2172 2155 0 1 0 0 0 0 0 0 0 0 0 26 27 2160 21.3 2058 2533 2150 2172 0 0 1 0 0 0 0 0 0 0 0 27 28 2260 20.7 2160 2058 2533 2150 0 0 0 1 0 0 0 0 0 0 0 28 29 2498 20.4 2260 2160 2058 2533 0 0 0 0 1 0 0 0 0 0 0 29 30 2695 20.3 2498 2260 2160 2058 0 0 0 0 0 1 0 0 0 0 0 30 31 2799 20.4 2695 2498 2260 2160 0 0 0 0 0 0 1 0 0 0 0 31 32 2946 19.8 2799 2695 2498 2260 0 0 0 0 0 0 0 1 0 0 0 32 33 2930 19.5 2946 2799 2695 2498 0 0 0 0 0 0 0 0 1 0 0 33 34 2318 23.1 2930 2946 2799 2695 0 0 0 0 0 0 0 0 0 1 0 34 35 2540 23.5 2318 2930 2946 2799 0 0 0 0 0 0 0 0 0 0 1 35 36 2570 23.5 2540 2318 2930 2946 0 0 0 0 0 0 0 0 0 0 0 36 37 2669 22.9 2570 2540 2318 2930 1 0 0 0 0 0 0 0 0 0 0 37 38 2450 21.9 2669 2570 2540 2318 0 1 0 0 0 0 0 0 0 0 0 38 39 2842 21.5 2450 2669 2570 2540 0 0 1 0 0 0 0 0 0 0 0 39 40 3440 20.5 2842 2450 2669 2570 0 0 0 1 0 0 0 0 0 0 0 40 41 2678 20.2 3440 2842 2450 2669 0 0 0 0 1 0 0 0 0 0 0 41 42 2981 19.4 2678 3440 2842 2450 0 0 0 0 0 1 0 0 0 0 0 42 43 2260 19.2 2981 2678 3440 2842 0 0 0 0 0 0 1 0 0 0 0 43 44 2844 18.8 2260 2981 2678 3440 0 0 0 0 0 0 0 1 0 0 0 44 45 2546 18.8 2844 2260 2981 2678 0 0 0 0 0 0 0 0 1 0 0 45 46 2456 22.6 2546 2844 2260 2981 0 0 0 0 0 0 0 0 0 1 0 46 47 2295 23.3 2456 2546 2844 2260 0 0 0 0 0 0 0 0 0 0 1 47 48 2379 23.0 2295 2456 2546 2844 0 0 0 0 0 0 0 0 0 0 0 48 49 2479 21.4 2379 2295 2456 2546 1 0 0 0 0 0 0 0 0 0 0 49 50 2057 19.9 2479 2379 2295 2456 0 1 0 0 0 0 0 0 0 0 0 50 51 2280 18.8 2057 2479 2379 2295 0 0 1 0 0 0 0 0 0 0 0 51 52 2351 18.6 2280 2057 2479 2379 0 0 0 1 0 0 0 0 0 0 0 52 53 2276 18.4 2351 2280 2057 2479 0 0 0 0 1 0 0 0 0 0 0 53 54 2548 18.6 2276 2351 2280 2057 0 0 0 0 0 1 0 0 0 0 0 54 55 2311 19.9 2548 2276 2351 2280 0 0 0 0 0 0 1 0 0 0 0 55 56 2201 19.2 2311 2548 2276 2351 0 0 0 0 0 0 0 1 0 0 0 56 57 2725 18.4 2201 2311 2548 2276 0 0 0 0 0 0 0 0 1 0 0 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 -521.12504 43.92473 0.26761 0.35365 0.04248 0.08787 M1 M2 M3 M4 M5 M6 127.55180 -192.61394 225.21262 443.73510 133.32615 512.43119 M7 M8 M9 M10 M11 t 188.75016 228.36932 514.60558 -216.10345 -264.76807 1.75132 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -466.92 -151.78 -23.89 113.07 580.72 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -521.12504 784.36378 -0.664 0.5103 X 43.92473 28.00947 1.568 0.1249 Y1 0.26761 0.15759 1.698 0.0974 . Y2 0.35365 0.16571 2.134 0.0392 * Y3 0.04248 0.16676 0.255 0.8003 Y4 0.08787 0.16145 0.544 0.5894 M1 127.55180 191.76934 0.665 0.5099 M2 -192.61394 216.30964 -0.890 0.3787 M3 225.21262 206.89073 1.089 0.2830 M4 443.73510 212.27328 2.090 0.0431 * M5 133.32615 252.33025 0.528 0.6002 M6 512.43119 246.67126 2.077 0.0444 * M7 188.75016 241.79160 0.781 0.4397 M8 228.36932 254.53488 0.897 0.3751 M9 514.60558 236.68530 2.174 0.0358 * M10 -216.10345 201.71932 -1.071 0.2906 M11 -264.76807 185.60999 -1.426 0.1617 t 1.75132 2.68830 0.651 0.5186 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 236.8 on 39 degrees of freedom Multiple R-squared: 0.6885, Adjusted R-squared: 0.5527 F-statistic: 5.07 on 17 and 39 DF, p-value: 1.382e-05 > 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.034820665 0.06964133 0.9651793 [2,] 0.015773029 0.03154606 0.9842270 [3,] 0.008660329 0.01732066 0.9913397 [4,] 0.061871243 0.12374249 0.9381288 [5,] 0.066061588 0.13212318 0.9339384 [6,] 0.083984359 0.16796872 0.9160156 [7,] 0.161759278 0.32351856 0.8382407 [8,] 0.483453700 0.96690740 0.5165463 [9,] 0.381526812 0.76305362 0.6184732 [10,] 0.367802762 0.73560552 0.6321972 [11,] 0.266823537 0.53364707 0.7331765 [12,] 0.423011514 0.84602303 0.5769885 [13,] 0.304326357 0.60865271 0.6956736 [14,] 0.221128256 0.44225651 0.7788717 [15,] 0.129905006 0.25981001 0.8700950 [16,] 0.082614414 0.16522883 0.9173856 > postscript(file="/var/www/html/rcomp/tmp/1ac0s1258741239.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/20slx1258741239.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/316m01258741239.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/4mdct1258741239.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/5xhyx1258741239.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 = 57 Frequency = 1 1 2 3 4 5 6 -89.051801 -53.120949 -23.893153 -206.250212 -131.080610 -56.839317 7 8 9 10 11 12 241.704072 -107.990477 -168.080725 297.771162 -151.148769 93.716902 13 14 15 16 17 18 -173.175559 -178.570258 155.234885 -19.642572 6.165578 315.801187 19 20 21 22 23 24 48.599482 -86.662339 423.402831 -172.120852 -151.779434 -171.827933 25 26 27 28 29 30 141.760689 40.063340 -255.659718 -223.227228 260.298484 19.182647 31 32 33 34 35 36 290.623366 306.212401 -89.994899 -200.597473 204.798366 113.065621 37 38 39 40 41 42 49.980114 200.560564 193.367294 580.723748 -157.496870 -205.185303 43 44 45 46 47 48 -466.919875 158.892432 -274.315241 74.947163 98.129837 -34.954590 49 50 51 52 53 54 70.486557 -8.932697 -69.049308 -131.603736 22.113419 -72.959213 55 56 57 -114.007045 -270.452017 108.988034 > postscript(file="/var/www/html/rcomp/tmp/6cd0i1258741239.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 = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 -89.051801 NA 1 -53.120949 -89.051801 2 -23.893153 -53.120949 3 -206.250212 -23.893153 4 -131.080610 -206.250212 5 -56.839317 -131.080610 6 241.704072 -56.839317 7 -107.990477 241.704072 8 -168.080725 -107.990477 9 297.771162 -168.080725 10 -151.148769 297.771162 11 93.716902 -151.148769 12 -173.175559 93.716902 13 -178.570258 -173.175559 14 155.234885 -178.570258 15 -19.642572 155.234885 16 6.165578 -19.642572 17 315.801187 6.165578 18 48.599482 315.801187 19 -86.662339 48.599482 20 423.402831 -86.662339 21 -172.120852 423.402831 22 -151.779434 -172.120852 23 -171.827933 -151.779434 24 141.760689 -171.827933 25 40.063340 141.760689 26 -255.659718 40.063340 27 -223.227228 -255.659718 28 260.298484 -223.227228 29 19.182647 260.298484 30 290.623366 19.182647 31 306.212401 290.623366 32 -89.994899 306.212401 33 -200.597473 -89.994899 34 204.798366 -200.597473 35 113.065621 204.798366 36 49.980114 113.065621 37 200.560564 49.980114 38 193.367294 200.560564 39 580.723748 193.367294 40 -157.496870 580.723748 41 -205.185303 -157.496870 42 -466.919875 -205.185303 43 158.892432 -466.919875 44 -274.315241 158.892432 45 74.947163 -274.315241 46 98.129837 74.947163 47 -34.954590 98.129837 48 70.486557 -34.954590 49 -8.932697 70.486557 50 -69.049308 -8.932697 51 -131.603736 -69.049308 52 22.113419 -131.603736 53 -72.959213 22.113419 54 -114.007045 -72.959213 55 -270.452017 -114.007045 56 108.988034 -270.452017 57 NA 108.988034 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -53.120949 -89.051801 [2,] -23.893153 -53.120949 [3,] -206.250212 -23.893153 [4,] -131.080610 -206.250212 [5,] -56.839317 -131.080610 [6,] 241.704072 -56.839317 [7,] -107.990477 241.704072 [8,] -168.080725 -107.990477 [9,] 297.771162 -168.080725 [10,] -151.148769 297.771162 [11,] 93.716902 -151.148769 [12,] -173.175559 93.716902 [13,] -178.570258 -173.175559 [14,] 155.234885 -178.570258 [15,] -19.642572 155.234885 [16,] 6.165578 -19.642572 [17,] 315.801187 6.165578 [18,] 48.599482 315.801187 [19,] -86.662339 48.599482 [20,] 423.402831 -86.662339 [21,] -172.120852 423.402831 [22,] -151.779434 -172.120852 [23,] -171.827933 -151.779434 [24,] 141.760689 -171.827933 [25,] 40.063340 141.760689 [26,] -255.659718 40.063340 [27,] -223.227228 -255.659718 [28,] 260.298484 -223.227228 [29,] 19.182647 260.298484 [30,] 290.623366 19.182647 [31,] 306.212401 290.623366 [32,] -89.994899 306.212401 [33,] -200.597473 -89.994899 [34,] 204.798366 -200.597473 [35,] 113.065621 204.798366 [36,] 49.980114 113.065621 [37,] 200.560564 49.980114 [38,] 193.367294 200.560564 [39,] 580.723748 193.367294 [40,] -157.496870 580.723748 [41,] -205.185303 -157.496870 [42,] -466.919875 -205.185303 [43,] 158.892432 -466.919875 [44,] -274.315241 158.892432 [45,] 74.947163 -274.315241 [46,] 98.129837 74.947163 [47,] -34.954590 98.129837 [48,] 70.486557 -34.954590 [49,] -8.932697 70.486557 [50,] -69.049308 -8.932697 [51,] -131.603736 -69.049308 [52,] 22.113419 -131.603736 [53,] -72.959213 22.113419 [54,] -114.007045 -72.959213 [55,] -270.452017 -114.007045 [56,] 108.988034 -270.452017 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -53.120949 -89.051801 2 -23.893153 -53.120949 3 -206.250212 -23.893153 4 -131.080610 -206.250212 5 -56.839317 -131.080610 6 241.704072 -56.839317 7 -107.990477 241.704072 8 -168.080725 -107.990477 9 297.771162 -168.080725 10 -151.148769 297.771162 11 93.716902 -151.148769 12 -173.175559 93.716902 13 -178.570258 -173.175559 14 155.234885 -178.570258 15 -19.642572 155.234885 16 6.165578 -19.642572 17 315.801187 6.165578 18 48.599482 315.801187 19 -86.662339 48.599482 20 423.402831 -86.662339 21 -172.120852 423.402831 22 -151.779434 -172.120852 23 -171.827933 -151.779434 24 141.760689 -171.827933 25 40.063340 141.760689 26 -255.659718 40.063340 27 -223.227228 -255.659718 28 260.298484 -223.227228 29 19.182647 260.298484 30 290.623366 19.182647 31 306.212401 290.623366 32 -89.994899 306.212401 33 -200.597473 -89.994899 34 204.798366 -200.597473 35 113.065621 204.798366 36 49.980114 113.065621 37 200.560564 49.980114 38 193.367294 200.560564 39 580.723748 193.367294 40 -157.496870 580.723748 41 -205.185303 -157.496870 42 -466.919875 -205.185303 43 158.892432 -466.919875 44 -274.315241 158.892432 45 74.947163 -274.315241 46 98.129837 74.947163 47 -34.954590 98.129837 48 70.486557 -34.954590 49 -8.932697 70.486557 50 -69.049308 -8.932697 51 -131.603736 -69.049308 52 22.113419 -131.603736 53 -72.959213 22.113419 54 -114.007045 -72.959213 55 -270.452017 -114.007045 56 108.988034 -270.452017 > 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/7erh51258741239.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/84nsv1258741239.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/9unem1258741239.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/103j4r1258741239.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/115j9u1258741239.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/12pby61258741239.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/13t91r1258741239.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/14b4sv1258741239.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/15bbec1258741239.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/165j441258741239.tab") + } > system("convert tmp/1ac0s1258741239.ps tmp/1ac0s1258741239.png") > system("convert tmp/20slx1258741239.ps tmp/20slx1258741239.png") > system("convert tmp/316m01258741239.ps tmp/316m01258741239.png") > system("convert tmp/4mdct1258741239.ps tmp/4mdct1258741239.png") > system("convert tmp/5xhyx1258741239.ps tmp/5xhyx1258741239.png") > system("convert tmp/6cd0i1258741239.ps tmp/6cd0i1258741239.png") > system("convert tmp/7erh51258741239.ps tmp/7erh51258741239.png") > system("convert tmp/84nsv1258741239.ps tmp/84nsv1258741239.png") > system("convert tmp/9unem1258741239.ps tmp/9unem1258741239.png") > system("convert tmp/103j4r1258741239.ps tmp/103j4r1258741239.png") > > > proc.time() user system elapsed 2.395 1.568 2.811