R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
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(1.4
+ ,8.2
+ ,1.7
+ ,1
+ ,1.2
+ ,1.4
+ ,1.2
+ ,8.0
+ ,1.4
+ ,1.7
+ ,1
+ ,1.2
+ ,1.0
+ ,7.5
+ ,1.2
+ ,1.4
+ ,1.7
+ ,1
+ ,1.7
+ ,6.8
+ ,1.0
+ ,1.2
+ ,1.4
+ ,1.7
+ ,2.4
+ ,6.5
+ ,1.7
+ ,1.0
+ ,1.2
+ ,1.4
+ ,2.0
+ ,6.6
+ ,2.4
+ ,1.7
+ ,1.0
+ ,1.2
+ ,2.1
+ ,7.6
+ ,2.0
+ ,2.4
+ ,1.7
+ ,1.0
+ ,2.0
+ ,8.0
+ ,2.1
+ ,2.0
+ ,2.4
+ ,1.7
+ ,1.8
+ ,8.1
+ ,2.0
+ ,2.1
+ ,2.0
+ ,2.4
+ ,2.7
+ ,7.7
+ ,1.8
+ ,2.0
+ ,2.1
+ ,2.0
+ ,2.3
+ ,7.5
+ ,2.7
+ ,1.8
+ ,2.0
+ ,2.1
+ ,1.9
+ ,7.6
+ ,2.3
+ ,2.7
+ ,1.8
+ ,2.0
+ ,2.0
+ ,7.8
+ ,1.9
+ ,2.3
+ ,2.7
+ ,1.8
+ ,2.3
+ ,7.8
+ ,2.0
+ ,1.9
+ ,2.3
+ ,2.7
+ ,2.8
+ ,7.8
+ ,2.3
+ ,2.0
+ ,1.9
+ ,2.3
+ ,2.4
+ ,7.5
+ ,2.8
+ ,2.3
+ ,2.0
+ ,1.9
+ ,2.3
+ ,7.5
+ ,2.4
+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,6.2
+ ,3.2
+ ,4.8
+ ,5.5
+ ,5.4
+ ,2.1
+ ,7.1
+ ,2.7
+ ,3.2
+ ,4.8
+ ,5.5
+ ,1.9
+ ,7.7
+ ,2.1
+ ,2.7
+ ,3.2
+ ,4.8
+ ,0.6
+ ,7.9
+ ,1.9
+ ,2.1
+ ,2.7
+ ,3.2
+ ,0.7
+ ,7.7
+ ,0.6
+ ,1.9
+ ,2.1
+ ,2.7)
+ ,dim=c(6
+ ,64)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:64))
> y <- array(NA,dim=c(6,64),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:64))
> 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 = 'Include Monthly 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
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 1.4 8.2 1.7 1.0 1.2 1.4 1 0 0 0 0 0 0 0 0 0 0 1
2 1.2 8.0 1.4 1.7 1.0 1.2 0 1 0 0 0 0 0 0 0 0 0 2
3 1.0 7.5 1.2 1.4 1.7 1.0 0 0 1 0 0 0 0 0 0 0 0 3
4 1.7 6.8 1.0 1.2 1.4 1.7 0 0 0 1 0 0 0 0 0 0 0 4
5 2.4 6.5 1.7 1.0 1.2 1.4 0 0 0 0 1 0 0 0 0 0 0 5
6 2.0 6.6 2.4 1.7 1.0 1.2 0 0 0 0 0 1 0 0 0 0 0 6
7 2.1 7.6 2.0 2.4 1.7 1.0 0 0 0 0 0 0 1 0 0 0 0 7
8 2.0 8.0 2.1 2.0 2.4 1.7 0 0 0 0 0 0 0 1 0 0 0 8
9 1.8 8.1 2.0 2.1 2.0 2.4 0 0 0 0 0 0 0 0 1 0 0 9
10 2.7 7.7 1.8 2.0 2.1 2.0 0 0 0 0 0 0 0 0 0 1 0 10
11 2.3 7.5 2.7 1.8 2.0 2.1 0 0 0 0 0 0 0 0 0 0 1 11
12 1.9 7.6 2.3 2.7 1.8 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6 3.5 0 0 0 0 1 0 0 0 0 0 0 53
54 5.8 6.1 5.1 4.1 4.4 3.6 0 0 0 0 0 1 0 0 0 0 0 54
55 5.9 7.2 5.8 5.1 4.1 4.4 0 0 0 0 0 0 1 0 0 0 0 55
56 5.4 7.3 5.9 5.8 5.1 4.1 0 0 0 0 0 0 0 1 0 0 0 56
57 5.5 6.9 5.4 5.9 5.8 5.1 0 0 0 0 0 0 0 0 1 0 0 57
58 4.8 6.1 5.5 5.4 5.9 5.8 0 0 0 0 0 0 0 0 0 1 0 58
59 3.2 5.8 4.8 5.5 5.4 5.9 0 0 0 0 0 0 0 0 0 0 1 59
60 2.7 6.2 3.2 4.8 5.5 5.4 0 0 0 0 0 0 0 0 0 0 0 60
61 2.1 7.1 2.7 3.2 4.8 5.5 1 0 0 0 0 0 0 0 0 0 0 61
62 1.9 7.7 2.1 2.7 3.2 4.8 0 1 0 0 0 0 0 0 0 0 0 62
63 0.6 7.9 1.9 2.1 2.7 3.2 0 0 1 0 0 0 0 0 0 0 0 63
64 0.7 7.7 0.6 1.9 2.1 2.7 0 0 0 1 0 0 0 0 0 0 0 64
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
1.1168201 -0.1023360 1.0922443 -0.1802210 0.2143989 -0.2723820
M1 M2 M3 M4 M5 M6
-0.1442300 0.0728580 -0.1897187 0.0739144 0.1677173 -0.0476956
M7 M8 M9 M10 M11 t
-0.0092929 -0.1689094 -0.0269912 -0.0081754 -0.1747252 0.0002828
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.96749 -0.28296 -0.05382 0.31636 0.93739
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.1168201 1.0781619 1.036 0.3057
X -0.1023360 0.1365553 -0.749 0.4574
Y1 1.0922443 0.1407973 7.758 6.75e-10 ***
Y2 -0.1802210 0.2182947 -0.826 0.4133
Y3 0.2143989 0.2233373 0.960 0.3421
Y4 -0.2723820 0.1554360 -1.752 0.0864 .
M1 -0.1442300 0.3127884 -0.461 0.6469
M2 0.0728580 0.3111597 0.234 0.8159
M3 -0.1897187 0.3120823 -0.608 0.5462
M4 0.0739144 0.3050044 0.242 0.8096
M5 0.1677173 0.3206938 0.523 0.6035
M6 -0.0476956 0.3265475 -0.146 0.8845
M7 -0.0092929 0.3204276 -0.029 0.9770
M8 -0.1689094 0.3210119 -0.526 0.6013
M9 -0.0269912 0.3175481 -0.085 0.9326
M10 -0.0081754 0.3189871 -0.026 0.9797
M11 -0.1747252 0.3198050 -0.546 0.5875
t 0.0002828 0.0053699 0.053 0.9582
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5005 on 46 degrees of freedom
Multiple R-squared: 0.8697, Adjusted R-squared: 0.8215
F-statistic: 18.05 on 17 and 46 DF, p-value: 6.618e-15
> 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.410667671 0.821335342 0.5893323
[2,] 0.610673705 0.778652591 0.3893263
[3,] 0.529099174 0.941801651 0.4709008
[4,] 0.436768862 0.873537724 0.5632311
[5,] 0.321971615 0.643943229 0.6780284
[6,] 0.215106034 0.430212068 0.7848940
[7,] 0.188093089 0.376186178 0.8119069
[8,] 0.140835863 0.281671727 0.8591641
[9,] 0.107396247 0.214792495 0.8926038
[10,] 0.090093879 0.180187758 0.9099061
[11,] 0.082582551 0.165165102 0.9174174
[12,] 0.069020012 0.138040023 0.9309800
[13,] 0.053440412 0.106880824 0.9465596
[14,] 0.031851367 0.063702735 0.9681486
[15,] 0.037481697 0.074963395 0.9625183
[16,] 0.028177642 0.056355285 0.9718224
[17,] 0.015420994 0.030841988 0.9845790
[18,] 0.007523289 0.015046579 0.9924767
[19,] 0.004130944 0.008261888 0.9958691
[20,] 0.003165766 0.006331532 0.9968342
[21,] 0.002189888 0.004379776 0.9978101
[22,] 0.010328978 0.020657956 0.9896710
[23,] 0.043306254 0.086612507 0.9566937
> postscript(file="/var/www/html/rcomp/tmp/11wrs1258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2q5q41258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3iz931258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4o1ve1258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5f01l1258718880.ps",horizontal=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 = 64
Frequency = 1
1 2 3 4 5 6
-0.286256059 -0.281862702 -0.310909878 0.490930776 0.226694209 -0.597955165
7 8 9 10 11 12
-0.075807857 -0.116264442 -0.044558338 0.865442692 -0.359143580 -0.309179802
13 14 15 16 17 18
0.072608492 0.304828250 0.734277642 -0.582787648 -0.286946589 0.298900246
19 20 21 22 23 24
0.068179902 0.412088999 0.048674976 -0.724417495 0.390787229 0.515881721
25 26 27 28 29 30
0.350953300 -0.005418930 -0.423086303 0.504535398 0.034718576 -0.129274153
31 32 33 34 35 36
-0.194365293 -0.044501274 -0.366470271 -0.206500808 0.410561881 0.040591322
37 38 39 40 41 42
-0.326459111 -0.117939747 0.002848817 -0.119813653 -0.864759258 -0.117203268
43 44 45 46 47 48
-0.215298436 -0.058998963 -0.048633745 0.485563046 0.525284994 -0.109534449
49 50 51 52 53 54
0.255776621 -0.194621300 0.937389777 -0.544283449 0.890293062 0.545532341
55 56 57 58 59 60
0.417291683 -0.192324319 0.410987379 -0.420087435 -0.967490524 -0.137758792
61 62 63 64
-0.066623243 0.295014430 -0.940520056 0.251418576
> postscript(file="/var/www/html/rcomp/tmp/6lsns1258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 64
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.286256059 NA
1 -0.281862702 -0.286256059
2 -0.310909878 -0.281862702
3 0.490930776 -0.310909878
4 0.226694209 0.490930776
5 -0.597955165 0.226694209
6 -0.075807857 -0.597955165
7 -0.116264442 -0.075807857
8 -0.044558338 -0.116264442
9 0.865442692 -0.044558338
10 -0.359143580 0.865442692
11 -0.309179802 -0.359143580
12 0.072608492 -0.309179802
13 0.304828250 0.072608492
14 0.734277642 0.304828250
15 -0.582787648 0.734277642
16 -0.286946589 -0.582787648
17 0.298900246 -0.286946589
18 0.068179902 0.298900246
19 0.412088999 0.068179902
20 0.048674976 0.412088999
21 -0.724417495 0.048674976
22 0.390787229 -0.724417495
23 0.515881721 0.390787229
24 0.350953300 0.515881721
25 -0.005418930 0.350953300
26 -0.423086303 -0.005418930
27 0.504535398 -0.423086303
28 0.034718576 0.504535398
29 -0.129274153 0.034718576
30 -0.194365293 -0.129274153
31 -0.044501274 -0.194365293
32 -0.366470271 -0.044501274
33 -0.206500808 -0.366470271
34 0.410561881 -0.206500808
35 0.040591322 0.410561881
36 -0.326459111 0.040591322
37 -0.117939747 -0.326459111
38 0.002848817 -0.117939747
39 -0.119813653 0.002848817
40 -0.864759258 -0.119813653
41 -0.117203268 -0.864759258
42 -0.215298436 -0.117203268
43 -0.058998963 -0.215298436
44 -0.048633745 -0.058998963
45 0.485563046 -0.048633745
46 0.525284994 0.485563046
47 -0.109534449 0.525284994
48 0.255776621 -0.109534449
49 -0.194621300 0.255776621
50 0.937389777 -0.194621300
51 -0.544283449 0.937389777
52 0.890293062 -0.544283449
53 0.545532341 0.890293062
54 0.417291683 0.545532341
55 -0.192324319 0.417291683
56 0.410987379 -0.192324319
57 -0.420087435 0.410987379
58 -0.967490524 -0.420087435
59 -0.137758792 -0.967490524
60 -0.066623243 -0.137758792
61 0.295014430 -0.066623243
62 -0.940520056 0.295014430
63 0.251418576 -0.940520056
64 NA 0.251418576
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.281862702 -0.286256059
[2,] -0.310909878 -0.281862702
[3,] 0.490930776 -0.310909878
[4,] 0.226694209 0.490930776
[5,] -0.597955165 0.226694209
[6,] -0.075807857 -0.597955165
[7,] -0.116264442 -0.075807857
[8,] -0.044558338 -0.116264442
[9,] 0.865442692 -0.044558338
[10,] -0.359143580 0.865442692
[11,] -0.309179802 -0.359143580
[12,] 0.072608492 -0.309179802
[13,] 0.304828250 0.072608492
[14,] 0.734277642 0.304828250
[15,] -0.582787648 0.734277642
[16,] -0.286946589 -0.582787648
[17,] 0.298900246 -0.286946589
[18,] 0.068179902 0.298900246
[19,] 0.412088999 0.068179902
[20,] 0.048674976 0.412088999
[21,] -0.724417495 0.048674976
[22,] 0.390787229 -0.724417495
[23,] 0.515881721 0.390787229
[24,] 0.350953300 0.515881721
[25,] -0.005418930 0.350953300
[26,] -0.423086303 -0.005418930
[27,] 0.504535398 -0.423086303
[28,] 0.034718576 0.504535398
[29,] -0.129274153 0.034718576
[30,] -0.194365293 -0.129274153
[31,] -0.044501274 -0.194365293
[32,] -0.366470271 -0.044501274
[33,] -0.206500808 -0.366470271
[34,] 0.410561881 -0.206500808
[35,] 0.040591322 0.410561881
[36,] -0.326459111 0.040591322
[37,] -0.117939747 -0.326459111
[38,] 0.002848817 -0.117939747
[39,] -0.119813653 0.002848817
[40,] -0.864759258 -0.119813653
[41,] -0.117203268 -0.864759258
[42,] -0.215298436 -0.117203268
[43,] -0.058998963 -0.215298436
[44,] -0.048633745 -0.058998963
[45,] 0.485563046 -0.048633745
[46,] 0.525284994 0.485563046
[47,] -0.109534449 0.525284994
[48,] 0.255776621 -0.109534449
[49,] -0.194621300 0.255776621
[50,] 0.937389777 -0.194621300
[51,] -0.544283449 0.937389777
[52,] 0.890293062 -0.544283449
[53,] 0.545532341 0.890293062
[54,] 0.417291683 0.545532341
[55,] -0.192324319 0.417291683
[56,] 0.410987379 -0.192324319
[57,] -0.420087435 0.410987379
[58,] -0.967490524 -0.420087435
[59,] -0.137758792 -0.967490524
[60,] -0.066623243 -0.137758792
[61,] 0.295014430 -0.066623243
[62,] -0.940520056 0.295014430
[63,] 0.251418576 -0.940520056
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.281862702 -0.286256059
2 -0.310909878 -0.281862702
3 0.490930776 -0.310909878
4 0.226694209 0.490930776
5 -0.597955165 0.226694209
6 -0.075807857 -0.597955165
7 -0.116264442 -0.075807857
8 -0.044558338 -0.116264442
9 0.865442692 -0.044558338
10 -0.359143580 0.865442692
11 -0.309179802 -0.359143580
12 0.072608492 -0.309179802
13 0.304828250 0.072608492
14 0.734277642 0.304828250
15 -0.582787648 0.734277642
16 -0.286946589 -0.582787648
17 0.298900246 -0.286946589
18 0.068179902 0.298900246
19 0.412088999 0.068179902
20 0.048674976 0.412088999
21 -0.724417495 0.048674976
22 0.390787229 -0.724417495
23 0.515881721 0.390787229
24 0.350953300 0.515881721
25 -0.005418930 0.350953300
26 -0.423086303 -0.005418930
27 0.504535398 -0.423086303
28 0.034718576 0.504535398
29 -0.129274153 0.034718576
30 -0.194365293 -0.129274153
31 -0.044501274 -0.194365293
32 -0.366470271 -0.044501274
33 -0.206500808 -0.366470271
34 0.410561881 -0.206500808
35 0.040591322 0.410561881
36 -0.326459111 0.040591322
37 -0.117939747 -0.326459111
38 0.002848817 -0.117939747
39 -0.119813653 0.002848817
40 -0.864759258 -0.119813653
41 -0.117203268 -0.864759258
42 -0.215298436 -0.117203268
43 -0.058998963 -0.215298436
44 -0.048633745 -0.058998963
45 0.485563046 -0.048633745
46 0.525284994 0.485563046
47 -0.109534449 0.525284994
48 0.255776621 -0.109534449
49 -0.194621300 0.255776621
50 0.937389777 -0.194621300
51 -0.544283449 0.937389777
52 0.890293062 -0.544283449
53 0.545532341 0.890293062
54 0.417291683 0.545532341
55 -0.192324319 0.417291683
56 0.410987379 -0.192324319
57 -0.420087435 0.410987379
58 -0.967490524 -0.420087435
59 -0.137758792 -0.967490524
60 -0.066623243 -0.137758792
61 0.295014430 -0.066623243
62 -0.940520056 0.295014430
63 0.251418576 -0.940520056
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7wxiw1258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/841ny1258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9vuh31258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10s4hd1258718880.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/111pai1258718880.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/129ob31258718880.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/13oy4u1258718880.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/147zne1258718880.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/15akii1258718880.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/16hm9x1258718880.tab")
+ }
>
> system("convert tmp/11wrs1258718880.ps tmp/11wrs1258718880.png")
> system("convert tmp/2q5q41258718880.ps tmp/2q5q41258718880.png")
> system("convert tmp/3iz931258718880.ps tmp/3iz931258718880.png")
> system("convert tmp/4o1ve1258718880.ps tmp/4o1ve1258718880.png")
> system("convert tmp/5f01l1258718880.ps tmp/5f01l1258718880.png")
> system("convert tmp/6lsns1258718880.ps tmp/6lsns1258718880.png")
> system("convert tmp/7wxiw1258718880.ps tmp/7wxiw1258718880.png")
> system("convert tmp/841ny1258718880.ps tmp/841ny1258718880.png")
> system("convert tmp/9vuh31258718880.ps tmp/9vuh31258718880.png")
> system("convert tmp/10s4hd1258718880.ps tmp/10s4hd1258718880.png")
>
>
> proc.time()
user system elapsed
2.460 1.588 3.208