Priyan,
It looks like you are solving the standard linear regression problem (minimum distance from a subspace to a given point). This problem is solved in Mathematica with the LinearModelFit function. This function not only gives you the functional form of the best fit, but also a whole array of statistical results from the fit which is probably more than you will ever need (including confidence intervals, ANOVA tables, prediction bands, etc.). The list of properties (shown below) has 64 entries. Have you tried to use this function for the regression problem you are trying to solve? The identification you describe looks correct, but it is impossible to say why your code is giving an error without looking at it.
Regards,
OL.
{"AdjustedRSquared", "AIC", "AICc", "ANOVATable", \
"ANOVATableDegreesOfFreedom", "ANOVATableEntries", \
"ANOVATableFStatistics", "ANOVATableMeanSquares", \
"ANOVATablePValues", "ANOVATableSumsOfSquares", "BasisFunctions", \
"BetaDifferences", "BestFit", "BestFitParameters", "BIC", \
"CatcherMatrix", "CoefficientOfVariation", "CookDistances", \
"CorrelationMatrix", "CovarianceMatrix", "CovarianceRatios", "Data", \
"DesignMatrix", "DurbinWatsonD", "EigenstructureTable", \
"EigenstructureTableEigenvalues", "EigenstructureTableEntries", \
"EigenstructureTableIndexes", "EigenstructureTablePartitions", \
"EstimatedVariance", "FitDifferences", "FitResiduals", "Function", \
"FVarianceRatios", "HatDiagonal", "MeanPredictionBands", \
"MeanPredictionConfidenceIntervals", \
"MeanPredictionConfidenceIntervalTable", \
"MeanPredictionConfidenceIntervalTableEntries", \
"MeanPredictionErrors", "ParameterConfidenceIntervals", \
"ParameterConfidenceIntervalTable", \
"ParameterConfidenceIntervalTableEntries", \
"ParameterConfidenceRegion", "ParameterErrors", "ParameterPValues", \
"ParameterTable", "ParameterTableEntries", "ParameterTStatistics", \
"PartialSumOfSquares", "PredictedResponse", "Properties", "Response", \
"RSquared", "SequentialSumOfSquares", "SingleDeletionVariances", \
"SinglePredictionBands", "SinglePredictionConfidenceIntervals", \
"SinglePredictionConfidenceIntervalTable", \
"SinglePredictionConfidenceIntervalTableEntries", \
"SinglePredictionErrors", "StandardizedResiduals", \
"StudentizedResiduals", "VarianceInflationFactors"}