Endogeneity in statistical inference and forecasting