R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(96 + ,6.08 + ,54.7 + ,1914 + ,1005 + ,2 + ,89 + ,5.73 + ,54.2 + ,1684 + ,963 + ,2 + ,87 + ,6.22 + ,53 + ,1902 + ,1035 + ,2 + ,87 + ,5.8 + ,52.9 + ,1860 + ,1027 + ,2 + ,101 + ,7.99 + ,57.8 + ,2264 + ,1281 + ,2 + ,103 + ,8.42 + ,56.9 + ,2216 + ,1272 + ,2 + ,103 + ,7.44 + ,56.6 + ,1866 + ,1051 + ,2 + ,96 + ,6.84 + ,55.3 + ,1850 + ,1079 + ,2 + ,127 + ,6.48 + ,53.1 + ,1743 + ,1034 + ,2 + ,126 + ,6.43 + ,54.8 + ,1709 + ,1070 + ,2 + ,101 + ,7.99 + ,57.2 + ,1689 + ,1173 + ,1 + ,96 + ,8.76 + ,57.2 + ,1806 + ,1079 + ,1 + ,93 + ,6.32 + ,57.2 + ,2136 + ,1067 + ,1 + ,88 + ,6.32 + ,57.2 + ,2018 + ,1104 + ,1 + ,94 + ,7.6 + ,55.8 + ,1966 + ,1347 + ,1 + ,85 + ,7.62 + ,57.2 + ,2154 + ,1439 + ,1 + ,97 + ,6.03 + ,57.2 + ,1767 + ,1029 + ,1 + ,114 + ,6.59 + ,56.5 + ,1827 + ,1100 + ,1 + ,113 + ,7.52 + ,59.2 + ,1773 + ,1204 + ,1 + ,124 + ,7.67 + ,58.5 + ,1971 + ,1160 + ,1 + ,129 + ,7.57 + ,57.3 + ,1867 + ,1401 + ,1 + ,110 + ,6.45 + ,53.7 + ,1993 + ,1142 + ,1 + ,102 + ,7.99 + ,56.6 + ,1910 + ,1288 + ,1 + ,134 + ,8.43 + ,57.5 + ,1688 + ,979 + ,1 + ,119 + ,7.02 + ,55.5 + ,1696 + ,1104 + ,2 + ,139 + ,5.21 + ,55.7 + ,2107 + ,956 + ,2 + ,75 + ,6.21 + ,53.1 + ,2060 + ,1153 + ,1 + ,138 + ,5.39 + ,55.9 + ,1870 + ,1001 + ,2 + ,132 + ,5.59 + ,57.8 + ,1808 + ,1230 + ,1 + ,122 + ,7.72 + ,59 + ,1846 + ,1014 + ,2 + ,102 + ,6.69 + ,58.4 + ,2227 + ,1287 + ,1 + ,78 + ,5.96 + ,55.4 + ,2177 + ,1198 + ,2 + ,119 + ,8.49 + ,59.5 + ,2295 + ,1125 + ,2 + ,136 + ,6.64 + ,53 + ,1788 + ,1142 + ,1 + ,109 + ,5.23 + ,54.6 + ,2337 + ,1379 + ,2 + ,85 + ,6.2 + ,58.4 + ,1678 + ,1148 + ,2 + ,119 + ,7.36 + ,58.2 + ,2103 + ,1318 + ,2 + ,136 + ,6.67 + ,53.2 + ,2018 + ,1041 + ,2 + ,72 + ,6.36 + ,54.2 + ,1697 + ,1253 + ,2 + ,125 + ,7.43 + ,53.8 + ,2158 + ,1264 + ,1 + ,87 + ,8.41 + ,53.8 + ,1964 + ,953 + ,1 + ,106 + ,7.15 + ,57.3 + ,1936 + ,1049 + ,1 + ,99 + ,5.36 + ,53 + ,2016 + ,1392 + ,2 + ,123 + ,7.39 + ,52.1 + ,2275 + ,1135 + ,1 + ,99 + ,5.63 + ,52.7 + ,2265 + ,1450 + ,1 + ,88 + ,8.47 + ,55.5 + ,2095 + ,958 + ,1 + ,97 + ,7.75 + ,57.8 + ,2070 + ,1209 + ,2 + ,119 + ,8.33 + ,55.4 + ,2135 + ,1441 + ,2 + ,77 + ,6 + ,57.9 + ,1882 + ,994 + ,1 + ,128 + ,5.45 + ,55.2 + ,1931 + ,1149 + ,1 + ,100 + ,8.28 + ,58.5 + ,2163 + ,1204 + ,1 + ,116 + ,5.6 + ,53.4 + ,2317 + ,1414 + ,2 + ,76 + ,7.38 + ,58.6 + ,1793 + ,1339 + ,2 + ,76 + ,7.99 + ,53.5 + ,2322 + ,1255 + ,1 + ,100 + ,6.83 + ,53.3 + ,2127 + ,1189 + ,2 + ,105 + ,5.64 + ,53.4 + ,1885 + ,1298 + ,2 + ,120 + ,8.43 + ,57.2 + ,1747 + ,1167 + ,2 + ,97 + ,7.38 + ,54.2 + ,1998 + ,1290 + ,2 + ,95 + ,6.55 + ,55.7 + ,2296 + ,1057 + ,2 + ,101 + ,5.71 + ,59.2 + ,2199 + ,1018 + ,1) + ,dim=c(6 + ,60) + ,dimnames=list(c('IQ' + ,'CCMIDSA' + ,'HC' + ,'TOTSA' + ,'TOTVOL' + ,'SEX') + ,1:60)) > y <- array(NA,dim=c(6,60),dimnames=list(c('IQ','CCMIDSA','HC','TOTSA','TOTVOL','SEX'),1:60)) > 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 IQ CCMIDSA HC TOTSA TOTVOL SEX t 1 96 6.08 54.7 1914 1005 2 1 2 89 5.73 54.2 1684 963 2 2 3 87 6.22 53.0 1902 1035 2 3 4 87 5.80 52.9 1860 1027 2 4 5 101 7.99 57.8 2264 1281 2 5 6 103 8.42 56.9 2216 1272 2 6 7 103 7.44 56.6 1866 1051 2 7 8 96 6.84 55.3 1850 1079 2 8 9 127 6.48 53.1 1743 1034 2 9 10 126 6.43 54.8 1709 1070 2 10 11 101 7.99 57.2 1689 1173 1 11 12 96 8.76 57.2 1806 1079 1 12 13 93 6.32 57.2 2136 1067 1 13 14 88 6.32 57.2 2018 1104 1 14 15 94 7.60 55.8 1966 1347 1 15 16 85 7.62 57.2 2154 1439 1 16 17 97 6.03 57.2 1767 1029 1 17 18 114 6.59 56.5 1827 1100 1 18 19 113 7.52 59.2 1773 1204 1 19 20 124 7.67 58.5 1971 1160 1 20 21 129 7.57 57.3 1867 1401 1 21 22 110 6.45 53.7 1993 1142 1 22 23 102 7.99 56.6 1910 1288 1 23 24 134 8.43 57.5 1688 979 1 24 25 119 7.02 55.5 1696 1104 2 25 26 139 5.21 55.7 2107 956 2 26 27 75 6.21 53.1 2060 1153 1 27 28 138 5.39 55.9 1870 1001 2 28 29 132 5.59 57.8 1808 1230 1 29 30 122 7.72 59.0 1846 1014 2 30 31 102 6.69 58.4 2227 1287 1 31 32 78 5.96 55.4 2177 1198 2 32 33 119 8.49 59.5 2295 1125 2 33 34 136 6.64 53.0 1788 1142 1 34 35 109 5.23 54.6 2337 1379 2 35 36 85 6.20 58.4 1678 1148 2 36 37 119 7.36 58.2 2103 1318 2 37 38 136 6.67 53.2 2018 1041 2 38 39 72 6.36 54.2 1697 1253 2 39 40 125 7.43 53.8 2158 1264 1 40 41 87 8.41 53.8 1964 953 1 41 42 106 7.15 57.3 1936 1049 1 42 43 99 5.36 53.0 2016 1392 2 43 44 123 7.39 52.1 2275 1135 1 44 45 99 5.63 52.7 2265 1450 1 45 46 88 8.47 55.5 2095 958 1 46 47 97 7.75 57.8 2070 1209 2 47 48 119 8.33 55.4 2135 1441 2 48 49 77 6.00 57.9 1882 994 1 49 50 128 5.45 55.2 1931 1149 1 50 51 100 8.28 58.5 2163 1204 1 51 52 116 5.60 53.4 2317 1414 2 52 53 76 7.38 58.6 1793 1339 2 53 54 76 7.99 53.5 2322 1255 1 54 55 100 6.83 53.3 2127 1189 2 55 56 105 5.64 53.4 1885 1298 2 56 57 120 8.43 57.2 1747 1167 2 57 58 97 7.38 54.2 1998 1290 2 58 59 95 6.55 55.7 2296 1057 2 59 60 101 5.71 59.2 2199 1018 1 60 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) CCMIDSA HC TOTSA TOTVOL SEX 110.681614 -0.159876 0.266203 -0.007993 -0.005144 1.031391 t 0.032283 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -35.404 -10.415 -2.041 14.462 33.182 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 110.681614 77.822491 1.422 0.161 CCMIDSA -0.159876 2.632704 -0.061 0.952 HC 0.266203 1.293318 0.206 0.838 TOTSA -0.007993 0.014089 -0.567 0.573 TOTVOL -0.005144 0.019150 -0.269 0.789 SEX 1.031391 5.018969 0.205 0.838 t 0.032283 0.152684 0.211 0.833 Residual standard error: 18.94 on 53 degrees of freedom Multiple R-squared: 0.01241, Adjusted R-squared: -0.0994 F-statistic: 0.111 on 6 and 53 DF, p-value: 0.9948 > 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.3690441813 0.738088363 0.6309558 [2,] 0.2119188118 0.423837624 0.7880812 [3,] 0.1138677849 0.227735570 0.8861322 [4,] 0.0582647096 0.116529419 0.9417353 [5,] 0.0416240206 0.083248041 0.9583760 [6,] 0.0269604158 0.053920832 0.9730396 [7,] 0.0208158473 0.041631695 0.9791842 [8,] 0.0129413365 0.025882673 0.9870587 [9,] 0.0078005407 0.015601081 0.9921995 [10,] 0.0034692696 0.006938539 0.9965307 [11,] 0.0019783019 0.003956604 0.9980217 [12,] 0.0018852188 0.003770438 0.9981148 [13,] 0.0009762503 0.001952501 0.9990237 [14,] 0.0025375623 0.005075125 0.9974624 [15,] 0.0013928501 0.002785700 0.9986071 [16,] 0.0055367067 0.011073413 0.9944633 [17,] 0.0041216649 0.008243330 0.9958783 [18,] 0.0266407000 0.053281400 0.9733593 [19,] 0.0209059644 0.041811929 0.9790940 [20,] 0.0187166681 0.037433336 0.9812833 [21,] 0.0389397787 0.077879557 0.9610602 [22,] 0.0292315617 0.058463123 0.9707684 [23,] 0.1390561261 0.278112252 0.8609439 [24,] 0.1011196019 0.202239204 0.8988804 [25,] 0.1625368771 0.325073754 0.8374631 [26,] 0.1217635681 0.243527136 0.8782364 [27,] 0.3095589369 0.619117874 0.6904411 [28,] 0.2458770210 0.491754042 0.7541230 [29,] 0.3160681762 0.632136352 0.6839318 [30,] 0.5483510199 0.903297960 0.4516490 [31,] 0.5456125367 0.908774927 0.4543875 [32,] 0.5931870247 0.813625951 0.4068130 [33,] 0.5172846018 0.965430796 0.4827154 [34,] 0.4511335277 0.902267055 0.5488665 [35,] 0.4581113388 0.916222678 0.5418887 [36,] 0.3649088473 0.729817695 0.6350912 [37,] 0.3057245510 0.611449102 0.6942754 [38,] 0.2221613492 0.444322698 0.7778387 [39,] 0.2010417067 0.402083413 0.7989583 [40,] 0.4128004644 0.825600929 0.5871995 [41,] 0.2789422980 0.557884596 0.7210577 > postscript(file="/var/wessaorg/rcomp/tmp/1lsex1321788470.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/wessaorg/rcomp/tmp/2a6m31321788470.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/wessaorg/rcomp/tmp/383g01321788470.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/wessaorg/rcomp/tmp/4a44d1321788470.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/wessaorg/rcomp/tmp/567tj1321788470.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 = 60 Frequency = 1 1 2 3 4 5 6 -9.8964078 -18.9061025 -18.4276380 -18.8773284 -1.3278623 0.5181993 7 8 9 10 11 12 -3.5255063 -10.2915056 20.1175079 18.5381044 -5.4822714 -9.9397815 13 14 15 16 17 18 -10.7860536 -16.5712245 -9.1917715 -16.6174935 -10.1066192 7.9818248 19 20 21 22 23 24 6.4828418 19.0172365 24.6968714 6.1186535 -2.3517942 26.0825431 25 26 27 28 29 30 11.0328371 33.1818887 -28.3292607 30.4299052 25.6376585 13.7876553 31 32 33 34 35 36 -0.7682806 -26.0075732 14.8408914 30.3093180 7.2019058 -24.1428941 37 38 39 40 41 42 14.3352736 30.4192694 -35.4040814 22.6141464 -18.4120724 -0.3074713 43 44 45 46 47 48 -5.1086727 21.2027814 -1.7300787 -16.9435750 -8.6432381 15.7691513 49 50 51 52 53 54 -30.5916156 22.1959664 -4.1249166 14.0518754 -31.6544779 -25.4037953 55 56 57 58 59 60 -4.4979345 -1.1207758 11.5044220 -8.2580133 -9.6388747 -4.6817664 > postscript(file="/var/wessaorg/rcomp/tmp/6e9v51321788470.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 = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 -9.8964078 NA 1 -18.9061025 -9.8964078 2 -18.4276380 -18.9061025 3 -18.8773284 -18.4276380 4 -1.3278623 -18.8773284 5 0.5181993 -1.3278623 6 -3.5255063 0.5181993 7 -10.2915056 -3.5255063 8 20.1175079 -10.2915056 9 18.5381044 20.1175079 10 -5.4822714 18.5381044 11 -9.9397815 -5.4822714 12 -10.7860536 -9.9397815 13 -16.5712245 -10.7860536 14 -9.1917715 -16.5712245 15 -16.6174935 -9.1917715 16 -10.1066192 -16.6174935 17 7.9818248 -10.1066192 18 6.4828418 7.9818248 19 19.0172365 6.4828418 20 24.6968714 19.0172365 21 6.1186535 24.6968714 22 -2.3517942 6.1186535 23 26.0825431 -2.3517942 24 11.0328371 26.0825431 25 33.1818887 11.0328371 26 -28.3292607 33.1818887 27 30.4299052 -28.3292607 28 25.6376585 30.4299052 29 13.7876553 25.6376585 30 -0.7682806 13.7876553 31 -26.0075732 -0.7682806 32 14.8408914 -26.0075732 33 30.3093180 14.8408914 34 7.2019058 30.3093180 35 -24.1428941 7.2019058 36 14.3352736 -24.1428941 37 30.4192694 14.3352736 38 -35.4040814 30.4192694 39 22.6141464 -35.4040814 40 -18.4120724 22.6141464 41 -0.3074713 -18.4120724 42 -5.1086727 -0.3074713 43 21.2027814 -5.1086727 44 -1.7300787 21.2027814 45 -16.9435750 -1.7300787 46 -8.6432381 -16.9435750 47 15.7691513 -8.6432381 48 -30.5916156 15.7691513 49 22.1959664 -30.5916156 50 -4.1249166 22.1959664 51 14.0518754 -4.1249166 52 -31.6544779 14.0518754 53 -25.4037953 -31.6544779 54 -4.4979345 -25.4037953 55 -1.1207758 -4.4979345 56 11.5044220 -1.1207758 57 -8.2580133 11.5044220 58 -9.6388747 -8.2580133 59 -4.6817664 -9.6388747 60 NA -4.6817664 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -18.9061025 -9.8964078 [2,] -18.4276380 -18.9061025 [3,] -18.8773284 -18.4276380 [4,] -1.3278623 -18.8773284 [5,] 0.5181993 -1.3278623 [6,] -3.5255063 0.5181993 [7,] -10.2915056 -3.5255063 [8,] 20.1175079 -10.2915056 [9,] 18.5381044 20.1175079 [10,] -5.4822714 18.5381044 [11,] -9.9397815 -5.4822714 [12,] -10.7860536 -9.9397815 [13,] -16.5712245 -10.7860536 [14,] -9.1917715 -16.5712245 [15,] -16.6174935 -9.1917715 [16,] -10.1066192 -16.6174935 [17,] 7.9818248 -10.1066192 [18,] 6.4828418 7.9818248 [19,] 19.0172365 6.4828418 [20,] 24.6968714 19.0172365 [21,] 6.1186535 24.6968714 [22,] -2.3517942 6.1186535 [23,] 26.0825431 -2.3517942 [24,] 11.0328371 26.0825431 [25,] 33.1818887 11.0328371 [26,] -28.3292607 33.1818887 [27,] 30.4299052 -28.3292607 [28,] 25.6376585 30.4299052 [29,] 13.7876553 25.6376585 [30,] -0.7682806 13.7876553 [31,] -26.0075732 -0.7682806 [32,] 14.8408914 -26.0075732 [33,] 30.3093180 14.8408914 [34,] 7.2019058 30.3093180 [35,] -24.1428941 7.2019058 [36,] 14.3352736 -24.1428941 [37,] 30.4192694 14.3352736 [38,] -35.4040814 30.4192694 [39,] 22.6141464 -35.4040814 [40,] -18.4120724 22.6141464 [41,] -0.3074713 -18.4120724 [42,] -5.1086727 -0.3074713 [43,] 21.2027814 -5.1086727 [44,] -1.7300787 21.2027814 [45,] -16.9435750 -1.7300787 [46,] -8.6432381 -16.9435750 [47,] 15.7691513 -8.6432381 [48,] -30.5916156 15.7691513 [49,] 22.1959664 -30.5916156 [50,] -4.1249166 22.1959664 [51,] 14.0518754 -4.1249166 [52,] -31.6544779 14.0518754 [53,] -25.4037953 -31.6544779 [54,] -4.4979345 -25.4037953 [55,] -1.1207758 -4.4979345 [56,] 11.5044220 -1.1207758 [57,] -8.2580133 11.5044220 [58,] -9.6388747 -8.2580133 [59,] -4.6817664 -9.6388747 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -18.9061025 -9.8964078 2 -18.4276380 -18.9061025 3 -18.8773284 -18.4276380 4 -1.3278623 -18.8773284 5 0.5181993 -1.3278623 6 -3.5255063 0.5181993 7 -10.2915056 -3.5255063 8 20.1175079 -10.2915056 9 18.5381044 20.1175079 10 -5.4822714 18.5381044 11 -9.9397815 -5.4822714 12 -10.7860536 -9.9397815 13 -16.5712245 -10.7860536 14 -9.1917715 -16.5712245 15 -16.6174935 -9.1917715 16 -10.1066192 -16.6174935 17 7.9818248 -10.1066192 18 6.4828418 7.9818248 19 19.0172365 6.4828418 20 24.6968714 19.0172365 21 6.1186535 24.6968714 22 -2.3517942 6.1186535 23 26.0825431 -2.3517942 24 11.0328371 26.0825431 25 33.1818887 11.0328371 26 -28.3292607 33.1818887 27 30.4299052 -28.3292607 28 25.6376585 30.4299052 29 13.7876553 25.6376585 30 -0.7682806 13.7876553 31 -26.0075732 -0.7682806 32 14.8408914 -26.0075732 33 30.3093180 14.8408914 34 7.2019058 30.3093180 35 -24.1428941 7.2019058 36 14.3352736 -24.1428941 37 30.4192694 14.3352736 38 -35.4040814 30.4192694 39 22.6141464 -35.4040814 40 -18.4120724 22.6141464 41 -0.3074713 -18.4120724 42 -5.1086727 -0.3074713 43 21.2027814 -5.1086727 44 -1.7300787 21.2027814 45 -16.9435750 -1.7300787 46 -8.6432381 -16.9435750 47 15.7691513 -8.6432381 48 -30.5916156 15.7691513 49 22.1959664 -30.5916156 50 -4.1249166 22.1959664 51 14.0518754 -4.1249166 52 -31.6544779 14.0518754 53 -25.4037953 -31.6544779 54 -4.4979345 -25.4037953 55 -1.1207758 -4.4979345 56 11.5044220 -1.1207758 57 -8.2580133 11.5044220 58 -9.6388747 -8.2580133 59 -4.6817664 -9.6388747 > 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/wessaorg/rcomp/tmp/70p561321788470.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/wessaorg/rcomp/tmp/8c1yx1321788470.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/wessaorg/rcomp/tmp/9tdu31321788470.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/wessaorg/rcomp/tmp/10kg7s1321788470.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11kntu1321788470.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/wessaorg/rcomp/tmp/12sx8z1321788471.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/wessaorg/rcomp/tmp/1351ik1321788471.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/wessaorg/rcomp/tmp/14bdqb1321788471.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/wessaorg/rcomp/tmp/153vif1321788471.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/wessaorg/rcomp/tmp/16whdq1321788471.tab") + } > > try(system("convert tmp/1lsex1321788470.ps tmp/1lsex1321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/2a6m31321788470.ps tmp/2a6m31321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/383g01321788470.ps tmp/383g01321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/4a44d1321788470.ps tmp/4a44d1321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/567tj1321788470.ps tmp/567tj1321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/6e9v51321788470.ps tmp/6e9v51321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/70p561321788470.ps tmp/70p561321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/8c1yx1321788470.ps tmp/8c1yx1321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/9tdu31321788470.ps tmp/9tdu31321788470.png",intern=TRUE)) character(0) > try(system("convert tmp/10kg7s1321788470.ps tmp/10kg7s1321788470.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.351 0.572 4.057