I am a data scientist working on time series forecasting (using R and Python 3) at the London Ambulance Service NHS Trust. I earned my PhD in cognitive neuroscience at the University of Glasgow working with fmri data and neural networks. I favour linux machines, and working in the terminal with Vim as my editor of choice.
We already have the method to give us a projection matrix. So here we take $I - P$ as our projection matrix. After transposing $A$ (to make accessing the columns easier) we loop over each column and make the others columns orthogonal. Then we move onto the next column and repeat:
The next step is to make the length of each column 1. Which we do by dividing by it's current length:
The last step is to transpose $A$ back to how it was originally, and to generate $R$ by multiplying $Q^TA$. Note that because we worked from $A^T$ from the beginning, our $Q$ is already transposed, so we just multiply this with $A$ and then transpose $Q$ before returning:
We create a matrix, call the qr method and print the results. Note that we print the $A$ computed from $QR$ at two levels of rounding precision. We begin to see rounding errors beyond 13 decimal places:
Outputs:
back to project main page
back to home