IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Trend and P-Value #6213

Open IbrahimDanDije opened 3 years ago

IbrahimDanDije commented 3 years ago

I suggest to add the trend calculation and p-value for summaries data(Decadal, Monthly, Seasonal and or Annual)

The trend calculation and p-value are the part of the activity in the department of climate at ACMAD and also Met Services. It is very easy to do this with R and it could be easy included in the dialogue Prepare: Data Reshape: Summaries. Data.zip Using the estimated C_OPI annual total data for Africa, the need is to compute the trend and p_value for the periods 1981-2000 2001-2020 1981-2020 by grids point and do the map. The following R-Script is used ############################################################# rm(list=ls())

library(rio) library(ggplot2) library(dplyr)

Be in the same directory when data are saved

Data=rio::import("RR_cum_Jan_Dec_1981_2020_OPI.csv")

Filter the data for the period 1981-2000

Data_81_2000<-dplyr::filter(Data, Time<= 2000)

Filter the data for the period 2001-2020

Data_2001_2020<-dplyr::filter(Data, Time > 2000)

##############################Trend######################### Trend_83_2000<-Data_81_2000%>% group_by(Longitude,Latitude)%>% summarise(Trend=summary(lm(precipitation~Time))$coefficients[2])

Trend_2001_2020<-Data_2001_2020%>% group_by(Longitude,Latitude)%>% summarise(Trend=summary(lm(precipitation~Time))$coefficients[2])

Trend_1981_2020<-Data%>% group_by(Longitude,Latitude)%>% summarise(Trend=summary(lm(precipitation~Time))$coefficients[2])

rio::export(Trend_83_2000,"Trend_RR1981_2000.xlsx") rio::export(Trend_2001_2020, "Trend_RR2001_2020.xlsx") rio::export(Trend_1981_2020, "Trend_RR1981_2020.xlsx") ###################P-Value#################################### P_value_83_2000<-Data_81_2000%>% group_by(Longitude,Latitude)%>% summarise(P_value=summary(lm(precipitation~Time))$coefficients[8])

P_value_2001_2020<-Data_2001_2020%>% group_by(Longitude,Latitude)%>% summarise(P_value=summary(lm(precipitation~Time))$coefficients[8])

P_value_1981_2020<-Data%>% group_by(Longitude,Latitude)%>% summarise(P_value=summary(lm(precipitation~Time))$coefficients[8])

rio::export(P_value_83_2000,"P_value_RR1981_2000.xlsx") rio::export(P_value_2001_2020, "P_value_RR2001_2020.xlsx") rio::export(P_value_1981_2020, "P_value_RR1981_2020.xlsx") ########################################################

IbrahimDanDije commented 3 years ago

You will find the data to test this script in Data.zip attached

IbrahimDanDije commented 3 years ago

Trend_Precip_1981_2020 See attached the different maps produce using the out put of the scripts: The maps have been done with QGIS and Surfer. We are working to produce the map with R so for the next we could have I new issue for Mapping Trend_Precip_1981_2000

Trend_Precip_2001_2020