R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(4.031636 + ,0.5215052 + ,9.166456 + ,1.303763 + ,3.702076 + ,0.4248284 + ,7.970589 + ,1.416094 + ,3.056176 + ,0.4250311 + ,7.104091 + ,1.052458 + ,3.280707 + ,0.4771938 + ,6.621064 + ,1.312283 + ,2.984728 + ,0.8280212 + ,7.529215 + ,1.309429 + ,3.693712 + ,0.6156186 + ,8.170938 + ,1.492409 + ,3.226317 + ,0.366627 + ,8.15745 + ,1.026556 + ,2.190349 + ,0.4308883 + ,7.378962 + ,1.005406 + ,2.599515 + ,0.2810287 + ,7.921496 + ,1.334886 + ,3.080288 + ,0.4646245 + ,8.15674 + ,1.393873 + ,2.929672 + ,0.2693951 + ,8.856365 + ,1.128092 + ,2.922548 + ,0.5779049 + ,8.817177 + ,1.122787 + ,3.234943 + ,0.5661151 + ,8.734347 + ,1.213104 + ,2.983081 + ,0.5077584 + ,9.345927 + ,1.253528 + ,3.284389 + ,0.7507175 + ,8.99297 + ,1.094796 + ,3.806511 + ,0.6808395 + ,10.78512 + ,0.9129438 + ,3.784579 + ,0.7661091 + ,8.886867 + ,1.19513 + ,2.645654 + ,0.4561473 + ,8.818847 + ,0.9274994 + ,3.092081 + ,0.4977496 + ,8.823744 + ,0.9653326 + ,3.204859 + ,0.4193273 + ,9.165298 + ,1.198078 + ,3.107225 + ,0.6095514 + ,8.652657 + ,0.966362 + ,3.466909 + ,0.457337 + ,8.173054 + ,0.9736851 + ,2.984404 + ,0.5705478 + ,7.563416 + ,0.9948013 + ,3.218072 + ,0.3478996 + ,7.595809 + ,0.8262616 + ,2.82731 + ,0.3874993 + ,8.381467 + ,0.6888877 + ,3.182049 + ,0.5824285 + ,7.216432 + ,0.7813066 + ,2.236319 + ,0.2391033 + ,6.540178 + ,0.6047907 + ,2.033218 + ,0.2367445 + ,6.238914 + ,1.08624 + ,1.644804 + ,0.2626158 + ,5.487288 + ,0.7740255 + ,1.627971 + ,0.4240934 + ,5.759462 + ,1.026032 + ,1.677559 + ,0.365275 + ,5.993215 + ,0.6764351 + ,2.330828 + ,0.3750758 + ,7.474726 + ,0.830525 + ,2.493615 + ,0.4090056 + ,7.348907 + ,0.7916238 + ,2.257172 + ,0.3891676 + ,7.303379 + ,0.7523907 + ,2.655517 + ,0.240261 + ,7.119314 + ,0.6702018 + ,2.298655 + ,0.1589496 + ,6.99378 + ,0.8803359 + ,2.600402 + ,0.4393373 + ,6.958153 + ,0.9142966 + ,3.04523 + ,0.5094681 + ,7.595706 + ,0.9610421 + ,2.790583 + ,0.3743465 + ,8.088153 + ,0.9301944 + ,3.227052 + ,0.4339828 + ,7.555753 + ,0.8679657 + ,2.967479 + ,0.4130557 + ,7.315433 + ,0.9891596 + ,2.938817 + ,0.3288928 + ,7.893427 + ,0.9972879 + ,3.277961 + ,0.5186648 + ,8.858794 + ,0.7987437 + ,3.423985 + ,0.5486504 + ,8.839367 + ,0.9753785 + ,3.072646 + ,0.5469111 + ,8.014733 + ,0.9347208 + ,2.754253 + ,0.4963494 + ,7.873465 + ,0.9732341 + ,2.910431 + ,0.5308929 + ,8.930377 + ,0.8152998 + ,3.174369 + ,0.5957761 + ,10.50055 + ,0.9402092 + ,3.068387 + ,0.5570584 + ,12.61144 + ,0.794493 + ,3.089543 + ,0.5731325 + ,11.41787 + ,0.9313403 + ,2.906654 + ,0.5005416 + ,11.87249 + ,0.9220503 + ,2.931161 + ,0.5431269 + ,11.06082 + ,0.7845167 + ,3.02566 + ,0.5593657 + ,12.04331 + ,0.8220981 + ,2.939551 + ,0.6911693 + ,9.776299 + ,0.8910255 + ,2.691019 + ,0.4403485 + ,9.557194 + ,0.8073056 + ,3.19812 + ,0.5676662 + ,9.20259 + ,0.9514406 + ,3.07639 + ,0.5969114 + ,10.22402 + ,1.147907 + ,2.863873 + ,0.4735537 + ,9.350807 + ,1.172609 + ,3.013802 + ,0.5923935 + ,8.300913 + ,1.281051 + ,3.053364 + ,0.5975556 + ,8.365779 + ,1.165962 + ,2.864753 + ,0.6334127 + ,8.133595 + ,0.9789106 + ,3.057062 + ,0.6057115 + ,7.66047 + ,1.410951 + ,2.959365 + ,0.7046107 + ,8.074839 + ,1.197838 + ,3.252258 + ,0.4805263 + ,7.848597 + ,1.288368 + ,3.602988 + ,0.702686 + ,7.99822 + ,1.102253 + ,3.497704 + ,0.7009017 + ,7.396895 + ,1.197657 + ,3.296867 + ,0.6030854 + ,7.900419 + ,1.299984 + ,3.602417 + ,0.6980919 + ,8.1005 + ,1.198611 + ,3.3001 + ,0.597656 + ,7.899453 + ,1.299252 + ,3.40193 + ,0.8023421 + ,7.599783 + ,1.097604 + ,3.502591 + ,0.6017109 + ,8.100929 + ,1.39977 + ,3.402348 + ,0.5993127 + ,9.002175 + ,1.398396 + ,3.498551 + ,0.6025625 + ,10.2989 + ,1.40188 + ,3.199823 + ,0.7016625 + ,10.10152 + ,1.699717 + ,2.700064 + ,0.4995714 + ,10.69915 + ,1.39761 + ,2.801034 + ,0.4980918 + ,9.69814 + ,1.500135 + ,2.898628 + ,0.497569 + ,9.800951 + ,1.400136 + ,2.800854 + ,0.600183 + ,10.90047 + ,1.400427 + ,2.399942 + ,0.3339542 + ,10.69785 + ,1.341477 + ,2.402724 + ,0.274437 + ,9.297252 + ,1.33858 + ,2.202331 + ,0.3209428 + ,10.39744 + ,1.482977 + ,2.102594 + ,0.5406671 + ,10.90072 + ,1.163253 + ,1.798293 + ,0.4050209 + ,12.90127 + ,1.328468 + ,1.202484 + ,0.2885961 + ,13.09906 + ,1.23455 + ,1.400201 + ,0.3275942 + ,11.69828 + ,1.484741 + ,1.200832 + ,0.3132606 + ,11.09987 + ,1.336579 + ,1.298083 + ,0.2575562 + ,11.30157 + ,1.339292 + ,1.099742 + ,0.2138386 + ,10.70211 + ,1.405225 + ,1.001377 + ,0.1861856 + ,10.09931 + ,1.333491 + ,0.8361743 + ,0.1592713 + ,9.591119 + ,1.14974) + ,dim=c(4 + ,90) + ,dimnames=list(c('firearmsuicide' + ,'firearmhomicide' + ,'nonfirearmsuicide' + ,'nonfirearmhomicide') + ,1:90)) > y <- array(NA,dim=c(4,90),dimnames=list(c('firearmsuicide','firearmhomicide','nonfirearmsuicide','nonfirearmhomicide'),1:90)) > 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 = '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 > 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 firearmsuicide firearmhomicide nonfirearmsuicide nonfirearmhomicide t 1 4.0316360 0.5215052 9.166456 1.3037630 1 2 3.7020760 0.4248284 7.970589 1.4160940 2 3 3.0561760 0.4250311 7.104091 1.0524580 3 4 3.2807070 0.4771938 6.621064 1.3122830 4 5 2.9847280 0.8280212 7.529215 1.3094290 5 6 3.6937120 0.6156186 8.170938 1.4924090 6 7 3.2263170 0.3666270 8.157450 1.0265560 7 8 2.1903490 0.4308883 7.378962 1.0054060 8 9 2.5995150 0.2810287 7.921496 1.3348860 9 10 3.0802880 0.4646245 8.156740 1.3938730 10 11 2.9296720 0.2693951 8.856365 1.1280920 11 12 2.9225480 0.5779049 8.817177 1.1227870 12 13 3.2349430 0.5661151 8.734347 1.2131040 13 14 2.9830810 0.5077584 9.345927 1.2535280 14 15 3.2843890 0.7507175 8.992970 1.0947960 15 16 3.8065110 0.6808395 10.785120 0.9129438 16 17 3.7845790 0.7661091 8.886867 1.1951300 17 18 2.6456540 0.4561473 8.818847 0.9274994 18 19 3.0920810 0.4977496 8.823744 0.9653326 19 20 3.2048590 0.4193273 9.165298 1.1980780 20 21 3.1072250 0.6095514 8.652657 0.9663620 21 22 3.4669090 0.4573370 8.173054 0.9736851 22 23 2.9844040 0.5705478 7.563416 0.9948013 23 24 3.2180720 0.3478996 7.595809 0.8262616 24 25 2.8273100 0.3874993 8.381467 0.6888877 25 26 3.1820490 0.5824285 7.216432 0.7813066 26 27 2.2363190 0.2391033 6.540178 0.6047907 27 28 2.0332180 0.2367445 6.238914 1.0862400 28 29 1.6448040 0.2626158 5.487288 0.7740255 29 30 1.6279710 0.4240934 5.759462 1.0260320 30 31 1.6775590 0.3652750 5.993215 0.6764351 31 32 2.3308280 0.3750758 7.474726 0.8305250 32 33 2.4936150 0.4090056 7.348907 0.7916238 33 34 2.2571720 0.3891676 7.303379 0.7523907 34 35 2.6555170 0.2402610 7.119314 0.6702018 35 36 2.2986550 0.1589496 6.993780 0.8803359 36 37 2.6004020 0.4393373 6.958153 0.9142966 37 38 3.0452300 0.5094681 7.595706 0.9610421 38 39 2.7905830 0.3743465 8.088153 0.9301944 39 40 3.2270520 0.4339828 7.555753 0.8679657 40 41 2.9674790 0.4130557 7.315433 0.9891596 41 42 2.9388170 0.3288928 7.893427 0.9972879 42 43 3.2779610 0.5186648 8.858794 0.7987437 43 44 3.4239850 0.5486504 8.839367 0.9753785 44 45 3.0726460 0.5469111 8.014733 0.9347208 45 46 2.7542530 0.4963494 7.873465 0.9732341 46 47 2.9104310 0.5308929 8.930377 0.8152998 47 48 3.1743690 0.5957761 10.500550 0.9402092 48 49 3.0683870 0.5570584 12.611440 0.7944930 49 50 3.0895430 0.5731325 11.417870 0.9313403 50 51 2.9066540 0.5005416 11.872490 0.9220503 51 52 2.9311610 0.5431269 11.060820 0.7845167 52 53 3.0256600 0.5593657 12.043310 0.8220981 53 54 2.9395510 0.6911693 9.776299 0.8910255 54 55 2.6910190 0.4403485 9.557194 0.8073056 55 56 3.1981200 0.5676662 9.202590 0.9514406 56 57 3.0763900 0.5969114 10.224020 1.1479070 57 58 2.8638730 0.4735537 9.350807 1.1726090 58 59 3.0138020 0.5923935 8.300913 1.2810510 59 60 3.0533640 0.5975556 8.365779 1.1659620 60 61 2.8647530 0.6334127 8.133595 0.9789106 61 62 3.0570620 0.6057115 7.660470 1.4109510 62 63 2.9593650 0.7046107 8.074839 1.1978380 63 64 3.2522580 0.4805263 7.848597 1.2883680 64 65 3.6029880 0.7026860 7.998220 1.1022530 65 66 3.4977040 0.7009017 7.396895 1.1976570 66 67 3.2968670 0.6030854 7.900419 1.2999840 67 68 3.6024170 0.6980919 8.100500 1.1986110 68 69 3.3001000 0.5976560 7.899453 1.2992520 69 70 3.4019300 0.8023421 7.599783 1.0976040 70 71 3.5025910 0.6017109 8.100929 1.3997700 71 72 3.4023480 0.5993127 9.002175 1.3983960 72 73 3.4985510 0.6025625 10.298900 1.4018800 73 74 3.1998230 0.7016625 10.101520 1.6997170 74 75 2.7000640 0.4995714 10.699150 1.3976100 75 76 2.8010340 0.4980918 9.698140 1.5001350 76 77 2.8986280 0.4975690 9.800951 1.4001360 77 78 2.8008540 0.6001830 10.900470 1.4004270 78 79 2.3999420 0.3339542 10.697850 1.3414770 79 80 2.4027240 0.2744370 9.297252 1.3385800 80 81 2.2023310 0.3209428 10.397440 1.4829770 81 82 2.1025940 0.5406671 10.900720 1.1632530 82 83 1.7982930 0.4050209 12.901270 1.3284680 83 84 1.2024840 0.2885961 13.099060 1.2345500 84 85 1.4002010 0.3275942 11.698280 1.4847410 85 86 1.2008320 0.3132606 11.099870 1.3365790 86 87 1.2980830 0.2575562 11.301570 1.3392920 87 88 1.0997420 0.2138386 10.702110 1.4052250 88 89 1.0013770 0.1861856 10.099310 1.3334910 89 90 0.8361743 0.1592713 9.591119 1.1497400 90 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) firearmhomicide nonfirearmsuicide nonfirearmhomicide 1.711996 3.036706 -0.013063 0.158490 t -0.009606 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.30287 -0.24348 0.04365 0.31893 0.65870 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.711996 0.318443 5.376 6.57e-07 *** firearmhomicide 3.036706 0.300588 10.103 3.19e-16 *** nonfirearmsuicide -0.013063 0.032495 -0.402 0.689 nonfirearmhomicide 0.158490 0.205871 0.770 0.444 t -0.009606 0.002101 -4.572 1.63e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4239 on 85 degrees of freedom Multiple R-squared: 0.6297, Adjusted R-squared: 0.6123 F-statistic: 36.14 on 4 and 85 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.4008221 0.8016442181 0.5991778910 [2,] 0.4323258 0.8646516343 0.5676741829 [3,] 0.3289218 0.6578436626 0.6710781687 [4,] 0.2422887 0.4845774063 0.7577112968 [5,] 0.1868200 0.3736400212 0.8131799894 [6,] 0.2106649 0.4213298343 0.7893350829 [7,] 0.1421643 0.2843286458 0.8578356771 [8,] 0.1880119 0.3760238828 0.8119880586 [9,] 0.1626089 0.3252177997 0.8373911002 [10,] 0.3516760 0.7033519502 0.6483240249 [11,] 0.2857827 0.5715653859 0.7142173071 [12,] 0.2902302 0.5804603191 0.7097698404 [13,] 0.2532827 0.5065654139 0.7467172931 [14,] 0.2490959 0.4981918488 0.7509040756 [15,] 0.4683961 0.9367921644 0.5316039178 [16,] 0.4449566 0.8899132065 0.5550433968 [17,] 0.5511962 0.8976075370 0.4488037685 [18,] 0.4797601 0.9595201609 0.5202399195 [19,] 0.4542927 0.9085854028 0.5457072986 [20,] 0.3978003 0.7956006555 0.6021996723 [21,] 0.3902099 0.7804197764 0.6097901118 [22,] 0.4250298 0.8500596766 0.5749701617 [23,] 0.7684129 0.4631742416 0.2315871208 [24,] 0.8871562 0.2256875533 0.1128437767 [25,] 0.8905043 0.2189914628 0.1094957314 [26,] 0.8910570 0.2178860765 0.1089430382 [27,] 0.9139670 0.1720659794 0.0860329897 [28,] 0.9303549 0.1392902087 0.0696451043 [29,] 0.9114038 0.1771923626 0.0885961813 [30,] 0.9332406 0.1335187616 0.0667593808 [31,] 0.9451855 0.1096289234 0.0548144617 [32,] 0.9303745 0.1392509980 0.0696254990 [33,] 0.9463466 0.1073067232 0.0536533616 [34,] 0.9394133 0.1211734639 0.0605867319 [35,] 0.9216021 0.1567958618 0.0783979309 [36,] 0.9030655 0.1938690168 0.0969345084 [37,] 0.8776431 0.2447138079 0.1223569040 [38,] 0.8535712 0.2928575572 0.1464287786 [39,] 0.8696085 0.2607829906 0.1303914953 [40,] 0.8530119 0.2939762838 0.1469881419 [41,] 0.8532089 0.2935822571 0.1467911286 [42,] 0.8955911 0.2088178325 0.1044089163 [43,] 0.8814777 0.2370446123 0.1185223061 [44,] 0.8747472 0.2505056198 0.1252528099 [45,] 0.8498675 0.3002649778 0.1501324889 [46,] 0.8521018 0.2957964823 0.1478982411 [47,] 0.8390786 0.3218428351 0.1609214176 [48,] 0.8100122 0.3799755683 0.1899877842 [49,] 0.7965607 0.4068785445 0.2034392723 [50,] 0.7486605 0.5026790539 0.2513395269 [51,] 0.6952936 0.6094127121 0.3047063561 [52,] 0.6878360 0.6243279474 0.3121639737 [53,] 0.6494872 0.7010256180 0.3505128090 [54,] 0.6409957 0.7180086703 0.3590043351 [55,] 0.8061221 0.3877558403 0.1938779202 [56,] 0.9703327 0.0593345389 0.0296672694 [57,] 0.9788758 0.0422484960 0.0211242480 [58,] 0.9764720 0.0470559991 0.0235279996 [59,] 0.9805042 0.0389916652 0.0194958326 [60,] 0.9928050 0.0143899916 0.0071949958 [61,] 0.9900497 0.0199005638 0.0099502819 [62,] 0.9960890 0.0078220156 0.0039110078 [63,] 0.9987292 0.0025415242 0.0012707621 [64,] 0.9988286 0.0023427614 0.0011713807 [65,] 0.9985836 0.0028327629 0.0014163814 [66,] 0.9978590 0.0042820096 0.0021410048 [67,] 0.9970335 0.0059329484 0.0029664742 [68,] 0.9987500 0.0025000685 0.0012500343 [69,] 0.9995927 0.0008145401 0.0004072701 [70,] 0.9988426 0.0023148097 0.0011574049 [71,] 0.9966602 0.0066796717 0.0033398358 [72,] 0.9903042 0.0193915898 0.0096957949 [73,] 0.9730961 0.0538077794 0.0269038897 [74,] 0.9833081 0.0333837666 0.0166918833 [75,] 0.9854140 0.0291720134 0.0145860067 > postscript(file="/var/www/rcomp/tmp/1g9wb1292944675.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/rcomp/tmp/2g9wb1292944675.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/rcomp/tmp/39jvw1292944675.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/rcomp/tmp/49jvw1292944675.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/rcomp/tmp/59jvw1292944675.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 = 90 Frequency = 1 1 2 3 4 5 6 0.658699413 0.598899093 0.008302983 0.036547672 -1.302868907 0.040107972 7 8 9 10 11 12 0.412090210 -0.816231953 0.012487693 -0.060935368 0.442172134 -0.491870353 13 14 15 16 17 18 -0.149463466 -0.212924707 -0.619259234 0.176901157 -0.163884754 -0.310412624 19 20 21 22 23 24 0.013354343 0.341457927 -0.294196697 0.529897885 -0.298099525 0.648426703 25 26 27 28 29 30 0.179053961 -0.078410326 0.047185250 -0.219387128 -0.637094403 -1.171066250 31 32 33 34 35 36 -0.874796692 -0.246751870 -0.172871730 -0.333843127 0.536915137 0.401633979 37 38 39 40 41 42 -0.144315672 0.098071761 0.274677509 0.542562423 0.333797563 0.576581959 43 44 45 46 47 48 0.393128633 0.429452664 0.088672855 -0.074522433 0.025201136 0.102428965 49 50 51 52 53 54 0.174297324 0.118966116 0.173531698 0.089520349 0.151191395 -0.366099401 55 56 57 58 59 60 0.167050205 0.269654638 0.050927061 0.207295070 -0.024953471 0.027626715 61 62 63 64 65 66 -0.233652933 -0.022272166 -0.371501436 0.594172471 0.311326937 0.198091520 67 68 69 70 71 72 0.294259880 0.339589580 0.333296018 -0.148794800 0.529386584 0.458023438 73 74 75 76 77 78 0.570351332 -0.069490752 0.109735624 0.195479071 0.321458701 -0.064000362 79 80 81 82 83 84 0.359848372 0.535135298 0.194610691 -0.505510582 -0.388338830 -0.603524963 85 86 87 88 89 90 -0.572579336 -0.703150339 -0.424930439 -0.499188540 -0.500478876 -0.551860624 > postscript(file="/var/www/rcomp/tmp/61acz1292944675.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 = 90 Frequency = 1 lag(myerror, k = 1) myerror 0 0.658699413 NA 1 0.598899093 0.658699413 2 0.008302983 0.598899093 3 0.036547672 0.008302983 4 -1.302868907 0.036547672 5 0.040107972 -1.302868907 6 0.412090210 0.040107972 7 -0.816231953 0.412090210 8 0.012487693 -0.816231953 9 -0.060935368 0.012487693 10 0.442172134 -0.060935368 11 -0.491870353 0.442172134 12 -0.149463466 -0.491870353 13 -0.212924707 -0.149463466 14 -0.619259234 -0.212924707 15 0.176901157 -0.619259234 16 -0.163884754 0.176901157 17 -0.310412624 -0.163884754 18 0.013354343 -0.310412624 19 0.341457927 0.013354343 20 -0.294196697 0.341457927 21 0.529897885 -0.294196697 22 -0.298099525 0.529897885 23 0.648426703 -0.298099525 24 0.179053961 0.648426703 25 -0.078410326 0.179053961 26 0.047185250 -0.078410326 27 -0.219387128 0.047185250 28 -0.637094403 -0.219387128 29 -1.171066250 -0.637094403 30 -0.874796692 -1.171066250 31 -0.246751870 -0.874796692 32 -0.172871730 -0.246751870 33 -0.333843127 -0.172871730 34 0.536915137 -0.333843127 35 0.401633979 0.536915137 36 -0.144315672 0.401633979 37 0.098071761 -0.144315672 38 0.274677509 0.098071761 39 0.542562423 0.274677509 40 0.333797563 0.542562423 41 0.576581959 0.333797563 42 0.393128633 0.576581959 43 0.429452664 0.393128633 44 0.088672855 0.429452664 45 -0.074522433 0.088672855 46 0.025201136 -0.074522433 47 0.102428965 0.025201136 48 0.174297324 0.102428965 49 0.118966116 0.174297324 50 0.173531698 0.118966116 51 0.089520349 0.173531698 52 0.151191395 0.089520349 53 -0.366099401 0.151191395 54 0.167050205 -0.366099401 55 0.269654638 0.167050205 56 0.050927061 0.269654638 57 0.207295070 0.050927061 58 -0.024953471 0.207295070 59 0.027626715 -0.024953471 60 -0.233652933 0.027626715 61 -0.022272166 -0.233652933 62 -0.371501436 -0.022272166 63 0.594172471 -0.371501436 64 0.311326937 0.594172471 65 0.198091520 0.311326937 66 0.294259880 0.198091520 67 0.339589580 0.294259880 68 0.333296018 0.339589580 69 -0.148794800 0.333296018 70 0.529386584 -0.148794800 71 0.458023438 0.529386584 72 0.570351332 0.458023438 73 -0.069490752 0.570351332 74 0.109735624 -0.069490752 75 0.195479071 0.109735624 76 0.321458701 0.195479071 77 -0.064000362 0.321458701 78 0.359848372 -0.064000362 79 0.535135298 0.359848372 80 0.194610691 0.535135298 81 -0.505510582 0.194610691 82 -0.388338830 -0.505510582 83 -0.603524963 -0.388338830 84 -0.572579336 -0.603524963 85 -0.703150339 -0.572579336 86 -0.424930439 -0.703150339 87 -0.499188540 -0.424930439 88 -0.500478876 -0.499188540 89 -0.551860624 -0.500478876 90 NA -0.551860624 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.598899093 0.658699413 [2,] 0.008302983 0.598899093 [3,] 0.036547672 0.008302983 [4,] -1.302868907 0.036547672 [5,] 0.040107972 -1.302868907 [6,] 0.412090210 0.040107972 [7,] -0.816231953 0.412090210 [8,] 0.012487693 -0.816231953 [9,] -0.060935368 0.012487693 [10,] 0.442172134 -0.060935368 [11,] -0.491870353 0.442172134 [12,] -0.149463466 -0.491870353 [13,] -0.212924707 -0.149463466 [14,] -0.619259234 -0.212924707 [15,] 0.176901157 -0.619259234 [16,] -0.163884754 0.176901157 [17,] -0.310412624 -0.163884754 [18,] 0.013354343 -0.310412624 [19,] 0.341457927 0.013354343 [20,] -0.294196697 0.341457927 [21,] 0.529897885 -0.294196697 [22,] -0.298099525 0.529897885 [23,] 0.648426703 -0.298099525 [24,] 0.179053961 0.648426703 [25,] -0.078410326 0.179053961 [26,] 0.047185250 -0.078410326 [27,] -0.219387128 0.047185250 [28,] -0.637094403 -0.219387128 [29,] -1.171066250 -0.637094403 [30,] -0.874796692 -1.171066250 [31,] -0.246751870 -0.874796692 [32,] -0.172871730 -0.246751870 [33,] -0.333843127 -0.172871730 [34,] 0.536915137 -0.333843127 [35,] 0.401633979 0.536915137 [36,] -0.144315672 0.401633979 [37,] 0.098071761 -0.144315672 [38,] 0.274677509 0.098071761 [39,] 0.542562423 0.274677509 [40,] 0.333797563 0.542562423 [41,] 0.576581959 0.333797563 [42,] 0.393128633 0.576581959 [43,] 0.429452664 0.393128633 [44,] 0.088672855 0.429452664 [45,] -0.074522433 0.088672855 [46,] 0.025201136 -0.074522433 [47,] 0.102428965 0.025201136 [48,] 0.174297324 0.102428965 [49,] 0.118966116 0.174297324 [50,] 0.173531698 0.118966116 [51,] 0.089520349 0.173531698 [52,] 0.151191395 0.089520349 [53,] -0.366099401 0.151191395 [54,] 0.167050205 -0.366099401 [55,] 0.269654638 0.167050205 [56,] 0.050927061 0.269654638 [57,] 0.207295070 0.050927061 [58,] -0.024953471 0.207295070 [59,] 0.027626715 -0.024953471 [60,] -0.233652933 0.027626715 [61,] -0.022272166 -0.233652933 [62,] -0.371501436 -0.022272166 [63,] 0.594172471 -0.371501436 [64,] 0.311326937 0.594172471 [65,] 0.198091520 0.311326937 [66,] 0.294259880 0.198091520 [67,] 0.339589580 0.294259880 [68,] 0.333296018 0.339589580 [69,] -0.148794800 0.333296018 [70,] 0.529386584 -0.148794800 [71,] 0.458023438 0.529386584 [72,] 0.570351332 0.458023438 [73,] -0.069490752 0.570351332 [74,] 0.109735624 -0.069490752 [75,] 0.195479071 0.109735624 [76,] 0.321458701 0.195479071 [77,] -0.064000362 0.321458701 [78,] 0.359848372 -0.064000362 [79,] 0.535135298 0.359848372 [80,] 0.194610691 0.535135298 [81,] -0.505510582 0.194610691 [82,] -0.388338830 -0.505510582 [83,] -0.603524963 -0.388338830 [84,] -0.572579336 -0.603524963 [85,] -0.703150339 -0.572579336 [86,] -0.424930439 -0.703150339 [87,] -0.499188540 -0.424930439 [88,] -0.500478876 -0.499188540 [89,] -0.551860624 -0.500478876 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.598899093 0.658699413 2 0.008302983 0.598899093 3 0.036547672 0.008302983 4 -1.302868907 0.036547672 5 0.040107972 -1.302868907 6 0.412090210 0.040107972 7 -0.816231953 0.412090210 8 0.012487693 -0.816231953 9 -0.060935368 0.012487693 10 0.442172134 -0.060935368 11 -0.491870353 0.442172134 12 -0.149463466 -0.491870353 13 -0.212924707 -0.149463466 14 -0.619259234 -0.212924707 15 0.176901157 -0.619259234 16 -0.163884754 0.176901157 17 -0.310412624 -0.163884754 18 0.013354343 -0.310412624 19 0.341457927 0.013354343 20 -0.294196697 0.341457927 21 0.529897885 -0.294196697 22 -0.298099525 0.529897885 23 0.648426703 -0.298099525 24 0.179053961 0.648426703 25 -0.078410326 0.179053961 26 0.047185250 -0.078410326 27 -0.219387128 0.047185250 28 -0.637094403 -0.219387128 29 -1.171066250 -0.637094403 30 -0.874796692 -1.171066250 31 -0.246751870 -0.874796692 32 -0.172871730 -0.246751870 33 -0.333843127 -0.172871730 34 0.536915137 -0.333843127 35 0.401633979 0.536915137 36 -0.144315672 0.401633979 37 0.098071761 -0.144315672 38 0.274677509 0.098071761 39 0.542562423 0.274677509 40 0.333797563 0.542562423 41 0.576581959 0.333797563 42 0.393128633 0.576581959 43 0.429452664 0.393128633 44 0.088672855 0.429452664 45 -0.074522433 0.088672855 46 0.025201136 -0.074522433 47 0.102428965 0.025201136 48 0.174297324 0.102428965 49 0.118966116 0.174297324 50 0.173531698 0.118966116 51 0.089520349 0.173531698 52 0.151191395 0.089520349 53 -0.366099401 0.151191395 54 0.167050205 -0.366099401 55 0.269654638 0.167050205 56 0.050927061 0.269654638 57 0.207295070 0.050927061 58 -0.024953471 0.207295070 59 0.027626715 -0.024953471 60 -0.233652933 0.027626715 61 -0.022272166 -0.233652933 62 -0.371501436 -0.022272166 63 0.594172471 -0.371501436 64 0.311326937 0.594172471 65 0.198091520 0.311326937 66 0.294259880 0.198091520 67 0.339589580 0.294259880 68 0.333296018 0.339589580 69 -0.148794800 0.333296018 70 0.529386584 -0.148794800 71 0.458023438 0.529386584 72 0.570351332 0.458023438 73 -0.069490752 0.570351332 74 0.109735624 -0.069490752 75 0.195479071 0.109735624 76 0.321458701 0.195479071 77 -0.064000362 0.321458701 78 0.359848372 -0.064000362 79 0.535135298 0.359848372 80 0.194610691 0.535135298 81 -0.505510582 0.194610691 82 -0.388338830 -0.505510582 83 -0.603524963 -0.388338830 84 -0.572579336 -0.603524963 85 -0.703150339 -0.572579336 86 -0.424930439 -0.703150339 87 -0.499188540 -0.424930439 88 -0.500478876 -0.499188540 89 -0.551860624 -0.500478876 > 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/rcomp/tmp/71acz1292944675.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/rcomp/tmp/8u1uk1292944675.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/rcomp/tmp/9u1uk1292944675.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/rcomp/tmp/10nab51292944675.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/11qbra1292944675.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/rcomp/tmp/12bbqy1292944675.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/rcomp/tmp/1383671292944675.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/rcomp/tmp/14b4mv1292944675.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/rcomp/tmp/15eml11292944675.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/rcomp/tmp/16injp1292944675.tab") + } > > try(system("convert tmp/1g9wb1292944675.ps tmp/1g9wb1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/2g9wb1292944675.ps tmp/2g9wb1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/39jvw1292944675.ps tmp/39jvw1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/49jvw1292944675.ps tmp/49jvw1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/59jvw1292944675.ps tmp/59jvw1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/61acz1292944675.ps tmp/61acz1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/71acz1292944675.ps tmp/71acz1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/8u1uk1292944675.ps tmp/8u1uk1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/9u1uk1292944675.ps tmp/9u1uk1292944675.png",intern=TRUE)) character(0) > try(system("convert tmp/10nab51292944675.ps tmp/10nab51292944675.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.490 0.720 4.201