Home » date » 2007 » Nov » 19 » attachments

R Software Module: rwasp_multipleregression.wasp (opens new window with default values)
Title produced by software: Multiple Regression
Date of computation: Mon, 19 Nov 2007 15:57:19 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd.htm/, Retrieved Mon, 19 Nov 2007 23:50:15 +0100
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
99.5 0 101.6 0 103.9 0 106.6 0 108.3 0 102 0 93.8 0 91.6 0 97.7 0 94.8 0 98 0 103.8 0 97.8 0 91.2 0 89.3 0 87.5 0 90.4 0 94.2 0 102.2 0 101.3 0 96 0 90.8 0 93.2 0 90.9 0 91.1 0 90.2 0 94.3 0 96 0 99 0 103.3 0 113.1 0 112.8 0 112.1 0 107.4 0 111 0 110.5 0 110.8 0 112.4 0 111.5 0 116.2 0 122.5 0 121.3 0 113.9 0 110.7 0 120.8 0 141.1 1 147.4 1 148 1 158.1 1 165 1 187 1 190.3 1 182.4 1 168.8 1 151.2 1 120.1 1 112.5 1 106.2 1 107.1 1 108.5 1 106.5 1 108.3 1 125.6 1 124 1 127.2 1 136.9 1 135.8 1 124.3 1 115.4 1 113.6 1 114.4 1 118.4 1 117 1 116.5 1 115.4 1 113.6 1 117.4 1 116.9 1 116.4 1 111.1 1 110.2 1 118.9 1 131.8 1 130.6 1 138.3 1 148.4 1 148.7 1 144.3 1 152.5 1 162.9 1 167.2 1 166.5 1 185.6 1
 
Text written by user:
 
Output produced by software:

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!


Summary of compuational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time5 seconds
R Server'Herman Ole Andreas Wold' @ 193.190.124.10:1001


Multiple Linear Regression - Estimated Regression Equation
Y[t] = + 94.5481481481482 + 27.6650462962963x[t] + 1.61778273809523M1[t] + 3.31658399470900M2[t] + 8.46538525132275M3[t] + 8.7016865079365M4[t] + 11.2379877645503M5[t] + 11.9492890211640M6[t] + 10.2480902777778M7[t] + 3.23439153439153M8[t] + 4.60819279100529M9[t] -5.18688822751323M10[t] -1.00058697089947M11[t] + 0.113698743386243t + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)94.54814814814828.26558811.438800
x27.66504629629638.1091283.41160.0010210.00051
M11.617782738095239.9481060.16260.8712310.435616
M23.316583994709009.9454230.33350.7396570.369828
M38.465385251322759.9450390.85120.3972220.198611
M48.70168650793659.9469560.87480.384330.192165
M511.23798776455039.9511711.12930.2621830.131092
M611.94928902116409.9576821.20.2337230.116861
M710.24809027777789.9664841.02830.3069680.153484
M83.234391534391539.9775710.32420.7466690.373334
M94.608192791005299.9909360.46120.6458960.322948
M10-5.1868882275132310.271291-0.5050.6149720.307486
M11-1.0005869708994710.26795-0.09740.9226180.461309
t0.1136987433862430.1512450.75180.4544330.227217


