How to Compare Yearly Patterns Graphically
Plotting data across time helps to reveal interesting patterns and relationships. This was true of a study of weather and temperature patterns in Illinois that was conducted by Carl von Ende from the Department of Biological Sciences at Northern Illinois University.
The goal was to visually compare the trends in temperate between two years, 2008 and 2009. The data, available from the National Weather Service Forecast Office (of) Central Illinois, gives temperatures (measured in Fahrenheit) and dates when the measurements were taken.
In this article, we will explore the steps needed to create such a plot, including the creation of new variables, using time and date functions and graph customization tools.
The data used to create the graph is presented above. As you can see, there is only one date variable, and we need to obtain from this variable the year for categorization as well as the day of the year for plotting along an axis. Therefore, the first step is creating two variables with this data.
In STATISTICA, select the Data tab. In the Variables group, click the Variables arrow, and from the menu, select Add. In the Add Variables dialog box, add two variables after Temperature (in F).
After you click OK, two new variables are added to the data file, NewVar1 and NewVar2.
Double-click on the variable header for NewVar1 to display the variable specifications dialog box. Change the variable name to Day_of_Year. In the Long name field, enter a function that returns a numerical code for the day of the year. You can see this function and the required parameters by clicking the Functions button, which displays the Function Browser. In the Category list, click on Date/Time, and in the Item list, scroll down to and click on DTDAYOFYEAR.
This is the function that will be used to bring back a numerical code for the day of the year. As you can see from the description of the function, it returns a numerical code between 1 and 366 that represents the day of the year. Close the function browser and return to the variable specification dialog. In the Long name field, type =DTDayOfYear(‘Date’).
When you click OK, a message will be displayed, letting you know whether the expression is correct. If the expression is correct, click Yes and the variable will be renamed and numerical codes for the day of the year will be included in the cases for the variable.
Now, double-click on the variable header for NewVar2, rename the variable Year, and in the Long name field, type =DTYEAR(‘Date’). This will rename the variable and add a four-digit number for the year in each case of the data set.
You will now have the complete data set with two additional variables, Day_of_Year and Year. These variables will be used in the results graph.
To create the graph, select the Graphs tab. In the Common group, click Scatterplot.
STATISTICA is designed so that when creating a 2D Scatterplot, the most common options for creating a scatterplot are shown on the Quick tab, as shown below. On the Quick tab of the 2D Scatterplots dialog box, click the Variables button. Select Day_of_Year as the x-axis variable and Temperature (in F) as the y-axis variable. Click OK in the variable selection dialog box. Under Fit type, clear the Linear check box.
On the Categorized tab, in the X-Categories group box, select the On check box. Click the Change Variable button, and select Year as the categorization variable. Click OK. In the Layout group box, select the Overlaid option button.
Click OK to create the scatterplot graph.
We still need to convert the numerical codes to date format and to connect the data points by lines. To do this, double-click in the graph background to display the Graph Options dialog box.
Select the General tab for Plot, and select the Multiple lines check box.
Select the Scale Values tab for Axis, and ensure that the X Axis is specified. Then, for the Value format, select Date and the option for 17-Mar. Finally, under Options in the Layout drop-down list, select Perpendicular.
Click OK to create a graph that shows the data for Day_of_Year categorized by Year for Temperature (in F), as shown below.