Trying to replicate the example from wikipedia for linear regression
using the following O-Matrix script
##### Code Start ###################################
height = {1.47, 1.5, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.7,
1.73, 1.75, 1.78, 1.8, 1.83}
weight = {52.21, 53.12, 54.48, 55.84, 57.2, 58.57, 59.93, 61.29,
63.11, 64.47, 66.28, 68.1, 69.92, 72.19, 74.46}
X = [ones(rowdim(height),1), height, height^2]
s = inv(X'*X)
bhat = X\weight # Backslash division
bhat2 = s*X'*weight # As shown
http://en.wikipedia.org/wiki/Linear_regression
print bhat
print bhat2
##### Code end #####################################
# O-Matrix responds
##### Command window output begin ##################
{
128.807
-143.155
61.9582
}
{
132.617
-147.417
63.0986
}
##### Command window output end ##################
Why if they are both implementations of linear regression (although
different methods) are the results so different?
Cheers,
Kurt