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(2333 + ,8 + ,2355 + ,2825 + ,2214 + ,2360 + ,3016 + ,8 + ,2333 + ,2355 + ,2825 + ,2214 + ,2155 + ,7.7 + ,3016 + ,2333 + ,2355 + ,2825 + ,2172 + ,6.9 + ,2155 + ,3016 + ,2333 + ,2355 + ,2150 + ,6.6 + ,2172 + ,2155 + ,3016 + ,2333 + ,2533 + ,6.9 + ,2150 + ,2172 + ,2155 + ,3016 + ,2058 + ,7.5 + ,2533 + ,2150 + ,2172 + ,2155 + ,2160 + ,7.9 + ,2058 + ,2533 + ,2150 + ,2172 + ,2260 + ,7.7 + ,2160 + ,2058 + ,2533 + ,2150 + ,2498 + ,6.5 + ,2260 + ,2160 + ,2058 + ,2533 + ,2695 + ,6.1 + ,2498 + ,2260 + ,2160 + ,2058 + ,2799 + ,6.4 + ,2695 + ,2498 + ,2260 + ,2160 + ,2947 + ,6.8 + ,2799 + ,2695 + ,2498 + ,2260 + ,2930 + ,7.1 + ,2947 + ,2799 + ,2695 + ,2498 + ,2318 + ,7.3 + ,2930 + ,2947 + ,2799 + ,2695 + ,2540 + ,7.2 + ,2318 + ,2930 + ,2947 + ,2799 + ,2570 + ,7 + ,2540 + ,2318 + ,2930 + ,2947 + ,2669 + ,7 + ,2570 + ,2540 + ,2318 + ,2930 + ,2450 + ,7 + ,2669 + ,2570 + ,2540 + ,2318 + ,2842 + ,7.3 + ,2450 + ,2669 + ,2570 + ,2540 + ,3440 + ,7.5 + ,2842 + ,2450 + ,2669 + ,2570 + ,2678 + ,7.2 + ,3440 + ,2842 + ,2450 + ,2669 + ,2981 + ,7.7 + ,2678 + ,3440 + ,2842 + ,2450 + ,2260 + ,8 + ,2981 + ,2678 + ,3440 + ,2842 + ,2844 + ,7.9 + ,2260 + ,2981 + ,2678 + ,3440 + ,2546 + ,8 + ,2844 + ,2260 + ,2981 + ,2678 + ,2456 + ,8 + ,2546 + ,2844 + ,2260 + ,2981 + ,2295 + ,7.9 + ,2456 + ,2546 + ,2844 + ,2260 + ,2379 + ,7.9 + ,2295 + ,2456 + ,2546 + ,2844 + ,2479 + ,8 + ,2379 + ,2295 + ,2456 + ,2546 + ,2057 + ,8.1 + ,2479 + ,2379 + ,2295 + ,2456 + ,2280 + ,8.1 + ,2057 + ,2479 + ,2379 + ,2295 + ,2351 + ,8.2 + ,2280 + ,2057 + ,2479 + ,2379 + ,2276 + ,8 + ,2351 + ,2280 + ,2057 + ,2479 + ,2548 + ,8.3 + ,2276 + ,2351 + ,2280 + ,2057 + ,2311 + ,8.5 + ,2548 + ,2276 + ,2351 + ,2280 + ,2201 + ,8.6 + ,2311 + ,2548 + ,2276 + ,2351 + ,2725 + ,8.7 + ,2201 + ,2311 + ,2548 + ,2276 + ,2408 + ,8.7 + ,2725 + ,2201 + ,2311 + ,2548 + ,2139 + ,8.5 + ,2408 + ,2725 + ,2201 + ,2311 + ,1898 + ,8.4 + ,2139 + ,2408 + ,2725 + ,2201 + ,2537 + ,8.5 + ,1898 + ,2139 + ,2408 + ,2725 + ,2069 + ,8.7 + ,2537 + ,1898 + ,2139 + ,2408 + ,2063 + ,8.7 + ,2069 + ,2537 + ,1898 + ,2139 + ,2524 + ,8.6 + ,2063 + ,2069 + ,2537 + ,1898 + ,2437 + ,7.9 + ,2524 + ,2063 + ,2069 + ,2537 + ,2189 + ,8.1 + ,2437 + ,2524 + ,2063 + ,2069 + ,2793 + ,8.2 + ,2189 + ,2437 + ,2524 + ,2063 + ,2074 + ,8.5 + ,2793 + ,2189 + ,2437 + ,2524 + ,2622 + ,8.6 + ,2074 + ,2793 + ,2189 + ,2437 + ,2278 + ,8.5 + ,2622 + ,2074 + ,2793 + ,2189 + ,2144 + ,8.3 + ,2278 + ,2622 + ,2074 + ,2793 + ,2427 + ,8.2 + ,2144 + ,2278 + ,2622 + ,2074 + ,2139 + ,8.7 + ,2427 + ,2144 + ,2278 + ,2622 + ,1828 + ,9.3 + ,2139 + ,2427 + ,2144 + ,2278 + ,2072 + ,9.3 + ,1828 + ,2139 + ,2427 + ,2144 + ,1800 + ,8.8 + ,2072 + ,1828 + ,2139 + ,2427 + ,1758 + ,7.4 + ,1800 + ,2072 + ,1828 + ,2139 + ,2246 + ,7.2 + ,1758 + ,1800 + ,2072 + ,1828 + ,1987 + ,7.5 + ,2246 + ,1758 + ,1800 + ,2072 + ,1868 + ,8.3 + ,1987 + ,2246 + ,1758 + ,1800 + ,2514 + ,8.8 + ,1868 + ,1987 + ,2246 + ,1758 + ,2121 + ,8.9 + ,2514 + ,1868 + ,1987 + ,2246) + ,dim=c(6 + ,63) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:63)) > y <- array(NA,dim=c(6,63),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:63)) > 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 2333 8.0 2355 2825 2214 2360 1 0 0 0 0 0 0 0 0 0 0 1 2 3016 8.0 2333 2355 2825 2214 0 1 0 0 0 0 0 0 0 0 0 2 3 2155 7.7 3016 2333 2355 2825 0 0 1 0 0 0 0 0 0 0 0 3 4 2172 6.9 2155 3016 2333 2355 0 0 0 1 0 0 0 0 0 0 0 4 5 2150 6.6 2172 2155 3016 2333 0 0 0 0 1 0 0 0 0 0 0 5 6 2533 6.9 2150 2172 2155 3016 0 0 0 0 0 1 0 0 0 0 0 6 7 2058 7.5 2533 2150 2172 2155 0 0 0 0 0 0 1 0 0 0 0 7 8 2160 7.9 2058 2533 2150 2172 0 0 0 0 0 0 0 1 0 0 0 8 9 2260 7.7 2160 2058 2533 2150 0 0 0 0 0 0 0 0 1 0 0 9 10 2498 6.5 2260 2160 2058 2533 0 0 0 0 0 0 0 0 0 1 0 10 11 2695 6.1 2498 2260 2160 2058 0 0 0 0 0 0 0 0 0 0 1 11 12 2799 6.4 2695 2498 2260 2160 0 0 0 0 0 0 0 0 0 0 0 12 13 2947 6.8 2799 2695 2498 2260 1 0 0 0 0 0 0 0 0 0 0 13 14 2930 7.1 2947 2799 2695 2498 0 1 0 0 0 0 0 0 0 0 0 14 15 2318 7.3 2930 2947 2799 2695 0 0 1 0 0 0 0 0 0 0 0 15 16 2540 7.2 2318 2930 2947 2799 0 0 0 1 0 0 0 0 0 0 0 16 17 2570 7.0 2540 2318 2930 2947 0 0 0 0 1 0 0 0 0 0 0 17 18 2669 7.0 2570 2540 2318 2930 0 0 0 0 0 1 0 0 0 0 0 18 19 2450 7.0 2669 2570 2540 2318 0 0 0 0 0 0 1 0 0 0 0 19 20 2842 7.3 2450 2669 2570 2540 0 0 0 0 0 0 0 1 0 0 0 20 21 3440 7.5 2842 2450 2669 2570 0 0 0 0 0 0 0 0 1 0 0 21 22 2678 7.2 3440 2842 2450 2669 0 0 0 0 0 0 0 0 0 1 0 22 23 2981 7.7 2678 3440 2842 2450 0 0 0 0 0 0 0 0 0 0 1 23 24 2260 8.0 2981 2678 3440 2842 0 0 0 0 0 0 0 0 0 0 0 24 25 2844 7.9 2260 2981 2678 3440 1 0 0 0 0 0 0 0 0 0 0 25 26 2546 8.0 2844 2260 2981 2678 0 1 0 0 0 0 0 0 0 0 0 26 27 2456 8.0 2546 2844 2260 2981 0 0 1 0 0 0 0 0 0 0 0 27 28 2295 7.9 2456 2546 2844 2260 0 0 0 1 0 0 0 0 0 0 0 28 29 2379 7.9 2295 2456 2546 2844 0 0 0 0 1 0 0 0 0 0 0 29 30 2479 8.0 2379 2295 2456 2546 0 0 0 0 0 1 0 0 0 0 0 30 31 2057 8.1 2479 2379 2295 2456 0 0 0 0 0 0 1 0 0 0 0 31 32 2280 8.1 2057 2479 2379 2295 0 0 0 0 0 0 0 1 0 0 0 32 33 2351 8.2 2280 2057 2479 2379 0 0 0 0 0 0 0 0 1 0 0 33 34 2276 8.0 2351 2280 2057 2479 0 0 0 0 0 0 0 0 0 1 0 34 35 2548 8.3 2276 2351 2280 2057 0 0 0 0 0 0 0 0 0 0 1 35 36 2311 8.5 2548 2276 2351 2280 0 0 0 0 0 0 0 0 0 0 0 36 37 2201 8.6 2311 2548 2276 2351 1 0 0 0 0 0 0 0 0 0 0 37 38 2725 8.7 2201 2311 2548 2276 0 1 0 0 0 0 0 0 0 0 0 38 39 2408 8.7 2725 2201 2311 2548 0 0 1 0 0 0 0 0 0 0 0 39 40 2139 8.5 2408 2725 2201 2311 0 0 0 1 0 0 0 0 0 0 0 40 41 1898 8.4 2139 2408 2725 2201 0 0 0 0 1 0 0 0 0 0 0 41 42 2537 8.5 1898 2139 2408 2725 0 0 0 0 0 1 0 0 0 0 0 42 43 2069 8.7 2537 1898 2139 2408 0 0 0 0 0 0 1 0 0 0 0 43 44 2063 8.7 2069 2537 1898 2139 0 0 0 0 0 0 0 1 0 0 0 44 45 2524 8.6 2063 2069 2537 1898 0 0 0 0 0 0 0 0 1 0 0 45 46 2437 7.9 2524 2063 2069 2537 0 0 0 0 0 0 0 0 0 1 0 46 47 2189 8.1 2437 2524 2063 2069 0 0 0 0 0 0 0 0 0 0 1 47 48 2793 8.2 2189 2437 2524 2063 0 0 0 0 0 0 0 0 0 0 0 48 49 2074 8.5 2793 2189 2437 2524 1 0 0 0 0 0 0 0 0 0 0 49 50 2622 8.6 2074 2793 2189 2437 0 1 0 0 0 0 0 0 0 0 0 50 51 2278 8.5 2622 2074 2793 2189 0 0 1 0 0 0 0 0 0 0 0 51 52 2144 8.3 2278 2622 2074 2793 0 0 0 1 0 0 0 0 0 0 0 52 53 2427 8.2 2144 2278 2622 2074 0 0 0 0 1 0 0 0 0 0 0 53 54 2139 8.7 2427 2144 2278 2622 0 0 0 0 0 1 0 0 0 0 0 54 55 1828 9.3 2139 2427 2144 2278 0 0 0 0 0 0 1 0 0 0 0 55 56 2072 9.3 1828 2139 2427 2144 0 0 0 0 0 0 0 1 0 0 0 56 57 1800 8.8 2072 1828 2139 2427 0 0 0 0 0 0 0 0 1 0 0 57 58 1758 7.4 1800 2072 1828 2139 0 0 0 0 0 0 0 0 0 1 0 58 59 2246 7.2 1758 1800 2072 1828 0 0 0 0 0 0 0 0 0 0 1 59 60 1987 7.5 2246 1758 1800 2072 0 0 0 0 0 0 0 0 0 0 0 60 61 1868 8.3 1987 2246 1758 1800 1 0 0 0 0 0 0 0 0 0 0 61 62 2514 8.8 1868 1987 2246 1758 0 1 0 0 0 0 0 0 0 0 0 62 63 2121 8.9 2514 1868 1987 2246 0 0 1 0 0 0 0 0 0 0 0 63 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 1908.34256 -146.92384 0.13237 0.29892 0.19761 0.04613 M1 M2 M3 M4 M5 M6 -39.76380 341.29459 -112.55365 -273.95529 -182.80880 122.83462 M7 M8 M9 M10 M11 t -212.27344 -9.44724 216.52381 -57.74343 97.31393 0.83515 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -498.96 -141.55 30.06 135.30 645.01 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1908.34256 640.87825 2.978 0.00466 ** X -146.92384 75.02945 -1.958 0.05642 . Y1 0.13237 0.14406 0.919 0.36307 Y2 0.29892 0.14326 2.087 0.04262 * Y3 0.19761 0.14374 1.375 0.17602 Y4 0.04613 0.14268 0.323 0.74798 M1 -39.76380 162.33470 -0.245 0.80761 M2 341.29459 159.34315 2.142 0.03765 * M3 -112.55365 163.53503 -0.688 0.49483 M4 -273.95529 173.84932 -1.576 0.12207 M5 -182.80880 173.78368 -1.052 0.29845 M6 122.83462 182.52251 0.673 0.50440 M7 -212.27344 167.68062 -1.266 0.21205 M8 -9.44724 177.97564 -0.053 0.95790 M9 216.52381 169.47188 1.278 0.20793 M10 -57.74343 170.39645 -0.339 0.73628 M11 97.31393 165.83668 0.587 0.56027 t 0.83515 3.14920 0.265 0.79207 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 248.9 on 45 degrees of freedom Multiple R-squared: 0.5932, Adjusted R-squared: 0.4395 F-statistic: 3.86 on 17 and 45 DF, p-value: 0.0001443 > 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.8252124 0.34957529 0.17478764 [2,] 0.8589494 0.28210112 0.14105056 [3,] 0.7915959 0.41680814 0.20840407 [4,] 0.9574062 0.08518762 0.04259381 [5,] 0.9439572 0.11208566 0.05604283 [6,] 0.9421696 0.11566080 0.05783040 [7,] 0.9272102 0.14557962 0.07278981 [8,] 0.9138187 0.17236266 0.08618133 [9,] 0.8699852 0.26002964 0.13001482 [10,] 0.8051101 0.38977972 0.19488986 [11,] 0.7404171 0.51916572 0.25958286 [12,] 0.6565594 0.68688125 0.34344063 [13,] 0.6091610 0.78167800 0.39083900 [14,] 0.4997089 0.99941787 0.50029107 [15,] 0.4177859 0.83557175 0.58221412 [16,] 0.3574242 0.71484836 0.64257582 [17,] 0.2750193 0.55003864 0.72498068 [18,] 0.2023095 0.40461902 0.79769049 [19,] 0.1596171 0.31923417 0.84038292 [20,] 0.1199569 0.23991370 0.88004315 [21,] 0.4947084 0.98941679 0.50529161 [22,] 0.5426339 0.91473225 0.45736612 > postscript(file="/var/www/html/rcomp/tmp/1mkpg1258743757.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/2v5fi1258743757.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/3235j1258743757.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/4yo9j1258743757.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/53vay1258743757.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 = 63 Frequency = 1 1 2 3 4 5 6 -63.566985 266.940738 -204.263500 -208.401674 -245.290903 11.774059 7 8 9 10 11 12 -48.565143 -139.504558 -241.878715 125.715042 48.410658 171.280868 13 14 15 16 17 18 292.681963 -162.719657 -363.949791 55.973594 114.693269 -41.397010 19 20 21 22 23 24 36.163879 251.807414 645.013588 -45.256390 30.063973 -498.961151 25 26 27 28 29 30 237.134544 -314.575919 41.812442 45.532434 117.714720 -5.534103 31 32 33 34 35 36 -80.949073 -44.814981 -112.938071 58.829297 183.117044 34.078717 37 38 39 40 41 42 -60.689371 131.224701 265.043729 45.220931 -270.559948 227.436350 43 44 45 46 47 48 178.327667 -100.363584 144.672293 232.034243 -245.987229 437.197647 49 50 51 52 53 54 -208.688067 -60.243631 68.546684 61.674715 283.442862 -192.279297 55 56 57 58 59 60 -84.977330 32.875709 -434.869094 -371.322191 -15.604445 -143.596081 61 62 63 -196.872084 139.373767 192.810437 > postscript(file="/var/www/html/rcomp/tmp/6ce4p1258743757.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 = 63 Frequency = 1 lag(myerror, k = 1) myerror 0 -63.566985 NA 1 266.940738 -63.566985 2 -204.263500 266.940738 3 -208.401674 -204.263500 4 -245.290903 -208.401674 5 11.774059 -245.290903 6 -48.565143 11.774059 7 -139.504558 -48.565143 8 -241.878715 -139.504558 9 125.715042 -241.878715 10 48.410658 125.715042 11 171.280868 48.410658 12 292.681963 171.280868 13 -162.719657 292.681963 14 -363.949791 -162.719657 15 55.973594 -363.949791 16 114.693269 55.973594 17 -41.397010 114.693269 18 36.163879 -41.397010 19 251.807414 36.163879 20 645.013588 251.807414 21 -45.256390 645.013588 22 30.063973 -45.256390 23 -498.961151 30.063973 24 237.134544 -498.961151 25 -314.575919 237.134544 26 41.812442 -314.575919 27 45.532434 41.812442 28 117.714720 45.532434 29 -5.534103 117.714720 30 -80.949073 -5.534103 31 -44.814981 -80.949073 32 -112.938071 -44.814981 33 58.829297 -112.938071 34 183.117044 58.829297 35 34.078717 183.117044 36 -60.689371 34.078717 37 131.224701 -60.689371 38 265.043729 131.224701 39 45.220931 265.043729 40 -270.559948 45.220931 41 227.436350 -270.559948 42 178.327667 227.436350 43 -100.363584 178.327667 44 144.672293 -100.363584 45 232.034243 144.672293 46 -245.987229 232.034243 47 437.197647 -245.987229 48 -208.688067 437.197647 49 -60.243631 -208.688067 50 68.546684 -60.243631 51 61.674715 68.546684 52 283.442862 61.674715 53 -192.279297 283.442862 54 -84.977330 -192.279297 55 32.875709 -84.977330 56 -434.869094 32.875709 57 -371.322191 -434.869094 58 -15.604445 -371.322191 59 -143.596081 -15.604445 60 -196.872084 -143.596081 61 139.373767 -196.872084 62 192.810437 139.373767 63 NA 192.810437 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 266.940738 -63.566985 [2,] -204.263500 266.940738 [3,] -208.401674 -204.263500 [4,] -245.290903 -208.401674 [5,] 11.774059 -245.290903 [6,] -48.565143 11.774059 [7,] -139.504558 -48.565143 [8,] -241.878715 -139.504558 [9,] 125.715042 -241.878715 [10,] 48.410658 125.715042 [11,] 171.280868 48.410658 [12,] 292.681963 171.280868 [13,] -162.719657 292.681963 [14,] -363.949791 -162.719657 [15,] 55.973594 -363.949791 [16,] 114.693269 55.973594 [17,] -41.397010 114.693269 [18,] 36.163879 -41.397010 [19,] 251.807414 36.163879 [20,] 645.013588 251.807414 [21,] -45.256390 645.013588 [22,] 30.063973 -45.256390 [23,] -498.961151 30.063973 [24,] 237.134544 -498.961151 [25,] -314.575919 237.134544 [26,] 41.812442 -314.575919 [27,] 45.532434 41.812442 [28,] 117.714720 45.532434 [29,] -5.534103 117.714720 [30,] -80.949073 -5.534103 [31,] -44.814981 -80.949073 [32,] -112.938071 -44.814981 [33,] 58.829297 -112.938071 [34,] 183.117044 58.829297 [35,] 34.078717 183.117044 [36,] -60.689371 34.078717 [37,] 131.224701 -60.689371 [38,] 265.043729 131.224701 [39,] 45.220931 265.043729 [40,] -270.559948 45.220931 [41,] 227.436350 -270.559948 [42,] 178.327667 227.436350 [43,] -100.363584 178.327667 [44,] 144.672293 -100.363584 [45,] 232.034243 144.672293 [46,] -245.987229 232.034243 [47,] 437.197647 -245.987229 [48,] -208.688067 437.197647 [49,] -60.243631 -208.688067 [50,] 68.546684 -60.243631 [51,] 61.674715 68.546684 [52,] 283.442862 61.674715 [53,] -192.279297 283.442862 [54,] -84.977330 -192.279297 [55,] 32.875709 -84.977330 [56,] -434.869094 32.875709 [57,] -371.322191 -434.869094 [58,] -15.604445 -371.322191 [59,] -143.596081 -15.604445 [60,] -196.872084 -143.596081 [61,] 139.373767 -196.872084 [62,] 192.810437 139.373767 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 266.940738 -63.566985 2 -204.263500 266.940738 3 -208.401674 -204.263500 4 -245.290903 -208.401674 5 11.774059 -245.290903 6 -48.565143 11.774059 7 -139.504558 -48.565143 8 -241.878715 -139.504558 9 125.715042 -241.878715 10 48.410658 125.715042 11 171.280868 48.410658 12 292.681963 171.280868 13 -162.719657 292.681963 14 -363.949791 -162.719657 15 55.973594 -363.949791 16 114.693269 55.973594 17 -41.397010 114.693269 18 36.163879 -41.397010 19 251.807414 36.163879 20 645.013588 251.807414 21 -45.256390 645.013588 22 30.063973 -45.256390 23 -498.961151 30.063973 24 237.134544 -498.961151 25 -314.575919 237.134544 26 41.812442 -314.575919 27 45.532434 41.812442 28 117.714720 45.532434 29 -5.534103 117.714720 30 -80.949073 -5.534103 31 -44.814981 -80.949073 32 -112.938071 -44.814981 33 58.829297 -112.938071 34 183.117044 58.829297 35 34.078717 183.117044 36 -60.689371 34.078717 37 131.224701 -60.689371 38 265.043729 131.224701 39 45.220931 265.043729 40 -270.559948 45.220931 41 227.436350 -270.559948 42 178.327667 227.436350 43 -100.363584 178.327667 44 144.672293 -100.363584 45 232.034243 144.672293 46 -245.987229 232.034243 47 437.197647 -245.987229 48 -208.688067 437.197647 49 -60.243631 -208.688067 50 68.546684 -60.243631 51 61.674715 68.546684 52 283.442862 61.674715 53 -192.279297 283.442862 54 -84.977330 -192.279297 55 32.875709 -84.977330 56 -434.869094 32.875709 57 -371.322191 -434.869094 58 -15.604445 -371.322191 59 -143.596081 -15.604445 60 -196.872084 -143.596081 61 139.373767 -196.872084 62 192.810437 139.373767 > 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/7rcwq1258743757.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/8s54f1258743757.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/9ffhq1258743757.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/10j28r1258743757.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/116ark1258743757.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/12judm1258743757.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/13hp7d1258743757.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/14aa8q1258743757.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/15qxor1258743757.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/16jqg71258743757.tab") + } > > system("convert tmp/1mkpg1258743757.ps tmp/1mkpg1258743757.png") > system("convert tmp/2v5fi1258743757.ps tmp/2v5fi1258743757.png") > system("convert tmp/3235j1258743757.ps tmp/3235j1258743757.png") > system("convert tmp/4yo9j1258743757.ps tmp/4yo9j1258743757.png") > system("convert tmp/53vay1258743757.ps tmp/53vay1258743757.png") > system("convert tmp/6ce4p1258743757.ps tmp/6ce4p1258743757.png") > system("convert tmp/7rcwq1258743757.ps tmp/7rcwq1258743757.png") > system("convert tmp/8s54f1258743757.ps tmp/8s54f1258743757.png") > system("convert tmp/9ffhq1258743757.ps tmp/9ffhq1258743757.png") > system("convert tmp/10j28r1258743757.ps tmp/10j28r1258743757.png") > > > proc.time() user system elapsed 2.448 1.575 3.277