R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(189917,0,184128,0,175335,0,179566,0,181140,0,177876,0,175041,0,169292,0,166070,0,166972,0,206348,0,215706,0,202108,0,195411,0,193111,0,195198,0,198770,0,194163,0,190420,0,189733,0,186029,0,191531,0,232571,0,243477,0,227247,0,217859,0,208679,0,213188,0,216234,0,213587,0,209465,0,204045,0,200237,0,203666,0,241476,0,260307,0,243324,0,244460,0,233575,0,237217,0,235243,0,230354,0,227184,0,221678,0,217142,0,219452,0,256446,0,265845,0,248624,0,241114,0,229245,0,231805,0,219277,1,219313,1,212610,1,214771,1,211142,1,211457,1,240048,1,240636,1,230580,1),dim=c(2,61),dimnames=list(c('y','d'),1:61))
> y <- array(NA,dim=c(2,61),dimnames=list(c('y','d'),1:61))
> 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 d M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 189917 0 1 0 0 0 0 0 0 0 0 0 0 1
2 184128 0 0 1 0 0 0 0 0 0 0 0 0 2
3 175335 0 0 0 1 0 0 0 0 0 0 0 0 3
4 179566 0 0 0 0 1 0 0 0 0 0 0 0 4
5 181140 0 0 0 0 0 1 0 0 0 0 0 0 5
6 177876 0 0 0 0 0 0 1 0 0 0 0 0 6
7 175041 0 0 0 0 0 0 0 1 0 0 0 0 7
8 169292 0 0 0 0 0 0 0 0 1 0 0 0 8
9 166070 0 0 0 0 0 0 0 0 0 1 0 0 9
10 166972 0 0 0 0 0 0 0 0 0 0 1 0 10
11 206348 0 0 0 0 0 0 0 0 0 0 0 1 11
12 215706 0 0 0 0 0 0 0 0 0 0 0 0 12
13 202108 0 1 0 0 0 0 0 0 0 0 0 0 13
14 195411 0 0 1 0 0 0 0 0 0 0 0 0 14
15 193111 0 0 0 1 0 0 0 0 0 0 0 0 15
16 195198 0 0 0 0 1 0 0 0 0 0 0 0 16
17 198770 0 0 0 0 0 1 0 0 0 0 0 0 17
18 194163 0 0 0 0 0 0 1 0 0 0 0 0 18
19 190420 0 0 0 0 0 0 0 1 0 0 0 0 19
20 189733 0 0 0 0 0 0 0 0 1 0 0 0 20
21 186029 0 0 0 0 0 0 0 0 0 1 0 0 21
22 191531 0 0 0 0 0 0 0 0 0 0 1 0 22
23 232571 0 0 0 0 0 0 0 0 0 0 0 1 23
24 243477 0 0 0 0 0 0 0 0 0 0 0 0 24
25 227247 0 1 0 0 0 0 0 0 0 0 0 0 25
26 217859 0 0 1 0 0 0 0 0 0 0 0 0 26
27 208679 0 0 0 1 0 0 0 0 0 0 0 0 27
28 213188 0 0 0 0 1 0 0 0 0 0 0 0 28
29 216234 0 0 0 0 0 1 0 0 0 0 0 0 29
30 213587 0 0 0 0 0 0 1 0 0 0 0 0 30
31 209465 0 0 0 0 0 0 0 1 0 0 0 0 31
32 204045 0 0 0 0 0 0 0 0 1 0 0 0 32
33 200237 0 0 0 0 0 0 0 0 0 1 0 0 33
34 203666 0 0 0 0 0 0 0 0 0 0 1 0 34
35 241476 0 0 0 0 0 0 0 0 0 0 0 1 35
36 260307 0 0 0 0 0 0 0 0 0 0 0 0 36
37 243324 0 1 0 0 0 0 0 0 0 0 0 0 37
38 244460 0 0 1 0 0 0 0 0 0 0 0 0 38
39 233575 0 0 0 1 0 0 0 0 0 0 0 0 39
40 237217 0 0 0 0 1 0 0 0 0 0 0 0 40
41 235243 0 0 0 0 0 1 0 0 0 0 0 0 41
42 230354 0 0 0 0 0 0 1 0 0 0 0 0 42
43 227184 0 0 0 0 0 0 0 1 0 0 0 0 43
44 221678 0 0 0 0 0 0 0 0 1 0 0 0 44
45 217142 0 0 0 0 0 0 0 0 0 1 0 0 45
46 219452 0 0 0 0 0 0 0 0 0 0 1 0 46
47 256446 0 0 0 0 0 0 0 0 0 0 0 1 47
48 265845 0 0 0 0 0 0 0 0 0 0 0 0 48
49 248624 0 1 0 0 0 0 0 0 0 0 0 0 49
50 241114 0 0 1 0 0 0 0 0 0 0 0 0 50
51 229245 0 0 0 1 0 0 0 0 0 0 0 0 51
52 231805 0 0 0 0 1 0 0 0 0 0 0 0 52
53 219277 1 0 0 0 0 1 0 0 0 0 0 0 53
54 219313 1 0 0 0 0 0 1 0 0 0 0 0 54
55 212610 1 0 0 0 0 0 0 1 0 0 0 0 55
56 214771 1 0 0 0 0 0 0 0 1 0 0 0 56
57 211142 1 0 0 0 0 0 0 0 0 1 0 0 57
58 211457 1 0 0 0 0 0 0 0 0 0 1 0 58
59 240048 1 0 0 0 0 0 0 0 0 0 0 1 59
60 240636 1 0 0 0 0 0 0 0 0 0 0 0 60
61 230580 1 1 0 0 0 0 0 0 0 0 0 0 61
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) d M1 M2 M3 M4
202652 -30249 -15820 -21152 -31107 -29051
M5 M6 M7 M8 M9 M10
-25613 -30037 -35501 -39891 -45021 -43879
M11 t
-8467 1350
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-12753.71 -2648.19 -23.35 1793.20 11668.44
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 202652.43 3029.73 66.888 < 2e-16 ***
d -30248.50 2671.39 -11.323 5.00e-15 ***
M1 -15820.34 3457.26 -4.576 3.47e-05 ***
M2 -21151.87 3634.10 -5.820 5.03e-07 ***
M3 -31107.03 3631.50 -8.566 3.69e-11 ***
M4 -29051.00 3629.67 -8.004 2.51e-10 ***
M5 -25613.06 3622.57 -7.070 6.39e-09 ***
M6 -30037.02 3617.52 -8.303 9.02e-11 ***
M7 -35501.39 3613.25 -9.825 5.64e-13 ***
M8 -39891.35 3609.74 -11.051 1.15e-14 ***
M9 -45020.91 3607.02 -12.481 < 2e-16 ***
M10 -43879.07 3605.07 -12.171 3.90e-16 ***
M11 -8466.64 3603.90 -2.349 0.0231 *
t 1349.76 53.02 25.456 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5698 on 47 degrees of freedom
Multiple R-squared: 0.9577, Adjusted R-squared: 0.946
F-statistic: 81.86 on 13 and 47 DF, p-value: < 2.2e-16
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.074162839 0.148325679 0.9258372
[2,] 0.027045668 0.054091335 0.9729543
[3,] 0.008779661 0.017559322 0.9912203
[4,] 0.009859802 0.019719605 0.9901402
[5,] 0.006937005 0.013874010 0.9930630
[6,] 0.017068976 0.034137952 0.9829310
[7,] 0.031076327 0.062152654 0.9689237
[8,] 0.049693808 0.099387615 0.9503062
[9,] 0.029749473 0.059498947 0.9702505
[10,] 0.017483719 0.034967439 0.9825163
[11,] 0.012525071 0.025050142 0.9874749
[12,] 0.007351955 0.014703909 0.9926480
[13,] 0.004320806 0.008641612 0.9956792
[14,] 0.002596482 0.005192965 0.9974035
[15,] 0.001611217 0.003222434 0.9983888
[16,] 0.002356305 0.004712609 0.9976437
[17,] 0.006514477 0.013028955 0.9934855
[18,] 0.032068780 0.064137560 0.9679312
[19,] 0.174013728 0.348027456 0.8259863
[20,] 0.140248566 0.280497132 0.8597514
[21,] 0.147503194 0.295006388 0.8524968
[22,] 0.202188918 0.404377836 0.7978111
[23,] 0.152797846 0.305595692 0.8472022
[24,] 0.106475305 0.212950610 0.8935247
[25,] 0.066099445 0.132198890 0.9339006
[26,] 0.038629656 0.077259312 0.9613703
[27,] 0.018595206 0.037190411 0.9814048
[28,] 0.017866120 0.035732239 0.9821339
> postscript(file="/var/www/html/rcomp/tmp/1a2c91229081663.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/20x7c1229081663.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/30wbl1229081663.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/4izdv1229081663.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/5un641229081663.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 = 61
Frequency = 1
1 2 3 4 5
1.735138e+03 -7.208920e+01 -2.596892e+02 5.655108e+02 -2.648190e+03
6 7 8 9 10
-2.837990e+03 -1.558390e+03 -4.267190e+03 -3.709390e+03 -5.298990e+03
11 12 13 14 15
-2.685190e+03 -3.143590e+03 -2.271017e+03 -4.986245e+03 1.319155e+03
16 17 18 19 20
3.554023e-01 -1.215345e+03 -2.748145e+03 -2.376545e+03 -2.334529e+01
21 22 23 24 25
5.245471e+01 3.062855e+03 7.340655e+03 8.430255e+03 6.670827e+03
26 27 28 29 30
1.264600e+03 6.900000e+02 1.793200e+03 5.149931e+01 4.786993e+02
31 32 33 34 35
4.712993e+02 -1.908501e+03 -1.936701e+03 -9.993007e+02 4.849931e+01
36 37 38 39 40
9.063099e+03 6.550672e+03 1.166844e+04 9.388845e+03 9.625045e+03
41 42 43 44 45
2.863344e+03 1.048544e+03 1.993144e+03 -4.726561e+02 -1.228856e+03
46 47 48 49 50
-1.410456e+03 -1.178656e+03 -1.596056e+03 -4.346484e+03 -7.874711e+03
51 52 53 54 55
-1.113831e+04 -1.198411e+04 9.486920e+02 4.058892e+03 1.470492e+03
56 57 58 59 60
6.671692e+03 6.822492e+03 4.645892e+03 -3.525308e+03 -1.275371e+04
61
-8.339136e+03
> postscript(file="/var/www/html/rcomp/tmp/63ags1229081664.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 1.735138e+03 NA
1 -7.208920e+01 1.735138e+03
2 -2.596892e+02 -7.208920e+01
3 5.655108e+02 -2.596892e+02
4 -2.648190e+03 5.655108e+02
5 -2.837990e+03 -2.648190e+03
6 -1.558390e+03 -2.837990e+03
7 -4.267190e+03 -1.558390e+03
8 -3.709390e+03 -4.267190e+03
9 -5.298990e+03 -3.709390e+03
10 -2.685190e+03 -5.298990e+03
11 -3.143590e+03 -2.685190e+03
12 -2.271017e+03 -3.143590e+03
13 -4.986245e+03 -2.271017e+03
14 1.319155e+03 -4.986245e+03
15 3.554023e-01 1.319155e+03
16 -1.215345e+03 3.554023e-01
17 -2.748145e+03 -1.215345e+03
18 -2.376545e+03 -2.748145e+03
19 -2.334529e+01 -2.376545e+03
20 5.245471e+01 -2.334529e+01
21 3.062855e+03 5.245471e+01
22 7.340655e+03 3.062855e+03
23 8.430255e+03 7.340655e+03
24 6.670827e+03 8.430255e+03
25 1.264600e+03 6.670827e+03
26 6.900000e+02 1.264600e+03
27 1.793200e+03 6.900000e+02
28 5.149931e+01 1.793200e+03
29 4.786993e+02 5.149931e+01
30 4.712993e+02 4.786993e+02
31 -1.908501e+03 4.712993e+02
32 -1.936701e+03 -1.908501e+03
33 -9.993007e+02 -1.936701e+03
34 4.849931e+01 -9.993007e+02
35 9.063099e+03 4.849931e+01
36 6.550672e+03 9.063099e+03
37 1.166844e+04 6.550672e+03
38 9.388845e+03 1.166844e+04
39 9.625045e+03 9.388845e+03
40 2.863344e+03 9.625045e+03
41 1.048544e+03 2.863344e+03
42 1.993144e+03 1.048544e+03
43 -4.726561e+02 1.993144e+03
44 -1.228856e+03 -4.726561e+02
45 -1.410456e+03 -1.228856e+03
46 -1.178656e+03 -1.410456e+03
47 -1.596056e+03 -1.178656e+03
48 -4.346484e+03 -1.596056e+03
49 -7.874711e+03 -4.346484e+03
50 -1.113831e+04 -7.874711e+03
51 -1.198411e+04 -1.113831e+04
52 9.486920e+02 -1.198411e+04
53 4.058892e+03 9.486920e+02
54 1.470492e+03 4.058892e+03
55 6.671692e+03 1.470492e+03
56 6.822492e+03 6.671692e+03
57 4.645892e+03 6.822492e+03
58 -3.525308e+03 4.645892e+03
59 -1.275371e+04 -3.525308e+03
60 -8.339136e+03 -1.275371e+04
61 NA -8.339136e+03
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -7.208920e+01 1.735138e+03
[2,] -2.596892e+02 -7.208920e+01
[3,] 5.655108e+02 -2.596892e+02
[4,] -2.648190e+03 5.655108e+02
[5,] -2.837990e+03 -2.648190e+03
[6,] -1.558390e+03 -2.837990e+03
[7,] -4.267190e+03 -1.558390e+03
[8,] -3.709390e+03 -4.267190e+03
[9,] -5.298990e+03 -3.709390e+03
[10,] -2.685190e+03 -5.298990e+03
[11,] -3.143590e+03 -2.685190e+03
[12,] -2.271017e+03 -3.143590e+03
[13,] -4.986245e+03 -2.271017e+03
[14,] 1.319155e+03 -4.986245e+03
[15,] 3.554023e-01 1.319155e+03
[16,] -1.215345e+03 3.554023e-01
[17,] -2.748145e+03 -1.215345e+03
[18,] -2.376545e+03 -2.748145e+03
[19,] -2.334529e+01 -2.376545e+03
[20,] 5.245471e+01 -2.334529e+01
[21,] 3.062855e+03 5.245471e+01
[22,] 7.340655e+03 3.062855e+03
[23,] 8.430255e+03 7.340655e+03
[24,] 6.670827e+03 8.430255e+03
[25,] 1.264600e+03 6.670827e+03
[26,] 6.900000e+02 1.264600e+03
[27,] 1.793200e+03 6.900000e+02
[28,] 5.149931e+01 1.793200e+03
[29,] 4.786993e+02 5.149931e+01
[30,] 4.712993e+02 4.786993e+02
[31,] -1.908501e+03 4.712993e+02
[32,] -1.936701e+03 -1.908501e+03
[33,] -9.993007e+02 -1.936701e+03
[34,] 4.849931e+01 -9.993007e+02
[35,] 9.063099e+03 4.849931e+01
[36,] 6.550672e+03 9.063099e+03
[37,] 1.166844e+04 6.550672e+03
[38,] 9.388845e+03 1.166844e+04
[39,] 9.625045e+03 9.388845e+03
[40,] 2.863344e+03 9.625045e+03
[41,] 1.048544e+03 2.863344e+03
[42,] 1.993144e+03 1.048544e+03
[43,] -4.726561e+02 1.993144e+03
[44,] -1.228856e+03 -4.726561e+02
[45,] -1.410456e+03 -1.228856e+03
[46,] -1.178656e+03 -1.410456e+03
[47,] -1.596056e+03 -1.178656e+03
[48,] -4.346484e+03 -1.596056e+03
[49,] -7.874711e+03 -4.346484e+03
[50,] -1.113831e+04 -7.874711e+03
[51,] -1.198411e+04 -1.113831e+04
[52,] 9.486920e+02 -1.198411e+04
[53,] 4.058892e+03 9.486920e+02
[54,] 1.470492e+03 4.058892e+03
[55,] 6.671692e+03 1.470492e+03
[56,] 6.822492e+03 6.671692e+03
[57,] 4.645892e+03 6.822492e+03
[58,] -3.525308e+03 4.645892e+03
[59,] -1.275371e+04 -3.525308e+03
[60,] -8.339136e+03 -1.275371e+04
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -7.208920e+01 1.735138e+03
2 -2.596892e+02 -7.208920e+01
3 5.655108e+02 -2.596892e+02
4 -2.648190e+03 5.655108e+02
5 -2.837990e+03 -2.648190e+03
6 -1.558390e+03 -2.837990e+03
7 -4.267190e+03 -1.558390e+03
8 -3.709390e+03 -4.267190e+03
9 -5.298990e+03 -3.709390e+03
10 -2.685190e+03 -5.298990e+03
11 -3.143590e+03 -2.685190e+03
12 -2.271017e+03 -3.143590e+03
13 -4.986245e+03 -2.271017e+03
14 1.319155e+03 -4.986245e+03
15 3.554023e-01 1.319155e+03
16 -1.215345e+03 3.554023e-01
17 -2.748145e+03 -1.215345e+03
18 -2.376545e+03 -2.748145e+03
19 -2.334529e+01 -2.376545e+03
20 5.245471e+01 -2.334529e+01
21 3.062855e+03 5.245471e+01
22 7.340655e+03 3.062855e+03
23 8.430255e+03 7.340655e+03
24 6.670827e+03 8.430255e+03
25 1.264600e+03 6.670827e+03
26 6.900000e+02 1.264600e+03
27 1.793200e+03 6.900000e+02
28 5.149931e+01 1.793200e+03
29 4.786993e+02 5.149931e+01
30 4.712993e+02 4.786993e+02
31 -1.908501e+03 4.712993e+02
32 -1.936701e+03 -1.908501e+03
33 -9.993007e+02 -1.936701e+03
34 4.849931e+01 -9.993007e+02
35 9.063099e+03 4.849931e+01
36 6.550672e+03 9.063099e+03
37 1.166844e+04 6.550672e+03
38 9.388845e+03 1.166844e+04
39 9.625045e+03 9.388845e+03
40 2.863344e+03 9.625045e+03
41 1.048544e+03 2.863344e+03
42 1.993144e+03 1.048544e+03
43 -4.726561e+02 1.993144e+03
44 -1.228856e+03 -4.726561e+02
45 -1.410456e+03 -1.228856e+03
46 -1.178656e+03 -1.410456e+03
47 -1.596056e+03 -1.178656e+03
48 -4.346484e+03 -1.596056e+03
49 -7.874711e+03 -4.346484e+03
50 -1.113831e+04 -7.874711e+03
51 -1.198411e+04 -1.113831e+04
52 9.486920e+02 -1.198411e+04
53 4.058892e+03 9.486920e+02
54 1.470492e+03 4.058892e+03
55 6.671692e+03 1.470492e+03
56 6.822492e+03 6.671692e+03
57 4.645892e+03 6.822492e+03
58 -3.525308e+03 4.645892e+03
59 -1.275371e+04 -3.525308e+03
60 -8.339136e+03 -1.275371e+04
> 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/7uqor1229081664.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/8ef1x1229081664.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/9m3s11229081664.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/1071r21229081664.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/11swce1229081664.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/126wk51229081664.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/13pxau1229081664.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/14mgai1229081664.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/15kj3g1229081664.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/16oe2z1229081664.tab")
+ }
>
> system("convert tmp/1a2c91229081663.ps tmp/1a2c91229081663.png")
> system("convert tmp/20x7c1229081663.ps tmp/20x7c1229081663.png")
> system("convert tmp/30wbl1229081663.ps tmp/30wbl1229081663.png")
> system("convert tmp/4izdv1229081663.ps tmp/4izdv1229081663.png")
> system("convert tmp/5un641229081663.ps tmp/5un641229081663.png")
> system("convert tmp/63ags1229081664.ps tmp/63ags1229081664.png")
> system("convert tmp/7uqor1229081664.ps tmp/7uqor1229081664.png")
> system("convert tmp/8ef1x1229081664.ps tmp/8ef1x1229081664.png")
> system("convert tmp/9m3s11229081664.ps tmp/9m3s11229081664.png")
> system("convert tmp/1071r21229081664.ps tmp/1071r21229081664.png")
>
>
> proc.time()
user system elapsed
2.399 1.539 3.911