Non-Negativity of a Quadratic form with Applications to Panel Data Estimation, Forecasting and Optimization