Partial Correlation of stacked rasters

Hello

I am a beginner in R. I have six variables in spatial raster datasets for the period of 18 years. I have created six different raster stacks with each stack containing 18 layers. Now I want to calculate a partial correlation between two variables by controlling the other fours. I have developed a pixel to pixel calculation code that works fine for a smaller area. However, my area of study is very big ( approx. 32000000 pixels) and my laptop would take ages to calculate partial correlation using pixel to pixel approach. Is there any other efficient method that could directly incorporate three-dimensional datasets to calculate partial correlation?

Thank you, would love to listen from someone who has expertise.

Hi, See the FAQ: How to do a minimal reproducible example reprex for beginners to help give the community some traction. The code and data for the smaller area will help replicate the issue. 3.2e7 isn't all that big, so long as the function to do the calculation isn't trying to grow an object that hasn't been pre-allocated.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.