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(5.3
+ ,190.7
+ ,2.97
+ ,17885.8
+ ,2609.3
+ ,5.4
+ ,191.8
+ ,3.01
+ ,16937.6
+ ,3058.1
+ ,5.2
+ ,193.3
+ ,3.15
+ ,16184.9
+ ,3336.4
+ ,5.2
+ ,194.6
+ ,3.51
+ ,18148.5
+ ,3263.7
+ ,5.1
+ ,194.4
+ ,2.80
+ ,19053.2
+ ,3222.9
+ ,5.0
+ ,194.5
+ ,2.53
+ ,20976.7
+ ,3370.7
+ ,5.0
+ ,195.4
+ ,3.17
+ ,21272.7
+ ,3560.0
+ ,4.9
+ ,196.4
+ ,3.64
+ ,22421.3
+ ,3728.7
+ ,5.0
+ ,198.8
+ ,4.69
+ ,23294.5
+ ,3165.8
+ ,5.0
+ ,199.2
+ ,4.35
+ ,24382.9
+ ,3899.2
+ ,5.0
+ ,197.6
+ ,3.46
+ ,22426.1
+ ,3807.5
+ ,4.9
+ ,196.8
+ ,3.42
+ ,20486.0
+ ,4169.8
+ ,4.7
+ ,198.3
+ ,3.99
+ ,21382.5
+ ,3396.9
+ ,4.8
+ ,198.7
+ ,3.60
+ ,17905.4
+ ,4072.2
+ ,4.7
+ ,199.8
+ ,3.36
+ ,20531.3
+ ,4867.1
+ ,4.7
+ ,201.5
+ ,3.55
+ ,21459.1
+ ,4232.4
+ ,4.6
+ ,202.5
+ ,4.17
+ ,22317.6
+ ,4434.1
+ ,4.6
+ ,202.9
+ ,4.32
+ ,23989.7
+ ,4302.9
+ ,4.7
+ ,203.5
+ ,4.15
+ ,24632.0
+ ,4806.3
+ ,4.7
+ ,203.9
+ ,3.82
+ ,26713.3
+ ,4603.3
+ ,4.5
+ ,202.9
+ ,2.06
+ ,27570.6
+ ,4461.0
+ ,4.4
+ ,201.8
+ ,1.31
+ ,29388.6
+ ,4885.3
+ ,4.5
+ ,201.5
+ ,1.97
+ ,27775.1
+ ,4595.8
+ ,4.4
+ ,201.8
+ ,2.54
+ ,24109.
+ ,5015.8
+ ,4.6
+ ,202.416
+ ,2.08
+ ,25640.6
+ ,4389.5
+ ,4.5
+ ,203.499
+ ,2.42
+ ,23038.9
+ ,4532.9
+ ,4.4
+ ,205.352
+ ,2.78
+ ,22723.0
+ ,5425.4
+ ,4.5
+ ,206.686
+ ,2.57
+ ,24241.5
+ ,4704.0
+ ,4.4
+ ,207.949
+ ,2.69
+ ,25290.6
+ ,5129.4
+ ,4.6
+ ,208.352
+ ,2.69
+ ,27071.0
+ ,5561.8
+ ,4.6
+ ,208.299
+ ,2.36
+ ,28601.2
+ ,4665.9
+ ,4.6
+ ,207.917
+ ,1.97
+ ,28424.5
+ ,5552.8
+ ,4.7
+ ,208.49
+ ,2.76
+ ,29419.0
+ ,5311.9
+ ,4.7
+ ,208.936
+ ,3.54
+ ,31555.4
+ ,5532.9
+ ,4.7
+ ,210.177
+ ,4.31
+ ,29780.7
+ ,5581.5
+ ,5.0
+ ,210.036
+ ,4.08
+ ,25656.6
+ ,6548.9
+ ,5.0
+ ,211.08
+ ,4.28
+ ,26193.0
+ ,5556.7
+ ,4.8
+ ,211.693
+ ,4.03
+ ,24095.9
+ ,5698.1
+ ,5.1
+ ,213.528
+ ,3.98
+ ,22440.2
+ ,6294.4
+ ,5.0
+ ,214.823
+ ,3.94
+ ,25951.7
+ ,5651.2
+ ,5.4
+ ,216.632
+ ,4.18
+ ,27634.5
+ ,6275.7
+ ,5.5
+ ,218.815
+ ,5.02
+ ,27930.6
+ ,6188.2
+ ,5.8
+ ,219.964
+ ,5.60
+ ,31247.3
+ ,6234.6
+ ,6.1
+ ,219.086
+ ,5.37
+ ,31823.7
+ ,6201.3
+ ,6.2
+ ,218.783
+ ,4.94
+ ,33078.7
+ ,5257.6
+ ,6.6
+ ,216.573
+ ,3.66
+ ,34032.4
+ ,6083.4
+ ,6.9
+ ,212.425
+ ,1.07
+ ,28265.0
+ ,5181.0
+ ,7.4
+ ,210.228
+ ,0.09
+ ,25079.5
+ ,5110.7
+ ,7.7
+ ,211.143
+ ,0.03
+ ,24743.5
+ ,4159.6
+ ,8.2
+ ,212.193
+ ,0.24
+ ,18845.5
+ ,4661.7
+ ,8.6
+ ,212.709
+ ,-0.38
+ ,21224.7
+ ,5579.3
+ ,8.9
+ ,213.24
+ ,-0.74
+ ,21920.6
+ ,5161.4
+ ,9.4
+ ,213.856
+ ,-1.28
+ ,22734.1
+ ,5256.0
+ ,9.5
+ ,215.693
+ ,-1.43
+ ,23972.8
+ ,5548.6
+ ,9.4
+ ,215.351
+ ,-2.10
+ ,25671.1
+ ,5269.3
+ ,9.7
+ ,215.834
+ ,-1.48
+ ,25798.1
+ ,5518.0
+ ,9.8
+ ,215.969
+ ,-1.29
+ ,27893.9
+ ,5764.3
+ ,10.1
+ ,216.177
+ ,-0.18
+ ,29557.8
+ ,6879.3
+ ,10.0
+ ,216.33
+ ,1.84
+ ,27541.7
+ ,7374.2
+ ,10.0
+ ,215.949
+ ,2.72
+ ,26470.1
+ ,8325.0
+ ,9.7
+ ,216.687
+ ,2.63
+ ,25185.1
+ ,6888.8
+ ,9.7
+ ,216.741
+ ,2.14
+ ,23363.8
+ ,6855.1
+ ,9.7
+ ,217.631
+ ,2.31
+ ,24300.2
+ ,7403.6
+ ,9.9
+ ,218.009
+ ,2.24
+ ,25905.7
+ ,6591.2
+ ,9.7
+ ,218.178
+ ,2.02
+ ,29036.8
+ ,6752.7
+ ,9.5
+ ,217.965
+ ,1.05
+ ,32866.5
+ ,6715.0
+ ,9.5
+ ,218.011
+ ,1.24
+ ,33260.0
+ ,7344.7
+ ,9.6
+ ,218.312
+ ,1.15
+ ,35288.5
+ ,7253.5
+ ,9.6
+ ,218.439
+ ,1.14
+ ,34999.2
+ ,7168.2
+ ,9.6
+ ,218.711
+ ,1.17
+ ,34820.2
+ ,9303.4)
+ ,dim=c(5
+ ,70)
+ ,dimnames=list(c('Unemployment'
+ ,'CPI'
+ ,'Inflation'
+ ,'Import'
+ ,'Export')
+ ,1:70))
> y <- array(NA,dim=c(5,70),dimnames=list(c('Unemployment','CPI','Inflation','Import','Export'),1:70))
> 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
Unemployment CPI Inflation Import Export M1 M2 M3 M4 M5 M6 M7 M8 M9 M10
1 5.3 190.700 2.97 17885.8 2609.3 1 0 0 0 0 0 0 0 0 0
2 5.4 191.800 3.01 16937.6 3058.1 0 1 0 0 0 0 0 0 0 0
3 5.2 193.300 3.15 16184.9 3336.4 0 0 1 0 0 0 0 0 0 0
4 5.2 194.600 3.51 18148.5 3263.7 0 0 0 1 0 0 0 0 0 0
5 5.1 194.400 2.80 19053.2 3222.9 0 0 0 0 1 0 0 0 0 0
6 5.0 194.500 2.53 20976.7 3370.7 0 0 0 0 0 1 0 0 0 0
7 5.0 195.400 3.17 21272.7 3560.0 0 0 0 0 0 0 1 0 0 0
8 4.9 196.400 3.64 22421.3 3728.7 0 0 0 0 0 0 0 1 0 0
9 5.0 198.800 4.69 23294.5 3165.8 0 0 0 0 0 0 0 0 1 0
10 5.0 199.200 4.35 24382.9 3899.2 0 0 0 0 0 0 0 0 0 1
11 5.0 197.600 3.46 22426.1 3807.5 0 0 0 0 0 0 0 0 0 0
12 4.9 196.800 3.42 20486.0 4169.8 0 0 0 0 0 0 0 0 0 0
13 4.7 198.300 3.99 21382.5 3396.9 1 0 0 0 0 0 0 0 0 0
14 4.8 198.700 3.60 17905.4 4072.2 0 1 0 0 0 0 0 0 0 0
15 4.7 199.800 3.36 20531.3 4867.1 0 0 1 0 0 0 0 0 0 0
16 4.7 201.500 3.55 21459.1 4232.4 0 0 0 1 0 0 0 0 0 0
17 4.6 202.500 4.17 22317.6 4434.1 0 0 0 0 1 0 0 0 0 0
18 4.6 202.900 4.32 23989.7 4302.9 0 0 0 0 0 1 0 0 0 0
19 4.7 203.500 4.15 24632.0 4806.3 0 0 0 0 0 0 1 0 0 0
20 4.7 203.900 3.82 26713.3 4603.3 0 0 0 0 0 0 0 1 0 0
21 4.5 202.900 2.06 27570.6 4461.0 0 0 0 0 0 0 0 0 1 0
22 4.4 201.800 1.31 29388.6 4885.3 0 0 0 0 0 0 0 0 0 1
23 4.5 201.500 1.97 27775.1 4595.8 0 0 0 0 0 0 0 0 0 0
24 4.4 201.800 2.54 24109.0 5015.8 0 0 0 0 0 0 0 0 0 0
25 4.6 202.416 2.08 25640.6 4389.5 1 0 0 0 0 0 0 0 0 0
26 4.5 203.499 2.42 23038.9 4532.9 0 1 0 0 0 0 0 0 0 0
27 4.4 205.352 2.78 22723.0 5425.4 0 0 1 0 0 0 0 0 0 0
28 4.5 206.686 2.57 24241.5 4704.0 0 0 0 1 0 0 0 0 0 0
29 4.4 207.949 2.69 25290.6 5129.4 0 0 0 0 1 0 0 0 0 0
30 4.6 208.352 2.69 27071.0 5561.8 0 0 0 0 0 1 0 0 0 0
31 4.6 208.299 2.36 28601.2 4665.9 0 0 0 0 0 0 1 0 0 0
32 4.6 207.917 1.97 28424.5 5552.8 0 0 0 0 0 0 0 1 0 0
33 4.7 208.490 2.76 29419.0 5311.9 0 0 0 0 0 0 0 0 1 0
34 4.7 208.936 3.54 31555.4 5532.9 0 0 0 0 0 0 0 0 0 1
35 4.7 210.177 4.31 29780.7 5581.5 0 0 0 0 0 0 0 0 0 0
36 5.0 210.036 4.08 25656.6 6548.9 0 0 0 0 0 0 0 0 0 0
37 5.0 211.080 4.28 26193.0 5556.7 1 0 0 0 0 0 0 0 0 0
38 4.8 211.693 4.03 24095.9 5698.1 0 1 0 0 0 0 0 0 0 0
39 5.1 213.528 3.98 22440.2 6294.4 0 0 1 0 0 0 0 0 0 0
40 5.0 214.823 3.94 25951.7 5651.2 0 0 0 1 0 0 0 0 0 0
41 5.4 216.632 4.18 27634.5 6275.7 0 0 0 0 1 0 0 0 0 0
42 5.5 218.815 5.02 27930.6 6188.2 0 0 0 0 0 1 0 0 0 0
43 5.8 219.964 5.60 31247.3 6234.6 0 0 0 0 0 0 1 0 0 0
44 6.1 219.086 5.37 31823.7 6201.3 0 0 0 0 0 0 0 1 0 0
45 6.2 218.783 4.94 33078.7 5257.6 0 0 0 0 0 0 0 0 1 0
46 6.6 216.573 3.66 34032.4 6083.4 0 0 0 0 0 0 0 0 0 1
47 6.9 212.425 1.07 28265.0 5181.0 0 0 0 0 0 0 0 0 0 0
48 7.4 210.228 0.09 25079.5 5110.7 0 0 0 0 0 0 0 0 0 0
49 7.7 211.143 0.03 24743.5 4159.6 1 0 0 0 0 0 0 0 0 0
50 8.2 212.193 0.24 18845.5 4661.7 0 1 0 0 0 0 0 0 0 0
51 8.6 212.709 -0.38 21224.7 5579.3 0 0 1 0 0 0 0 0 0 0
52 8.9 213.240 -0.74 21920.6 5161.4 0 0 0 1 0 0 0 0 0 0
53 9.4 213.856 -1.28 22734.1 5256.0 0 0 0 0 1 0 0 0 0 0
54 9.5 215.693 -1.43 23972.8 5548.6 0 0 0 0 0 1 0 0 0 0
55 9.4 215.351 -2.10 25671.1 5269.3 0 0 0 0 0 0 1 0 0 0
56 9.7 215.834 -1.48 25798.1 5518.0 0 0 0 0 0 0 0 1 0 0
57 9.8 215.969 -1.29 27893.9 5764.3 0 0 0 0 0 0 0 0 1 0
58 10.1 216.177 -0.18 29557.8 6879.3 0 0 0 0 0 0 0 0 0 1
59 10.0 216.330 1.84 27541.7 7374.2 0 0 0 0 0 0 0 0 0 0
60 10.0 215.949 2.72 26470.1 8325.0 0 0 0 0 0 0 0 0 0 0
61 9.7 216.687 2.63 25185.1 6888.8 1 0 0 0 0 0 0 0 0 0
62 9.7 216.741 2.14 23363.8 6855.1 0 1 0 0 0 0 0 0 0 0
63 9.7 217.631 2.31 24300.2 7403.6 0 0 1 0 0 0 0 0 0 0
64 9.9 218.009 2.24 25905.7 6591.2 0 0 0 1 0 0 0 0 0 0
65 9.7 218.178 2.02 29036.8 6752.7 0 0 0 0 1 0 0 0 0 0
66 9.5 217.965 1.05 32866.5 6715.0 0 0 0 0 0 1 0 0 0 0
67 9.5 218.011 1.24 33260.0 7344.7 0 0 0 0 0 0 1 0 0 0
68 9.6 218.312 1.15 35288.5 7253.5 0 0 0 0 0 0 0 1 0 0
69 9.6 218.439 1.14 34999.2 7168.2 0 0 0 0 0 0 0 0 1 0
70 9.6 218.711 1.17 34820.2 9303.4 0 0 0 0 0 0 0 0 0 1
M11 t
1 0 1
2 0 2
3 0 3
4 0 4
5 0 5
6 0 6
7 0 7
8 0 8
9 0 9
10 0 10
11 1 11
12 0 12
13 0 13
14 0 14
15 0 15
16 0 16
17 0 17
18 0 18
19 0 19
20 0 20
21 0 21
22 0 22
23 1 23
24 0 24
25 0 25
26 0 26
27 0 27
28 0 28
29 0 29
30 0 30
31 0 31
32 0 32
33 0 33
34 0 34
35 1 35
36 0 36
37 0 37
38 0 38
39 0 39
40 0 40
41 0 41
42 0 42
43 0 43
44 0 44
45 0 45
46 0 46
47 1 47
48 0 48
49 0 49
50 0 50
51 0 51
52 0 52
53 0 53
54 0 54
55 0 55
56 0 56
57 0 57
58 0 58
59 1 59
60 0 60
61 0 61
62 0 62
63 0 63
64 0 64
65 0 65
66 0 66
67 0 67
68 0 68
69 0 69
70 0 70
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) CPI Inflation Import Export M1
64.1172982 -0.2810974 0.3243366 -0.0003722 -0.0001871 0.0426952
M2 M3 M4 M5 M6 M7
-0.9164173 -0.4379033 0.2197988 0.8303010 1.5046217 1.8739540
M8 M9 M10 M11 t
2.1337511 2.3017028 2.6971733 1.2868487 0.2701218
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.05129 -0.34052 -0.06503 0.30945 1.47353
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.412e+01 7.363e+00 8.708 8.43e-12 ***
CPI -2.811e-01 3.856e-02 -7.290 1.54e-09 ***
Inflation 3.243e-01 8.606e-02 3.769 0.000414 ***
Import -3.722e-04 4.136e-05 -8.998 2.95e-12 ***
Export -1.871e-04 1.724e-04 -1.085 0.282768
M1 4.270e-02 3.904e-01 0.109 0.913327
M2 -9.164e-01 3.849e-01 -2.381 0.020888 *
M3 -4.379e-01 3.702e-01 -1.183 0.242115
M4 2.198e-01 3.749e-01 0.586 0.560193
M5 8.303e-01 3.695e-01 2.247 0.028803 *
M6 1.505e+00 3.812e-01 3.947 0.000234 ***
M7 1.874e+00 3.951e-01 4.743 1.63e-05 ***
M8 2.134e+00 4.020e-01 5.307 2.23e-06 ***
M9 2.302e+00 4.338e-01 5.306 2.24e-06 ***
M10 2.697e+00 4.269e-01 6.318 5.62e-08 ***
M11 1.287e+00 3.967e-01 3.244 0.002044 **
t 2.701e-01 2.321e-02 11.636 3.23e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5771 on 53 degrees of freedom
Multiple R-squared: 0.9451, Adjusted R-squared: 0.9286
F-statistic: 57.06 on 16 and 53 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.145555e-03 1.029111e-02 0.9948544
[2,] 6.876398e-04 1.375280e-03 0.9993124
[3,] 2.329999e-04 4.659997e-04 0.9997670
[4,] 6.720590e-05 1.344118e-04 0.9999328
[5,] 1.255106e-05 2.510212e-05 0.9999874
[6,] 1.347682e-04 2.695363e-04 0.9998652
[7,] 7.249091e-05 1.449818e-04 0.9999275
[8,] 5.723877e-05 1.144775e-04 0.9999428
[9,] 3.451245e-05 6.902491e-05 0.9999655
[10,] 1.008245e-05 2.016490e-05 0.9999899
[11,] 4.906827e-05 9.813653e-05 0.9999509
[12,] 1.939115e-05 3.878230e-05 0.9999806
[13,] 3.001354e-05 6.002708e-05 0.9999700
[14,] 5.666264e-04 1.133253e-03 0.9994334
[15,] 9.840985e-04 1.968197e-03 0.9990159
[16,] 1.191289e-03 2.382579e-03 0.9988087
[17,] 4.008685e-03 8.017371e-03 0.9959913
[18,] 5.139361e-03 1.027872e-02 0.9948606
[19,] 7.565453e-03 1.513091e-02 0.9924345
[20,] 4.465248e-03 8.930497e-03 0.9955348
[21,] 3.514310e-03 7.028620e-03 0.9964857
[22,] 2.087530e-02 4.175060e-02 0.9791247
[23,] 3.899586e-02 7.799171e-02 0.9610041
[24,] 6.324337e-02 1.264867e-01 0.9367566
[25,] 1.147639e-01 2.295277e-01 0.8852361
[26,] 1.555342e-01 3.110684e-01 0.8444658
[27,] 3.184295e-01 6.368590e-01 0.6815705
[28,] 8.331407e-01 3.337185e-01 0.1668593
[29,] 7.922117e-01 4.155765e-01 0.2077883
[30,] 7.512028e-01 4.975943e-01 0.2487972
[31,] 8.409245e-01 3.181509e-01 0.1590755
> postscript(file="/var/www/html/freestat/rcomp/tmp/12x7b1293198202.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/22x7b1293198202.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/3v6oe1293198202.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/4v6oe1293198202.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/5v6oe1293198202.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 = 70
Frequency = 1
1 2 3 4 5 6
0.65723709 1.47352529 0.67305189 0.71113966 0.23366899 0.04848986
7 8 9 10 11 12
-0.39995763 -0.44214082 -0.22646406 -0.12700148 0.10662592 0.15714122
13 14 15 16 17 18
0.07014368 -0.06974165 0.59477666 0.30975058 -0.23358787 -0.51643881
19 20 21 22 23 24
-0.49883331 -0.07261103 -0.12849148 -0.20398181 0.08311254 -0.38662889
25 26 27 28 29 30
0.27576688 0.11739505 -0.27769421 -0.23223325 -0.42667301 -0.31425550
31 32 33 34 35 36
-0.45968565 -0.87029610 -0.97845375 -0.93513741 -0.34727941 -0.34954876
37 38 39 40 41 42
-0.41978836 -0.43147990 -0.85275082 -0.31696340 0.37627553 -0.03313960
43 44 45 46 47 48
1.00542793 0.81160711 0.81834293 0.85617306 -0.34507079 -0.32686079
49 50 51 52 53 54
-0.36605007 -1.05129175 0.00345266 -0.17753477 0.11062542 0.34700626
55 56 57 58 59 60
0.30856338 0.10713388 0.57152942 0.73234203 0.50261174 0.90589721
61 62 63 64 65 66
-0.21730921 -0.03840704 -0.14083619 -0.29415882 -0.06030907 0.46833780
67 68 69 70
0.04448529 0.46630697 -0.05646306 -0.32239439
> postscript(file="/var/www/html/freestat/rcomp/tmp/6ng5h1293198202.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 = 70
Frequency = 1
lag(myerror, k = 1) myerror
0 0.65723709 NA
1 1.47352529 0.65723709
2 0.67305189 1.47352529
3 0.71113966 0.67305189
4 0.23366899 0.71113966
5 0.04848986 0.23366899
6 -0.39995763 0.04848986
7 -0.44214082 -0.39995763
8 -0.22646406 -0.44214082
9 -0.12700148 -0.22646406
10 0.10662592 -0.12700148
11 0.15714122 0.10662592
12 0.07014368 0.15714122
13 -0.06974165 0.07014368
14 0.59477666 -0.06974165
15 0.30975058 0.59477666
16 -0.23358787 0.30975058
17 -0.51643881 -0.23358787
18 -0.49883331 -0.51643881
19 -0.07261103 -0.49883331
20 -0.12849148 -0.07261103
21 -0.20398181 -0.12849148
22 0.08311254 -0.20398181
23 -0.38662889 0.08311254
24 0.27576688 -0.38662889
25 0.11739505 0.27576688
26 -0.27769421 0.11739505
27 -0.23223325 -0.27769421
28 -0.42667301 -0.23223325
29 -0.31425550 -0.42667301
30 -0.45968565 -0.31425550
31 -0.87029610 -0.45968565
32 -0.97845375 -0.87029610
33 -0.93513741 -0.97845375
34 -0.34727941 -0.93513741
35 -0.34954876 -0.34727941
36 -0.41978836 -0.34954876
37 -0.43147990 -0.41978836
38 -0.85275082 -0.43147990
39 -0.31696340 -0.85275082
40 0.37627553 -0.31696340
41 -0.03313960 0.37627553
42 1.00542793 -0.03313960
43 0.81160711 1.00542793
44 0.81834293 0.81160711
45 0.85617306 0.81834293
46 -0.34507079 0.85617306
47 -0.32686079 -0.34507079
48 -0.36605007 -0.32686079
49 -1.05129175 -0.36605007
50 0.00345266 -1.05129175
51 -0.17753477 0.00345266
52 0.11062542 -0.17753477
53 0.34700626 0.11062542
54 0.30856338 0.34700626
55 0.10713388 0.30856338
56 0.57152942 0.10713388
57 0.73234203 0.57152942
58 0.50261174 0.73234203
59 0.90589721 0.50261174
60 -0.21730921 0.90589721
61 -0.03840704 -0.21730921
62 -0.14083619 -0.03840704
63 -0.29415882 -0.14083619
64 -0.06030907 -0.29415882
65 0.46833780 -0.06030907
66 0.04448529 0.46833780
67 0.46630697 0.04448529
68 -0.05646306 0.46630697
69 -0.32239439 -0.05646306
70 NA -0.32239439
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.47352529 0.65723709
[2,] 0.67305189 1.47352529
[3,] 0.71113966 0.67305189
[4,] 0.23366899 0.71113966
[5,] 0.04848986 0.23366899
[6,] -0.39995763 0.04848986
[7,] -0.44214082 -0.39995763
[8,] -0.22646406 -0.44214082
[9,] -0.12700148 -0.22646406
[10,] 0.10662592 -0.12700148
[11,] 0.15714122 0.10662592
[12,] 0.07014368 0.15714122
[13,] -0.06974165 0.07014368
[14,] 0.59477666 -0.06974165
[15,] 0.30975058 0.59477666
[16,] -0.23358787 0.30975058
[17,] -0.51643881 -0.23358787
[18,] -0.49883331 -0.51643881
[19,] -0.07261103 -0.49883331
[20,] -0.12849148 -0.07261103
[21,] -0.20398181 -0.12849148
[22,] 0.08311254 -0.20398181
[23,] -0.38662889 0.08311254
[24,] 0.27576688 -0.38662889
[25,] 0.11739505 0.27576688
[26,] -0.27769421 0.11739505
[27,] -0.23223325 -0.27769421
[28,] -0.42667301 -0.23223325
[29,] -0.31425550 -0.42667301
[30,] -0.45968565 -0.31425550
[31,] -0.87029610 -0.45968565
[32,] -0.97845375 -0.87029610
[33,] -0.93513741 -0.97845375
[34,] -0.34727941 -0.93513741
[35,] -0.34954876 -0.34727941
[36,] -0.41978836 -0.34954876
[37,] -0.43147990 -0.41978836
[38,] -0.85275082 -0.43147990
[39,] -0.31696340 -0.85275082
[40,] 0.37627553 -0.31696340
[41,] -0.03313960 0.37627553
[42,] 1.00542793 -0.03313960
[43,] 0.81160711 1.00542793
[44,] 0.81834293 0.81160711
[45,] 0.85617306 0.81834293
[46,] -0.34507079 0.85617306
[47,] -0.32686079 -0.34507079
[48,] -0.36605007 -0.32686079
[49,] -1.05129175 -0.36605007
[50,] 0.00345266 -1.05129175
[51,] -0.17753477 0.00345266
[52,] 0.11062542 -0.17753477
[53,] 0.34700626 0.11062542
[54,] 0.30856338 0.34700626
[55,] 0.10713388 0.30856338
[56,] 0.57152942 0.10713388
[57,] 0.73234203 0.57152942
[58,] 0.50261174 0.73234203
[59,] 0.90589721 0.50261174
[60,] -0.21730921 0.90589721
[61,] -0.03840704 -0.21730921
[62,] -0.14083619 -0.03840704
[63,] -0.29415882 -0.14083619
[64,] -0.06030907 -0.29415882
[65,] 0.46833780 -0.06030907
[66,] 0.04448529 0.46833780
[67,] 0.46630697 0.04448529
[68,] -0.05646306 0.46630697
[69,] -0.32239439 -0.05646306
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.47352529 0.65723709
2 0.67305189 1.47352529
3 0.71113966 0.67305189
4 0.23366899 0.71113966
5 0.04848986 0.23366899
6 -0.39995763 0.04848986
7 -0.44214082 -0.39995763
8 -0.22646406 -0.44214082
9 -0.12700148 -0.22646406
10 0.10662592 -0.12700148
11 0.15714122 0.10662592
12 0.07014368 0.15714122
13 -0.06974165 0.07014368
14 0.59477666 -0.06974165
15 0.30975058 0.59477666
16 -0.23358787 0.30975058
17 -0.51643881 -0.23358787
18 -0.49883331 -0.51643881
19 -0.07261103 -0.49883331
20 -0.12849148 -0.07261103
21 -0.20398181 -0.12849148
22 0.08311254 -0.20398181
23 -0.38662889 0.08311254
24 0.27576688 -0.38662889
25 0.11739505 0.27576688
26 -0.27769421 0.11739505
27 -0.23223325 -0.27769421
28 -0.42667301 -0.23223325
29 -0.31425550 -0.42667301
30 -0.45968565 -0.31425550
31 -0.87029610 -0.45968565
32 -0.97845375 -0.87029610
33 -0.93513741 -0.97845375
34 -0.34727941 -0.93513741
35 -0.34954876 -0.34727941
36 -0.41978836 -0.34954876
37 -0.43147990 -0.41978836
38 -0.85275082 -0.43147990
39 -0.31696340 -0.85275082
40 0.37627553 -0.31696340
41 -0.03313960 0.37627553
42 1.00542793 -0.03313960
43 0.81160711 1.00542793
44 0.81834293 0.81160711
45 0.85617306 0.81834293
46 -0.34507079 0.85617306
47 -0.32686079 -0.34507079
48 -0.36605007 -0.32686079
49 -1.05129175 -0.36605007
50 0.00345266 -1.05129175
51 -0.17753477 0.00345266
52 0.11062542 -0.17753477
53 0.34700626 0.11062542
54 0.30856338 0.34700626
55 0.10713388 0.30856338
56 0.57152942 0.10713388
57 0.73234203 0.57152942
58 0.50261174 0.73234203
59 0.90589721 0.50261174
60 -0.21730921 0.90589721
61 -0.03840704 -0.21730921
62 -0.14083619 -0.03840704
63 -0.29415882 -0.14083619
64 -0.06030907 -0.29415882
65 0.46833780 -0.06030907
66 0.04448529 0.46833780
67 0.46630697 0.04448529
68 -0.05646306 0.46630697
69 -0.32239439 -0.05646306
> 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/7ng5h1293198202.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/8y7521293198202.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/9y7521293198202.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/109gmn1293198202.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/11uh2s1293198202.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/12yzjh1293198202.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/13t9y71293198202.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/14miys1293198202.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/1581ey1293198202.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/16msc71293198202.tab")
+ }
>
> try(system("convert tmp/12x7b1293198202.ps tmp/12x7b1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/22x7b1293198202.ps tmp/22x7b1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/3v6oe1293198202.ps tmp/3v6oe1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/4v6oe1293198202.ps tmp/4v6oe1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/5v6oe1293198202.ps tmp/5v6oe1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ng5h1293198202.ps tmp/6ng5h1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ng5h1293198202.ps tmp/7ng5h1293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/8y7521293198202.ps tmp/8y7521293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/9y7521293198202.ps tmp/9y7521293198202.png",intern=TRUE))
character(0)
> try(system("convert tmp/109gmn1293198202.ps tmp/109gmn1293198202.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.230 2.630 5.276