Dapaong Monthly Temperature Averages and Monthly Rainfall Averages
Chris Milesky and Patrick Nielsen

1. In the first report, by Rachel Driehaus, Connor Edwards, Terra Ficke, the conclusion was that the minimum was increasing and the maximum was decreasing. They were dissatisfied with their conclusion that the temperatures were decreasing because of an outlier included in the creation of the model. The second Dapaong Report, by Maria Ruwe, Leah Gillespie, Austin Hardesty, using monthly averages for the data agreed with the conclusion that the minimum temperature was increasing in Dapaong. They did not agree that the maximum temperature was increasing or decreasing. That monthly temperature data is the same we used and our analysis reached some of the same conclusions. We removed more outliers in the than the second report as they used 3 times the interquartile range instead of the standard 1.5 times the interquartile range. This ruthless identification and removal of the temperature outliers meant that we took out many more outliers than the groups previously had and by consequence had a model that fit better. Refer to significant temperature change as half a degree or more.

2.Dapaong is located in the north of Togo, in the Savanes region.  It is the northern most city in Togo for which we have data. The rainy season takes place during the summer with the rainiest average month being August. The dry season takes place during the winter and seldom receives any rain having many years of 0 millimeters of rain for years during December and January.

Pull data into Mathematica and prepare it for calculation

mintemp=Flatten[Import["C:\\Users\\Christopher\\Documents\\MAT 375\\Mini-Project 3 Reports\\MIN.xls"]];

maxtemp=Flatten[Import["C:\\Users\\Christopher\\Documents\\MAT 375\\Mini-Project 3 Reports\\MAX.xls"]];

rain=Flatten[Import["C:\\Users\\Christopher\\Documents\\MAT 375\\Mini-Project 3 Reports\\RAIN.xls"]];

months=Table[n,{n,660}];
datamax=Table[{months[[u]],maxtemp[[u]]},{u,660}];
datamin=Table[{months[[u]],mintemp[[u]]},{u,660}];

rainmax=Table[{rain[[u]],maxtemp[[u]]},{u,660}];
rainmin=Table[{rain[[u]],mintemp[[u]]},{u,660}]; raindata=Table[{months[[u]],rain[[u]]},{u,660}];

Preliminary ListPlot of each before outliers are removed.

ListPlot[datamax]

ListPlot[datamin]

ListPlot[{rainmax}]

ListPlot[rainmin]

ListPlot[raindata]

Ruthless attack on the outliers in the data sets

We checked for the outliers directly in the Excel file using the quartiles and interquartile ranges calculated here

Maximum Temperature Outliers

Quartiles[Sort[maxtemp]]
IQR=InterquartileRange[Sort[maxtemp]]
31.087096774193547` - (IQR*1.5)
35.806666666666665` + (IQR*1.5)

Remove outliers for max data @ 411,418,430,466,478

datamax=Delete[datamax,{{411},{418},{430},{466},{478}}];

Minimum Temperature Outliers

Quartiles[Sort[mintemp]]
IQR2=InterquartileRange[Sort[mintemp]]
21.226182795698925` - (IQR2*1.5)
23.63666666666667` + (IQR2*1.5)

Remove outliers from min data @ 1,12, 13, 36, 60, 61, 65, 66, 72, 73, 85, 96, 97,108,120,121,133,145,169,180,181,193,204,205,216,217,228, 259, 283,396,408,409, 292,531,543,544,570,591, and 593

datamin=Delete[datamin,{{1},{12},{13},{36},{60},{61},{65},{66},{72},{73},{85},{96},{97},{108},{120},{121},{133},{145},{169},{180},{181},{193},{204},{205},{216},{217},{228},{259},{283},{396},{408},{409},{292},{531},{543},{544},{570},{591},{593}}];

Other none necessary data points

Our Data contained missing rain averages that were replaced with *****’s. We found and removed these points as they would have provided no relevant information to the models.

rainmax[[371]]

***** existed at all of the flowing flowing table positions: 64, 65, 66, 210, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 370, and 371

