How to perform model fitting for system identification
In any signal processing problem, there are usually two components: the signal model and the channel model.

The signal model is the mathematical description of how your ideal signal, call it $s(t)$ is generated.

The channel model is the mathematical description of how your channel corrupts or alters the signal. 

One aim in telecommunications is to look at the received signal $r(t)$ --- $s(t)$ corrupted by the channel --- and try to undo the effects of the channel.

For example, suppose
$$
s(t) = A \sin(\omega_0 t + \phi)
$$
and suppose the channel is:
$$
r(t) = h(t)*s(t) + n(t)
$$
where $h(t)$ is the impulse response of the channel, and $n(t)$ is some additive noise.

In this context, your "AR"  filter is the $h(t)$.

If the context is in robotics or kinematics, then things get a little more complicated.



Did you open the "Algorithm" tab on the link in your comment? It's pretty straighforward:


  The polyfit MATLAB file forms the Vandermonde matrix, $\bf V$, whose elements are powers of $x$: 
  $v_{i,j} = x_i^{n - j}$ 
  It then uses the backslash operator, $\backslash $, to solve the least squares problem ${\bf V} p \approx y$.