I have 3D position measurements $x_i,y_i,z_i$ and their corresponding timestamps $t_i$ in a buffer. The time intervals are not equal between all timestamps. I would like to carry out linear regression, to obtain an estimate of the velocity (= slope of the linear fit) "during" the buffer. My idea is to perform linear regression with least squares.
I have multiple ideas but cannot connect the dots. Main question is under point 2, since I have some ideas but don't know if I am wrong or if I am right, how to exactly do it.
I would prefer a solution in vector and matrix notation, that solves the slopes/velocities in all 3 dimensions at the same time, if possible.
I know some linear regression with least squares from machine learning courses I took and was wondering how to apply that to this scenario. In linear regression we have matrix $\textbf{X}$, which contains our observations $\vec{x_1},...,\vec{x_N}$, we have $\vec{y}$, containing the target we want to predict, we have a weight vector $\vec{w}$ (or should I use a weight matrix $\textbf{W}$?)) and we have a bias $\vec{b}$ if we don't absorb it into the weights. Then the equation looks like this:
$$\vec{y} = \vec{w}^T \textbf{X}+\vec{b}$$ But I have position and time measurements and I don't know which to treat as observations and which as targets, or if all of the four should be treated as measurements. Also since I have a time series/multiple measurements, how do I put my position and time measurements into matrices and vectors and adjust this equation?
I also noticed that this resembles the motion equation: $$ \vec{s} = \begin{pmatrix} x \\ y \\z \end{pmatrix} = \vec{v} \cdot t + \vec{v_0}$$
I guess if you consider the time series here, the time would become a vector and the velocities would become a Matrix, but so would the positions. Does this resemblance between the two formulae have some meaning / is it related to the solution of the linear regression or is it a coincidence and maybe even wrong?
To summarize this part: How do I model the linear regression problem and how do I solve it with least squares? Is it somehow related to the motion equation?My intuition tells me that I could simply obtain the linear fit by calculating the position differences $x_i - x_{i-1}$ and time intervals $t_i-t_{i-1}$, obtain the velocities between two measurements by dividing and then taking the average of these velocities between intervals. Then repeat for $y$ and $z$. Would this be equivalent to a specific solution method of linear regression?