Previous Work:

From the work done for Mini-Project #1 and #2, we can say that the minimum and the maximum temperature for Sokode are significantly rising with time. We would like to explore to see what is happening to rainfall in Sokode with time.

Importing Data/Creating Arrays

mindata=Import["C:\\Users\\Maria\\Documents\\NKU Spring 2018\\MAT 375\\SokodeMin.xlsx"];

rainfall=Import["C:\\Users\\Maria\\Documents\\NKU Spring 2018\\MAT 375\\Rainfall.xlsx"];

maxdata=Import["C:\\Users\\Maria\\Documents\\NKU Spring 2018\\MAT 375\\SokodeMax.xlsx"];

maxdataclean=Flatten[maxdata];

mindataclean=Flatten[mindata];

rainfallclean=Flatten[rainfall];

Determine outliers

StandardDeviation[rainfallclean]

105.90107326688666`*4

Mean[rainfallclean]

110.69363636363634`+423.6042930675466`

Importing

keeling1=Import["C:\\Users\\Maria\\Documents\\NKU Spring 2018\\MAT 375\\Keeling.csv"];

months1=Table[keeling1[[i,3]],{i,35,694}]-1961;

rainandkeel=Table[{months1[[i]],rainfallclean[[i]]},{i,660}];

mintempandtime=Table[{months1[[i]],mindataclean[[i]]},{i,660}];

maxtempandtime=Table[{months1[[i]],maxdataclean[[i]]},{i,660}];

datatogethermin=Table[{mindataclean[[i]],rainfallclean[[i]]},{i,660}];

3D Plots

PDF

Ω=SmoothKernelDistribution[Transpose[{mindataclean,maxdataclean}]];
contour1=ContourPlot[PDF[Ω,{x,y}]//Evaluate,
{x,Min[mindataclean],Max[maxdataclean]},{y,Min[maxdataclean],Max[maxdataclean]},PlotRange->All,AxesLabel->{"Min","Max"},PlotPoints->50,Contours->15,ColorFunction->"TemperatureMap"]

3D Surface Plot of PDF and 3D plot of (min, max, rainfall)

denst=Plot3D[PDF[Ω,{x,y}]//Evaluate,{x,Min[mindataclean],Max[mindataclean]},{y,Min[maxdataclean],Max[maxdataclean]},PlotRange->All,PlotPoints->50,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","PDF"}]
ListPointPlot3D[Transpose[{mindataclean,maxdataclean,rainfallclean}],PlotRange->All,ColorFunction->"TemperatureMap",AxesLabel->{"Min","Max","Rainfall"}]

Point Plot of (year, month, rainfall)

raintable1=Table[{i+1960,j,rainfallclean[[12*(i-1)+j]]},{i,1,55,1},{j,1,12,1}];
ListPointPlot3D[raintable1,PlotRange->All,ColorFunction->"TemperatureMap",AxesLabel->{"Year","Month of the Year","Rainfall"}]

Scale rainfall to use it in visualizations:

scaledrain=rainfallclean*.03/Max[rainfallclean];
Manipulate[pl1=ListPointPlot3D[{{mindataclean[[t]],maxdataclean[[t]],scaledrain[[t]]},{mindataclean[[t]],maxdataclean[[t]],PDF[Ω,{mindataclean[[t]],maxdataclean[[t]]}]+scaledrain[[t]]}},PlotRange->All,PlotStyle->{Black,PointSize[.02+scaledrain[[t]]]}];Show[denst,pl1],{{t,1},1,Length[rainfallclean],1}]

Models

Rainfall Model

bigmodel1=LinearModelFit[rainandkeel,{Sin[2*Pi*x],Cos[2*Pi*x],Sin[2*Pi*x/.5],Cos[2*Pi*x/.5],Cos[2*Pi*x/.3333], Sin[2*Pi*x/.3333],Sin[2*Pi*x/.25],Cos[2*Pi*x/.25],x},x]

Show[ListPlot[rainandkeel],Plot[bigmodel1[x],{x,1,660}],Frame->True,PlotLabel->"Model of Rainfall",FrameLabel->{"Year","Rainfall"}]

ListPlot[bigmodel1["FitResiduals"],Filling->Axis,Axes->True,AxesLabel->{"Month","Temperature"},PlotLabel->"Residuals"]

The residuals look fairly random and independent. There may be a very slight wave-like pattern.

Histogram[bigmodel1["FitResiduals"],AxesLabel->{"Month","Temperature"},PlotLabel->"Historgram"]

The histogram does not look at normal as it could be. It is too skinny.

bigmodel1["ParameterTable"]

bigmodel1["RSquared"]

bigmodel1["ParameterConfidenceIntervals"]

We do not find evidence of significant increase or decrease of rainfall with time. The model is dipping which is kind of strange. It looks like it is oscillating and appears somewhat wave-like.

Minimum Temperature Model

minmodel1=LinearModelFit[mintempandtime,{Sin[2*Pi*x],Cos[2*Pi*x],Sin[2*Pi*x/.5],Cos[2*Pi*x/.5],x},x]

Show[ListPlot[mintempandtime],Plot[minmodel1[x],{x,1,660}],Frame->True]

minmodel1["ParameterTable"]

Histogram[minmodel1["FitResiduals"],AxesLabel->{"Month","Temperature"},PlotLabel->"Historgram"]

ListPlot[minmodel1["FitResiduals"],Filling->Axis,Axes->True,AxesLabel->{"Month","Temperature"},PlotLabel->"Residuals"]

Maximum Temperature Model

maxmodel1=LinearModelFit[maxtempandtime,{Sin[2*Pi*x],Cos[2*Pi*x],Sin[2*Pi*x/.5],Cos[2*Pi*x/.5],x},x]
Show[ListPlot[maxtempandtime],Plot[maxmodel1[x],{x,1,660}],Frame->True]

maxmodel1["ParameterTable"]

Histogram[maxmodel1["FitResiduals"],AxesLabel->{"Month","Temperature"},PlotLabel->"Historgram"]

ListPlot[maxmodel1["FitResiduals"],Filling->Axis,Axes->True,AxesLabel->{"Month","Temperature"},PlotLabel->"Residuals"]

The residuals are random and independent. The histogram is not as normal as we would like--there is a “shrug” to the left. The model is clearly increasing.

Visualize each model, period by period:

Rain Model

rain=rainfallclean;
days=365.25*months1;
raindataplot=ListPlot[Transpose[{days,rainfallclean}]];
Manipulate[
rainmodelplot=Plot[bigmodel[x/365.25],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[rain],Max[rain]}},PlotLabel->"Model Versus Rain Data",AxesLabel->{"Days","Rainfall"}];
Show[rainmodelplot,raindataplot],
{{t,0},0,50,1},
{{n,1},1,5,1}]

From the model, rainfall certainly appears to not be increasing. In fact, there may be a slight decrease in rainfall. As time goes on, the model slightly decreases.

Max Temp Model

maxtempdataplot=ListPlot[Transpose[{days,maxdataclean}]];
Manipulate[
maxmodelplot=Plot[maxmodel1[x/365.25],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[maxdataclean],Max[maxdataclean]}},PlotLabel->"Model Versus Max Temp Data",AxesLabel->{"Days","Max Temp"}];
Show[maxmodelplot,maxtempdataplot],
{{t,0},0,50,1},
{{n,1},1,5,1}]

As time goes on, the maximum temperature is clearly increasing. The first two groups supported this conclusion through their work, too.

Min Temp Model

mintempdataplot=ListPlot[Transpose[{days,mindataclean}]];
Manipulate[
minmodelplot=Plot[minmodel1[x/365.25],{x,t*365.25,(t+n)*365.25},PlotRange->{{t*365.25,(t+n)*365.25},{Min[mindataclean],Max[mindataclean]}},PlotLabel->"Model Versus Min Temp Data",AxesLabel->{"Days","Min Temp"}];
Show[minmodelplot,mintempdataplot],
{{t,0},0,50,1},
{{n,1},1,5,1}]

As time goes on, minimum temperature is clearly increasing. This conclusion was supported by the first two mini-projects for Sokode.

Put it all together (min temp, max temp, rainfall)

Manipulate[
p1=ListPlot[{{mindataclean[[t]],maxdataclean[[t]]}},PlotRange->All,PlotStyle->{Black,PointSize[0.02+scaledrain[[t]]]}];
p2=ListPlot[{{minmodel1[days[[t]]],maxmodel1[days[[t]]]}},PlotRange->All,PlotStyle->{Blue,PointSize[0.02+Max[{0,bigmodel1[days[[t]]]}]*.03/Max[rain]]}];
Show[contour1,p1,p2],
{{t,1},1,Length[rain],1}
]

We do not see anything significant happening with rainfall in Sokode. Temperature is definitely increasing with time, but we do not see any relationship between temperature and rainfall.