Multiple Linear Regression - Regression Statistics
Multiple R0.695525186305115
R-squared0.483755284784765
Adjusted R-squared0.398803622787321
F-TEST (value)5.6944769932732
F-TEST (DF numerator)13
F-TEST (DF denominator)79
p-value3.14955991953525e-07
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation19.2074917059669
Sum Squared Residuals29145.2912731482


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
199.596.27962962962973.22037037037033
2101.698.09212962962963.50787037037038
3103.9103.3546296296300.54537037037038
4106.6103.7046296296302.89537037037037
5108.3106.3546296296301.94537037037038
6102107.179629629630-5.17962962962963
793.8105.592129629630-11.7921296296296
891.698.6921296296296-7.09212962962964
997.7100.179629629630-2.47962962962962
1094.890.49824735449744.30175264550264
119894.79824735449733.20175264550265
12103.895.9125330687837.88746693121693
1397.897.64401455026450.155985449735449
1491.299.4565145502646-8.25651455026456
1589.3104.719014550265-15.4190145502646
1687.5105.069014550265-17.5690145502646
1790.4107.719014550265-17.3190145502646
1894.2108.544014550265-14.3440145502646
19102.2106.956514550265-4.75651455026454
20101.3100.0565145502651.24348544973545
2196101.544014550265-5.54401455026455
2290.891.8626322751323-1.06263227513227
2393.296.1626322751323-2.96263227513228
2490.997.276917989418-6.37691798941798
2591.199.0083994708995-7.90839947089947
2690.2100.820899470899-10.6208994708995
2794.3106.083399470899-11.7833994708995
2896106.433399470899-10.4333994708995
2999109.083399470899-10.0833994708995
30103.3109.908399470899-6.60839947089947
31113.1108.3208994708994.77910052910053
32112.8101.42089947089911.3791005291005
33112.1102.9083994708999.19160052910053
34107.493.227017195767214.1729828042328
3511197.527017195767213.4729828042328
36110.598.641302910052911.8586970899471
37110.8100.37278439153410.4272156084656
38112.4102.18528439153410.2147156084656
39111.5107.4477843915344.05221560846561
40116.2107.7977843915348.40221560846561
41122.5110.44778439153412.0522156084656
42121.3111.27278439153410.0272156084656
43113.9109.6852843915344.21471560846562
44110.7102.7852843915347.91471560846562
45120.8104.27278439153416.5272156084656
46141.1122.25644841269818.8435515873016
47147.4126.55644841269820.8435515873016
48148127.67073412698420.3292658730159
49158.1129.40221560846628.6977843915344
50165131.21471560846633.7852843915344
51187136.47721560846650.5227843915344
52190.3136.82721560846653.4727843915344
53182.4139.47721560846642.9227843915344
54168.8140.30221560846628.4977843915344
55151.2138.71471560846612.4852843915344
56120.1131.814715608466-11.7147156084656
57112.5133.302215608466-20.8022156084656
58106.2123.620833333333-17.4208333333333
59107.1127.920833333333-20.8208333333334
60108.5129.035119047619-20.5351190476191
61106.5130.766600529101-24.2666005291005
62108.3132.579100529101-24.2791005291005
63125.6137.841600529101-12.2416005291005
64124138.191600529101-14.1916005291005
65127.2140.841600529101-13.6416005291005
66136.9141.666600529101-4.76660052910053
67135.8140.079100529101-4.27910052910052
68124.3133.179100529101-8.87910052910053
69115.4134.666600529101-19.2666005291005
70113.6124.985218253968-11.3852182539683
71114.4129.285218253968-14.8852182539683
72118.4130.399503968254-11.9995039682540
73117132.130985449735-15.1309854497354
74116.5133.943485449735-17.4434854497355
75115.4139.205985449735-23.8059854497354
76113.6139.555985449735-25.9559854497355
77117.4142.205985449735-24.8059854497355
78116.9143.030985449735-26.1309854497355
79116.4141.443485449735-25.0434854497354
80111.1134.543485449735-23.4434854497355
81110.2136.030985449735-25.8309854497354
82118.9126.349603174603-7.44960317460317
83131.8130.6496031746031.15039682539683
84130.6131.763888888889-1.16388888888890
85138.3133.4953703703704.80462962962964
86148.4135.30787037037013.0921296296296
87148.7140.5703703703708.12962962962961
88144.3140.9203703703703.37962962962964
89152.5143.5703703703708.92962962962963
90162.9144.39537037037018.5046296296296
91167.2142.80787037037024.3921296296296
92166.5135.90787037037030.5921296296296
93185.6137.39537037037048.2046296296296
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/1c9gq1195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/1c9gq1195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/28mn61195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/28mn61195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/3kcdr1195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/3kcdr1195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/40vv21195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/40vv21195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/55ijy1195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/55ijy1195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/617py1195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/617py1195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/7qmt11195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/7qmt11195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/88yk51195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/88yk51195513030.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/9i0dj1195513030.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/19/t11955126157k5xwjvmkapa2yd/9i0dj1195513030.ps (open in new window)


 
Parameters:
par1 = 1 ; par2 = Include Monthly Dummies ; par3 = Linear Trend ;
 
R code (references can be found in the software module):
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
k <- length(x[1,])
df <- as.data.frame(x)
(mylm <- lm(df))
(mysum <- summary(mylm))
bitmap(file='test0.png')
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()
bitmap(file='test1.png')
plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
grid()
dev.off()
bitmap(file='test2.png')
hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
grid()
dev.off()
bitmap(file='test3.png')
densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
dev.off()
bitmap(file='test4.png')
qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
grid()
dev.off()
(myerror <- as.ts(mysum$resid))
bitmap(file='test5.png')
dum <- cbind(lag(myerror,k=1),myerror)
dum
dum1 <- dum[2:length(myerror),]
dum1
z <- as.data.frame(dum1)
z
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()
bitmap(file='test6.png')
acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
grid()
dev.off()
bitmap(file='test7.png')
pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
grid()
dev.off()
bitmap(file='test8.png')
opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
plot(mylm, las = 1, sub='Residual Diagnostics')
par(opar)
dev.off()
load(file='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='mytable1.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<br />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='mytable2.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='mytable3.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<br />Forecast', 1, TRUE)
a<-table.element(a, 'Residuals<br />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='mytable4.tab')
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by