Time series analysis function improves to allow adding variables