Home » date » 2007 » Nov » 15 » attachments

Workshop 6, question 3

R Software Module: rwasp_multipleregression.wasp (opens new window with default values)
Title produced by software: Multiple Regression
Date of computation: Thu, 15 Nov 2007 05:23:03 -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/15/t1195129263jk2q90bwoo1k0h4.htm/, Retrieved Thu, 15 Nov 2007 13:21:14 +0100
 
User-defined keywords:
Workshop 6, question 3, Workshop 6, question 3, multiple lineair regression, seaonality, lineair trend, lineaire trend
 
Dataseries X:
» Textbox « » Textfile « » CSV «
108.4 106.7 117 100.6 103.8 101.2 100.8 93.1 110.6 84.2 104 85.8 112.6 91.8 107.3 92.4 98.9 80.3 109.8 79.7 104.9 62.5 102.2 57.1 123.9 100.8 124.9 100.7 112.7 86.2 121.9 83.2 100.6 71.7 104.3 77.5 120.4 89.8 107.5 80.3 102.9 78.7 125.6 93.8 107.5 57.6 108.8 60.6 128.4 91 121.1 85.3 119.5 77.4 128.7 77.3 108.7 68.3 105.5 69.9 119.8 81.7 111.3 75.1 110.6 69.9 120.1 84 97.5 54.3 107.7 60 127.3 89.9 117.2 77 119.8 85.3 116.2 77.6 111 69.2 112.4 75.5 130.6 85.7 109.1 72.2 118.8 79.9 123.9 85.3 101.6 52.2 112.8 61.2 128 82.4 129.6 85.4 125.8 78.2 119.5 70.2 115.7 70.2 113.6 69.3 129.7 77.5 112 66.1 116.8 69 126.3 75.3 112.9 58.2 115.9 59.7
 
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 time3 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Multiple Linear Regression - Estimated Regression Equation
Y[t] = + 46.7786688827454 + 0.233342458448343X[t] + 27.3870133153562M1[t] + 23.6664968869897M2[t] + 21.1926872757958M3[t] + 15.9061494946601M4[t] + 10.5863623312492M5[t] + 14.1338469978965M6[t] + 20.7631854802013M7[t] + 16.1087780057079M8[t] + 14.7615821355137M9[t] + 20.4789490881773M10[t] -2.03676361429512M11[t] -0.350138923157501t + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)46.778668882745415.4546163.02680.0040390.00202
X0.2333424584483430.1518511.53660.131230.065615
M127.38701331535624.1333816.625800
M223.66649688698973.9951675.923800
M321.19268727579583.5552555.960900
M415.90614949466013.6036094.4146.1e-053e-05
M510.58636233124923.2740763.23340.0022660.001133
M614.13384699789653.261524.33357.9e-053.9e-05
M720.76318548020133.9268555.28753e-062e-06
M816.10877800570793.2602864.94091.1e-055e-06
M914.76158213551373.2579934.53094.2e-052.1e-05
M1020.47894908817733.742525.4722e-061e-06
M11-2.036763614295123.319451-0.61360.5425120.271256
t-0.3501389231575010.055309-6.330500


Multiple Linear Regression - Regression Statistics
Multiple R0.934214213782551
R-squared0.87275619723335
Adjusted R-squared0.836795992103645
F-TEST (value)24.2700561380391
F-TEST (DF numerator)13
F-TEST (DF denominator)46
p-value2.22044604925031e-16
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation5.14353483274104
Sum Squared Residuals1216.97372647854


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
1106.799.10986577074447.59013422925556
2100.697.04595556187623.55404443812376
3101.291.141886576006810.0581134239932
493.184.80518249636868.29481750363144
584.281.4220125025942.77798749740609
685.883.07929802032462.72070197967542
791.891.36524272212760.434757277872374
892.485.12398129470067.27601870529944
980.381.4665698503827-1.16656985038274
1079.789.3772306769758-9.67723067697578
1162.565.368001004949-2.86800100494898
1257.166.4246010582761-9.32460105827608
13100.898.52500679880392.27499320119612
14100.794.68769390572816.01230609427187
1586.289.016967378307-2.81696737830701
1683.285.5270412917386-2.32704129173858
1771.774.8869208402205-3.18692084022045
1877.578.947633679969-1.44763367996907
1989.888.98364682013470.816353179865309
2080.380.9689827085002-0.668982708500228
2178.778.19827260628610.501727393713884
2293.888.86237444256964.93762555743037
2357.661.7730243190247-4.17302431902467
2460.663.7629942061451-3.16299420614513
259195.3733807839314-4.37338078393141
2685.389.5993254857344-4.29932548573443
2777.486.4020290178657-9.00202901786573
2877.382.9121029312973-5.61210293129731
2968.372.575327675762-4.27532767576203
3069.975.025977552217-5.12597755221707
3181.784.6419742671757-2.94197426717567
3275.177.6540169727139-2.55401697271392
3369.975.7933424584484-5.89334245844834
348483.37732384321370.622676156786272
3554.355.2379326566512-0.937932656651237
366059.30465042396190.695349576038052
3789.990.9150370017482-1.01503700174822
387784.4876228198959-7.48762281989588
3985.382.27036467751023.02963532248977
4077.675.7936551228031.80634487719698
4169.268.91034825230320.289651747696798
4275.572.43437343762063.06562656237936
4385.782.96040574052782.73959425947224
4472.272.9389964862376-0.738996486237551
4579.973.50508353983486.39491646016525
4685.380.06235810742745.23764189257257
4752.251.99296965839940.207030341600577
4861.256.29302988415854.90697011584152
4982.486.876709644772-4.47670964477205
5085.483.17940222676532.22059777323468
5178.279.4687523503103-1.26875235031028
5270.272.3620181577925-2.16201815779253
5370.265.80539072912044.39460927087959
5469.368.51271730986860.787282690131359
5577.578.5487304500343-1.04873045003425
5666.169.4140225378478-3.31402253784776
576968.8367315450480.163268454951940
5875.376.4207129298134-1.12071292981344
5958.250.42807236097577.77192763902431
6059.752.81472442745846.88527557254165
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/14hg91195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/14hg91195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/2xpb91195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/2xpb91195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/3sijv1195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/3sijv1195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/4t7o21195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/4t7o21195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/583dn1195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/583dn1195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/607nb1195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/607nb1195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/7jo7c1195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/7jo7c1195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/8u2wc1195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/8u2wc1195129379.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/95a3w1195129379.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195129263jk2q90bwoo1k0h4/95a3w1195129379.ps (open in new window)


 
Parameters:
par1 = 2 ; par2 = Do not include Seasonal Dummies ; par3 = No 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