R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(12 + ,1221.53 + ,2617.2 + ,10168.52 + ,6957.61 + ,23448.78 + ,11 + ,1180.55 + ,2506.13 + ,9937.04 + ,6688.49 + ,23007.99 + ,10 + ,1183.26 + ,2679.07 + ,9202.45 + ,6601.37 + ,23096.32 + ,9 + ,1141.2 + ,2589.73 + ,9369.35 + ,6229.02 + ,22358.17 + ,8 + ,1049.33 + ,2457.46 + ,8824.06 + ,5925.22 + ,20536.49 + ,7 + ,1101.6 + ,2517.3 + ,9537.3 + ,6147.97 + ,21029.81 + ,6 + ,1030.71 + ,2386.53 + ,9382.64 + ,5965.52 + ,20128.99 + ,5 + ,1089.41 + ,2453.37 + ,9768.7 + ,5964.33 + ,19765.19 + ,4 + ,1186.69 + ,2529.66 + ,11057.4 + ,6135.7 + ,21108.59 + ,3 + ,1169.43 + ,2475.14 + ,11089.94 + ,6153.55 + ,21239.35 + ,2 + ,1104.49 + ,2525.93 + ,10126.03 + ,5598.46 + ,20608.7 + ,1 + ,1073.87 + ,2480.93 + ,10198.04 + ,5608.79 + ,20121.99 + ,12 + ,1115.1 + ,2229.85 + ,10546.44 + ,5957.43 + ,21872.5 + ,11 + ,1095.63 + ,2169.14 + ,9345.55 + ,5625.95 + ,21821.5 + ,10 + ,1036.19 + ,2030.98 + ,10034.74 + ,5414.96 + ,21752.87 + ,9 + ,1057.08 + ,2071.37 + ,10133.23 + ,5675.16 + ,20955.25 + ,8 + ,1020.62 + ,1953.35 + ,10492.53 + ,5458.04 + ,19724.19 + ,7 + ,987.48 + ,1748.74 + ,10356.83 + ,5332.14 + ,20573.33 + ,6 + ,919.32 + ,1696.58 + ,9958.44 + ,4808.64 + ,18378.73 + ,5 + ,919.14 + ,1900.09 + ,9522.5 + ,4940.82 + ,18171 + ,4 + ,872.81 + ,1908.64 + ,8828.26 + ,4769.45 + ,15520.99 + ,3 + ,797.87 + ,1881.46 + ,8109.53 + ,4084.76 + ,13576.02 + ,2 + ,735.09 + ,2100.18 + ,7568.42 + ,3843.74 + ,12811.57 + ,1 + ,825.88 + ,2672.2 + ,7994.05 + ,4338.35 + ,13278.21 + ,12 + ,903.25 + ,3136 + ,8859.56 + ,4810.2 + ,14387.48 + ,11 + ,896.24 + ,2994.38 + ,8512.27 + ,4669.44 + ,13888.24 + ,10 + ,968.75 + ,3168.22 + ,8576.98 + ,4987.97 + ,13968.67 + ,9 + ,1166.36 + ,3751.41 + ,11259.86 + ,5831.02 + ,18016.21 + ,8 + ,1282.83 + ,3925.43 + ,13072.87 + ,6422.3 + ,21261.89 + ,7 + ,1267.38 + ,3719.52 + ,13376.81 + ,6479.56 + ,22731.1 + ,6 + ,1280 + ,3757.12 + ,13481.38 + ,6418.32 + ,22102.01 + ,5 + ,1400.38 + ,3722.23 + ,14338.54 + ,7096.79 + ,24533.12 + ,4 + ,1385.59 + ,4127.47 + ,13849.99 + ,6948.82 + ,25755.35 + ,3 + ,1322.7 + ,4162.5 + ,12525.54 + ,6534.97 + ,22849.2 + ,2 + ,1330.63 + ,4441.82 + ,13603.02 + ,6748.13 + ,24331.67 + ,1 + ,1378.55 + ,4325.29 + ,13592.47 + ,6851.75 + ,23455.74 + ,12 + ,1468.36 + ,4350.83 + ,15307.78 + ,8067.32 + ,27812.65 + ,11 + ,1481.14 + ,4384.47 + ,15680.67 + ,7870.52 + ,28643.61 + ,10 + ,1549.38 + ,4639.4 + ,16737.63 + ,8019.22 + ,31352.58 + ,9 + ,1526.75 + ,4697.86 + ,16785.69 + ,7861.51 + ,27142.47 + ,8 + ,1473.99 + ,4614.76 + ,16569.09 + ,7638.17 + ,23984.14 + ,7 + ,1455.27 + ,4471.65 + ,17248.89 + ,7584.14 + ,23184.94 + ,6 + ,1503.35 + ,4305.23 + ,18138.36 + ,8007.32 + ,21772.73 + ,5 + ,1530.62 + ,4433.57 + ,17875.75 + ,7883.04 + ,20634.47 + ,4 + ,1482.37 + ,4388.53 + ,17400.41 + ,7408.87 + ,20318.98 + ,3 + ,1420.86 + ,4140.3 + ,17287.65 + ,6917.03 + ,19800.93 + ,2 + ,1406.82 + ,4144.38 + ,17604.12 + ,6715.44 + ,19651.51 + ,1 + ,1438.24 + ,4070.78 + ,17383.42 + ,6789.11 + ,20106.42 + ,12 + ,1418.3 + ,3906.01 + ,17225.83 + ,6596.92 + ,19964.72 + ,11 + ,1400.63 + ,3795.91 + ,16274.33 + ,6309.19 + ,18960.48 + ,10 + ,1377.94 + ,3703.32 + ,16399.39 + ,6268.92 + ,18324.35 + ,9 + ,1335.85 + ,3675.8 + ,16127.58 + ,6004.33 + ,17543.05 + ,8 + ,1303.82 + ,3911.06 + ,16140.76 + ,5859.57 + ,17392.27 + ,7 + ,1276.66 + ,3912.28 + ,15456.81 + ,5681.97 + ,16971.34 + ,6 + ,1270.2 + ,3839.25 + ,15505.18 + ,5683.31 + ,16267.62 + ,5 + ,1270.09 + ,3744.63 + ,15467.33 + ,5692.86 + ,15857.89 + ,4 + ,1310.61 + ,3549.25 + ,16906.23 + ,6009.89 + ,16661.3 + ,3 + ,1294.87 + ,3394.14 + ,17059.66 + ,5970.08 + ,15805.04 + ,2 + ,1280.66 + ,3264.26 + ,16205.43 + ,5796.04 + ,15918.48 + ,1 + ,1280.08 + ,3328.8 + ,16649.82 + ,5674.15 + ,15753.14 + ,12 + ,1248.29 + ,3223.98 + ,16111.43 + ,5408.26 + ,14876.43 + ,11 + ,1249.48 + ,3228.01 + ,14872.15 + ,5193.4 + ,14937.14 + ,10 + ,1207.01 + ,3112.83 + ,13606.5 + ,4929.07 + ,14386.37 + ,9 + ,1228.81 + ,3051.67 + ,13574.3 + ,5044.12 + ,15428.52 + ,8 + ,1220.33 + ,3039.71 + ,12413.6 + ,4829.69 + ,14903.55 + ,7 + ,1234.18 + ,3125.67 + ,11899.6 + ,4886.5 + ,14880.98 + ,6 + ,1191.33 + ,3106.54 + ,11584.01 + ,4586.28 + ,14201.06 + ,5 + ,1191.5 + ,11276.59 + ,4460.63 + ,13867.07 + ,4 + ,1156.85 + ,11008.9 + ,4184.84 + ,13908.97 + ,3 + ,1180.59 + ,11668.95 + ,4348.77 + ,13516.88 + ,2 + ,1203.6 + ,11740.6 + ,4350.49 + ,14195.35 + ,1 + ,1181.27 + ,11387.59 + ,4254.85 + ,13721.69) + ,dim=c(6 + ,72) + ,dimnames=list(c('month' + ,'S&P' + ,'Bel20' + ,'Nikkei225' + ,'DAX' + ,'HangSeng') + ,1:72)) > y <- array(NA,dim=c(6,72),dimnames=list(c('month','S&P','Bel20','Nikkei225','DAX','HangSeng'),1:72)) > 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 = 'Do not include Seasonal Dummies' > par1 = '4' > #'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 Nikkei225 month S&P Bel20 DAX HangSeng t 1 10168.52 12.00 1221.53 2617.20 6957.61 23448.78 1 2 9937.04 11.00 1180.55 2506.13 6688.49 23007.99 2 3 9202.45 10.00 1183.26 2679.07 6601.37 23096.32 3 4 9369.35 9.00 1141.20 2589.73 6229.02 22358.17 4 5 8824.06 8.00 1049.33 2457.46 5925.22 20536.49 5 6 9537.30 7.00 1101.60 2517.30 6147.97 21029.81 6 7 9382.64 6.00 1030.71 2386.53 5965.52 20128.99 7 8 9768.70 5.00 1089.41 2453.37 5964.33 19765.19 8 9 11057.40 4.00 1186.69 2529.66 6135.70 21108.59 9 10 11089.94 3.00 1169.43 2475.14 6153.55 21239.35 10 11 10126.03 2.00 1104.49 2525.93 5598.46 20608.70 11 12 10198.04 1.00 1073.87 2480.93 5608.79 20121.99 12 13 10546.44 12.00 1115.10 2229.85 5957.43 21872.50 13 14 9345.55 11.00 1095.63 2169.14 5625.95 21821.50 14 15 10034.74 10.00 1036.19 2030.98 5414.96 21752.87 15 16 10133.23 9.00 1057.08 2071.37 5675.16 20955.25 16 17 10492.53 8.00 1020.62 1953.35 5458.04 19724.19 17 18 10356.83 7.00 987.48 1748.74 5332.14 20573.33 18 19 9958.44 6.00 919.32 1696.58 4808.64 18378.73 19 20 9522.50 5.00 919.14 1900.09 4940.82 18171.00 20 21 8828.26 4.00 872.81 1908.64 4769.45 15520.99 21 22 8109.53 3.00 797.87 1881.46 4084.76 13576.02 22 23 7568.42 2.00 735.09 2100.18 3843.74 12811.57 23 24 7994.05 1.00 825.88 2672.20 4338.35 13278.21 24 25 8859.56 12.00 903.25 3136.00 4810.20 14387.48 25 26 8512.27 11.00 896.24 2994.38 4669.44 13888.24 26 27 8576.98 10.00 968.75 3168.22 4987.97 13968.67 27 28 11259.86 9.00 1166.36 3751.41 5831.02 18016.21 28 29 13072.87 8.00 1282.83 3925.43 6422.30 21261.89 29 30 13376.81 7.00 1267.38 3719.52 6479.56 22731.10 30 31 13481.38 6.00 1280.00 3757.12 6418.32 22102.01 31 32 14338.54 5.00 1400.38 3722.23 7096.79 24533.12 32 33 13849.99 4.00 1385.59 4127.47 6948.82 25755.35 33 34 12525.54 3.00 1322.70 4162.50 6534.97 22849.20 34 35 13603.02 2.00 1330.63 4441.82 6748.13 24331.67 35 36 13592.47 1.00 1378.55 4325.29 6851.75 23455.74 36 37 15307.78 12.00 1468.36 4350.83 8067.32 27812.65 37 38 15680.67 11.00 1481.14 4384.47 7870.52 28643.61 38 39 16737.63 10.00 1549.38 4639.40 8019.22 31352.58 39 40 16785.69 9.00 1526.75 4697.86 7861.51 27142.47 40 41 16569.09 8.00 1473.99 4614.76 7638.17 23984.14 41 42 17248.89 7.00 1455.27 4471.65 7584.14 23184.94 42 43 18138.36 6.00 1503.35 4305.23 8007.32 21772.73 43 44 17875.75 5.00 1530.62 4433.57 7883.04 20634.47 44 45 17400.41 4.00 1482.37 4388.53 7408.87 20318.98 45 46 17287.65 3.00 1420.86 4140.30 6917.03 19800.93 46 47 17604.12 2.00 1406.82 4144.38 6715.44 19651.51 47 48 17383.42 1.00 1438.24 4070.78 6789.11 20106.42 48 49 17225.83 12.00 1418.30 3906.01 6596.92 19964.72 49 50 16274.33 11.00 1400.63 3795.91 6309.19 18960.48 50 51 16399.39 10.00 1377.94 3703.32 6268.92 18324.35 51 52 16127.58 9.00 1335.85 3675.80 6004.33 17543.05 52 53 16140.76 8.00 1303.82 3911.06 5859.57 17392.27 53 54 15456.81 7.00 1276.66 3912.28 5681.97 16971.34 54 55 15505.18 6.00 1270.20 3839.25 5683.31 16267.62 55 56 15467.33 5.00 1270.09 3744.63 5692.86 15857.89 56 57 16906.23 4.00 1310.61 3549.25 6009.89 16661.30 57 58 17059.66 3.00 1294.87 3394.14 5970.08 15805.04 58 59 16205.43 2.00 1280.66 3264.26 5796.04 15918.48 59 60 16649.82 1.00 1280.08 3328.80 5674.15 15753.14 60 61 16111.43 12.00 1248.29 3223.98 5408.26 14876.43 61 62 14872.15 11.00 1249.48 3228.01 5193.40 14937.14 62 63 13606.50 10.00 1207.01 3112.83 4929.07 14386.37 63 64 13574.30 9.00 1228.81 3051.67 5044.12 15428.52 64 65 12413.60 8.00 1220.33 3039.71 4829.69 14903.55 65 66 11899.60 7.00 1234.18 3125.67 4886.50 14880.98 66 67 11584.01 6.00 1191.33 3106.54 4586.28 14201.06 67 68 4460.63 5.00 1191.50 11276.59 13867.07 4.00 68 69 13908.97 1156.85 11008.90 4184.84 3.00 1180.59 69 70 2.00 11668.95 4348.77 13516.88 1203.60 11740.60 70 71 1181.27 4350.49 14195.35 1.00 11387.59 4254.85 71 72 2617.20 13721.69 12.00 1221.53 10168.52 6957.61 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) month `S&P` Bel20 DAX HangSeng 1.7614 -0.9603 -0.1553 -0.1953 -0.1864 0.4772 t 164.1086 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -4537.52 -1014.54 -73.81 1136.01 5658.13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.76137 1398.86140 0.001 0.999 month -0.96026 0.11796 -8.141 1.64e-11 *** `S&P` -0.15526 0.13169 -1.179 0.243 Bel20 -0.19526 0.14125 -1.382 0.172 DAX -0.18641 0.12839 -1.452 0.151 HangSeng 0.47720 0.05324 8.963 5.74e-13 *** t 164.10859 14.16248 11.588 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1906 on 65 degrees of freedom Multiple R-squared: 0.7975, Adjusted R-squared: 0.7789 F-statistic: 42.68 on 6 and 65 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,] 1.398492e-03 2.796983e-03 0.9986015 [2,] 1.276666e-04 2.553332e-04 0.9998723 [3,] 1.151137e-05 2.302274e-05 0.9999885 [4,] 8.125220e-07 1.625044e-06 0.9999992 [5,] 1.256267e-05 2.512535e-05 0.9999874 [6,] 2.763499e-06 5.526999e-06 0.9999972 [7,] 6.647030e-07 1.329406e-06 0.9999993 [8,] 8.942687e-08 1.788537e-07 0.9999999 [9,] 1.949130e-08 3.898260e-08 1.0000000 [10,] 2.502494e-09 5.004988e-09 1.0000000 [11,] 4.036579e-10 8.073158e-10 1.0000000 [12,] 1.259379e-10 2.518757e-10 1.0000000 [13,] 1.598399e-11 3.196797e-11 1.0000000 [14,] 9.417316e-12 1.883463e-11 1.0000000 [15,] 1.990987e-12 3.981974e-12 1.0000000 [16,] 9.920055e-12 1.984011e-11 1.0000000 [17,] 1.918182e-12 3.836365e-12 1.0000000 [18,] 3.501249e-12 7.002497e-12 1.0000000 [19,] 8.666880e-13 1.733376e-12 1.0000000 [20,] 1.937829e-13 3.875658e-13 1.0000000 [21,] 5.033432e-14 1.006686e-13 1.0000000 [22,] 1.690204e-14 3.380407e-14 1.0000000 [23,] 5.952244e-14 1.190449e-13 1.0000000 [24,] 1.677484e-13 3.354968e-13 1.0000000 [25,] 2.203521e-11 4.407043e-11 1.0000000 [26,] 2.691365e-10 5.382730e-10 1.0000000 [27,] 1.289855e-06 2.579711e-06 0.9999987 [28,] 3.046183e-06 6.092365e-06 0.9999970 [29,] 3.865893e-06 7.731785e-06 0.9999961 [30,] 4.323810e-06 8.647621e-06 0.9999957 [31,] 5.336750e-06 1.067350e-05 0.9999947 [32,] 9.417636e-06 1.883527e-05 0.9999906 [33,] 1.764513e-05 3.529026e-05 0.9999824 [34,] 8.997253e-06 1.799451e-05 0.9999910 [35,] 4.678705e-06 9.357410e-06 0.9999953 [36,] 1.894093e-06 3.788186e-06 0.9999981 [37,] 1.191046e-06 2.382091e-06 0.9999988 [38,] 1.188800e-06 2.377600e-06 0.9999988 [39,] 4.926738e-07 9.853476e-07 0.9999995 [40,] 2.068428e-07 4.136855e-07 0.9999998 [41,] 1.968641e-07 3.937283e-07 0.9999998 [42,] 1.300657e-07 2.601314e-07 0.9999999 [43,] 1.439172e-07 2.878345e-07 0.9999999 [44,] 1.344073e-07 2.688147e-07 0.9999999 [45,] 1.006935e-06 2.013871e-06 0.9999990 [46,] 6.409372e-05 1.281874e-04 0.9999359 [47,] 2.102965e-01 4.205930e-01 0.7897035 [48,] 2.180342e-01 4.360683e-01 0.7819658 [49,] 1.679831e-01 3.359663e-01 0.8320169 [50,] 2.235374e-01 4.470747e-01 0.7764626 [51,] 2.770577e-01 5.541154e-01 0.7229423 [52,] 3.526935e-01 7.053870e-01 0.6473065 [53,] 3.802987e-01 7.605973e-01 0.6197013 > postscript(file="/var/www/html/freestat/rcomp/tmp/1qac61291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/2qac61291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/31jc81291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/41jc81291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/51jc81291415244.ps",horizontal=F,onefile=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 = 72 Frequency = 1 1 2 3 4 5 6 822.08270 557.66125 -366.19948 -105.50854 -43.28355 330.79836 7 8 9 10 11 12 370.38964 786.92965 1331.43494 1126.50928 194.83590 322.42030 13 14 15 16 17 18 -295.70468 -1713.99594 -1232.66198 -858.98107 -146.46680 -921.01356 19 20 21 22 23 24 -555.56214 -993.09179 -625.28283 -725.51802 -1078.86907 -822.99649 25 26 27 28 29 30 -449.84219 -778.94441 -813.10391 74.92970 336.31471 -257.85382 31 32 33 34 35 36 -20.26509 -349.94862 -1537.56796 -1720.34079 -1419.85751 -1173.47976 37 38 39 40 41 42 -1445.30742 -1662.15442 -1974.89311 -104.33147 955.10612 1810.29370 43 44 45 46 47 48 3262.45816 3384.08449 2789.55022 2609.22951 2792.97178 2194.35936 49 50 51 52 53 54 1879.74672 1164.52340 1398.96723 1273.69383 1207.73691 522.50062 55 56 57 58 59 60 726.60429 702.49629 1620.17861 1976.99557 843.55262 1191.56448 61 62 63 64 65 66 843.02682 -629.37403 -1875.62387 -2557.31843 -3676.19573 -4314.96883 67 68 69 70 71 72 -4537.52250 -1725.71839 5658.12756 -2345.91702 -3998.10966 2791.70016 > postscript(file="/var/www/html/freestat/rcomp/tmp/6uttb1291415244.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 822.08270 NA 1 557.66125 822.08270 2 -366.19948 557.66125 3 -105.50854 -366.19948 4 -43.28355 -105.50854 5 330.79836 -43.28355 6 370.38964 330.79836 7 786.92965 370.38964 8 1331.43494 786.92965 9 1126.50928 1331.43494 10 194.83590 1126.50928 11 322.42030 194.83590 12 -295.70468 322.42030 13 -1713.99594 -295.70468 14 -1232.66198 -1713.99594 15 -858.98107 -1232.66198 16 -146.46680 -858.98107 17 -921.01356 -146.46680 18 -555.56214 -921.01356 19 -993.09179 -555.56214 20 -625.28283 -993.09179 21 -725.51802 -625.28283 22 -1078.86907 -725.51802 23 -822.99649 -1078.86907 24 -449.84219 -822.99649 25 -778.94441 -449.84219 26 -813.10391 -778.94441 27 74.92970 -813.10391 28 336.31471 74.92970 29 -257.85382 336.31471 30 -20.26509 -257.85382 31 -349.94862 -20.26509 32 -1537.56796 -349.94862 33 -1720.34079 -1537.56796 34 -1419.85751 -1720.34079 35 -1173.47976 -1419.85751 36 -1445.30742 -1173.47976 37 -1662.15442 -1445.30742 38 -1974.89311 -1662.15442 39 -104.33147 -1974.89311 40 955.10612 -104.33147 41 1810.29370 955.10612 42 3262.45816 1810.29370 43 3384.08449 3262.45816 44 2789.55022 3384.08449 45 2609.22951 2789.55022 46 2792.97178 2609.22951 47 2194.35936 2792.97178 48 1879.74672 2194.35936 49 1164.52340 1879.74672 50 1398.96723 1164.52340 51 1273.69383 1398.96723 52 1207.73691 1273.69383 53 522.50062 1207.73691 54 726.60429 522.50062 55 702.49629 726.60429 56 1620.17861 702.49629 57 1976.99557 1620.17861 58 843.55262 1976.99557 59 1191.56448 843.55262 60 843.02682 1191.56448 61 -629.37403 843.02682 62 -1875.62387 -629.37403 63 -2557.31843 -1875.62387 64 -3676.19573 -2557.31843 65 -4314.96883 -3676.19573 66 -4537.52250 -4314.96883 67 -1725.71839 -4537.52250 68 5658.12756 -1725.71839 69 -2345.91702 5658.12756 70 -3998.10966 -2345.91702 71 2791.70016 -3998.10966 72 NA 2791.70016 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 557.66125 822.08270 [2,] -366.19948 557.66125 [3,] -105.50854 -366.19948 [4,] -43.28355 -105.50854 [5,] 330.79836 -43.28355 [6,] 370.38964 330.79836 [7,] 786.92965 370.38964 [8,] 1331.43494 786.92965 [9,] 1126.50928 1331.43494 [10,] 194.83590 1126.50928 [11,] 322.42030 194.83590 [12,] -295.70468 322.42030 [13,] -1713.99594 -295.70468 [14,] -1232.66198 -1713.99594 [15,] -858.98107 -1232.66198 [16,] -146.46680 -858.98107 [17,] -921.01356 -146.46680 [18,] -555.56214 -921.01356 [19,] -993.09179 -555.56214 [20,] -625.28283 -993.09179 [21,] -725.51802 -625.28283 [22,] -1078.86907 -725.51802 [23,] -822.99649 -1078.86907 [24,] -449.84219 -822.99649 [25,] -778.94441 -449.84219 [26,] -813.10391 -778.94441 [27,] 74.92970 -813.10391 [28,] 336.31471 74.92970 [29,] -257.85382 336.31471 [30,] -20.26509 -257.85382 [31,] -349.94862 -20.26509 [32,] -1537.56796 -349.94862 [33,] -1720.34079 -1537.56796 [34,] -1419.85751 -1720.34079 [35,] -1173.47976 -1419.85751 [36,] -1445.30742 -1173.47976 [37,] -1662.15442 -1445.30742 [38,] -1974.89311 -1662.15442 [39,] -104.33147 -1974.89311 [40,] 955.10612 -104.33147 [41,] 1810.29370 955.10612 [42,] 3262.45816 1810.29370 [43,] 3384.08449 3262.45816 [44,] 2789.55022 3384.08449 [45,] 2609.22951 2789.55022 [46,] 2792.97178 2609.22951 [47,] 2194.35936 2792.97178 [48,] 1879.74672 2194.35936 [49,] 1164.52340 1879.74672 [50,] 1398.96723 1164.52340 [51,] 1273.69383 1398.96723 [52,] 1207.73691 1273.69383 [53,] 522.50062 1207.73691 [54,] 726.60429 522.50062 [55,] 702.49629 726.60429 [56,] 1620.17861 702.49629 [57,] 1976.99557 1620.17861 [58,] 843.55262 1976.99557 [59,] 1191.56448 843.55262 [60,] 843.02682 1191.56448 [61,] -629.37403 843.02682 [62,] -1875.62387 -629.37403 [63,] -2557.31843 -1875.62387 [64,] -3676.19573 -2557.31843 [65,] -4314.96883 -3676.19573 [66,] -4537.52250 -4314.96883 [67,] -1725.71839 -4537.52250 [68,] 5658.12756 -1725.71839 [69,] -2345.91702 5658.12756 [70,] -3998.10966 -2345.91702 [71,] 2791.70016 -3998.10966 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 557.66125 822.08270 2 -366.19948 557.66125 3 -105.50854 -366.19948 4 -43.28355 -105.50854 5 330.79836 -43.28355 6 370.38964 330.79836 7 786.92965 370.38964 8 1331.43494 786.92965 9 1126.50928 1331.43494 10 194.83590 1126.50928 11 322.42030 194.83590 12 -295.70468 322.42030 13 -1713.99594 -295.70468 14 -1232.66198 -1713.99594 15 -858.98107 -1232.66198 16 -146.46680 -858.98107 17 -921.01356 -146.46680 18 -555.56214 -921.01356 19 -993.09179 -555.56214 20 -625.28283 -993.09179 21 -725.51802 -625.28283 22 -1078.86907 -725.51802 23 -822.99649 -1078.86907 24 -449.84219 -822.99649 25 -778.94441 -449.84219 26 -813.10391 -778.94441 27 74.92970 -813.10391 28 336.31471 74.92970 29 -257.85382 336.31471 30 -20.26509 -257.85382 31 -349.94862 -20.26509 32 -1537.56796 -349.94862 33 -1720.34079 -1537.56796 34 -1419.85751 -1720.34079 35 -1173.47976 -1419.85751 36 -1445.30742 -1173.47976 37 -1662.15442 -1445.30742 38 -1974.89311 -1662.15442 39 -104.33147 -1974.89311 40 955.10612 -104.33147 41 1810.29370 955.10612 42 3262.45816 1810.29370 43 3384.08449 3262.45816 44 2789.55022 3384.08449 45 2609.22951 2789.55022 46 2792.97178 2609.22951 47 2194.35936 2792.97178 48 1879.74672 2194.35936 49 1164.52340 1879.74672 50 1398.96723 1164.52340 51 1273.69383 1398.96723 52 1207.73691 1273.69383 53 522.50062 1207.73691 54 726.60429 522.50062 55 702.49629 726.60429 56 1620.17861 702.49629 57 1976.99557 1620.17861 58 843.55262 1976.99557 59 1191.56448 843.55262 60 843.02682 1191.56448 61 -629.37403 843.02682 62 -1875.62387 -629.37403 63 -2557.31843 -1875.62387 64 -3676.19573 -2557.31843 65 -4314.96883 -3676.19573 66 -4537.52250 -4314.96883 67 -1725.71839 -4537.52250 68 5658.12756 -1725.71839 69 -2345.91702 5658.12756 70 -3998.10966 -2345.91702 71 2791.70016 -3998.10966 > 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/freestat/rcomp/tmp/7m2ae1291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/8m2ae1291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/9m2ae1291415244.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/10ftaz1291415244.ps",horizontal=F,onefile=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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11juq51291415244.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/freestat/rcomp/tmp/124cot1291415244.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/freestat/rcomp/tmp/1304m21291415244.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/freestat/rcomp/tmp/143m3q1291415244.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/freestat/rcomp/tmp/15pn1d1291415244.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/freestat/rcomp/tmp/16s5011291415244.tab") + } > > try(system("convert tmp/1qac61291415244.ps tmp/1qac61291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/2qac61291415244.ps tmp/2qac61291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/31jc81291415244.ps tmp/31jc81291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/41jc81291415244.ps tmp/41jc81291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/51jc81291415244.ps tmp/51jc81291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/6uttb1291415244.ps tmp/6uttb1291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/7m2ae1291415244.ps tmp/7m2ae1291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/8m2ae1291415244.ps tmp/8m2ae1291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/9m2ae1291415244.ps tmp/9m2ae1291415244.png",intern=TRUE)) character(0) > try(system("convert tmp/10ftaz1291415244.ps tmp/10ftaz1291415244.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.043 2.467 4.374