General expression for linear and nonlinear time series models