I have two matrices with numeric data and a lot of missing values. The missing values are not completely coherent in both matrices. My aim is to fill the missing values so I can perform further analysis on it. I can calculate the correlation using the cor() function and use the highly correlated matrices for filling in the gaps. But how can I after finding the correlation, fill the missing values? Say, I have 5 matrices and I want to use 4 matrices to fill the gaps in the first matrix.
So to add more detail, I have monthly rainfall data from 30 stations. The data is for more than 100 years but not of the same length for each station. Some stations have data for 120 years and some for 60 or 80 years. What I basically want to do is here:
- Using the 5 neighboring stations (the ones within an area of 80 km), fill in the missing data.
- For this purpose I intend to use correlation and select the station with the highest correlation for imputing missing values.
- Now, I can find the correlation between two matrices but is there a way to now replace the missing data in the first matrix with the rainfall data present in the second matrix? Like if I have matrix A which has a No data at row 30, column 6 and I have a matrix B which is highly correlated with matrix A and has a valid data entry at the same column and row id, how can I replace the data in that cell in A with B?
I know doing it manually would be an option but as I said there are more than 30 stations and each station has almost a matrix of size (120 x 13), so using part of some could would make it easier.