Thursday, April 9, 2020

How to Calculate Correlation with Significance and Regression using Python and Pandas

In this post, we correlate climate data, predict elevation from independent climate variables using python|pandas. The objectives are:-

  • Find the significance (p-value) for each correlation. 
  • Find the correlation coefficients. 
  • Find regression equation. 
  • Predict elevation from climate data. 
  • Plot Residual plot.

Table: Climate and Elevation data.
     
Station Elevation_mASL Temp_Jan_DegC Temp_Jul_DegC Rainfall_mm
Porto Amelia 0 27 24 860
Salisbury 1480 20 14 860
Broken Hill 1210 21 15 920
Zomba 960 23 17 1350
Dar es Salaam 0 27 23 1040
Nairobi 1800 18 15 930
Voi 603 26 23 515
Wajir 262 29 26 273
Thika 1574 20 18 949
Nyeri 1968 18 16 935
Narok 1706 18 15 747
Nakuru 1901 19 17 950
Kisii 1837 21 19 2037
Embu 1607 19 17 1327
Eldoret 2120 17 16 1041
Moyale 1197 24 19 735
Entebbe 1150 22 21 930
Lodwar 520 29 28 160
Mogadishu 0 26 26 430
Addis Ababa 2360 17 16 1200
Asmara 2320 15 17 470

Python Code:

No comments:

Post a Comment