Home » date » 2007 » Dec » 02 » attachments

Multiple Linear Regression

R Software Module: rwasp_multipleregression.wasp (opens new window with default values)
Title produced by software: Multiple Regression
Date of computation: Sun, 02 Dec 2007 04:37:30 -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/Dec/02/t1196594920e26p5rf3axsgwsr.htm/, Retrieved Sun, 02 Dec 2007 12:28:51 +0100
 
User-defined keywords:
Multiple Linear Regression
 
Dataseries X:
» Textbox « » Textfile « » CSV «
100.6 115.9 59.7 125 96.1 112.9 58.2 121.7 110 126.3 75.3 134.3 108.2 116.8 69 124.3 106.9 112 66.1 119.1 117.2 129.7 77.5 137.8 105.2 113.6 69.3 120.5 106.3 115.7 70.2 122.7 95.9 119.5 70.2 127.2 107.5 125.8 78.2 133.2 113 129.6 85.4 136.3 111.4 128 82.4 134.9 95.5 112.8 61.2 120.9 90.3 101.6 52.2 109.4 110.8 123.9 85.3 129.6 107.1 118.8 79.9 124.7 101.4 109.1 72.2 114.6 112.9 130.6 85.7 137.4 98.5 112.4 75.5 117.9 100.1 111 69.2 117.4 93.4 116.2 77.6 122 104.4 119.8 85.3 124.8 101.8 117.2 77 123.3 107.9 127.3 89.9 132.8 91.3 107.7 60 115.1 86.6 97.5 54.3 104.2 111.4 120.1 84 125.5 98.4 110.6 69.9 116.8 102.2 111.3 75.1 116.8 103 119.8 81.7 125.5 95.8 105.5 69.9 110.9 96 108.7 68.3 114.9 95.7 128.7 77.3 136.4 106.4 119.5 77.4 125.8 112 121.1 85.3 126.5 116.2 128.4 91 134 93.9 108.8 60.6 116.1 100.5 107.5 57.6 115 112.5 125.6 93.8 130.3 101.2 102.9 78.7 106.5 107.8 107.5 80.3 111.6 114.3 120.4 89.8 125 99.6 104.3 77.5 108.3 98.6 100.6 71.7 105 93.6 121.9 83.2 127.4 99.6 112.7 86.2 116.6 113.1 124.9 100.7 128.6 110.7 123.9 100.8 127.5 88.1 102.2 57.1 108.4 93.1 104.9 62.5 110.8 107.4 109.8 79.7 114.2 99.5 98.9 80.3 101.8 105.6 107.3 92.4 109.8 108.3 112.6 91.8 115.9 99.2 104 85.8 106.9 99.3 110.6 84.2 114.6 107.1 100.8 93.1 105.4 106.9 103.8 101.2 108.1 115.4 117 100.6 118.4 99 108.4 106.7 112.7 100.1 95.5 64 98.4 96.2 96.9 67.5 99.6 96.9 103.9 101 103.9 96.2 101.1 95.5 101.5 91 100.6 97 100.8 99 104.3 103.8 104.5 99 98 95.2 98.2 107.2 99.5 86.7 99.9 110.8 97.4 93.5 97.5 111.1 105.6 102.5 105.7 104.6 117.5 112.3 117.7 94.3 107.4 105.5 107.4 90.7 97.8 75.4 98.4 88.8 91.5 70.4 92 90.9 107.7 108 107.7 90.5 100.1 100 100.2 95.5 96.6 93.3 96.7 103.1 106.8 111.1 106.8 100.6 98 101.1 98 103.1 98.6 98.1 98.6
 
Text written by user:
Multiple Linear Regression
 
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
1[t] = + 53.2368533361207 + 0.761056250969949`2`[t] + 0.217444956801800`3`[t] -0.423766010526483`4 `[t] -0.115859441483030t + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)53.236853336120711.3106524.70681.1e-056e-06
`2`0.7610562509699490.8494750.89590.3731660.186583
`3`0.2174449568018000.1049142.07260.0416460.020823
`4 `-0.4237660105264830.769568-0.55070.5835070.291754
t-0.1158594414830300.072774-1.5920.115580.05779


