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(10.51
+ ,7.63
+ ,-15.57
+ ,16.07
+ ,-1.02
+ ,-1.52
+ ,-7
+ ,-8.58
+ ,-2.68
+ ,5.71
+ ,-2.08
+ ,5.08
+ ,-9.75
+ ,13.19
+ ,6.06
+ ,0.09
+ ,3.64
+ ,-5.5
+ ,3.1
+ ,3.83
+ ,9.5
+ ,1.77
+ ,-7.28
+ ,5.82
+ ,-0.33
+ ,1.97
+ ,11.93
+ ,37.12
+ ,-0.99
+ ,-5.61
+ ,-15.18
+ ,-0.46
+ ,3.16
+ ,-7.32
+ ,-4.97
+ ,-3.63
+ ,4.27
+ ,-1.09
+ ,-3.06
+ ,-3.88
+ ,-2.97
+ ,-0.1
+ ,5.18
+ ,4.62
+ ,-7.49
+ ,-9.4
+ ,-2.3
+ ,-12.97
+ ,0.33
+ ,-6.39
+ ,-1.86
+ ,3.2
+ ,-2.57
+ ,-2.03
+ ,-8.75
+ ,-5.75
+ ,4.07
+ ,0.9
+ ,-8.02
+ ,-0.57
+ ,5.31
+ ,7.57
+ ,4.8
+ ,-7.16
+ ,-8.09
+ ,-2.19
+ ,3.9
+ ,-18.05
+ ,5.29
+ ,3.59
+ ,-11.31
+ ,15.63
+ ,7.38
+ ,-1.69
+ ,4.26
+ ,-18.68
+ ,-6.12
+ ,-1.54
+ ,-6.89
+ ,-0.7
+ ,-3.38
+ ,13.36
+ ,4.13
+ ,2.59
+ ,-8.61
+ ,-3.66
+ ,4.25
+ ,2.57
+ ,2.58
+ ,0.61
+ ,-5.92
+ ,0.36
+ ,10.02
+ ,9.25
+ ,-2.62
+ ,32.56
+ ,7.08
+ ,11.03
+ ,-5.12
+ ,8.53
+ ,-2.75
+ ,-3.5
+ ,-6.19
+ ,1.42
+ ,3.42
+ ,-6.56
+ ,1.58
+ ,3.53
+ ,-1.6
+ ,5.55
+ ,6.93
+ ,0.9
+ ,0.65
+ ,16.5
+ ,1.3
+ ,-1.1
+ ,2.86
+ ,-0.09
+ ,0.7
+ ,13.32
+ ,-3.52
+ ,-10.19
+ ,18.15
+ ,-33.59
+ ,5.65
+ ,-1.56
+ ,-13.63
+ ,-0.85
+ ,4.31
+ ,3.62
+ ,-8.97
+ ,42.09
+ ,-4.39
+ ,-3.46
+ ,-3.48
+ ,-6.25
+ ,-5.85
+ ,-0.84
+ ,0.13
+ ,-11.08
+ ,-5.47
+ ,-1.75
+ ,0.16
+ ,-29.29
+ ,-2.3
+ ,-5.59
+ ,-1.28
+ ,-11.17
+ ,-0.14
+ ,-4.31
+ ,-8.46
+ ,13.92
+ ,8.08
+ ,8.29
+ ,-2.92
+ ,13.54
+ ,-7.43
+ ,-14.07
+ ,0.15
+ ,-16.49
+ ,0.02
+ ,-4.08
+ ,3.87
+ ,-9.38
+ ,-2.47
+ ,3.96
+ ,7.71
+ ,-2.84
+ ,-2.11
+ ,-2.54
+ ,-4.12
+ ,-2.88
+ ,7.87
+ ,24.36
+ ,-2.74
+ ,6.18
+ ,4.66
+ ,11.73
+ ,3.19
+ ,3.71
+ ,3.6
+ ,3.82
+ ,-6.22
+ ,3.18
+ ,-3.64
+ ,-2.98
+ ,1.25
+ ,-4.18
+ ,7.26
+ ,7.46
+ ,4.24
+ ,13.6
+ ,-7.62
+ ,-6.39
+ ,0.15
+ ,4.82
+ ,13.83
+ ,11.7
+ ,-2.06
+ ,10.05
+ ,1.28
+ ,2.36
+ ,2.14
+ ,9.69
+ ,-0.32
+ ,-7.48
+ ,-1.68
+ ,-13.63
+ ,-2.9
+ ,-2.54
+ ,5.03
+ ,2.81
+ ,4.92
+ ,-2.31
+ ,2.25
+ ,2.39
+ ,11.99
+ ,10.86
+ ,-6.58
+ ,9.12
+ ,10.06
+ ,-2.11
+ ,-2.85
+ ,14.21
+ ,-2.22
+ ,3.41
+ ,5.04
+ ,3.49
+ ,3.97
+ ,11.2
+ ,4.44
+ ,5.51
+ ,0.56
+ ,-1.21
+ ,-0.68
+ ,-6.15
+ ,3.34
+ ,5.82
+ ,-2.51
+ ,2.72
+ ,-2.86
+ ,-2.61
+ ,2.36
+ ,-11.12
+ ,4.38
+ ,-1.54
+ ,-6.32
+ ,-4.7
+ ,1.43
+ ,-5.42
+ ,-3.82
+ ,1.82
+ ,-0.49
+ ,11.6
+ ,2.17
+ ,-10.44
+ ,-1.23
+ ,-9.07
+ ,4.14
+ ,6.04)
+ ,dim=c(4
+ ,65)
+ ,dimnames=list(c('Producten'
+ ,'Machines'
+ ,'Electronica'
+ ,'Medisch')
+ ,1:65))
> y <- array(NA,dim=c(4,65),dimnames=list(c('Producten','Machines','Electronica','Medisch'),1:65))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '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)
> 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
Producten Machines Electronica Medisch
1 10.51 7.63 -15.57 16.07
2 -1.02 -1.52 -7.00 -8.58
3 -2.68 5.71 -2.08 5.08
4 -9.75 13.19 6.06 0.09
5 3.64 -5.50 3.10 3.83
6 9.50 1.77 -7.28 5.82
7 -0.33 1.97 11.93 37.12
8 -0.99 -5.61 -15.18 -0.46
9 3.16 -7.32 -4.97 -3.63
10 4.27 -1.09 -3.06 -3.88
11 -2.97 -0.10 5.18 4.62
12 -7.49 -9.40 -2.30 -12.97
13 0.33 -6.39 -1.86 3.20
14 -2.57 -2.03 -8.75 -5.75
15 4.07 0.90 -8.02 -0.57
16 5.31 7.57 4.80 -7.16
17 -8.09 -2.19 3.90 -18.05
18 5.29 3.59 -11.31 15.63
19 7.38 -1.69 4.26 -18.68
20 -6.12 -1.54 -6.89 -0.70
21 -3.38 13.36 4.13 2.59
22 -8.61 -3.66 4.25 2.57
23 2.58 0.61 -5.92 0.36
24 10.02 9.25 -2.62 32.56
25 7.08 11.03 -5.12 8.53
26 -2.75 -3.50 -6.19 1.42
27 3.42 -6.56 1.58 3.53
28 -1.60 5.55 6.93 0.90
29 0.65 16.50 1.30 -1.10
30 2.86 -0.09 0.70 13.32
31 -3.52 -10.19 18.15 -33.59
32 5.65 -1.56 -13.63 -0.85
33 4.31 3.62 -8.97 42.09
34 -4.39 -3.46 -3.48 -6.25
35 -5.85 -0.84 0.13 -11.08
36 -5.47 -1.75 0.16 -29.29
37 -2.30 -5.59 -1.28 -11.17
38 -0.14 -4.31 -8.46 13.92
39 8.08 8.29 -2.92 13.54
40 -7.43 -14.07 0.15 -16.49
41 0.02 -4.08 3.87 -9.38
42 -2.47 3.96 7.71 -2.84
43 -2.11 -2.54 -4.12 -2.88
44 7.87 24.36 -2.74 6.18
45 4.66 11.73 3.19 3.71
46 3.60 3.82 -6.22 3.18
47 -3.64 -2.98 1.25 -4.18
48 7.26 7.46 4.24 13.60
49 -7.62 -6.39 0.15 4.82
50 13.83 11.70 -2.06 10.05
51 1.28 2.36 2.14 9.69
52 -0.32 -7.48 -1.68 -13.63
53 -2.90 -2.54 5.03 2.81
54 4.92 -2.31 2.25 2.39
55 11.99 10.86 -6.58 9.12
56 10.06 -2.11 -2.85 14.21
57 -2.22 3.41 5.04 3.49
58 3.97 11.20 4.44 5.51
59 0.56 -1.21 -0.68 -6.15
60 3.34 5.82 -2.51 2.72
61 -2.86 -2.61 2.36 -11.12
62 4.38 -1.54 -6.32 -4.70
63 1.43 -5.42 -3.82 1.82
64 -0.49 11.60 2.17 -10.44
65 -1.23 -9.07 4.14 6.04
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Machines Electronica Medisch
0.3442 0.2443 -0.2408 0.1208
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-11.8685 -2.7687 0.1678 2.7379 10.7317
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.34424 0.56443 0.610 0.54420
Machines 0.24431 0.08277 2.952 0.00448 **
Electronica -0.24078 0.09335 -2.579 0.01233 *
Medisch 0.12084 0.04855 2.489 0.01555 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.439 on 61 degrees of freedom
Multiple R-squared: 0.366, Adjusted R-squared: 0.3348
F-statistic: 11.74 on 3 and 61 DF, p-value: 3.608e-06
> postscript(file="/var/www/html/freestat/rcomp/tmp/17io41230473946.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/freestat/rcomp/tmp/2oj041230473946.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/freestat/rcomp/tmp/33jq01230473946.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/freestat/rcomp/tmp/419i31230473946.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/freestat/rcomp/tmp/5viij1230473946.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 65
Frequency = 1
1 2 3 4 5 6
2.6107286 -1.6415151 -5.5339713 -11.8684508 4.9230721 6.2671282
7 8 9 10 11 12
-2.7687260 -3.5631261 3.8461053 3.9241453 -2.6008536 -4.5241567
13 14 15 16 17 18
0.7123634 -3.8302722 1.6436931 5.1373157 -4.7789128 -0.5433485
19 20 21 22 23 24
10.7317442 -7.6623921 -6.3068024 -7.3472998 0.6178008 2.8503536
25 26 27 28 29 30
1.7774003 -3.9011820 4.6323076 -1.7403096 -3.2794413 1.0966594
31 32 33 34 35 36
7.0546384 2.5077509 -4.1647756 -3.9715636 -4.6187631 -1.8086498
37 38 39 40 41 42
-0.2369072 -3.1504117 3.3711081 -2.3079335 2.7378977 -1.5820877
43 44 45 46 47 48
-2.4776748 0.1677639 1.7697463 0.4405449 -2.4500819 4.4706346
49 50 51 52 53 54
-6.9494320 8.9168211 -0.2965163 2.4058057 -1.7521220 5.3930670
55 56 57 58 59 60
6.3060940 7.8278432 -2.6055450 1.2926902 1.0908390 0.6408096
61 62 63 64 65
-0.6545534 3.4582288 1.2702127 -1.8841506 0.9086146
> postscript(file="/var/www/html/freestat/rcomp/tmp/69ows1230473946.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 = 65
Frequency = 1
lag(myerror, k = 1) myerror
0 2.6107286 NA
1 -1.6415151 2.6107286
2 -5.5339713 -1.6415151
3 -11.8684508 -5.5339713
4 4.9230721 -11.8684508
5 6.2671282 4.9230721
6 -2.7687260 6.2671282
7 -3.5631261 -2.7687260
8 3.8461053 -3.5631261
9 3.9241453 3.8461053
10 -2.6008536 3.9241453
11 -4.5241567 -2.6008536
12 0.7123634 -4.5241567
13 -3.8302722 0.7123634
14 1.6436931 -3.8302722
15 5.1373157 1.6436931
16 -4.7789128 5.1373157
17 -0.5433485 -4.7789128
18 10.7317442 -0.5433485
19 -7.6623921 10.7317442
20 -6.3068024 -7.6623921
21 -7.3472998 -6.3068024
22 0.6178008 -7.3472998
23 2.8503536 0.6178008
24 1.7774003 2.8503536
25 -3.9011820 1.7774003
26 4.6323076 -3.9011820
27 -1.7403096 4.6323076
28 -3.2794413 -1.7403096
29 1.0966594 -3.2794413
30 7.0546384 1.0966594
31 2.5077509 7.0546384
32 -4.1647756 2.5077509
33 -3.9715636 -4.1647756
34 -4.6187631 -3.9715636
35 -1.8086498 -4.6187631
36 -0.2369072 -1.8086498
37 -3.1504117 -0.2369072
38 3.3711081 -3.1504117
39 -2.3079335 3.3711081
40 2.7378977 -2.3079335
41 -1.5820877 2.7378977
42 -2.4776748 -1.5820877
43 0.1677639 -2.4776748
44 1.7697463 0.1677639
45 0.4405449 1.7697463
46 -2.4500819 0.4405449
47 4.4706346 -2.4500819
48 -6.9494320 4.4706346
49 8.9168211 -6.9494320
50 -0.2965163 8.9168211
51 2.4058057 -0.2965163
52 -1.7521220 2.4058057
53 5.3930670 -1.7521220
54 6.3060940 5.3930670
55 7.8278432 6.3060940
56 -2.6055450 7.8278432
57 1.2926902 -2.6055450
58 1.0908390 1.2926902
59 0.6408096 1.0908390
60 -0.6545534 0.6408096
61 3.4582288 -0.6545534
62 1.2702127 3.4582288
63 -1.8841506 1.2702127
64 0.9086146 -1.8841506
65 NA 0.9086146
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.6415151 2.6107286
[2,] -5.5339713 -1.6415151
[3,] -11.8684508 -5.5339713
[4,] 4.9230721 -11.8684508
[5,] 6.2671282 4.9230721
[6,] -2.7687260 6.2671282
[7,] -3.5631261 -2.7687260
[8,] 3.8461053 -3.5631261
[9,] 3.9241453 3.8461053
[10,] -2.6008536 3.9241453
[11,] -4.5241567 -2.6008536
[12,] 0.7123634 -4.5241567
[13,] -3.8302722 0.7123634
[14,] 1.6436931 -3.8302722
[15,] 5.1373157 1.6436931
[16,] -4.7789128 5.1373157
[17,] -0.5433485 -4.7789128
[18,] 10.7317442 -0.5433485
[19,] -7.6623921 10.7317442
[20,] -6.3068024 -7.6623921
[21,] -7.3472998 -6.3068024
[22,] 0.6178008 -7.3472998
[23,] 2.8503536 0.6178008
[24,] 1.7774003 2.8503536
[25,] -3.9011820 1.7774003
[26,] 4.6323076 -3.9011820
[27,] -1.7403096 4.6323076
[28,] -3.2794413 -1.7403096
[29,] 1.0966594 -3.2794413
[30,] 7.0546384 1.0966594
[31,] 2.5077509 7.0546384
[32,] -4.1647756 2.5077509
[33,] -3.9715636 -4.1647756
[34,] -4.6187631 -3.9715636
[35,] -1.8086498 -4.6187631
[36,] -0.2369072 -1.8086498
[37,] -3.1504117 -0.2369072
[38,] 3.3711081 -3.1504117
[39,] -2.3079335 3.3711081
[40,] 2.7378977 -2.3079335
[41,] -1.5820877 2.7378977
[42,] -2.4776748 -1.5820877
[43,] 0.1677639 -2.4776748
[44,] 1.7697463 0.1677639
[45,] 0.4405449 1.7697463
[46,] -2.4500819 0.4405449
[47,] 4.4706346 -2.4500819
[48,] -6.9494320 4.4706346
[49,] 8.9168211 -6.9494320
[50,] -0.2965163 8.9168211
[51,] 2.4058057 -0.2965163
[52,] -1.7521220 2.4058057
[53,] 5.3930670 -1.7521220
[54,] 6.3060940 5.3930670
[55,] 7.8278432 6.3060940
[56,] -2.6055450 7.8278432
[57,] 1.2926902 -2.6055450
[58,] 1.0908390 1.2926902
[59,] 0.6408096 1.0908390
[60,] -0.6545534 0.6408096
[61,] 3.4582288 -0.6545534
[62,] 1.2702127 3.4582288
[63,] -1.8841506 1.2702127
[64,] 0.9086146 -1.8841506
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.6415151 2.6107286
2 -5.5339713 -1.6415151
3 -11.8684508 -5.5339713
4 4.9230721 -11.8684508
5 6.2671282 4.9230721
6 -2.7687260 6.2671282
7 -3.5631261 -2.7687260
8 3.8461053 -3.5631261
9 3.9241453 3.8461053
10 -2.6008536 3.9241453
11 -4.5241567 -2.6008536
12 0.7123634 -4.5241567
13 -3.8302722 0.7123634
14 1.6436931 -3.8302722
15 5.1373157 1.6436931
16 -4.7789128 5.1373157
17 -0.5433485 -4.7789128
18 10.7317442 -0.5433485
19 -7.6623921 10.7317442
20 -6.3068024 -7.6623921
21 -7.3472998 -6.3068024
22 0.6178008 -7.3472998
23 2.8503536 0.6178008
24 1.7774003 2.8503536
25 -3.9011820 1.7774003
26 4.6323076 -3.9011820
27 -1.7403096 4.6323076
28 -3.2794413 -1.7403096
29 1.0966594 -3.2794413
30 7.0546384 1.0966594
31 2.5077509 7.0546384
32 -4.1647756 2.5077509
33 -3.9715636 -4.1647756
34 -4.6187631 -3.9715636
35 -1.8086498 -4.6187631
36 -0.2369072 -1.8086498
37 -3.1504117 -0.2369072
38 3.3711081 -3.1504117
39 -2.3079335 3.3711081
40 2.7378977 -2.3079335
41 -1.5820877 2.7378977
42 -2.4776748 -1.5820877
43 0.1677639 -2.4776748
44 1.7697463 0.1677639
45 0.4405449 1.7697463
46 -2.4500819 0.4405449
47 4.4706346 -2.4500819
48 -6.9494320 4.4706346
49 8.9168211 -6.9494320
50 -0.2965163 8.9168211
51 2.4058057 -0.2965163
52 -1.7521220 2.4058057
53 5.3930670 -1.7521220
54 6.3060940 5.3930670
55 7.8278432 6.3060940
56 -2.6055450 7.8278432
57 1.2926902 -2.6055450
58 1.0908390 1.2926902
59 0.6408096 1.0908390
60 -0.6545534 0.6408096
61 3.4582288 -0.6545534
62 1.2702127 3.4582288
63 -1.8841506 1.2702127
64 0.9086146 -1.8841506
> 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/76mld1230473946.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/freestat/rcomp/tmp/8tyhb1230473946.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/freestat/rcomp/tmp/9sxh41230473946.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
>
> #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/109skd1230473946.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/11jb3s1230473946.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/12sgs41230473946.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/13yvfk1230473946.tab")
>
> system("convert tmp/17io41230473946.ps tmp/17io41230473946.png")
> system("convert tmp/2oj041230473946.ps tmp/2oj041230473946.png")
> system("convert tmp/33jq01230473946.ps tmp/33jq01230473946.png")
> system("convert tmp/419i31230473946.ps tmp/419i31230473946.png")
> system("convert tmp/5viij1230473946.ps tmp/5viij1230473946.png")
> system("convert tmp/69ows1230473946.ps tmp/69ows1230473946.png")
> system("convert tmp/76mld1230473946.ps tmp/76mld1230473946.png")
> system("convert tmp/8tyhb1230473946.ps tmp/8tyhb1230473946.png")
> system("convert tmp/9sxh41230473946.ps tmp/9sxh41230473946.png")
>
>
> proc.time()
user system elapsed
3.007 2.246 3.366