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(8776 + ,0 + ,8823 + ,9051 + ,8255 + ,0 + ,8776 + ,8823 + ,7969 + ,0 + ,8255 + ,8776 + ,8758 + ,0 + ,7969 + ,8255 + ,8693 + ,0 + ,8758 + ,7969 + ,8271 + ,0 + ,8693 + ,8758 + ,7790 + ,0 + ,8271 + ,8693 + ,7769 + ,0 + ,7790 + ,8271 + ,8170 + ,0 + ,7769 + ,7790 + ,8209 + ,0 + ,8170 + ,7769 + ,9395 + ,0 + ,8209 + ,8170 + ,9260 + ,0 + ,9395 + ,8209 + ,9018 + ,0 + ,9260 + ,9395 + ,8501 + ,0 + ,9018 + ,9260 + ,8500 + ,0 + ,8501 + ,9018 + ,9649 + ,0 + ,8500 + ,8501 + ,9319 + ,0 + ,9649 + ,8500 + ,8830 + ,0 + ,9319 + ,9649 + ,8436 + ,0 + ,8830 + ,9319 + ,8169 + ,0 + ,8436 + ,8830 + ,8269 + ,0 + ,8169 + ,8436 + ,7945 + ,0 + ,8269 + ,8169 + ,9144 + ,0 + ,7945 + ,8269 + ,8770 + ,0 + ,9144 + ,7945 + ,8834 + ,0 + ,8770 + ,9144 + ,7837 + ,0 + ,8834 + ,8770 + ,7792 + ,0 + ,7837 + ,8834 + ,8616 + ,0 + ,7792 + ,7837 + ,8518 + ,0 + ,8616 + ,7792 + ,7940 + ,0 + ,8518 + ,8616 + ,7545 + ,0 + ,7940 + ,8518 + ,7531 + ,0 + ,7545 + ,7940 + ,7665 + ,0 + ,7531 + ,7545 + ,7599 + ,0 + ,7665 + ,7531 + ,8444 + ,0 + ,7599 + ,7665 + ,8549 + ,0 + ,8444 + ,7599 + ,7986 + ,0 + ,8549 + ,8444 + ,7335 + ,0 + ,7986 + ,8549 + ,7287 + ,0 + ,7335 + ,7986 + ,7870 + ,0 + ,7287 + ,7335 + ,7839 + ,0 + ,7870 + ,7287 + ,7327 + ,0 + ,7839 + ,7870 + ,7259 + ,0 + ,7327 + ,7839 + ,6964 + ,0 + ,7259 + ,7327 + ,7271 + ,0 + ,6964 + ,7259 + ,6956 + ,0 + ,7271 + ,6964 + ,7608 + ,0 + ,6956 + ,7271 + ,7692 + ,0 + ,7608 + ,6956 + ,7255 + ,0 + ,7692 + ,7608 + ,6804 + ,0 + ,7255 + ,7692 + ,6655 + ,0 + ,6804 + ,7255 + ,7341 + ,0 + ,6655 + ,6804 + ,7602 + ,0 + ,7341 + ,6655 + ,7086 + ,0 + ,7602 + ,7341 + ,6625 + ,0 + ,7086 + ,7602 + ,6272 + ,0 + ,6625 + ,7086 + ,6576 + ,0 + ,6272 + ,6625 + ,6491 + ,0 + ,6576 + ,6272 + ,7649 + ,0 + ,6491 + ,6576 + ,7400 + ,0 + ,7649 + ,6491 + ,6913 + ,0 + ,7400 + ,7649 + ,6532 + ,0 + ,6913 + ,7400 + ,6486 + ,0 + ,6532 + ,6913 + ,7295 + ,0 + ,6486 + ,6532 + ,7556 + ,0 + ,7295 + ,6486 + ,7088 + ,1 + ,7556 + ,7295 + ,6952 + ,1 + ,7088 + ,7556 + ,6773 + ,1 + ,6952 + ,7088 + ,6917 + ,1 + ,6773 + ,6952 + ,7371 + ,1 + ,6917 + ,6773 + ,8221 + ,1 + ,7371 + ,6917 + ,7953 + ,1 + ,8221 + ,7371 + ,8027 + ,1 + ,7953 + ,8221 + ,7287 + ,1 + ,8027 + ,7953 + ,8076 + ,1 + ,7287 + ,8027 + ,8933 + ,1 + ,8076 + ,7287 + ,9433 + ,1 + ,8933 + ,8076 + ,9479 + ,1 + ,9433 + ,8933 + ,9199 + ,1 + ,9479 + ,9433 + ,9469 + ,1 + ,9199 + ,9479 + ,10015 + ,1 + ,9469 + ,9199 + ,10999 + ,1 + ,10015 + ,9469 + ,13009 + ,1 + ,10999 + ,10015 + ,13699 + ,1 + ,13009 + ,10999 + ,13895 + ,1 + ,13699 + ,13009 + ,13248 + ,1 + ,13895 + ,13699 + ,13973 + ,1 + ,13248 + ,13895 + ,15095 + ,1 + ,13973 + ,13248 + ,15201 + ,1 + ,15095 + ,13973 + ,14823 + ,1 + ,15201 + ,15095 + ,14538 + ,1 + ,14823 + ,15201 + ,14547 + ,1 + ,14538 + ,14823 + ,14407 + ,1 + ,14547 + ,14538) + ,dim=c(4 + ,93) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2') + ,1:93)) > y <- array(NA,dim=c(4,93),dimnames=list(c('Y','X','Y1','Y2'),1:93)) > 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 8776 0 8823 9051 1 0 0 0 0 0 0 0 0 0 0 1 2 8255 0 8776 8823 0 1 0 0 0 0 0 0 0 0 0 2 3 7969 0 8255 8776 0 0 1 0 0 0 0 0 0 0 0 3 4 8758 0 7969 8255 0 0 0 1 0 0 0 0 0 0 0 4 5 8693 0 8758 7969 0 0 0 0 1 0 0 0 0 0 0 5 6 8271 0 8693 8758 0 0 0 0 0 1 0 0 0 0 0 6 7 7790 0 8271 8693 0 0 0 0 0 0 1 0 0 0 0 7 8 7769 0 7790 8271 0 0 0 0 0 0 0 1 0 0 0 8 9 8170 0 7769 7790 0 0 0 0 0 0 0 0 1 0 0 9 10 8209 0 8170 7769 0 0 0 0 0 0 0 0 0 1 0 10 11 9395 0 8209 8170 0 0 0 0 0 0 0 0 0 0 1 11 12 9260 0 9395 8209 0 0 0 0 0 0 0 0 0 0 0 12 13 9018 0 9260 9395 1 0 0 0 0 0 0 0 0 0 0 13 14 8501 0 9018 9260 0 1 0 0 0 0 0 0 0 0 0 14 15 8500 0 8501 9018 0 0 1 0 0 0 0 0 0 0 0 15 16 9649 0 8500 8501 0 0 0 1 0 0 0 0 0 0 0 16 17 9319 0 9649 8500 0 0 0 0 1 0 0 0 0 0 0 17 18 8830 0 9319 9649 0 0 0 0 0 1 0 0 0 0 0 18 19 8436 0 8830 9319 0 0 0 0 0 0 1 0 0 0 0 19 20 8169 0 8436 8830 0 0 0 0 0 0 0 1 0 0 0 20 21 8269 0 8169 8436 0 0 0 0 0 0 0 0 1 0 0 21 22 7945 0 8269 8169 0 0 0 0 0 0 0 0 0 1 0 22 23 9144 0 7945 8269 0 0 0 0 0 0 0 0 0 0 1 23 24 8770 0 9144 7945 0 0 0 0 0 0 0 0 0 0 0 24 25 8834 0 8770 9144 1 0 0 0 0 0 0 0 0 0 0 25 26 7837 0 8834 8770 0 1 0 0 0 0 0 0 0 0 0 26 27 7792 0 7837 8834 0 0 1 0 0 0 0 0 0 0 0 27 28 8616 0 7792 7837 0 0 0 1 0 0 0 0 0 0 0 28 29 8518 0 8616 7792 0 0 0 0 1 0 0 0 0 0 0 29 30 7940 0 8518 8616 0 0 0 0 0 1 0 0 0 0 0 30 31 7545 0 7940 8518 0 0 0 0 0 0 1 0 0 0 0 31 32 7531 0 7545 7940 0 0 0 0 0 0 0 1 0 0 0 32 33 7665 0 7531 7545 0 0 0 0 0 0 0 0 1 0 0 33 34 7599 0 7665 7531 0 0 0 0 0 0 0 0 0 1 0 34 35 8444 0 7599 7665 0 0 0 0 0 0 0 0 0 0 1 35 36 8549 0 8444 7599 0 0 0 0 0 0 0 0 0 0 0 36 37 7986 0 8549 8444 1 0 0 0 0 0 0 0 0 0 0 37 38 7335 0 7986 8549 0 1 0 0 0 0 0 0 0 0 0 38 39 7287 0 7335 7986 0 0 1 0 0 0 0 0 0 0 0 39 40 7870 0 7287 7335 0 0 0 1 0 0 0 0 0 0 0 40 41 7839 0 7870 7287 0 0 0 0 1 0 0 0 0 0 0 41 42 7327 0 7839 7870 0 0 0 0 0 1 0 0 0 0 0 42 43 7259 0 7327 7839 0 0 0 0 0 0 1 0 0 0 0 43 44 6964 0 7259 7327 0 0 0 0 0 0 0 1 0 0 0 44 45 7271 0 6964 7259 0 0 0 0 0 0 0 0 1 0 0 45 46 6956 0 7271 6964 0 0 0 0 0 0 0 0 0 1 0 46 47 7608 0 6956 7271 0 0 0 0 0 0 0 0 0 0 1 47 48 7692 0 7608 6956 0 0 0 0 0 0 0 0 0 0 0 48 49 7255 0 7692 7608 1 0 0 0 0 0 0 0 0 0 0 49 50 6804 0 7255 7692 0 1 0 0 0 0 0 0 0 0 0 50 51 6655 0 6804 7255 0 0 1 0 0 0 0 0 0 0 0 51 52 7341 0 6655 6804 0 0 0 1 0 0 0 0 0 0 0 52 53 7602 0 7341 6655 0 0 0 0 1 0 0 0 0 0 0 53 54 7086 0 7602 7341 0 0 0 0 0 1 0 0 0 0 0 54 55 6625 0 7086 7602 0 0 0 0 0 0 1 0 0 0 0 55 56 6272 0 6625 7086 0 0 0 0 0 0 0 1 0 0 0 56 57 6576 0 6272 6625 0 0 0 0 0 0 0 0 1 0 0 57 58 6491 0 6576 6272 0 0 0 0 0 0 0 0 0 1 0 58 59 7649 0 6491 6576 0 0 0 0 0 0 0 0 0 0 1 59 60 7400 0 7649 6491 0 0 0 0 0 0 0 0 0 0 0 60 61 6913 0 7400 7649 1 0 0 0 0 0 0 0 0 0 0 61 62 6532 0 6913 7400 0 1 0 0 0 0 0 0 0 0 0 62 63 6486 0 6532 6913 0 0 1 0 0 0 0 0 0 0 0 63 64 7295 0 6486 6532 0 0 0 1 0 0 0 0 0 0 0 64 65 7556 0 7295 6486 0 0 0 0 1 0 0 0 0 0 0 65 66 7088 1 7556 7295 0 0 0 0 0 1 0 0 0 0 0 66 67 6952 1 7088 7556 0 0 0 0 0 0 1 0 0 0 0 67 68 6773 1 6952 7088 0 0 0 0 0 0 0 1 0 0 0 68 69 6917 1 6773 6952 0 0 0 0 0 0 0 0 1 0 0 69 70 7371 1 6917 6773 0 0 0 0 0 0 0 0 0 1 0 70 71 8221 1 7371 6917 0 0 0 0 0 0 0 0 0 0 1 71 72 7953 1 8221 7371 0 0 0 0 0 0 0 0 0 0 0 72 73 8027 1 7953 8221 1 0 0 0 0 0 0 0 0 0 0 73 74 7287 1 8027 7953 0 1 0 0 0 0 0 0 0 0 0 74 75 8076 1 7287 8027 0 0 1 0 0 0 0 0 0 0 0 75 76 8933 1 8076 7287 0 0 0 1 0 0 0 0 0 0 0 76 77 9433 1 8933 8076 0 0 0 0 1 0 0 0 0 0 0 77 78 9479 1 9433 8933 0 0 0 0 0 1 0 0 0 0 0 78 79 9199 1 9479 9433 0 0 0 0 0 0 1 0 0 0 0 79 80 9469 1 9199 9479 0 0 0 0 0 0 0 1 0 0 0 80 81 10015 1 9469 9199 0 0 0 0 0 0 0 0 1 0 0 81 82 10999 1 10015 9469 0 0 0 0 0 0 0 0 0 1 0 82 83 13009 1 10999 10015 0 0 0 0 0 0 0 0 0 0 1 83 84 13699 1 13009 10999 0 0 0 0 0 0 0 0 0 0 0 84 85 13895 1 13699 13009 1 0 0 0 0 0 0 0 0 0 0 85 86 13248 1 13895 13699 0 1 0 0 0 0 0 0 0 0 0 86 87 13973 1 13248 13895 0 0 1 0 0 0 0 0 0 0 0 87 88 15095 1 13973 13248 0 0 0 1 0 0 0 0 0 0 0 88 89 15201 1 15095 13973 0 0 0 0 1 0 0 0 0 0 0 89 90 14823 1 15201 15095 0 0 0 0 0 1 0 0 0 0 0 90 91 14538 1 14823 15201 0 0 0 0 0 0 1 0 0 0 0 91 92 14547 1 14538 14823 0 0 0 0 0 0 0 1 0 0 0 92 93 14407 1 14547 14538 0 0 0 0 0 0 0 0 1 0 0 93 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 M1 M2 -1.183e+02 2.984e+02 1.002e+00 4.471e-06 -1.490e+02 -5.814e+02 M3 M4 M5 M6 M7 M8 1.503e+02 8.852e+02 1.068e+02 -4.206e+02 -3.177e+02 -1.108e+02 M9 M10 M11 t 2.203e+02 1.212e+02 1.152e+03 -9.217e-02 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -558.229 -165.970 -5.163 167.644 672.063 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.183e+02 2.014e+02 -0.587 0.55883 X 2.984e+02 1.121e+02 2.663 0.00943 ** Y1 1.002e+00 1.194e-01 8.387 1.82e-12 *** Y2 4.471e-06 1.223e-01 3.66e-05 0.99997 M1 -1.490e+02 1.972e+02 -0.755 0.45226 M2 -5.814e+02 2.087e+02 -2.786 0.00672 ** M3 1.503e+02 2.495e+02 0.602 0.54868 M4 8.852e+02 1.817e+02 4.871 5.80e-06 *** M5 1.068e+02 1.403e+02 0.761 0.44882 M6 -4.206e+02 1.900e+02 -2.214 0.02979 * M7 -3.177e+02 2.344e+02 -1.355 0.17930 M8 -1.108e+02 2.236e+02 -0.495 0.62176 M9 2.203e+02 2.041e+02 1.079 0.28377 M10 1.212e+02 1.734e+02 0.699 0.48686 M11 1.152e+03 1.869e+02 6.162 3.05e-08 *** t -9.217e-02 1.683e+00 -0.055 0.95648 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 263.3 on 77 degrees of freedom Multiple R-squared: 0.9883, Adjusted R-squared: 0.986 F-statistic: 432.9 on 15 and 77 DF, p-value: < 2.2e-16 > 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.2996351025 0.5992702049 0.7003649 [2,] 0.1940842073 0.3881684146 0.8059158 [3,] 0.1524739544 0.3049479088 0.8475260 [4,] 0.1804426611 0.3608853223 0.8195573 [5,] 0.1097935686 0.2195871372 0.8902064 [6,] 0.1115455338 0.2230910676 0.8884545 [7,] 0.1001690816 0.2003381632 0.8998309 [8,] 0.1791749789 0.3583499578 0.8208250 [9,] 0.1279598147 0.2559196294 0.8720402 [10,] 0.0858777441 0.1717554882 0.9141223 [11,] 0.0602859512 0.1205719024 0.9397140 [12,] 0.0368083687 0.0736167374 0.9631916 [13,] 0.0223349986 0.0446699973 0.9776650 [14,] 0.0174874889 0.0349749778 0.9825125 [15,] 0.0103109706 0.0206219411 0.9896890 [16,] 0.0058983199 0.0117966397 0.9941017 [17,] 0.0058856964 0.0117713927 0.9941143 [18,] 0.0064400772 0.0128801544 0.9935599 [19,] 0.0061247775 0.0122495549 0.9938752 [20,] 0.0038121825 0.0076243651 0.9961878 [21,] 0.0024625607 0.0049251214 0.9975374 [22,] 0.0019420518 0.0038841035 0.9980579 [23,] 0.0010486854 0.0020973707 0.9989513 [24,] 0.0006003204 0.0012006407 0.9993997 [25,] 0.0016683596 0.0033367193 0.9983316 [26,] 0.0008951255 0.0017902509 0.9991049 [27,] 0.0008521826 0.0017043652 0.9991478 [28,] 0.0006582757 0.0013165514 0.9993417 [29,] 0.0016653625 0.0033307250 0.9983346 [30,] 0.0013673998 0.0027347996 0.9986326 [31,] 0.0007665078 0.0015330156 0.9992335 [32,] 0.0010362384 0.0020724769 0.9989638 [33,] 0.0007461586 0.0014923173 0.9992538 [34,] 0.0004929152 0.0009858304 0.9995071 [35,] 0.0009474891 0.0018949783 0.9990525 [36,] 0.0006477990 0.0012955980 0.9993522 [37,] 0.0004152813 0.0008305626 0.9995847 [38,] 0.0002834352 0.0005668705 0.9997166 [39,] 0.0006690300 0.0013380600 0.9993310 [40,] 0.0005457383 0.0010914765 0.9994543 [41,] 0.0005212206 0.0010424412 0.9994788 [42,] 0.0002705894 0.0005411787 0.9997294 [43,] 0.0002339248 0.0004678495 0.9997661 [44,] 0.0010966208 0.0021932417 0.9989034 [45,] 0.0104353566 0.0208707132 0.9895646 [46,] 0.0070678362 0.0141356724 0.9929322 [47,] 0.0066221938 0.0132443876 0.9933778 [48,] 0.0037031452 0.0074062903 0.9962969 [49,] 0.0098691913 0.0197383825 0.9901308 [50,] 0.0056894093 0.0113788187 0.9943106 [51,] 0.0203485741 0.0406971483 0.9796514 [52,] 0.0379147853 0.0758295706 0.9620852 [53,] 0.0362354258 0.0724708517 0.9637646 [54,] 0.1090865462 0.2181730924 0.8909135 [55,] 0.0781665887 0.1563331773 0.9218334 [56,] 0.0570658190 0.1141316380 0.9429342 > postscript(file="/var/www/html/rcomp/tmp/1h6sp1260039641.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/2kls91260039641.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/381x01260039641.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/4lup91260039641.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/5s1en1260039641.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 = 93 Frequency = 1 1 2 3 4 5 6 204.342370 162.977267 -332.689889 8.038991 -68.969625 101.714824 7 8 9 10 11 12 -59.396214 194.658462 285.755086 22.211279 138.889080 -32.643056 13 14 15 16 17 18 9.656743 167.643780 -47.029736 368.183854 -334.476908 34.685044 19 20 21 22 23 24 27.696325 -51.405992 -14.864996 -339.863502 153.471940 -270.082077 25 26 27 28 29 30 317.649770 -310.915365 -88.722420 45.572866 -99.500107 -51.756152 31 32 33 34 35 36 29.415002 204.314890 21.398473 -79.662635 -198.793803 211.291050 37 38 39 40 41 42 -307.841540 37.724783 -89.705028 -193.405865 -30.043102 16.580796 43 44 45 46 47 48 358.632323 -75.059291 196.530871 -326.841761 -389.523516 192.911389 49 50 51 52 53 54 -179.182371 240.156242 -188.635728 -88.154854 264.022139 14.117648 55 56 57 58 59 60 -32.824898 -130.805960 195.890822 -94.476127 118.426296 -139.054662 61 62 63 64 65 66 -227.548628 311.881872 -84.036433 36.257907 265.212059 -235.134137 67 68 69 70 71 72 -5.163466 -254.732335 -262.351594 146.569956 -488.501404 -456.427916 73 74 75 76 77 78 35.113846 -346.469843 452.258407 -215.955307 203.908328 276.570967 79 80 81 82 83 84 -152.388730 191.300451 135.870055 672.062791 666.031407 494.005274 85 86 87 88 89 90 147.809809 -262.998736 378.560827 39.462407 -200.152785 -156.778989 91 92 93 -165.970342 -78.270226 -558.228718 > postscript(file="/var/www/html/rcomp/tmp/69zih1260039641.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 = 93 Frequency = 1 lag(myerror, k = 1) myerror 0 204.342370 NA 1 162.977267 204.342370 2 -332.689889 162.977267 3 8.038991 -332.689889 4 -68.969625 8.038991 5 101.714824 -68.969625 6 -59.396214 101.714824 7 194.658462 -59.396214 8 285.755086 194.658462 9 22.211279 285.755086 10 138.889080 22.211279 11 -32.643056 138.889080 12 9.656743 -32.643056 13 167.643780 9.656743 14 -47.029736 167.643780 15 368.183854 -47.029736 16 -334.476908 368.183854 17 34.685044 -334.476908 18 27.696325 34.685044 19 -51.405992 27.696325 20 -14.864996 -51.405992 21 -339.863502 -14.864996 22 153.471940 -339.863502 23 -270.082077 153.471940 24 317.649770 -270.082077 25 -310.915365 317.649770 26 -88.722420 -310.915365 27 45.572866 -88.722420 28 -99.500107 45.572866 29 -51.756152 -99.500107 30 29.415002 -51.756152 31 204.314890 29.415002 32 21.398473 204.314890 33 -79.662635 21.398473 34 -198.793803 -79.662635 35 211.291050 -198.793803 36 -307.841540 211.291050 37 37.724783 -307.841540 38 -89.705028 37.724783 39 -193.405865 -89.705028 40 -30.043102 -193.405865 41 16.580796 -30.043102 42 358.632323 16.580796 43 -75.059291 358.632323 44 196.530871 -75.059291 45 -326.841761 196.530871 46 -389.523516 -326.841761 47 192.911389 -389.523516 48 -179.182371 192.911389 49 240.156242 -179.182371 50 -188.635728 240.156242 51 -88.154854 -188.635728 52 264.022139 -88.154854 53 14.117648 264.022139 54 -32.824898 14.117648 55 -130.805960 -32.824898 56 195.890822 -130.805960 57 -94.476127 195.890822 58 118.426296 -94.476127 59 -139.054662 118.426296 60 -227.548628 -139.054662 61 311.881872 -227.548628 62 -84.036433 311.881872 63 36.257907 -84.036433 64 265.212059 36.257907 65 -235.134137 265.212059 66 -5.163466 -235.134137 67 -254.732335 -5.163466 68 -262.351594 -254.732335 69 146.569956 -262.351594 70 -488.501404 146.569956 71 -456.427916 -488.501404 72 35.113846 -456.427916 73 -346.469843 35.113846 74 452.258407 -346.469843 75 -215.955307 452.258407 76 203.908328 -215.955307 77 276.570967 203.908328 78 -152.388730 276.570967 79 191.300451 -152.388730 80 135.870055 191.300451 81 672.062791 135.870055 82 666.031407 672.062791 83 494.005274 666.031407 84 147.809809 494.005274 85 -262.998736 147.809809 86 378.560827 -262.998736 87 39.462407 378.560827 88 -200.152785 39.462407 89 -156.778989 -200.152785 90 -165.970342 -156.778989 91 -78.270226 -165.970342 92 -558.228718 -78.270226 93 NA -558.228718 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 162.977267 204.342370 [2,] -332.689889 162.977267 [3,] 8.038991 -332.689889 [4,] -68.969625 8.038991 [5,] 101.714824 -68.969625 [6,] -59.396214 101.714824 [7,] 194.658462 -59.396214 [8,] 285.755086 194.658462 [9,] 22.211279 285.755086 [10,] 138.889080 22.211279 [11,] -32.643056 138.889080 [12,] 9.656743 -32.643056 [13,] 167.643780 9.656743 [14,] -47.029736 167.643780 [15,] 368.183854 -47.029736 [16,] -334.476908 368.183854 [17,] 34.685044 -334.476908 [18,] 27.696325 34.685044 [19,] -51.405992 27.696325 [20,] -14.864996 -51.405992 [21,] -339.863502 -14.864996 [22,] 153.471940 -339.863502 [23,] -270.082077 153.471940 [24,] 317.649770 -270.082077 [25,] -310.915365 317.649770 [26,] -88.722420 -310.915365 [27,] 45.572866 -88.722420 [28,] -99.500107 45.572866 [29,] -51.756152 -99.500107 [30,] 29.415002 -51.756152 [31,] 204.314890 29.415002 [32,] 21.398473 204.314890 [33,] -79.662635 21.398473 [34,] -198.793803 -79.662635 [35,] 211.291050 -198.793803 [36,] -307.841540 211.291050 [37,] 37.724783 -307.841540 [38,] -89.705028 37.724783 [39,] -193.405865 -89.705028 [40,] -30.043102 -193.405865 [41,] 16.580796 -30.043102 [42,] 358.632323 16.580796 [43,] -75.059291 358.632323 [44,] 196.530871 -75.059291 [45,] -326.841761 196.530871 [46,] -389.523516 -326.841761 [47,] 192.911389 -389.523516 [48,] -179.182371 192.911389 [49,] 240.156242 -179.182371 [50,] -188.635728 240.156242 [51,] -88.154854 -188.635728 [52,] 264.022139 -88.154854 [53,] 14.117648 264.022139 [54,] -32.824898 14.117648 [55,] -130.805960 -32.824898 [56,] 195.890822 -130.805960 [57,] -94.476127 195.890822 [58,] 118.426296 -94.476127 [59,] -139.054662 118.426296 [60,] -227.548628 -139.054662 [61,] 311.881872 -227.548628 [62,] -84.036433 311.881872 [63,] 36.257907 -84.036433 [64,] 265.212059 36.257907 [65,] -235.134137 265.212059 [66,] -5.163466 -235.134137 [67,] -254.732335 -5.163466 [68,] -262.351594 -254.732335 [69,] 146.569956 -262.351594 [70,] -488.501404 146.569956 [71,] -456.427916 -488.501404 [72,] 35.113846 -456.427916 [73,] -346.469843 35.113846 [74,] 452.258407 -346.469843 [75,] -215.955307 452.258407 [76,] 203.908328 -215.955307 [77,] 276.570967 203.908328 [78,] -152.388730 276.570967 [79,] 191.300451 -152.388730 [80,] 135.870055 191.300451 [81,] 672.062791 135.870055 [82,] 666.031407 672.062791 [83,] 494.005274 666.031407 [84,] 147.809809 494.005274 [85,] -262.998736 147.809809 [86,] 378.560827 -262.998736 [87,] 39.462407 378.560827 [88,] -200.152785 39.462407 [89,] -156.778989 -200.152785 [90,] -165.970342 -156.778989 [91,] -78.270226 -165.970342 [92,] -558.228718 -78.270226 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 162.977267 204.342370 2 -332.689889 162.977267 3 8.038991 -332.689889 4 -68.969625 8.038991 5 101.714824 -68.969625 6 -59.396214 101.714824 7 194.658462 -59.396214 8 285.755086 194.658462 9 22.211279 285.755086 10 138.889080 22.211279 11 -32.643056 138.889080 12 9.656743 -32.643056 13 167.643780 9.656743 14 -47.029736 167.643780 15 368.183854 -47.029736 16 -334.476908 368.183854 17 34.685044 -334.476908 18 27.696325 34.685044 19 -51.405992 27.696325 20 -14.864996 -51.405992 21 -339.863502 -14.864996 22 153.471940 -339.863502 23 -270.082077 153.471940 24 317.649770 -270.082077 25 -310.915365 317.649770 26 -88.722420 -310.915365 27 45.572866 -88.722420 28 -99.500107 45.572866 29 -51.756152 -99.500107 30 29.415002 -51.756152 31 204.314890 29.415002 32 21.398473 204.314890 33 -79.662635 21.398473 34 -198.793803 -79.662635 35 211.291050 -198.793803 36 -307.841540 211.291050 37 37.724783 -307.841540 38 -89.705028 37.724783 39 -193.405865 -89.705028 40 -30.043102 -193.405865 41 16.580796 -30.043102 42 358.632323 16.580796 43 -75.059291 358.632323 44 196.530871 -75.059291 45 -326.841761 196.530871 46 -389.523516 -326.841761 47 192.911389 -389.523516 48 -179.182371 192.911389 49 240.156242 -179.182371 50 -188.635728 240.156242 51 -88.154854 -188.635728 52 264.022139 -88.154854 53 14.117648 264.022139 54 -32.824898 14.117648 55 -130.805960 -32.824898 56 195.890822 -130.805960 57 -94.476127 195.890822 58 118.426296 -94.476127 59 -139.054662 118.426296 60 -227.548628 -139.054662 61 311.881872 -227.548628 62 -84.036433 311.881872 63 36.257907 -84.036433 64 265.212059 36.257907 65 -235.134137 265.212059 66 -5.163466 -235.134137 67 -254.732335 -5.163466 68 -262.351594 -254.732335 69 146.569956 -262.351594 70 -488.501404 146.569956 71 -456.427916 -488.501404 72 35.113846 -456.427916 73 -346.469843 35.113846 74 452.258407 -346.469843 75 -215.955307 452.258407 76 203.908328 -215.955307 77 276.570967 203.908328 78 -152.388730 276.570967 79 191.300451 -152.388730 80 135.870055 191.300451 81 672.062791 135.870055 82 666.031407 672.062791 83 494.005274 666.031407 84 147.809809 494.005274 85 -262.998736 147.809809 86 378.560827 -262.998736 87 39.462407 378.560827 88 -200.152785 39.462407 89 -156.778989 -200.152785 90 -165.970342 -156.778989 91 -78.270226 -165.970342 92 -558.228718 -78.270226 > 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/71ey11260039641.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/8v3py1260039641.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/9wsfv1260039641.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/10lotb1260039641.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/119zm21260039641.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/12a56v1260039641.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/132ymu1260039641.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/14ub1j1260039641.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/15zshs1260039641.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/16m1w01260039641.tab") + } > > system("convert tmp/1h6sp1260039641.ps tmp/1h6sp1260039641.png") > system("convert tmp/2kls91260039641.ps tmp/2kls91260039641.png") > system("convert tmp/381x01260039641.ps tmp/381x01260039641.png") > system("convert tmp/4lup91260039641.ps tmp/4lup91260039641.png") > system("convert tmp/5s1en1260039641.ps tmp/5s1en1260039641.png") > system("convert tmp/69zih1260039641.ps tmp/69zih1260039641.png") > system("convert tmp/71ey11260039641.ps tmp/71ey11260039641.png") > system("convert tmp/8v3py1260039641.ps tmp/8v3py1260039641.png") > system("convert tmp/9wsfv1260039641.ps tmp/9wsfv1260039641.png") > system("convert tmp/10lotb1260039641.ps tmp/10lotb1260039641.png") > > > proc.time() user system elapsed 2.925 1.640 4.738