Multiple Linear Regression - Regression Statistics
Multiple R0.692089938519227
R-squared0.478988482999547
Adjusted R-squared0.451201202092857
F-TEST (value)17.2376881569659
F-TEST (DF numerator)4
F-TEST (DF denominator)75
p-value4.56730875342259e-10
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation5.5816683947729
Sum Squared Residuals2336.62665519050


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
1100.6101.338125987312-0.738125987312079
296.1100.011358192454-3.91135819245363
3110108.4725095426451.52749045735504
4108.2103.9943725943614.20562740563907
5106.9101.7984360282355.10156397176537
6117.2109.7077203396157.49227966038502
7105.2102.8869585938492.31304140615083
8106.3103.6327325173662.66726748263360
995.9104.5019397822-8.6019397822
10107.5108.377698313083-0.877698313083153
11113111.4057816816271.59421831837322
12111.4110.0131697829241.38683021707649
1395.599.6521463898699-4.15214638986986
1490.393.9287614473618-3.62876144736176
15110.8109.4218110600131.37818893998678
16107.1106.3268154234330.773184576566506
17101.4101.434420886486-0.0344208864855695
18112.9110.9549127176771.94508728232308
1998.5103.033328154429-4.53332815442889
20100.1100.693969739000-0.59396973899984
2193.4104.412816791274-11.0128167912738
22104.4107.524541191182-3.12454119118232
23101.8104.260791371512-2.46079137151222
24107.9110.610862907567-2.71086290756729
2591.396.5773551250182-5.27735512501821
2686.692.0783351846101-5.47833518461011
27111.4106.5942462078474.80575379215273
2898.499.8691427828248-1.46914278282476
29102.2101.416736492390.783263507609949
30103105.518227607463-2.51822760746306
3195.898.1403970405352-2.34039704053519
329698.4169416291672-2.41694162916718
3395.7106.36824259198-10.6682425919799
34106.4103.7643298488342.63567015116573
35112106.2873393602695.71266063973116
36116.2109.7883817256886.41161827431192
3793.995.7309046668434-1.83090466684338
38100.594.43947984027326.06052015972685
39112.5109.4866260165163.01337398348386
40101.298.89700188083842.30299811916159
41107.8100.4687064710157.33129352898504
42114.3106.5577352156067.7422647843935
4399.698.59118954063741.00881045936258
4498.695.79666905585252.80333094414747
4593.6104.899566127457-11.2995661274569
4699.6103.010996961142-3.41099696114175
47113.1110.2477835288002.8522164711996
48110.7109.8587549436070.841245056393281
4988.191.819561044893-3.71956104489298
5093.193.915717822495-0.815717822494978
51107.499.82828283196567.57171716803441
5299.596.80207575951962.6979242404804
53105.6102.3200447192743.27995528072595
54108.3103.5223437696394.77765623036088
5599.299.370624923742-0.170624923742072
5699.3100.666826526724-1.36682652672391
57107.198.9265232381158.17347676188495
58106.9101.7109684712155.18903152878507
59115.4107.1457946600318.25420533996864
6099104.226731956699-5.22673195669872
61100.191.06820117279529.0317988272048
6296.292.27035861884463.92964138115538
6396.9102.944105141748-6.04410514174764
6496.2100.518379360402-4.31837936040241
6591100.644795436006-9.64479543600565
6699103.255535590416-4.25553559041568
679999.1447210056433-0.144721005643339
68107.297.6017615899059.5982384100951
69110.898.383348152900812.4166518470992
70111.1102.9902732942708.10972670572962
71104.6108.976751689670-4.37675168966958
7294.3104.060388315561-9.7603883155606
7390.793.9071897597702-3.20718975977023
7488.890.621553620537-1.82155362053702
7590.9104.357609455249-13.4576094552490
7690.599.8964079309286-9.39640793092863
7795.597.1431514373214-1.64315143732141
78103.1104.380549280486-1.28054928048642
79100.699.12208615508291.47791384491711
80103.198.55626598746054.54373401253946
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/1fhg21196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/1fhg21196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/2vczu1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/2vczu1196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/3x7qc1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/3x7qc1196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/4gexn1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/4gexn1196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/5xeqi1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/5xeqi1196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/6ucl81196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/6ucl81196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/7uogl1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/7uogl1196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/80e2x1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/80e2x1196595445.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/9o1sg1196595445.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Dec/02/t1196594920e26p5rf3axsgwsr/9o1sg1196595445.ps (open in new window)


 
Parameters:
par1 = 1 ; par2 = Do not include Seasonal 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