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(7,14,5,18,5,11,8,16,6,18,5,14,6,14,5,15,4,15,5,19,6,16,7,18,6,17,7,16,5,11,7,14,7,12,4,9,6,14,5,15,5,16,6,17,5,15,5,17,7,16,7,12,7,11,5,15,5,15,4,17,4,16,7,12,5,15,6,16,4,15,6,12,6,11,8,14,7,15,6,11,5,15,5,16,4,15,6,12,6,17,7,13,5,15,8,15,8,14,5,14,6,13,4,7,5,17,5,13,5,15,5,14,6,13,6,16,5,12,6,14,5,17,6,16,4,15,5,16,9,10,6,15,6,11,5,13,5,18,7,14,5,14,7,14,6,14,6,12,9,14,7,15,6,15,5,15,5,13,6,17,7,19,5,15,6,15,7,16,7,11,6,15,8,15,5,14,6,16,4,16,6,16,7,13,6,12,8,9,4,13,5,13,6,14,7,19,7,13,6,12,6,13),dim=c(2,101),dimnames=list(c('Leeftijd','Happiness'),1:101)) > y <- array(NA,dim=c(2,101),dimnames=list(c('Leeftijd','Happiness'),1:101)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '2' > #'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 Happiness Leeftijd 1 14 7 2 18 5 3 11 5 4 16 8 5 18 6 6 14 5 7 14 6 8 15 5 9 15 4 10 19 5 11 16 6 12 18 7 13 17 6 14 16 7 15 11 5 16 14 7 17 12 7 18 9 4 19 14 6 20 15 5 21 16 5 22 17 6 23 15 5 24 17 5 25 16 7 26 12 7 27 11 7 28 15 5 29 15 5 30 17 4 31 16 4 32 12 7 33 15 5 34 16 6 35 15 4 36 12 6 37 11 6 38 14 8 39 15 7 40 11 6 41 15 5 42 16 5 43 15 4 44 12 6 45 17 6 46 13 7 47 15 5 48 15 8 49 14 8 50 14 5 51 13 6 52 7 4 53 17 5 54 13 5 55 15 5 56 14 5 57 13 6 58 16 6 59 12 5 60 14 6 61 17 5 62 16 6 63 15 4 64 16 5 65 10 9 66 15 6 67 11 6 68 13 5 69 18 5 70 14 7 71 14 5 72 14 7 73 14 6 74 12 6 75 14 9 76 15 7 77 15 6 78 15 5 79 13 5 80 17 6 81 19 7 82 15 5 83 15 6 84 16 7 85 11 7 86 15 6 87 15 8 88 14 5 89 16 6 90 16 4 91 16 6 92 13 7 93 12 6 94 9 8 95 13 4 96 13 5 97 14 6 98 19 7 99 13 7 100 12 6 101 13 6 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Leeftijd 15.4702 -0.1883 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.7169 -1.3402 0.2831 1.4714 4.8481 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 15.4702 1.1688 13.236 <2e-16 *** Leeftijd -0.1883 0.1957 -0.962 0.338 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.249 on 99 degrees of freedom Multiple R-squared: 0.009267, Adjusted R-squared: -0.0007401 F-statistic: 0.926 on 1 and 99 DF, p-value: 0.3382 > 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.9255717 0.1488566 0.07442832 [2,] 0.8671037 0.2657926 0.13289630 [3,] 0.7966740 0.4066519 0.20332597 [4,] 0.6995560 0.6008880 0.30044399 [5,] 0.5953704 0.8092593 0.40462965 [6,] 0.7624735 0.4750530 0.23752650 [7,] 0.6868477 0.6263047 0.31315233 [8,] 0.6969021 0.6061958 0.30309789 [9,] 0.6490258 0.7019485 0.35097423 [10,] 0.5726203 0.8547594 0.42737971 [11,] 0.7535094 0.4929812 0.24649061 [12,] 0.7252769 0.5494463 0.27472313 [13,] 0.7887356 0.4225288 0.21126441 [14,] 0.9412584 0.1174831 0.05874157 [15,] 0.9194696 0.1610608 0.08053039 [16,] 0.8913887 0.2172225 0.10861126 [17,] 0.8719003 0.2561993 0.12809966 [18,] 0.8680487 0.2639026 0.13195130 [19,] 0.8293554 0.3412891 0.17064456 [20,] 0.8334276 0.3331447 0.16657237 [21,] 0.8013569 0.3972862 0.19864308 [22,] 0.8378123 0.3243754 0.16218772 [23,] 0.8956884 0.2086231 0.10431156 [24,] 0.8647147 0.2705706 0.13528532 [25,] 0.8282621 0.3434759 0.17173794 [26,] 0.8283121 0.3433758 0.17168791 [27,] 0.7981952 0.4036095 0.20180475 [28,] 0.8064988 0.3870025 0.19350123 [29,] 0.7630173 0.4739654 0.23698271 [30,] 0.7344012 0.5311976 0.26559880 [31,] 0.6834158 0.6331684 0.31658421 [32,] 0.6971773 0.6056454 0.30282272 [33,] 0.7624142 0.4751716 0.23758579 [34,] 0.7145645 0.5708711 0.28543555 [35,] 0.6680746 0.6638507 0.33192535 [36,] 0.7316705 0.5366589 0.26832947 [37,] 0.6830981 0.6338037 0.31690187 [38,] 0.6506982 0.6986036 0.34930181 [39,] 0.5965159 0.8069682 0.40348410 [40,] 0.6021450 0.7957099 0.39785497 [41,] 0.6203818 0.7592364 0.37961822 [42,] 0.5799469 0.8401062 0.42005308 [43,] 0.5255384 0.9489232 0.47446160 [44,] 0.4788600 0.9577199 0.52114004 [45,] 0.4218559 0.8437119 0.57814407 [46,] 0.3698457 0.7396914 0.63015430 [47,] 0.3354702 0.6709404 0.66452982 [48,] 0.8658191 0.2683617 0.13418087 [49,] 0.8711127 0.2577746 0.12888731 [50,] 0.8547374 0.2905253 0.14526263 [51,] 0.8202204 0.3595592 0.17977960 [52,] 0.7822590 0.4354819 0.21774097 [53,] 0.7535788 0.4928425 0.24642123 [54,] 0.7317074 0.5365852 0.26829260 [55,] 0.7485408 0.5029183 0.25145917 [56,] 0.7003856 0.5992287 0.29961435 [57,] 0.7064510 0.5870980 0.29354899 [58,] 0.6828469 0.6343062 0.31715312 [59,] 0.6284960 0.7430080 0.37150402 [60,] 0.5937779 0.8124441 0.40622206 [61,] 0.6868060 0.6263880 0.31319400 [62,] 0.6361661 0.7276678 0.36383391 [63,] 0.7008434 0.5983132 0.29915658 [64,] 0.6711092 0.6577815 0.32889077 [65,] 0.7489431 0.5021138 0.25105688 [66,] 0.6957265 0.6085471 0.30427353 [67,] 0.6394555 0.7210891 0.36054454 [68,] 0.5775604 0.8448791 0.42243956 [69,] 0.5139643 0.9720713 0.48603565 [70,] 0.5173016 0.9653969 0.48269843 [71,] 0.4511316 0.9022632 0.54886842 [72,] 0.3925284 0.7850569 0.60747156 [73,] 0.3335603 0.6671206 0.66643970 [74,] 0.2763118 0.5526237 0.72368817 [75,] 0.2424602 0.4849204 0.75753982 [76,] 0.2581920 0.5163840 0.74180802 [77,] 0.5119958 0.9760085 0.48800424 [78,] 0.4421277 0.8842554 0.55787229 [79,] 0.3801380 0.7602760 0.61986200 [80,] 0.3821851 0.7643702 0.61781489 [81,] 0.4084037 0.8168074 0.59159632 [82,] 0.3441247 0.6882494 0.65587532 [83,] 0.3124282 0.6248565 0.68757175 [84,] 0.2398887 0.4797775 0.76011126 [85,] 0.2298711 0.4597422 0.77012888 [86,] 0.1938488 0.3876975 0.80615125 [87,] 0.2035669 0.4071337 0.79643314 [88,] 0.1392288 0.2784577 0.86077116 [89,] 0.1004824 0.2009649 0.89951757 [90,] 0.4023724 0.8047449 0.59762757 [91,] 0.3352267 0.6704535 0.66477327 [92,] 0.2668300 0.5336600 0.73316999 > postscript(file="/var/wessaorg/rcomp/tmp/1p8wm1321995465.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/20nh61321995465.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/3zdg21321995465.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/4149j1321995465.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/5sors1321995465.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 = 101 Frequency = 1 1 2 3 4 5 6 -0.15189684 3.47143500 -3.52856500 2.03643725 3.65976908 -0.52856500 7 8 9 10 11 12 -0.34023092 0.47143500 0.28310091 4.47143500 1.65976908 3.84810316 13 14 15 16 17 18 2.65976908 1.84810316 -3.52856500 -0.15189684 -2.15189684 -5.71689909 19 20 21 22 23 24 -0.34023092 0.47143500 1.47143500 2.65976908 0.47143500 2.47143500 25 26 27 28 29 30 1.84810316 -2.15189684 -3.15189684 0.47143500 0.47143500 2.28310091 31 32 33 34 35 36 1.28310091 -2.15189684 0.47143500 1.65976908 0.28310091 -2.34023092 37 38 39 40 41 42 -3.34023092 0.03643725 0.84810316 -3.34023092 0.47143500 1.47143500 43 44 45 46 47 48 0.28310091 -2.34023092 2.65976908 -1.15189684 0.47143500 1.03643725 49 50 51 52 53 54 0.03643725 -0.52856500 -1.34023092 -7.71689909 2.47143500 -1.52856500 55 56 57 58 59 60 0.47143500 -0.52856500 -1.34023092 1.65976908 -2.52856500 -0.34023092 61 62 63 64 65 66 2.47143500 1.65976908 0.28310091 1.47143500 -3.77522867 0.65976908 67 68 69 70 71 72 -3.34023092 -1.52856500 3.47143500 -0.15189684 -0.52856500 -0.15189684 73 74 75 76 77 78 -0.34023092 -2.34023092 0.22477133 0.84810316 0.65976908 0.47143500 79 80 81 82 83 84 -1.52856500 2.65976908 4.84810316 0.47143500 0.65976908 1.84810316 85 86 87 88 89 90 -3.15189684 0.65976908 1.03643725 -0.52856500 1.65976908 1.28310091 91 92 93 94 95 96 1.65976908 -1.15189684 -2.34023092 -4.96356275 -1.71689909 -1.52856500 97 98 99 100 101 -0.34023092 4.84810316 -1.15189684 -2.34023092 -1.34023092 > postscript(file="/var/wessaorg/rcomp/tmp/6b81l1321995465.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 = 101 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.15189684 NA 1 3.47143500 -0.15189684 2 -3.52856500 3.47143500 3 2.03643725 -3.52856500 4 3.65976908 2.03643725 5 -0.52856500 3.65976908 6 -0.34023092 -0.52856500 7 0.47143500 -0.34023092 8 0.28310091 0.47143500 9 4.47143500 0.28310091 10 1.65976908 4.47143500 11 3.84810316 1.65976908 12 2.65976908 3.84810316 13 1.84810316 2.65976908 14 -3.52856500 1.84810316 15 -0.15189684 -3.52856500 16 -2.15189684 -0.15189684 17 -5.71689909 -2.15189684 18 -0.34023092 -5.71689909 19 0.47143500 -0.34023092 20 1.47143500 0.47143500 21 2.65976908 1.47143500 22 0.47143500 2.65976908 23 2.47143500 0.47143500 24 1.84810316 2.47143500 25 -2.15189684 1.84810316 26 -3.15189684 -2.15189684 27 0.47143500 -3.15189684 28 0.47143500 0.47143500 29 2.28310091 0.47143500 30 1.28310091 2.28310091 31 -2.15189684 1.28310091 32 0.47143500 -2.15189684 33 1.65976908 0.47143500 34 0.28310091 1.65976908 35 -2.34023092 0.28310091 36 -3.34023092 -2.34023092 37 0.03643725 -3.34023092 38 0.84810316 0.03643725 39 -3.34023092 0.84810316 40 0.47143500 -3.34023092 41 1.47143500 0.47143500 42 0.28310091 1.47143500 43 -2.34023092 0.28310091 44 2.65976908 -2.34023092 45 -1.15189684 2.65976908 46 0.47143500 -1.15189684 47 1.03643725 0.47143500 48 0.03643725 1.03643725 49 -0.52856500 0.03643725 50 -1.34023092 -0.52856500 51 -7.71689909 -1.34023092 52 2.47143500 -7.71689909 53 -1.52856500 2.47143500 54 0.47143500 -1.52856500 55 -0.52856500 0.47143500 56 -1.34023092 -0.52856500 57 1.65976908 -1.34023092 58 -2.52856500 1.65976908 59 -0.34023092 -2.52856500 60 2.47143500 -0.34023092 61 1.65976908 2.47143500 62 0.28310091 1.65976908 63 1.47143500 0.28310091 64 -3.77522867 1.47143500 65 0.65976908 -3.77522867 66 -3.34023092 0.65976908 67 -1.52856500 -3.34023092 68 3.47143500 -1.52856500 69 -0.15189684 3.47143500 70 -0.52856500 -0.15189684 71 -0.15189684 -0.52856500 72 -0.34023092 -0.15189684 73 -2.34023092 -0.34023092 74 0.22477133 -2.34023092 75 0.84810316 0.22477133 76 0.65976908 0.84810316 77 0.47143500 0.65976908 78 -1.52856500 0.47143500 79 2.65976908 -1.52856500 80 4.84810316 2.65976908 81 0.47143500 4.84810316 82 0.65976908 0.47143500 83 1.84810316 0.65976908 84 -3.15189684 1.84810316 85 0.65976908 -3.15189684 86 1.03643725 0.65976908 87 -0.52856500 1.03643725 88 1.65976908 -0.52856500 89 1.28310091 1.65976908 90 1.65976908 1.28310091 91 -1.15189684 1.65976908 92 -2.34023092 -1.15189684 93 -4.96356275 -2.34023092 94 -1.71689909 -4.96356275 95 -1.52856500 -1.71689909 96 -0.34023092 -1.52856500 97 4.84810316 -0.34023092 98 -1.15189684 4.84810316 99 -2.34023092 -1.15189684 100 -1.34023092 -2.34023092 101 NA -1.34023092 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 3.47143500 -0.15189684 [2,] -3.52856500 3.47143500 [3,] 2.03643725 -3.52856500 [4,] 3.65976908 2.03643725 [5,] -0.52856500 3.65976908 [6,] -0.34023092 -0.52856500 [7,] 0.47143500 -0.34023092 [8,] 0.28310091 0.47143500 [9,] 4.47143500 0.28310091 [10,] 1.65976908 4.47143500 [11,] 3.84810316 1.65976908 [12,] 2.65976908 3.84810316 [13,] 1.84810316 2.65976908 [14,] -3.52856500 1.84810316 [15,] -0.15189684 -3.52856500 [16,] -2.15189684 -0.15189684 [17,] -5.71689909 -2.15189684 [18,] -0.34023092 -5.71689909 [19,] 0.47143500 -0.34023092 [20,] 1.47143500 0.47143500 [21,] 2.65976908 1.47143500 [22,] 0.47143500 2.65976908 [23,] 2.47143500 0.47143500 [24,] 1.84810316 2.47143500 [25,] -2.15189684 1.84810316 [26,] -3.15189684 -2.15189684 [27,] 0.47143500 -3.15189684 [28,] 0.47143500 0.47143500 [29,] 2.28310091 0.47143500 [30,] 1.28310091 2.28310091 [31,] -2.15189684 1.28310091 [32,] 0.47143500 -2.15189684 [33,] 1.65976908 0.47143500 [34,] 0.28310091 1.65976908 [35,] -2.34023092 0.28310091 [36,] -3.34023092 -2.34023092 [37,] 0.03643725 -3.34023092 [38,] 0.84810316 0.03643725 [39,] -3.34023092 0.84810316 [40,] 0.47143500 -3.34023092 [41,] 1.47143500 0.47143500 [42,] 0.28310091 1.47143500 [43,] -2.34023092 0.28310091 [44,] 2.65976908 -2.34023092 [45,] -1.15189684 2.65976908 [46,] 0.47143500 -1.15189684 [47,] 1.03643725 0.47143500 [48,] 0.03643725 1.03643725 [49,] -0.52856500 0.03643725 [50,] -1.34023092 -0.52856500 [51,] -7.71689909 -1.34023092 [52,] 2.47143500 -7.71689909 [53,] -1.52856500 2.47143500 [54,] 0.47143500 -1.52856500 [55,] -0.52856500 0.47143500 [56,] -1.34023092 -0.52856500 [57,] 1.65976908 -1.34023092 [58,] -2.52856500 1.65976908 [59,] -0.34023092 -2.52856500 [60,] 2.47143500 -0.34023092 [61,] 1.65976908 2.47143500 [62,] 0.28310091 1.65976908 [63,] 1.47143500 0.28310091 [64,] -3.77522867 1.47143500 [65,] 0.65976908 -3.77522867 [66,] -3.34023092 0.65976908 [67,] -1.52856500 -3.34023092 [68,] 3.47143500 -1.52856500 [69,] -0.15189684 3.47143500 [70,] -0.52856500 -0.15189684 [71,] -0.15189684 -0.52856500 [72,] -0.34023092 -0.15189684 [73,] -2.34023092 -0.34023092 [74,] 0.22477133 -2.34023092 [75,] 0.84810316 0.22477133 [76,] 0.65976908 0.84810316 [77,] 0.47143500 0.65976908 [78,] -1.52856500 0.47143500 [79,] 2.65976908 -1.52856500 [80,] 4.84810316 2.65976908 [81,] 0.47143500 4.84810316 [82,] 0.65976908 0.47143500 [83,] 1.84810316 0.65976908 [84,] -3.15189684 1.84810316 [85,] 0.65976908 -3.15189684 [86,] 1.03643725 0.65976908 [87,] -0.52856500 1.03643725 [88,] 1.65976908 -0.52856500 [89,] 1.28310091 1.65976908 [90,] 1.65976908 1.28310091 [91,] -1.15189684 1.65976908 [92,] -2.34023092 -1.15189684 [93,] -4.96356275 -2.34023092 [94,] -1.71689909 -4.96356275 [95,] -1.52856500 -1.71689909 [96,] -0.34023092 -1.52856500 [97,] 4.84810316 -0.34023092 [98,] -1.15189684 4.84810316 [99,] -2.34023092 -1.15189684 [100,] -1.34023092 -2.34023092 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 3.47143500 -0.15189684 2 -3.52856500 3.47143500 3 2.03643725 -3.52856500 4 3.65976908 2.03643725 5 -0.52856500 3.65976908 6 -0.34023092 -0.52856500 7 0.47143500 -0.34023092 8 0.28310091 0.47143500 9 4.47143500 0.28310091 10 1.65976908 4.47143500 11 3.84810316 1.65976908 12 2.65976908 3.84810316 13 1.84810316 2.65976908 14 -3.52856500 1.84810316 15 -0.15189684 -3.52856500 16 -2.15189684 -0.15189684 17 -5.71689909 -2.15189684 18 -0.34023092 -5.71689909 19 0.47143500 -0.34023092 20 1.47143500 0.47143500 21 2.65976908 1.47143500 22 0.47143500 2.65976908 23 2.47143500 0.47143500 24 1.84810316 2.47143500 25 -2.15189684 1.84810316 26 -3.15189684 -2.15189684 27 0.47143500 -3.15189684 28 0.47143500 0.47143500 29 2.28310091 0.47143500 30 1.28310091 2.28310091 31 -2.15189684 1.28310091 32 0.47143500 -2.15189684 33 1.65976908 0.47143500 34 0.28310091 1.65976908 35 -2.34023092 0.28310091 36 -3.34023092 -2.34023092 37 0.03643725 -3.34023092 38 0.84810316 0.03643725 39 -3.34023092 0.84810316 40 0.47143500 -3.34023092 41 1.47143500 0.47143500 42 0.28310091 1.47143500 43 -2.34023092 0.28310091 44 2.65976908 -2.34023092 45 -1.15189684 2.65976908 46 0.47143500 -1.15189684 47 1.03643725 0.47143500 48 0.03643725 1.03643725 49 -0.52856500 0.03643725 50 -1.34023092 -0.52856500 51 -7.71689909 -1.34023092 52 2.47143500 -7.71689909 53 -1.52856500 2.47143500 54 0.47143500 -1.52856500 55 -0.52856500 0.47143500 56 -1.34023092 -0.52856500 57 1.65976908 -1.34023092 58 -2.52856500 1.65976908 59 -0.34023092 -2.52856500 60 2.47143500 -0.34023092 61 1.65976908 2.47143500 62 0.28310091 1.65976908 63 1.47143500 0.28310091 64 -3.77522867 1.47143500 65 0.65976908 -3.77522867 66 -3.34023092 0.65976908 67 -1.52856500 -3.34023092 68 3.47143500 -1.52856500 69 -0.15189684 3.47143500 70 -0.52856500 -0.15189684 71 -0.15189684 -0.52856500 72 -0.34023092 -0.15189684 73 -2.34023092 -0.34023092 74 0.22477133 -2.34023092 75 0.84810316 0.22477133 76 0.65976908 0.84810316 77 0.47143500 0.65976908 78 -1.52856500 0.47143500 79 2.65976908 -1.52856500 80 4.84810316 2.65976908 81 0.47143500 4.84810316 82 0.65976908 0.47143500 83 1.84810316 0.65976908 84 -3.15189684 1.84810316 85 0.65976908 -3.15189684 86 1.03643725 0.65976908 87 -0.52856500 1.03643725 88 1.65976908 -0.52856500 89 1.28310091 1.65976908 90 1.65976908 1.28310091 91 -1.15189684 1.65976908 92 -2.34023092 -1.15189684 93 -4.96356275 -2.34023092 94 -1.71689909 -4.96356275 95 -1.52856500 -1.71689909 96 -0.34023092 -1.52856500 97 4.84810316 -0.34023092 98 -1.15189684 4.84810316 99 -2.34023092 -1.15189684 100 -1.34023092 -2.34023092 > 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/77glc1321995465.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/8ip181321995465.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/9yyvz1321995465.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/10ld6l1321995465.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/11qmnr1321995465.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/12rxbk1321995466.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/13l3cx1321995466.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/14bejj1321995466.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/15u4vd1321995466.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/16uxmt1321995466.tab") + } > > try(system("convert tmp/1p8wm1321995465.ps tmp/1p8wm1321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/20nh61321995465.ps tmp/20nh61321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/3zdg21321995465.ps tmp/3zdg21321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/4149j1321995465.ps tmp/4149j1321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/5sors1321995465.ps tmp/5sors1321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/6b81l1321995465.ps tmp/6b81l1321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/77glc1321995465.ps tmp/77glc1321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/8ip181321995465.ps tmp/8ip181321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/9yyvz1321995465.ps tmp/9yyvz1321995465.png",intern=TRUE)) character(0) > try(system("convert tmp/10ld6l1321995465.ps tmp/10ld6l1321995465.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.731 0.480 4.237