MATRIX CALCULATIONS IN R R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. Type 'license()' or 'licence()' for distribution details. > lotsize<-read.table(stdin(), header=F) 0: 80 399 1: 30 121 2: 50 221 3: 90 376 4: 70 361 6: 60 224 7: 120 546 8: 80 352 9: 100 353 10: 50 157 11: 40 160 12: 70 252 13: 90 389 14: 20 113 15: 110 435 16: 100 420 17: 30 212 18: 50 268 19: 90 377 20: 110 421 21: 30 273 22: 90 468 23: 40 244 24: 80 342 25: 70 323 26: > summary(lotsize) V1 V2 Min. : 20 Min. :113.0 1st Qu.: 50 1st Qu.:224.0 Median : 70 Median :342.0 Mean : 70 Mean :312.3 3rd Qu.: 90 3rd Qu.:389.0 Max. :120 Max. :546.0 > > X<-cbind(rep(1,25),lotsize$V1) > Y<-lotsize$V2 > > xpx <- t(X)%*%X > xpx [,1] [,2] [1,] 25 1750 [2,] 1750 142300 > > xpy <- t(X)%*%Y > xpy [,1] [1,] 7807 [2,] 617180 > b<-solve(xpx)%*%xpy > b [,1] [1,] 62.365859 [2,] 3.570202