newrainmax=Delete[rainmax,{{64},{65},{66},{210},{214},{215},{216},{217},{218},{219},{220},{221},{222},{223},{224},{225},{226},{227},{228},{370},{371}}];

newraindata=Delete[raindata,{{64},{65},{66},{210},{214},{215},{216},{217},{218},{219},{220},{221},{222},{223},{224},{225},{226},{227},{228},{370},{371}}];

newrainmin=Delete[rainmin,{{64},{65},{66},{210},{214},{215},{216},{217},{218},{219},{220},{221},{222},{223},{224},{225},{226},{227},{228},{370},{371}}];

rainmax[[64]]

newrainmax[[64]]

ListPlot[{newrainmax}]

Rainfall(time, temperature) Models

Created a PDF of the minimum and maximum data.

𝒟=SmoothKernelDistribution[Transpose[{mintemp,maxtemp}]];
contour=ContourPlot[PDF[𝒟,{x,y}]//Evaluate,{x,Min[mintemp],Max[mintemp]},{y,Min[maxtemp],Max[maxtemp]},PlotRange->All,AxesLabel->{"Minimum","Maximum"},PlotPoints->50,Contours->15,ColorFunction->"TemperatureMap",FrameLabel->{"Minimum Monthly Averages","Maximum Monthly Averages"}]

Added in the rain data and then removed the data points that would contain *****’s in the rain value. This 3 coordinate data set was used to create a model of the Rainfall with both Maximum and Minimum temperature.

dens=Plot3D[PDF[𝒟,{x,y}]//Evaluate,{x,Min[mintemp],Max[mintemp]},{y,Min[maxtemp],Max[maxtemp]},PlotRange->All,PlotPoints->50,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","PDF"}]
threeDmodel=Transpose[{mintemp,maxtemp,rain}];

threeDmodel=Delete[threeDmodel,{{64},{65},{66},{210},{214},{215},{216},{217},{218},{219},{220},{221},{222},{223},{224},{225},{226},{227},{228},{370},{371}}];

ListPointPlot3D[threeDmodel,PlotRange->All,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","Rainfall"}]

Scaled the rain to be used as a plot point for future manipulation. It appears that the

scalerain=rain*.03/Max[rain];
Manipulate[
p1=ListPointPlot3D[{{mintemp[[t]],maxtemp[[t]],scalerain[[t]]}
,{mintemp[[t]],maxtemp[[t]],PDF[𝒟,{mintemp[[t]],maxtemp[[t]]}]+scalerain[[t]]}},PlotRange->All,PlotStyle->{Black,PointSize[0.02+scalerain[[t]]]}];
Show[dens,p1],
{{t,1},1,Length[rain],1}
]

Linear models for the Minimum temperature, Maximum temperature, and the rainfall data. The periods are one year(1/12), six months(2/12), or three months(4/12).

minmodel=LinearModelFit[datamin,{1,x,
Sin[2Pi (1 x/12)],Cos[2Pi (1x/12)],
Sin[2Pi (2 x/12)],Cos[2Pi (2 x/12)]},x];minmodel["ParameterConfidenceIntervals"]
minmodel["ParameterTable"]
minmodel["RSquared"]
ListPlot[minmodel["FitResiduals"], Filling->Axis,PlotLabel->"Residuals Plot for Min Data",Axes->True,AxesLabel->{"\!\(\*
StyleBox[\"Months\",\nFontWeight->\"Plain\"]\)","Temp"}]
p1=ListPlot[datamin];
p2=Plot[minmodel[x],{x,0,660}];
Show[p1,p2,Frame->True,PlotLabel->"Report 3 Minimum graph",FrameLabel->{"Months since January 1961","Monthly Minimum Average Temperature"}]

In the Minimum model, we removed the three month oscillation terms as they had parameters of confidence that included zero. The residuals model appears random besides a primarily positive section between 200 months and 350 months. With a R-Squared of 0.707355 This model is better than that of the previous group who had a minimum model R-Squared of 0.46. The Minimum model appears significantly increasing.

maxmodel=LinearModelFit[datamax,{1,x,
Sin[2Pi (1 x/12)],Cos[2Pi (1x/12)],
Sin[2Pi (2 x/12)],Cos[2Pi (2 x/12)]},x];
maxmodel["ParameterConfidenceIntervals"]
maxmodel["ParameterTable"]
maxmodel["RSquared"]
ListPlot[maxmodel["FitResiduals"], Filling->Axis,PlotLabel->"Residuals Plot for Max Data",Axes->True,AxesLabel->{"\!\(\*
StyleBox[\"Months\",\nFontWeight->\"Plain\"]\)","Temp"}]
p1=ListPlot[datamax];
p2=Plot[maxmodel[x],{x,0,660}];
Show[p1,p2,Frame->True,PlotLabel->"Report 3 Maximum graph",FrameLabel->{"Months since January 1961","Monthly Maximum Average Temperature"}]
maxmodel[1] 
maxmodel[661]

maxmodel[0]

In the Maximum model, we removed the three month oscillation terms as the Cosine had parameters of confidence that included zero. The residuals model appears random.  With a R-Squared of 0.831605 This model fits the data far better than the previous groups cubic model with oscillation terms, which had a R-Squared of 0.6359. Using the model to predict a value 55 years forward from January 1961 we can look if there was a significant decrease or increase in the model’s predicted temperature.There was a decreasing of 0.5444 which means it is possible there is a significant decrease in  maximum temperatures of Dapaong.

rainmodel=LinearModelFit[newraindata,{1,x,
Sin[2Pi (1 x/12)],Cos[2Pi (1x/12)],
Sin[2Pi (2 x/12)],Cos[2Pi (2 x/12)]},x];
rainmodel["ParameterConfidenceIntervals"]
rainmodel["ParameterTable"]
rainmodel["RSquared"]
ListPlot[rainmodel["FitResiduals"], Filling->Axis,PlotLabel->"Residuals Plot for Rain Data",Axes->True,AxesLabel->{"\!\(\*
StyleBox[\"Months\",\nFontWeight->\"Plain\"]\)","Rain"}]
p1=ListPlot[newraindata];
p2=Plot[rainmodel[x],{x,0,660}];
Show[p1,p2,Frame->True,PlotLabel->"Report 3 Minimum graph",FrameLabel->{"Months since January 1961","Monthly Average Rainfall"}]

The rain model the R-Squared was 0.758574 the highest out of any of our models. The oscillation terms were for a quarter year oscillation were again removed as the Cosine contained zero as a potential parameter. The rain model seems also be inconclusive as to whether or not it is significantly increasing or decreasing.  The coefficient on the x term is small, 0.0119, and does not provide much slope to conclude either way.

raindataplot=ListPlot[newraindata];
Manipulate[
rainmodelplot=Plot[rainmodel[x],{x,t*12,(t+n)*12},PlotRange->{{t*12,(t+n)*12},{Min[newraindata],Max[newraindata]}},PlotLabel->"Model Versus Rain Data",AxesLabel->{"Months","Rainfall"}];
Show[rainmodelplot,raindataplot],
{{t,0},0,50,1},
{{n,1},1,5,1}]

This manipulate displays the rain model overlaid with the rain data so show how the model fits the data.

4. The rainfall in Dapaong primarily oscillates during the year between the dry and rainy season. Which would be around our 6 month oscillation term causing the variation between the high rainfall, lower monthly temperature averages to low rainfall, higher monthly averages for temperature. The half year/six month oscillation terms working the best in every model gave a hint that there was some variation in the rain over time.

8. Moving forward we would like to find ways to fix the issues of the missing data in rainfall. The missing year and a quarter in a row did not help our ability to model the data accurately. Is the rainfall in the month of August just so from the mean rainfall for the year that is should be considered an outlier? Was that a mistake of our calculations of the InterQuartile Ranges? It would be interesting to hear back from the Togolese meteorologist on some of the previous mini reports before preceding to see what they think of all this and discuss with the the implication that global climate change has on a nation such as Togo. Have the Togolese meteorologist also worked with the data and we could compare our models with their own?