R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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
+ ,1
+ ,0
+ ,6
+ ,0
+ ,7
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,1
+ ,0
+ ,6
+ ,1
+ ,7
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,7
+ ,0
+ ,4
+ ,1
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,1
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,5
+ ,1
+ ,8
+ ,0
+ ,4
+ ,1
+ ,0
+ ,6
+ ,0
+ ,8
+ ,0
+ ,4
+ ,0
+ ,0
+ ,5
+ ,1
+ ,7
+ ,0
+ ,4
+ ,0
+ ,0
+ ,5
+ ,1
+ ,7
+ ,0
+ ,4
+ ,1
+ ,0
+ ,5
+ ,1
+ ,8
+ ,1
+ ,4
+ ,1
+ ,0
+ ,6
+ ,0
+ ,8
+ ,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+ ,0
+ ,2
+ ,0
+ ,4
+ ,5
+ ,0
+ ,7
+ ,1
+ ,2
+ ,0
+ ,3
+ ,5
+ ,0
+ ,7
+ ,0
+ ,2
+ ,1
+ ,4
+ ,6
+ ,0
+ ,8
+ ,0
+ ,2
+ ,0
+ ,4
+ ,6
+ ,1
+ ,7
+ ,0
+ ,2
+ ,0
+ ,4
+ ,6
+ ,1
+ ,8
+ ,0
+ ,2
+ ,0
+ ,3
+ ,6
+ ,0
+ ,7
+ ,0
+ ,2
+ ,0
+ ,3
+ ,5
+ ,0
+ ,8
+ ,0
+ ,2
+ ,0
+ ,3
+ ,6
+ ,0
+ ,8
+ ,0
+ ,2
+ ,1
+ ,4
+ ,6
+ ,0
+ ,8
+ ,0
+ ,2
+ ,0
+ ,4
+ ,6
+ ,1
+ ,7
+ ,0
+ ,2
+ ,0
+ ,4
+ ,6
+ ,0
+ ,7
+ ,0
+ ,2
+ ,1
+ ,4
+ ,5
+ ,0
+ ,8
+ ,1
+ ,2
+ ,1
+ ,4
+ ,5
+ ,1
+ ,8
+ ,1
+ ,2
+ ,1
+ ,4
+ ,5
+ ,0
+ ,8
+ ,0)
+ ,dim=c(7
+ ,154)
+ ,dimnames=list(c('Weeks'
+ ,'UsedLimit'
+ ,'T20'
+ ,'Used'
+ ,'Useful'
+ ,'Outcome'
+ ,'CorrectAnalysis')
+ ,1:154))
> y <- array(NA,dim=c(7,154),dimnames=list(c('Weeks','UsedLimit','T20','Used','Useful','Outcome','CorrectAnalysis'),1:154))
> 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 = '7'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
CorrectAnalysis Weeks UsedLimit T20 Used Useful Outcome
1 0 4 1 0 6 0 7
2 0 4 0 0 6 0 8
3 0 4 0 0 6 0 8
4 0 4 0 0 6 0 8
5 0 4 0 0 6 0 8
6 0 4 1 0 6 1 7
7 0 4 0 0 6 0 8
8 0 4 0 0 6 0 8
9 0 4 0 0 6 0 7
10 0 4 1 0 6 0 8
11 0 4 1 0 6 0 8
12 0 4 0 0 6 0 8
13 0 4 0 0 5 1 8
14 0 4 1 0 6 0 8
15 0 4 0 0 5 1 7
16 0 4 0 0 5 1 7
17 1 4 1 0 5 1 8
18 0 4 1 0 6 0 8
19 0 4 0 0 6 0 7
20 1 4 0 0 5 1 7
21 0 4 1 0 6 1 8
22 0 4 1 0 5 1 7
23 0 4 0 0 6 1 7
24 0 4 1 0 6 1 7
25 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0 2 0 4 6 0 8
90 0 2 0 4 6 0 7
91 0 2 0 4 6 1 8
92 0 2 1 3 6 0 8
93 0 2 1 4 6 1 8
94 0 2 0 4 6 0 8
95 0 2 0 3 6 0 8
96 0 2 0 4 6 0 7
97 0 2 1 3 6 0 8
98 0 2 0 4 6 0 8
99 0 2 1 4 6 0 8
100 0 2 0 4 6 0 7
101 0 2 1 4 6 0 7
102 0 2 0 4 6 0 8
103 0 2 0 4 6 0 8
104 0 2 0 4 6 0 8
105 0 2 0 3 5 0 8
106 0 2 0 4 6 0 8
107 0 2 0 4 6 0 8
108 0 2 1 3 5 0 8
109 0 2 0 4 6 0 8
110 0 2 1 4 6 0 8
111 0 2 1 3 5 1 8
112 0 2 0 3 6 0 8
113 0 2 0 4 5 0 8
114 0 2 1 3 5 0 8
115 0 2 1 4 6 0 8
116 0 2 0 4 6 0 8
117 0 2 1 4 6 0 7
118 0 2 1 4 6 0 8
119 0 2 0 4 6 0 8
120 0 2 0 4 6 0 7
121 0 2 1 4 6 0 8
122 0 2 0 4 6 0 8
123 0 2 1 3 5 0 8
124 0 2 0 4 5 1 7
125 0 2 0 4 6 0 7
126 0 2 0 3 6 0 8
127 0 2 0 4 6 1 8
128 0 2 0 4 6 0 7
129 0 2 0 4 6 0 8
130 0 2 0 4 6 0 7
131 0 2 1 4 6 0 8
132 0 2 1 4 6 0 7
133 0 2 1 4 5 0 8
134 0 2 0 4 6 0 8
135 0 2 0 4 6 0 8
136 0 2 0 4 6 0 8
137 0 2 1 4 5 1 7
138 0 2 1 3 5 1 7
139 0 2 0 3 6 0 8
140 0 2 0 4 6 0 8
141 1 2 0 4 5 0 7
142 0 2 0 3 5 0 7
143 0 2 1 4 6 0 8
144 0 2 0 4 6 1 7
145 0 2 0 4 6 1 8
146 0 2 0 3 6 0 7
147 0 2 0 3 5 0 8
148 0 2 0 3 6 0 8
149 0 2 1 4 6 0 8
150 0 2 0 4 6 1 7
151 0 2 0 4 6 0 7
152 1 2 1 4 5 0 8
153 1 2 1 4 5 1 8
154 0 2 1 4 5 0 8
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Weeks UsedLimit T20 Used Useful
0.09101 0.32780 0.01121 0.16478 -0.27876 0.04529
Outcome
0.03522
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.34661 -0.05929 -0.01489 0.02033 0.74511
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.09101 0.62013 0.147 0.8835
Weeks 0.32780 0.13148 2.493 0.0138 *
UsedLimit 0.01121 0.04167 0.269 0.7883
T20 0.16478 0.06915 2.383 0.0184 *
Used -0.27876 0.04538 -6.143 7.22e-09 ***
Useful 0.04529 0.04647 0.975 0.3314
Outcome 0.03522 0.04036 0.873 0.3843
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2378 on 147 degrees of freedom
Multiple R-squared: 0.2489, Adjusted R-squared: 0.2182
F-statistic: 8.118 on 6 and 147 DF, p-value: 1.383e-07
> 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.000000000 0.000000000 1.0000000000
[2,] 0.000000000 0.000000000 1.0000000000
[3,] 0.000000000 0.000000000 1.0000000000
[4,] 0.000000000 0.000000000 1.0000000000
[5,] 0.000000000 0.000000000 1.0000000000
[6,] 0.000000000 0.000000000 1.0000000000
[7,] 0.000000000 0.000000000 1.0000000000
[8,] 0.434515961 0.869031921 0.5654840394
[9,] 0.378869942 0.757739883 0.6211300584
[10,] 0.341586834 0.683173668 0.6584131661
[11,] 0.883877041 0.232245917 0.1161229587
[12,] 0.841391786 0.317216428 0.1586082140
[13,] 0.896952587 0.206094825 0.1030474126
[14,] 0.863012126 0.273975747 0.1369878735
[15,] 0.819533950 0.360932101 0.1804660503
[16,] 0.807872872 0.384254257 0.1921271284
[17,] 0.832093094 0.335813811 0.1679069057
[18,] 0.786133813 0.427732373 0.2138661866
[19,] 0.773296328 0.453407344 0.2267036722
[20,] 0.724759061 0.550481878 0.2752409389
[21,] 0.670577035 0.658845929 0.3294229646
[22,] 0.611857601 0.776284797 0.3881423986
[23,] 0.551146771 0.897706458 0.4488532292
[24,] 0.497838798 0.995677596 0.5021612020
[25,] 0.439020787 0.878041575 0.5609792127
[26,] 0.380468041 0.760936081 0.6195319593
[27,] 0.324969738 0.649939476 0.6750302622
[28,] 0.352373554 0.704747108 0.6476264458
[29,] 0.328008586 0.656017173 0.6719914136
[30,] 0.277872120 0.555744239 0.7221278803
[31,] 0.233846020 0.467692040 0.7661539799
[32,] 0.689119740 0.621760520 0.3108802601
[33,] 0.676072406 0.647855189 0.3239275945
[34,] 0.629870537 0.740258927 0.3701294634
[35,] 0.578443799 0.843112403 0.4215562014
[36,] 0.529040335 0.941919330 0.4709596651
[37,] 0.477835106 0.955670211 0.5221648944
[38,] 0.426296648 0.852593297 0.5737033516
[39,] 0.375356109 0.750712218 0.6246438909
[40,] 0.328286172 0.656572345 0.6717138275
[41,] 0.283365527 0.566731054 0.7166344729
[42,] 0.283023928 0.566047855 0.7169760725
[43,] 0.618520633 0.762958734 0.3814793668
[44,] 0.571617306 0.856765387 0.4283826936
[45,] 0.878820752 0.242358496 0.1211792480
[46,] 0.852042585 0.295914831 0.1479574153
[47,] 0.852645303 0.294709393 0.1473546967
[48,] 0.865939975 0.268120050 0.1340600250
[49,] 0.839222482 0.321555036 0.1607775180
[50,] 0.809115806 0.381768388 0.1908841942
[51,] 0.954063408 0.091873184 0.0459365922
[52,] 0.941160451 0.117679099 0.0588395494
[53,] 0.952266725 0.095466550 0.0477332748
[54,] 0.939522728 0.120954543 0.0604772716
[55,] 0.923918476 0.152163049 0.0760815244
[56,] 0.905910314 0.188179372 0.0940896861
[57,] 0.885051458 0.229897083 0.1149485416
[58,] 0.977895717 0.044208566 0.0221042828
[59,] 0.970871179 0.058257642 0.0291288210
[60,] 0.962372646 0.075254707 0.0376273536
[61,] 0.967411627 0.065176745 0.0325883727
[62,] 0.958090284 0.083819432 0.0419097161
[63,] 0.946769788 0.106460424 0.0532302122
[64,] 0.952131978 0.095736045 0.0478680225
[65,] 0.962694320 0.074611360 0.0373056801
[66,] 0.953021153 0.093957694 0.0469788470
[67,] 0.940297445 0.119405111 0.0597025554
[68,] 0.926762255 0.146475490 0.0732377448
[69,] 0.944005492 0.111989017 0.0559945084
[70,] 0.993320775 0.013358451 0.0066792253
[71,] 0.990923941 0.018152118 0.0090760591
[72,] 0.988112490 0.023775019 0.0118875097
[73,] 0.992007941 0.015984119 0.0079920595
[74,] 0.991126119 0.017747761 0.0088738806
[75,] 0.999188621 0.001622759 0.0008113794
[76,] 0.998771632 0.002456736 0.0012283678
[77,] 0.998162661 0.003674677 0.0018373386
[78,] 0.997286814 0.005426372 0.0027131861
[79,] 0.996267757 0.007464486 0.0037322430
[80,] 0.994637988 0.010724024 0.0053620122
[81,] 0.992392847 0.015214305 0.0076071525
[82,] 0.989420655 0.021158690 0.0105793448
[83,] 0.986997313 0.026005373 0.0130026867
[84,] 0.982337969 0.035324062 0.0176620309
[85,] 0.976115149 0.047769701 0.0238848506
[86,] 0.970782052 0.058435897 0.0292179484
[87,] 0.961398525 0.077202950 0.0386014749
[88,] 0.953711193 0.092577615 0.0462888073
[89,] 0.939988700 0.120022600 0.0600113000
[90,] 0.923094154 0.153811691 0.0769058457
[91,] 0.902997046 0.194005907 0.0970029535
[92,] 0.878805127 0.242389747 0.1211948733
[93,] 0.850800378 0.298399244 0.1491996219
[94,] 0.818670676 0.362658648 0.1813293242
[95,] 0.782408368 0.435183264 0.2175916320
[96,] 0.756337391 0.487325218 0.2436626090
[97,] 0.713570326 0.572859347 0.2864296735
[98,] 0.667407575 0.665184850 0.3325924249
[99,] 0.632783386 0.734433228 0.3672166138
[100,] 0.581887576 0.836224847 0.4181124235
[101,] 0.528485424 0.943029151 0.4715145755
[102,] 0.491596966 0.983193932 0.5084030341
[103,] 0.455392665 0.910785330 0.5446073352
[104,] 0.506703679 0.986592643 0.4932963213
[105,] 0.470090010 0.940180020 0.5299099899
[106,] 0.414144136 0.828288271 0.5858558644
[107,] 0.362011229 0.724022458 0.6379887712
[108,] 0.310038718 0.620077435 0.6899612824
[109,] 0.260774326 0.521548651 0.7392256744
[110,] 0.217915994 0.435831988 0.7820840059
[111,] 0.177238464 0.354476927 0.8227615364
[112,] 0.141245427 0.282490854 0.8587545729
[113,] 0.112132130 0.224264259 0.8878678705
[114,] 0.096434501 0.192869003 0.9035654987
[115,] 0.119892480 0.239784960 0.8801075198
[116,] 0.091707425 0.183414850 0.9082925748
[117,] 0.075994135 0.151988271 0.9240058647
[118,] 0.056397937 0.112795875 0.9436020626
[119,] 0.040361137 0.080722273 0.9596388633
[120,] 0.028806268 0.057612537 0.9711937317
[121,] 0.019581105 0.039162209 0.9804188954
[122,] 0.012709079 0.025418159 0.9872909206
[123,] 0.008143962 0.016287924 0.9918560382
[124,] 0.015346173 0.030692346 0.9846538268
[125,] 0.010286650 0.020573299 0.9897133504
[126,] 0.006885498 0.013770997 0.9931145016
[127,] 0.004719633 0.009439265 0.9952803674
[128,] 0.008335562 0.016671124 0.9916644381
[129,] 0.006992506 0.013985012 0.9930074941
[130,] 0.005743929 0.011487857 0.9942560714
[131,] 0.002899058 0.005798115 0.9971009423
[132,] 0.031959003 0.063918006 0.9680409972
[133,] 0.025777253 0.051554507 0.9742227467
[134,] 0.014118248 0.028236496 0.9858817519
[135,] 0.006692859 0.013385717 0.9933071413
> postscript(file="/var/wessaorg/rcomp/tmp/1m8vc1355681615.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/28kf71355681615.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/3v3u71355681615.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/4wjn81355681615.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/5wdd81355681615.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 = 154
Frequency = 1
1 2 3 4 5 6
0.01266011 -0.01134305 -0.01134305 -0.01134305 -0.01134305 -0.03262865
7 8 9 10 11 12
-0.01134305 -0.01134305 0.02387272 -0.02255565 -0.02255565 -0.01134305
13 14 15 16 17 18
-0.33539478 -0.02255565 -0.30017901 -0.30017901 0.65339262 -0.02255565
19 20 21 22 23 24
0.02387272 0.69982099 -0.06784442 -0.31139162 -0.02141604 -0.03262865
25 26 27 28 29 30
-0.25489025 -0.33539478 0.01266011 -0.29010601 0.02387272 -0.05663181
31 32 33 34 35 36
-0.01134305 -0.02255565 -0.06784442 0.02387272 -0.01134305 -0.01134305
37 38 39 40 41 42
-0.34660738 -0.25489025 -0.02141604 -0.05663181 0.69982099 -0.25489025
43 44 45 46 47 48
-0.03262865 -0.02255565 -0.05663181 -0.02141604 -0.01134305 0.02387272
49 50 51 52 53 54
-0.02141604 -0.01134305 -0.29010601 0.65339262 0.02387272 0.70989399
55 56 57 58 59 60
-0.01134305 -0.25489025 -0.30017901 0.02387272 0.02387272 0.68860838
61 62 63 64 65 66
0.01266011 -0.33539478 -0.01134305 0.01266011 -0.01134305 -0.01134305
67 68 69 70 71 72
0.66460522 -0.02255565 0.02387272 -0.29010601 -0.01134305 0.02387272
73 74 75 76 77 78
-0.25489025 -0.30131862 0.02387272 -0.02141604 0.02387272 -0.30017901
79 80 81 82 83 84
0.74510975 -0.05663181 -0.01134305 -0.26610286 -0.01134305 0.70989399
85 86 87 88 89 90
-0.02141604 -0.02255565 0.00911809 -0.10486087 -0.01488507 0.02033070
91 92 93 94 95 96
-0.06017383 0.13868634 -0.07138644 -0.01488507 0.14989894 0.02033070
97 98 99 100 101 102
0.13868634 -0.01488507 -0.02609768 0.02033070 0.00911809 -0.01488507
103 104 105 106 107 108
-0.01488507 -0.01488507 -0.12886402 -0.01488507 -0.01488507 -0.14007663
109 110 111 112 113 114
-0.01488507 -0.02609768 -0.18536539 0.14989894 -0.29364804 -0.14007663
115 116 117 118 119 120
-0.02609768 -0.01488507 0.00911809 -0.02609768 -0.01488507 0.02033070
121 122 123 124 125 126
-0.02609768 -0.01488507 -0.14007663 -0.30372103 0.02033070 0.14989894
127 128 129 130 131 132
-0.06017383 0.02033070 -0.01488507 0.02033070 -0.02609768 0.00911809
133 134 135 136 137 138
-0.30486064 -0.01488507 -0.01488507 -0.01488507 -0.31493364 -0.15014963
139 140 141 142 143 144
0.14989894 -0.01488507 0.74156773 -0.09364826 -0.02609768 -0.02495806
145 146 147 148 149 150
-0.06017383 0.18511471 -0.12886402 0.14989894 -0.02609768 -0.02495806
151 152 153 154
0.02033070 0.69513936 0.64985060 -0.30486064
> postscript(file="/var/wessaorg/rcomp/tmp/6a3f51355681615.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 = 154
Frequency = 1
lag(myerror, k = 1) myerror
0 0.01266011 NA
1 -0.01134305 0.01266011
2 -0.01134305 -0.01134305
3 -0.01134305 -0.01134305
4 -0.01134305 -0.01134305
5 -0.03262865 -0.01134305
6 -0.01134305 -0.03262865
7 -0.01134305 -0.01134305
8 0.02387272 -0.01134305
9 -0.02255565 0.02387272
10 -0.02255565 -0.02255565
11 -0.01134305 -0.02255565
12 -0.33539478 -0.01134305
13 -0.02255565 -0.33539478
14 -0.30017901 -0.02255565
15 -0.30017901 -0.30017901
16 0.65339262 -0.30017901
17 -0.02255565 0.65339262
18 0.02387272 -0.02255565
19 0.69982099 0.02387272
20 -0.06784442 0.69982099
21 -0.31139162 -0.06784442
22 -0.02141604 -0.31139162
23 -0.03262865 -0.02141604
24 -0.25489025 -0.03262865
25 -0.33539478 -0.25489025
26 0.01266011 -0.33539478
27 -0.29010601 0.01266011
28 0.02387272 -0.29010601
29 -0.05663181 0.02387272
30 -0.01134305 -0.05663181
31 -0.02255565 -0.01134305
32 -0.06784442 -0.02255565
33 0.02387272 -0.06784442
34 -0.01134305 0.02387272
35 -0.01134305 -0.01134305
36 -0.34660738 -0.01134305
37 -0.25489025 -0.34660738
38 -0.02141604 -0.25489025
39 -0.05663181 -0.02141604
40 0.69982099 -0.05663181
41 -0.25489025 0.69982099
42 -0.03262865 -0.25489025
43 -0.02255565 -0.03262865
44 -0.05663181 -0.02255565
45 -0.02141604 -0.05663181
46 -0.01134305 -0.02141604
47 0.02387272 -0.01134305
48 -0.02141604 0.02387272
49 -0.01134305 -0.02141604
50 -0.29010601 -0.01134305
51 0.65339262 -0.29010601
52 0.02387272 0.65339262
53 0.70989399 0.02387272
54 -0.01134305 0.70989399
55 -0.25489025 -0.01134305
56 -0.30017901 -0.25489025
57 0.02387272 -0.30017901
58 0.02387272 0.02387272
59 0.68860838 0.02387272
60 0.01266011 0.68860838
61 -0.33539478 0.01266011
62 -0.01134305 -0.33539478
63 0.01266011 -0.01134305
64 -0.01134305 0.01266011
65 -0.01134305 -0.01134305
66 0.66460522 -0.01134305
67 -0.02255565 0.66460522
68 0.02387272 -0.02255565
69 -0.29010601 0.02387272
70 -0.01134305 -0.29010601
71 0.02387272 -0.01134305
72 -0.25489025 0.02387272
73 -0.30131862 -0.25489025
74 0.02387272 -0.30131862
75 -0.02141604 0.02387272
76 0.02387272 -0.02141604
77 -0.30017901 0.02387272
78 0.74510975 -0.30017901
79 -0.05663181 0.74510975
80 -0.01134305 -0.05663181
81 -0.26610286 -0.01134305
82 -0.01134305 -0.26610286
83 0.70989399 -0.01134305
84 -0.02141604 0.70989399
85 -0.02255565 -0.02141604
86 0.00911809 -0.02255565
87 -0.10486087 0.00911809
88 -0.01488507 -0.10486087
89 0.02033070 -0.01488507
90 -0.06017383 0.02033070
91 0.13868634 -0.06017383
92 -0.07138644 0.13868634
93 -0.01488507 -0.07138644
94 0.14989894 -0.01488507
95 0.02033070 0.14989894
96 0.13868634 0.02033070
97 -0.01488507 0.13868634
98 -0.02609768 -0.01488507
99 0.02033070 -0.02609768
100 0.00911809 0.02033070
101 -0.01488507 0.00911809
102 -0.01488507 -0.01488507
103 -0.01488507 -0.01488507
104 -0.12886402 -0.01488507
105 -0.01488507 -0.12886402
106 -0.01488507 -0.01488507
107 -0.14007663 -0.01488507
108 -0.01488507 -0.14007663
109 -0.02609768 -0.01488507
110 -0.18536539 -0.02609768
111 0.14989894 -0.18536539
112 -0.29364804 0.14989894
113 -0.14007663 -0.29364804
114 -0.02609768 -0.14007663
115 -0.01488507 -0.02609768
116 0.00911809 -0.01488507
117 -0.02609768 0.00911809
118 -0.01488507 -0.02609768
119 0.02033070 -0.01488507
120 -0.02609768 0.02033070
121 -0.01488507 -0.02609768
122 -0.14007663 -0.01488507
123 -0.30372103 -0.14007663
124 0.02033070 -0.30372103
125 0.14989894 0.02033070
126 -0.06017383 0.14989894
127 0.02033070 -0.06017383
128 -0.01488507 0.02033070
129 0.02033070 -0.01488507
130 -0.02609768 0.02033070
131 0.00911809 -0.02609768
132 -0.30486064 0.00911809
133 -0.01488507 -0.30486064
134 -0.01488507 -0.01488507
135 -0.01488507 -0.01488507
136 -0.31493364 -0.01488507
137 -0.15014963 -0.31493364
138 0.14989894 -0.15014963
139 -0.01488507 0.14989894
140 0.74156773 -0.01488507
141 -0.09364826 0.74156773
142 -0.02609768 -0.09364826
143 -0.02495806 -0.02609768
144 -0.06017383 -0.02495806
145 0.18511471 -0.06017383
146 -0.12886402 0.18511471
147 0.14989894 -0.12886402
148 -0.02609768 0.14989894
149 -0.02495806 -0.02609768
150 0.02033070 -0.02495806
151 0.69513936 0.02033070
152 0.64985060 0.69513936
153 -0.30486064 0.64985060
154 NA -0.30486064
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.01134305 0.01266011
[2,] -0.01134305 -0.01134305
[3,] -0.01134305 -0.01134305
[4,] -0.01134305 -0.01134305
[5,] -0.03262865 -0.01134305
[6,] -0.01134305 -0.03262865
[7,] -0.01134305 -0.01134305
[8,] 0.02387272 -0.01134305
[9,] -0.02255565 0.02387272
[10,] -0.02255565 -0.02255565
[11,] -0.01134305 -0.02255565
[12,] -0.33539478 -0.01134305
[13,] -0.02255565 -0.33539478
[14,] -0.30017901 -0.02255565
[15,] -0.30017901 -0.30017901
[16,] 0.65339262 -0.30017901
[17,] -0.02255565 0.65339262
[18,] 0.02387272 -0.02255565
[19,] 0.69982099 0.02387272
[20,] -0.06784442 0.69982099
[21,] -0.31139162 -0.06784442
[22,] -0.02141604 -0.31139162
[23,] -0.03262865 -0.02141604
[24,] -0.25489025 -0.03262865
[25,] -0.33539478 -0.25489025
[26,] 0.01266011 -0.33539478
[27,] -0.29010601 0.01266011
[28,] 0.02387272 -0.29010601
[29,] -0.05663181 0.02387272
[30,] -0.01134305 -0.05663181
[31,] -0.02255565 -0.01134305
[32,] -0.06784442 -0.02255565
[33,] 0.02387272 -0.06784442
[34,] -0.01134305 0.02387272
[35,] -0.01134305 -0.01134305
[36,] -0.34660738 -0.01134305
[37,] -0.25489025 -0.34660738
[38,] -0.02141604 -0.25489025
[39,] -0.05663181 -0.02141604
[40,] 0.69982099 -0.05663181
[41,] -0.25489025 0.69982099
[42,] -0.03262865 -0.25489025
[43,] -0.02255565 -0.03262865
[44,] -0.05663181 -0.02255565
[45,] -0.02141604 -0.05663181
[46,] -0.01134305 -0.02141604
[47,] 0.02387272 -0.01134305
[48,] -0.02141604 0.02387272
[49,] -0.01134305 -0.02141604
[50,] -0.29010601 -0.01134305
[51,] 0.65339262 -0.29010601
[52,] 0.02387272 0.65339262
[53,] 0.70989399 0.02387272
[54,] -0.01134305 0.70989399
[55,] -0.25489025 -0.01134305
[56,] -0.30017901 -0.25489025
[57,] 0.02387272 -0.30017901
[58,] 0.02387272 0.02387272
[59,] 0.68860838 0.02387272
[60,] 0.01266011 0.68860838
[61,] -0.33539478 0.01266011
[62,] -0.01134305 -0.33539478
[63,] 0.01266011 -0.01134305
[64,] -0.01134305 0.01266011
[65,] -0.01134305 -0.01134305
[66,] 0.66460522 -0.01134305
[67,] -0.02255565 0.66460522
[68,] 0.02387272 -0.02255565
[69,] -0.29010601 0.02387272
[70,] -0.01134305 -0.29010601
[71,] 0.02387272 -0.01134305
[72,] -0.25489025 0.02387272
[73,] -0.30131862 -0.25489025
[74,] 0.02387272 -0.30131862
[75,] -0.02141604 0.02387272
[76,] 0.02387272 -0.02141604
[77,] -0.30017901 0.02387272
[78,] 0.74510975 -0.30017901
[79,] -0.05663181 0.74510975
[80,] -0.01134305 -0.05663181
[81,] -0.26610286 -0.01134305
[82,] -0.01134305 -0.26610286
[83,] 0.70989399 -0.01134305
[84,] -0.02141604 0.70989399
[85,] -0.02255565 -0.02141604
[86,] 0.00911809 -0.02255565
[87,] -0.10486087 0.00911809
[88,] -0.01488507 -0.10486087
[89,] 0.02033070 -0.01488507
[90,] -0.06017383 0.02033070
[91,] 0.13868634 -0.06017383
[92,] -0.07138644 0.13868634
[93,] -0.01488507 -0.07138644
[94,] 0.14989894 -0.01488507
[95,] 0.02033070 0.14989894
[96,] 0.13868634 0.02033070
[97,] -0.01488507 0.13868634
[98,] -0.02609768 -0.01488507
[99,] 0.02033070 -0.02609768
[100,] 0.00911809 0.02033070
[101,] -0.01488507 0.00911809
[102,] -0.01488507 -0.01488507
[103,] -0.01488507 -0.01488507
[104,] -0.12886402 -0.01488507
[105,] -0.01488507 -0.12886402
[106,] -0.01488507 -0.01488507
[107,] -0.14007663 -0.01488507
[108,] -0.01488507 -0.14007663
[109,] -0.02609768 -0.01488507
[110,] -0.18536539 -0.02609768
[111,] 0.14989894 -0.18536539
[112,] -0.29364804 0.14989894
[113,] -0.14007663 -0.29364804
[114,] -0.02609768 -0.14007663
[115,] -0.01488507 -0.02609768
[116,] 0.00911809 -0.01488507
[117,] -0.02609768 0.00911809
[118,] -0.01488507 -0.02609768
[119,] 0.02033070 -0.01488507
[120,] -0.02609768 0.02033070
[121,] -0.01488507 -0.02609768
[122,] -0.14007663 -0.01488507
[123,] -0.30372103 -0.14007663
[124,] 0.02033070 -0.30372103
[125,] 0.14989894 0.02033070
[126,] -0.06017383 0.14989894
[127,] 0.02033070 -0.06017383
[128,] -0.01488507 0.02033070
[129,] 0.02033070 -0.01488507
[130,] -0.02609768 0.02033070
[131,] 0.00911809 -0.02609768
[132,] -0.30486064 0.00911809
[133,] -0.01488507 -0.30486064
[134,] -0.01488507 -0.01488507
[135,] -0.01488507 -0.01488507
[136,] -0.31493364 -0.01488507
[137,] -0.15014963 -0.31493364
[138,] 0.14989894 -0.15014963
[139,] -0.01488507 0.14989894
[140,] 0.74156773 -0.01488507
[141,] -0.09364826 0.74156773
[142,] -0.02609768 -0.09364826
[143,] -0.02495806 -0.02609768
[144,] -0.06017383 -0.02495806
[145,] 0.18511471 -0.06017383
[146,] -0.12886402 0.18511471
[147,] 0.14989894 -0.12886402
[148,] -0.02609768 0.14989894
[149,] -0.02495806 -0.02609768
[150,] 0.02033070 -0.02495806
[151,] 0.69513936 0.02033070
[152,] 0.64985060 0.69513936
[153,] -0.30486064 0.64985060
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.01134305 0.01266011
2 -0.01134305 -0.01134305
3 -0.01134305 -0.01134305
4 -0.01134305 -0.01134305
5 -0.03262865 -0.01134305
6 -0.01134305 -0.03262865
7 -0.01134305 -0.01134305
8 0.02387272 -0.01134305
9 -0.02255565 0.02387272
10 -0.02255565 -0.02255565
11 -0.01134305 -0.02255565
12 -0.33539478 -0.01134305
13 -0.02255565 -0.33539478
14 -0.30017901 -0.02255565
15 -0.30017901 -0.30017901
16 0.65339262 -0.30017901
17 -0.02255565 0.65339262
18 0.02387272 -0.02255565
19 0.69982099 0.02387272
20 -0.06784442 0.69982099
21 -0.31139162 -0.06784442
22 -0.02141604 -0.31139162
23 -0.03262865 -0.02141604
24 -0.25489025 -0.03262865
25 -0.33539478 -0.25489025
26 0.01266011 -0.33539478
27 -0.29010601 0.01266011
28 0.02387272 -0.29010601
29 -0.05663181 0.02387272
30 -0.01134305 -0.05663181
31 -0.02255565 -0.01134305
32 -0.06784442 -0.02255565
33 0.02387272 -0.06784442
34 -0.01134305 0.02387272
35 -0.01134305 -0.01134305
36 -0.34660738 -0.01134305
37 -0.25489025 -0.34660738
38 -0.02141604 -0.25489025
39 -0.05663181 -0.02141604
40 0.69982099 -0.05663181
41 -0.25489025 0.69982099
42 -0.03262865 -0.25489025
43 -0.02255565 -0.03262865
44 -0.05663181 -0.02255565
45 -0.02141604 -0.05663181
46 -0.01134305 -0.02141604
47 0.02387272 -0.01134305
48 -0.02141604 0.02387272
49 -0.01134305 -0.02141604
50 -0.29010601 -0.01134305
51 0.65339262 -0.29010601
52 0.02387272 0.65339262
53 0.70989399 0.02387272
54 -0.01134305 0.70989399
55 -0.25489025 -0.01134305
56 -0.30017901 -0.25489025
57 0.02387272 -0.30017901
58 0.02387272 0.02387272
59 0.68860838 0.02387272
60 0.01266011 0.68860838
61 -0.33539478 0.01266011
62 -0.01134305 -0.33539478
63 0.01266011 -0.01134305
64 -0.01134305 0.01266011
65 -0.01134305 -0.01134305
66 0.66460522 -0.01134305
67 -0.02255565 0.66460522
68 0.02387272 -0.02255565
69 -0.29010601 0.02387272
70 -0.01134305 -0.29010601
71 0.02387272 -0.01134305
72 -0.25489025 0.02387272
73 -0.30131862 -0.25489025
74 0.02387272 -0.30131862
75 -0.02141604 0.02387272
76 0.02387272 -0.02141604
77 -0.30017901 0.02387272
78 0.74510975 -0.30017901
79 -0.05663181 0.74510975
80 -0.01134305 -0.05663181
81 -0.26610286 -0.01134305
82 -0.01134305 -0.26610286
83 0.70989399 -0.01134305
84 -0.02141604 0.70989399
85 -0.02255565 -0.02141604
86 0.00911809 -0.02255565
87 -0.10486087 0.00911809
88 -0.01488507 -0.10486087
89 0.02033070 -0.01488507
90 -0.06017383 0.02033070
91 0.13868634 -0.06017383
92 -0.07138644 0.13868634
93 -0.01488507 -0.07138644
94 0.14989894 -0.01488507
95 0.02033070 0.14989894
96 0.13868634 0.02033070
97 -0.01488507 0.13868634
98 -0.02609768 -0.01488507
99 0.02033070 -0.02609768
100 0.00911809 0.02033070
101 -0.01488507 0.00911809
102 -0.01488507 -0.01488507
103 -0.01488507 -0.01488507
104 -0.12886402 -0.01488507
105 -0.01488507 -0.12886402
106 -0.01488507 -0.01488507
107 -0.14007663 -0.01488507
108 -0.01488507 -0.14007663
109 -0.02609768 -0.01488507
110 -0.18536539 -0.02609768
111 0.14989894 -0.18536539
112 -0.29364804 0.14989894
113 -0.14007663 -0.29364804
114 -0.02609768 -0.14007663
115 -0.01488507 -0.02609768
116 0.00911809 -0.01488507
117 -0.02609768 0.00911809
118 -0.01488507 -0.02609768
119 0.02033070 -0.01488507
120 -0.02609768 0.02033070
121 -0.01488507 -0.02609768
122 -0.14007663 -0.01488507
123 -0.30372103 -0.14007663
124 0.02033070 -0.30372103
125 0.14989894 0.02033070
126 -0.06017383 0.14989894
127 0.02033070 -0.06017383
128 -0.01488507 0.02033070
129 0.02033070 -0.01488507
130 -0.02609768 0.02033070
131 0.00911809 -0.02609768
132 -0.30486064 0.00911809
133 -0.01488507 -0.30486064
134 -0.01488507 -0.01488507
135 -0.01488507 -0.01488507
136 -0.31493364 -0.01488507
137 -0.15014963 -0.31493364
138 0.14989894 -0.15014963
139 -0.01488507 0.14989894
140 0.74156773 -0.01488507
141 -0.09364826 0.74156773
142 -0.02609768 -0.09364826
143 -0.02495806 -0.02609768
144 -0.06017383 -0.02495806
145 0.18511471 -0.06017383
146 -0.12886402 0.18511471
147 0.14989894 -0.12886402
148 -0.02609768 0.14989894
149 -0.02495806 -0.02609768
150 0.02033070 -0.02495806
151 0.69513936 0.02033070
152 0.64985060 0.69513936
153 -0.30486064 0.64985060
> 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/757941355681615.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/8fn5p1355681615.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/9gvfv1355681615.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/105lze1355681615.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/11hpgu1355681615.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/12hktm1355681615.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/13ht1v1355681615.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/14syxl1355681615.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/15hp9b1355681615.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/16sufa1355681615.tab")
+ }
>
> try(system("convert tmp/1m8vc1355681615.ps tmp/1m8vc1355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/28kf71355681615.ps tmp/28kf71355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/3v3u71355681615.ps tmp/3v3u71355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/4wjn81355681615.ps tmp/4wjn81355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/5wdd81355681615.ps tmp/5wdd81355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/6a3f51355681615.ps tmp/6a3f51355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/757941355681615.ps tmp/757941355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/8fn5p1355681615.ps tmp/8fn5p1355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/9gvfv1355681615.ps tmp/9gvfv1355681615.png",intern=TRUE))
character(0)
> try(system("convert tmp/105lze1355681615.ps tmp/105lze1355681615.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
7.217 0.767 7.972