Project Help Notebook by Keith Stroyan

Help NoteBook Copyright 1998 by Academic Press, Inc. - All rights reserved.
Modify this Notebook to prepare your project report.

Project 1:  Linear Approximation to CO2 Data

by A. Student and B. Pupil

with technical help from Da LabMonitor & Help NoteBook

My Project Introduction

Write this last.  Begin with the basic question and state your main finding clearly, but with few technical details.

The co2data

Concentrations of atmospheric carbon dioxide.  
(Don't open this cell, just enter it or say "YES" to "Evaluate Initialization?" in the first graph below.)

This is pretty horrible; we told you not to open it.  It is a list of approximate numerical data beginning in May 1958 (1958.33) monthly until January 1984.  Don't read it, just use it.  These data are similar to those taken at Mauna Loa Observatory, Hawaii, but since we couldn't find the originals, we approximated them from a published graph.

Needs["Graphics`Colors`"];

months = Range[N[1958 + 1/3], 1984, N[1/12]] ;
co2values = {316, 317.5, 318, 316, 315, 313.5, 313.5, 315,
	315.5, 316.5, 317, 318, 318.5, 318, 317, 315, 314.5, 313.5,
	315, 316, 317, 317.5, 318, 319, 320, 319.5, 318.5, 316,
	314.5, 314.5, 315, 316.5, 317, 317.5, 318.5, 319, 321,
	319.5, 319, 317, 315, 315.5, 316.5, 317, 318, 319,
	320, 320.5, 321, 320.5, 320, 317.5, 317, 316, 317,
	318, 319, 319.5, 320, 321.5, 322.5, 322, 320, 318,
	316.5, 316.5, 317, 318.5, 319.5, 320, 321, 322, 322.5,
	322, 320.5, 318.5, 317, 317.5, 318, 319, 320, 321,
	321.5, 322.5, 322.5, 322.5, 321.5, 319, 318.5, 318,
	319, 319.5, 320.5, 321.5, 322.5, 323.5, 324, 323.5,
	322.5, 320, 318.5, 317.5, 319.5, 321, 322.5, 322.5,
	323, 324.5, 325, 324, 323, 321, 319, 319, 321, 321.5,
	323, 324, 325, 325.5, 325.5, 324, 322, 320, 320, 321,
	323, 324, 324.5, 325.5, 327, 327.5, 327, 325.5,
	325, 323, 322, 321.5, 322.5, 324, 325, 326, 327,
	328, 328, 327.5, 327, 325, 323.5, 323.5, 324.5,
	325.5, 326.5, 327, 327.5, 328, 329.5, 329, 328,
	326, 324, 324, 325.5, 326.5, 327, 328, 328, 329.5,
	330.5, 329, 328.5, 327, 325.5, 325.5, 327, 328, 329,
	330, 331, 332, 333, 332.5, 331.5, 329.5, 328,
	327.5, 328.5, 330, 330, 331.5, 332, 333, 333.5, 333,
	332, 330, 328, 328, 329, 330, 331, 331.5, 332, 333,
	334, 334, 333, 330, 329, 328.5, 329.5, 331, 332, 333,
	333.5, 335, 335.5, 335, 333.5, 332.5, 331, 329.5, 329,
	330.5, 332, 333.5, 335, 336.5, 337, 336.5, 335, 333,
	332, 331, 332.5, 334, 335.5, 337, 337.5, 338, 338,
	337, 335, 333, 332.5, 334, 335.5, 336, 337, 338, 339,
	339.5, 339, 338, 336.5, 334.5, 334.5, 335.5, 337, 338,
	338.5, 339, 340, 341, 341.5, 341.5, 339.5, 337.5,
	336, 336, 337, 338, 340, 341, 342.5, 343, 342, 340, 
	338, 336.5, 337, 338, 339.5, 340, 341, 342.5, 343,
	344, 343, 342, 339.5, 338, 338, 339, 340.5, 341.5,
	343, 343.5, 345, 345.5, 345, 344.5, 343, 340, 340,
	341.5, 343, 344, 344.5} ;
co2data = Transpose[{months, co2values}] ;
Needs["Graphics`Colors`"];

Displaying the Data

The cell above contains a list of atmospheric concentrations of carbon dioxide as measured at Mauna Loa observatory in Hawaii.  The observatory continually monitors these concentrations and the numbers in the closed cell above are montly averages taken from May 1958  until January  1984.  First we plot these concentrations from May 1958 to January 1968  to see if there are any trends to be found.  (Enter the next computation and say "YES" to "Evaluate Initialization?".)

earlydata = Take[co2data, 117] ; 
earlygraph = ListPlot[ earlydata, PlotJoined -> False, 
		PlotRange -> {312, 330},
		AxesLabel -> {year, CO2 in ppm},PlotStyle->Red ] ;

We can also join the points in the plot:

earlyplot = ListPlot[earlydata, PlotJoined -> True,
			PlotRange -> {312, 330}] ;

The next command displays the two views together.

Show[earlyplot, earlygraph];

If you would like to see the data, enter the next command.  (You can cut the whole cell out later if you don't want it in your notebook.)

TableForm[co2data]

Fitting a Linear Function to the Early Data

You can see from the graphs above that the carbon dioxide level goes up and down by about 4 or 5 parts per million each year in what one might surmise is a seasonal fluctuation.   However, it is also clear that there is a general upward trend in concentrations, from an average of about 316 parts per million in 1958 to an average of about 322 parts per million in 1967.  This average trend looks fairly linear, so we fit a linear function to the early data using Mathematica:

f = Fit[ Take[co2data, 117], {1, x}, x ] ;
fitplot = Plot[ f, {x, 1958, 1968}, PlotRange -> {312, 330},PlotStyle->Blue] ;
f

Show[ fitplot, earlyplot ] ;

We can also compute the yearly averages as follows:

aves = {Apply[Plus,Take[co2values,{1,8}]]/8} ;
Do[
AppendTo[aves,
Apply[Plus, Take[co2values,{12 (k-1) + 9, 12 k + 8}]]/12];
,{k,1,9}
	] ;
years = Range[1958, 1967] ;
co2aves = Transpose[{years, aves}] ;
aveplot = ListPlot[co2aves, PlotJoined -> True,
		PlotRange -> {312, 330},PlotStyle->DarkGreen];
co2aves

The function  g  is Mathematica's fit of the data for yearly averages:

g = Fit[ co2aves, {1, x}, x ];
avefitplot = Plot[ g, {x, 1958, 1968}, PlotRange -> {312, 330},PlotStyle->Brown] ;
Show[avefitplot, aveplot];
g

Finally, here are all the early data plots together:

Show[earlygraph,earlyplot, fitplot,avefitplot, aveplot];

Hint 1.5

From a graph of the data, make an "eyeball" fit of the best straight line and use that to find a formula for your line.  Then compare with Mathematica.  Following is a poor guess that you can edit and improve.

h  =  x  -  1645\(eyeBallPlot = Plot[h, {x, 1958, 1968}, PlotStyle -> Purple]; 

    Show[earlygraph, eyeBallPlot]; 
    Show[earlygraph, eyeBallPlot, earlyplot, \ fitplot, avefitplot, \ 
      aveplot]; \)

HINT 1.5
2)  How does your "eyeball" approximation compare with the two computer approximations  f  and  g?

Prediction of 1983 from the Early Data Fits vs. The Measurements

We might imagine the linear fits as a way to predict the annual average concentration of CO2, or at least some general trend.  The combined graph just above showing the  1958 - 1968  data and the linear fit makes this look plausible.  The annual average seems to be going up about linearly.  We have no mathematical reason to believe this annual average is linear, but we can easily use a linear function to make predictions.  The fit functions printed above are

f = 0.678326 x - 1012.7      &       g = 0.713258 x - 1080.95

so you could substitute  x = 1983  in these formulas to compute  f  and  g  or Enter the computation using Mathematica:

x = 1983 ;  (* Predict annual average in 1983. *)
Print["f[1983] =",f,"    ","g[1983] = ",g]

HINT 1.5
3)  Modify the computation above to also use your "eyeball" approximation function  h.

The average of the last year of data is:

Apply[Plus, Take[co2values, {-13,-2}]/12]

The prediction of  333  is off by about  10.  Ten out of  340  does not seem like much, but probably the correct comparison is with the excess over the  1958  level of 316.  The excess prediction is  333 - 316 = 17, while the measured excess is  343 - 316 = 27  and an error of  10 out of 27  is certainly significant.    It is more revealing to look at the graphs of the linear prediction and the measured data:

Clear[x] ;
fitplot2 = Plot[f, {x, 1958, 1984}, PlotRange -> {312, 350},PlotStyle->Blue];
co2graph = ListPlot[ co2data, PlotJoined -> True, PlotRange -> {312, 350},AxesLabel -> {year, CO2 in ppm} ] ;
Show[fitplot2,co2graph];

The Moral of the Story

The moral of the story is that CO2 is increasing more than the linear prediction based on the decade from  1958  to  1968.  Roughly, it looks like the 1984 average was over  340 ppm, well above the  333  prediction.  What would you guess as the actual  1990  average?