To carry out the Granger causality test, ascertain if one time series forecasts another using a vector autoregression model. Initially presume that lagged values of X don't predict Y. Compare models using an F-test. If significant, X is said to Granger-cause Y.
1- The first step you sudy the stationarity of your variables by unit root test.
2- The second step if your series don't stationary, you need to transform your variables to get stationary variables (in generaly we use the first defference yt-yt-1.
3- the third step is to estimate two models (restricted model and unrestricted model) by Vector Autoregressive VAR.
4- The forth step we use fisher test to make the decesion.
Note: you can use Eviews, it is easy to apply this test.
Use YouTube video for better illustration and understanding.
This test is based on the idea that if X causes Y, then the past values of X should contain information that can improve the forecast of the current values of Y.
It involves estimating two models: one that includes the lagged values of both X and Y, and another that includes only the lagged values of Y.
The test then compares the sum of squared residuals of both models using an F-test. If the model with X is significantly better than the model without X, then it means that X Granger-causes Y.
I also suggest using cross sectional time series data (panel data) based methods, as Granger makes strong assumptions about stationary data which is often misleading.