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.
Natural language support but running in an English locale
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(9,2,3,2,14,9,2,4,1,18,9,4,2,2,11,9,3,2,2,12,9,3,4,1,16,9,2,4,1,18,9,4,4,2,14,9,3,4,3,14,9,2,3,2,15,9,2,3,2,15,9,2,5,2,17,9,1,4,1,19,9,2,2,4,10,9,1,3,2,16,9,2,5,2,18,9,3,4,3,14,9,2,3,3,14,9,2,4,1,17,9,3,2,1,14,9,2,3,2,16,9,1,4,1,18,9,3,2,3,11,9,4,5,2,14,9,3,3,3,12,9,2,4,2,17,9,4,3,4,9,9,2,4,2,16,9,4,4,2,14,9,3,4,2,15,9,4,2,2,11,9,2,4,2,16,9,3,4,3,13,9,1,4,2,17,9,2,3,2,15,9,3,4,3,14,9,2,4,2,16,9,4,3,4,9,9,2,3,2,15,9,2,4,2,17,9,2,4,4,13,9,2,4,3,15,9,2,4,2,16,9,2,4,3,16,9,3,4,4,12,9,2,2,12,9,4,3,3,11,9,2,4,3,15,9,2,3,2,15,9,3,4,1,17,9,4,3,2,13,9,2,4,1,16,9,2,3,2,14,9,4,2,3,11,9,2,3,4,12,9,3,4,5,12,9,2,4,3,15,9,2,4,2,16,9,2,4,2,15,9,3,3,3,12,9,4,3,2,12,9,5,2,4,8,9,3,3,3,13,9,5,2,2,11,9,3,3,2,14,9,3,4,2,15,10,4,2,3,10),dim=c(5,66),dimnames=list(c('month','IDT','TGYW','POP','PSS
'),1:66))
> y <- array(NA,dim=c(5,66),dimnames=list(c('month','IDT','TGYW','POP','PSS
'),1:66))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '5'
> #'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
PSS\r month IDT TGYW POP t
1 14 9 2 3 2 1
2 18 9 2 4 1 2
3 11 9 4 2 2 3
4 12 9 3 2 2 4
5 16 9 3 4 1 5
6 18 9 2 4 1 6
7 14 9 4 4 2 7
8 14 9 3 4 3 8
9 15 9 2 3 2 9
10 15 9 2 3 2 10
11 17 9 2 5 2 11
12 19 9 1 4 1 12
13 10 9 2 2 4 13
14 16 9 1 3 2 14
15 18 9 2 5 2 15
16 14 9 3 4 3 16
17 14 9 2 3 3 17
18 17 9 2 4 1 18
19 14 9 3 2 1 19
20 16 9 2 3 2 20
21 18 9 1 4 1 21
22 11 9 3 2 3 22
23 14 9 4 5 2 23
24 12 9 3 3 3 24
25 17 9 2 4 2 25
26 9 9 4 3 4 26
27 16 9 2 4 2 27
28 14 9 4 4 2 28
29 15 9 3 4 2 29
30 11 9 4 2 2 30
31 16 9 2 4 2 31
32 13 9 3 4 3 32
33 17 9 1 4 2 33
34 15 9 2 3 2 34
35 14 9 3 4 3 35
36 16 9 2 4 2 36
37 9 9 4 3 4 37
38 15 9 2 3 2 38
39 17 9 2 4 2 39
40 13 9 2 4 4 40
41 15 9 2 4 3 41
42 16 9 2 4 2 42
43 16 9 2 4 3 43
44 12 9 3 4 4 44
45 9 9 2 2 12 45
46 9 4 3 3 11 46
47 9 2 4 3 15 47
48 9 2 3 2 15 48
49 9 3 4 1 17 49
50 9 4 3 2 13 50
51 9 2 4 1 16 51
52 9 2 3 2 14 52
53 9 4 2 3 11 53
54 9 2 3 4 12 54
55 9 3 4 5 12 55
56 9 2 4 3 15 56
57 9 2 4 2 16 57
58 9 2 4 2 15 58
59 9 3 3 3 12 59
60 9 4 3 2 12 60
61 9 5 2 4 8 61
62 9 3 3 3 13 62
63 9 5 2 2 11 63
64 9 3 3 2 14 64
65 10 3 4 2 15 65
66 9 4 2 3 10 66
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) month IDT TGYW POP t
17.50562 -0.17151 -1.15793 0.87447 -0.28441 -0.04594
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3.75244 -0.99172 0.05891 1.01204 3.14394
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.50562 2.87998 6.078 9.09e-08 ***
month -0.17151 0.23394 -0.733 0.46633
IDT -1.15793 0.24640 -4.699 1.57e-05 ***
TGYW 0.87447 0.25474 3.433 0.00109 **
POP -0.28441 0.14842 -1.916 0.06010 .
t -0.04594 0.01774 -2.590 0.01202 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.537 on 60 degrees of freedom
Multiple R-squared: 0.8025, Adjusted R-squared: 0.786
F-statistic: 48.76 on 5 and 60 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,] 5.085538e-02 1.017108e-01 9.491446e-01
[2,] 1.422307e-02 2.844614e-02 9.857769e-01
[3,] 1.427934e-02 2.855869e-02 9.857207e-01
[4,] 4.556482e-03 9.112963e-03 9.954435e-01
[5,] 2.657376e-03 5.314752e-03 9.973426e-01
[6,] 8.071271e-04 1.614254e-03 9.991929e-01
[7,] 2.596935e-04 5.193870e-04 9.997403e-01
[8,] 7.694754e-05 1.538951e-04 9.999231e-01
[9,] 3.466113e-05 6.932226e-05 9.999653e-01
[10,] 8.069054e-05 1.613811e-04 9.999193e-01
[11,] 2.664156e-05 5.328311e-05 9.999734e-01
[12,] 3.361453e-05 6.722907e-05 9.999664e-01
[13,] 5.018067e-05 1.003613e-04 9.999498e-01
[14,] 2.768275e-05 5.536549e-05 9.999723e-01
[15,] 7.162504e-05 1.432501e-04 9.999284e-01
[16,] 3.916669e-05 7.833339e-05 9.999608e-01
[17,] 3.307017e-05 6.614035e-05 9.999669e-01
[18,] 7.138597e-05 1.427719e-04 9.999286e-01
[19,] 2.957262e-05 5.914524e-05 9.999704e-01
[20,] 1.302110e-05 2.604221e-05 9.999870e-01
[21,] 4.943484e-06 9.886968e-06 9.999951e-01
[22,] 5.726310e-06 1.145262e-05 9.999943e-01
[23,] 2.379670e-06 4.759339e-06 9.999976e-01
[24,] 1.435504e-06 2.871007e-06 9.999986e-01
[25,] 8.932724e-07 1.786545e-06 9.999991e-01
[26,] 3.285487e-07 6.570973e-07 9.999997e-01
[27,] 1.705805e-07 3.411610e-07 9.999998e-01
[28,] 8.231421e-08 1.646284e-07 9.999999e-01
[29,] 3.259600e-04 6.519200e-04 9.996740e-01
[30,] 2.457200e-04 4.914400e-04 9.997543e-01
[31,] 9.334678e-04 1.866936e-03 9.990665e-01
[32,] 5.513274e-04 1.102655e-03 9.994487e-01
[33,] 4.250378e-04 8.500755e-04 9.995750e-01
[34,] 1.062767e-03 2.125535e-03 9.989372e-01
[35,] 9.759583e-01 4.808330e-02 2.404165e-02
[36,] 9.999240e-01 1.519047e-04 7.595236e-05
[37,] 9.999998e-01 3.220090e-07 1.610045e-07
[38,] 9.999994e-01 1.179890e-06 5.899451e-07
[39,] 9.999988e-01 2.467523e-06 1.233762e-06
[40,] 9.999962e-01 7.534349e-06 3.767174e-06
[41,] 9.999985e-01 3.053835e-06 1.526918e-06
[42,] 9.999925e-01 1.505387e-05 7.526936e-06
[43,] 9.999755e-01 4.901141e-05 2.450570e-05
[44,] 9.999220e-01 1.559320e-04 7.796601e-05
[45,] 9.999465e-01 1.070446e-04 5.352230e-05
[46,] 9.999909e-01 1.814035e-05 9.070177e-06
[47,] 9.999859e-01 2.825021e-05 1.412510e-05
[48,] 9.998315e-01 3.369784e-04 1.684892e-04
[49,] 9.983155e-01 3.369096e-03 1.684548e-03
> postscript(file="/var/www/html/freestat/rcomp/tmp/1peyl1292968472.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/www/html/freestat/rcomp/tmp/2peyl1292968472.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/www/html/freestat/rcomp/tmp/3dlr01292968472.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/www/html/freestat/rcomp/tmp/4dlr01292968472.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/www/html/freestat/rcomp/tmp/5dlr01292968472.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 = 66
Frequency = 1
1 2 3 4 5 6
-1.65484462 1.23222470 -1.37264255 -1.48462768 0.52797488 1.41598975
7 8 9 10 11 12
0.06218897 -0.76539099 -0.28731453 -0.24137327 0.05563446 1.53371092
13 14 15 16 17 18
-3.66027237 -0.21553462 1.23939950 -0.39786090 -0.63537927 0.96728487
19 20 21 22 23 24
0.92008606 1.21803934 0.94718226 -1.37327981 -0.07721762 -1.15586405
25 26 27 28 29 30
1.57327888 -2.62164996 0.66516140 1.02695544 0.91497031 -0.13222851
31 32 33 34 35 36
0.84892644 -0.66280073 0.78288257 0.86121699 0.47502305 1.07863274
37 38 39 40 41 42
-2.11629609 1.04498203 2.21645653 -1.16879186 0.59274422 1.35428031
43 44 45 46 47 48
1.68462674 -0.82710043 -0.91491062 -1.72745367 0.27101918 0.03350081
49 50 51 52 53 54
2.85215333 -0.10041151 2.48812293 -0.06713932 -2.56379124 -2.29300068
55 56 57 58 59 60
-1.79209204 0.68449053 1.88930373 1.65083981 -1.01731986 0.07459592
61 62 63 64 65 66
-3.75243569 -0.59509090 -1.05840411 0.65566356 3.14393639 -2.25096003
> postscript(file="/var/www/html/freestat/rcomp/tmp/66uql1292968472.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 = 66
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.65484462 NA
1 1.23222470 -1.65484462
2 -1.37264255 1.23222470
3 -1.48462768 -1.37264255
4 0.52797488 -1.48462768
5 1.41598975 0.52797488
6 0.06218897 1.41598975
7 -0.76539099 0.06218897
8 -0.28731453 -0.76539099
9 -0.24137327 -0.28731453
10 0.05563446 -0.24137327
11 1.53371092 0.05563446
12 -3.66027237 1.53371092
13 -0.21553462 -3.66027237
14 1.23939950 -0.21553462
15 -0.39786090 1.23939950
16 -0.63537927 -0.39786090
17 0.96728487 -0.63537927
18 0.92008606 0.96728487
19 1.21803934 0.92008606
20 0.94718226 1.21803934
21 -1.37327981 0.94718226
22 -0.07721762 -1.37327981
23 -1.15586405 -0.07721762
24 1.57327888 -1.15586405
25 -2.62164996 1.57327888
26 0.66516140 -2.62164996
27 1.02695544 0.66516140
28 0.91497031 1.02695544
29 -0.13222851 0.91497031
30 0.84892644 -0.13222851
31 -0.66280073 0.84892644
32 0.78288257 -0.66280073
33 0.86121699 0.78288257
34 0.47502305 0.86121699
35 1.07863274 0.47502305
36 -2.11629609 1.07863274
37 1.04498203 -2.11629609
38 2.21645653 1.04498203
39 -1.16879186 2.21645653
40 0.59274422 -1.16879186
41 1.35428031 0.59274422
42 1.68462674 1.35428031
43 -0.82710043 1.68462674
44 -0.91491062 -0.82710043
45 -1.72745367 -0.91491062
46 0.27101918 -1.72745367
47 0.03350081 0.27101918
48 2.85215333 0.03350081
49 -0.10041151 2.85215333
50 2.48812293 -0.10041151
51 -0.06713932 2.48812293
52 -2.56379124 -0.06713932
53 -2.29300068 -2.56379124
54 -1.79209204 -2.29300068
55 0.68449053 -1.79209204
56 1.88930373 0.68449053
57 1.65083981 1.88930373
58 -1.01731986 1.65083981
59 0.07459592 -1.01731986
60 -3.75243569 0.07459592
61 -0.59509090 -3.75243569
62 -1.05840411 -0.59509090
63 0.65566356 -1.05840411
64 3.14393639 0.65566356
65 -2.25096003 3.14393639
66 NA -2.25096003
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.23222470 -1.65484462
[2,] -1.37264255 1.23222470
[3,] -1.48462768 -1.37264255
[4,] 0.52797488 -1.48462768
[5,] 1.41598975 0.52797488
[6,] 0.06218897 1.41598975
[7,] -0.76539099 0.06218897
[8,] -0.28731453 -0.76539099
[9,] -0.24137327 -0.28731453
[10,] 0.05563446 -0.24137327
[11,] 1.53371092 0.05563446
[12,] -3.66027237 1.53371092
[13,] -0.21553462 -3.66027237
[14,] 1.23939950 -0.21553462
[15,] -0.39786090 1.23939950
[16,] -0.63537927 -0.39786090
[17,] 0.96728487 -0.63537927
[18,] 0.92008606 0.96728487
[19,] 1.21803934 0.92008606
[20,] 0.94718226 1.21803934
[21,] -1.37327981 0.94718226
[22,] -0.07721762 -1.37327981
[23,] -1.15586405 -0.07721762
[24,] 1.57327888 -1.15586405
[25,] -2.62164996 1.57327888
[26,] 0.66516140 -2.62164996
[27,] 1.02695544 0.66516140
[28,] 0.91497031 1.02695544
[29,] -0.13222851 0.91497031
[30,] 0.84892644 -0.13222851
[31,] -0.66280073 0.84892644
[32,] 0.78288257 -0.66280073
[33,] 0.86121699 0.78288257
[34,] 0.47502305 0.86121699
[35,] 1.07863274 0.47502305
[36,] -2.11629609 1.07863274
[37,] 1.04498203 -2.11629609
[38,] 2.21645653 1.04498203
[39,] -1.16879186 2.21645653
[40,] 0.59274422 -1.16879186
[41,] 1.35428031 0.59274422
[42,] 1.68462674 1.35428031
[43,] -0.82710043 1.68462674
[44,] -0.91491062 -0.82710043
[45,] -1.72745367 -0.91491062
[46,] 0.27101918 -1.72745367
[47,] 0.03350081 0.27101918
[48,] 2.85215333 0.03350081
[49,] -0.10041151 2.85215333
[50,] 2.48812293 -0.10041151
[51,] -0.06713932 2.48812293
[52,] -2.56379124 -0.06713932
[53,] -2.29300068 -2.56379124
[54,] -1.79209204 -2.29300068
[55,] 0.68449053 -1.79209204
[56,] 1.88930373 0.68449053
[57,] 1.65083981 1.88930373
[58,] -1.01731986 1.65083981
[59,] 0.07459592 -1.01731986
[60,] -3.75243569 0.07459592
[61,] -0.59509090 -3.75243569
[62,] -1.05840411 -0.59509090
[63,] 0.65566356 -1.05840411
[64,] 3.14393639 0.65566356
[65,] -2.25096003 3.14393639
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.23222470 -1.65484462
2 -1.37264255 1.23222470
3 -1.48462768 -1.37264255
4 0.52797488 -1.48462768
5 1.41598975 0.52797488
6 0.06218897 1.41598975
7 -0.76539099 0.06218897
8 -0.28731453 -0.76539099
9 -0.24137327 -0.28731453
10 0.05563446 -0.24137327
11 1.53371092 0.05563446
12 -3.66027237 1.53371092
13 -0.21553462 -3.66027237
14 1.23939950 -0.21553462
15 -0.39786090 1.23939950
16 -0.63537927 -0.39786090
17 0.96728487 -0.63537927
18 0.92008606 0.96728487
19 1.21803934 0.92008606
20 0.94718226 1.21803934
21 -1.37327981 0.94718226
22 -0.07721762 -1.37327981
23 -1.15586405 -0.07721762
24 1.57327888 -1.15586405
25 -2.62164996 1.57327888
26 0.66516140 -2.62164996
27 1.02695544 0.66516140
28 0.91497031 1.02695544
29 -0.13222851 0.91497031
30 0.84892644 -0.13222851
31 -0.66280073 0.84892644
32 0.78288257 -0.66280073
33 0.86121699 0.78288257
34 0.47502305 0.86121699
35 1.07863274 0.47502305
36 -2.11629609 1.07863274
37 1.04498203 -2.11629609
38 2.21645653 1.04498203
39 -1.16879186 2.21645653
40 0.59274422 -1.16879186
41 1.35428031 0.59274422
42 1.68462674 1.35428031
43 -0.82710043 1.68462674
44 -0.91491062 -0.82710043
45 -1.72745367 -0.91491062
46 0.27101918 -1.72745367
47 0.03350081 0.27101918
48 2.85215333 0.03350081
49 -0.10041151 2.85215333
50 2.48812293 -0.10041151
51 -0.06713932 2.48812293
52 -2.56379124 -0.06713932
53 -2.29300068 -2.56379124
54 -1.79209204 -2.29300068
55 0.68449053 -1.79209204
56 1.88930373 0.68449053
57 1.65083981 1.88930373
58 -1.01731986 1.65083981
59 0.07459592 -1.01731986
60 -3.75243569 0.07459592
61 -0.59509090 -3.75243569
62 -1.05840411 -0.59509090
63 0.65566356 -1.05840411
64 3.14393639 0.65566356
65 -2.25096003 3.14393639
> 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/freestat/rcomp/tmp/7h3po1292968472.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/www/html/freestat/rcomp/tmp/8h3po1292968472.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/www/html/freestat/rcomp/tmp/9h3po1292968472.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/www/html/freestat/rcomp/tmp/109vpr1292968472.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/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11dv5x1292968472.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/freestat/rcomp/tmp/12gwm21292968472.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/freestat/rcomp/tmp/13cn1t1292968472.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/freestat/rcomp/tmp/14f6ih1292968472.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/freestat/rcomp/tmp/15qxh21292968472.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/freestat/rcomp/tmp/1647fb1292968472.tab")
+ }
>
> try(system("convert tmp/1peyl1292968472.ps tmp/1peyl1292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/2peyl1292968472.ps tmp/2peyl1292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/3dlr01292968472.ps tmp/3dlr01292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/4dlr01292968472.ps tmp/4dlr01292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/5dlr01292968472.ps tmp/5dlr01292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/66uql1292968472.ps tmp/66uql1292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/7h3po1292968472.ps tmp/7h3po1292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/8h3po1292968472.ps tmp/8h3po1292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/9h3po1292968472.ps tmp/9h3po1292968472.png",intern=TRUE))
character(0)
> try(system("convert tmp/109vpr1292968472.ps tmp/109vpr1292968472.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.185 2.594 16.380