#"The GLS model is used in the presence of heteroscedasticity."#
#"It generalizes the OLS (Ordinary Least Squares) model."#
#"If we take the two variable linear regression"#
#Y = beta_1 + beta_2 * X#
#"Then we have the following formulas with OLS :"#
#hat beta_2 = (sum_{i=1}^{i=n} x_i*y_i) / (sum_{i=1}^{i=n} x_i^2)#
#hat beta_1 = bar Y - hat beta_2 * bar X#
#"with "x_i = X_i - bar X#
#"and "y_i = Y_i - bar Y#
#"("bar X" and "bar Y" being the average values of the observations"#
#(X_i, Y_i)).#
#"With GLS we have a weighted sum"#
#hat beta_2 = ((sum w_i)(sum w_i X_i Y_i) - (sum w_i X_i)(sum w_i Y_i))/((sum w_i)(sum w_i X_i^2) - (sum w_i X_i)^2)#
#"with "w_i = 1/sigma_i^2 ,#
#sigma_i^2" being the variances of the deviations "u_i = Y_i-E(Y|X_i)#