Your Analysis Scripts generate your results--the figures, tables and other computational output you present in the report for your project.
You will write one or more Analysis Scripts for your project; they should all be saved in your AnalysisScripts/ folder.
Guidelines for Writing Analysis Scripts
When you write your analysis scripts, be sure to follow the general guidelines that apply to all scripts.
Additional guidelines that apply particularly to analysis scripts are presented below.
The header in the analysis script
The header in each of your analysis scripts should give all the information specified in the general guidelines that apply to the headers in all the scripts you write.
In addition, the header of every analysis script should remind the user that they must execute all the processing scripts before they execute any of the analysis scripts (because the processing scripts create the Analysis Data Files that are used by the analysis scripts).
Tasks your analysis scripts should accomplish
The tasks that should be accomplished by the commands in your processing scripts fall in three categories:
● Open the Analysis Data Files
Before any commands that begin implementing your analysis, you must write a command that opens the Analysis Data File containing the data you will use in the analysis.
When you write a command that opens an Analysis Data File, you must specify where the file is stored, and you should do so using a relative directory path.
- You have adopted the convention of keeping your Project/ folder set as the working directory at all times, and
- The Analysis Data File is stored in the AnalysisData/ folder
the relative directory path should begin in your Project/ folder and lead to the AnalysisData/ folder:
● Generate the figures, tables and other computational output you present in your report.
For every result of your project--that is for every figure, table, or other computational output you present in your report--your analysis scripts should include a command (or perhaps a sequence of commands) that generates the result.
Before the command(s) that generate each result, write a comment that indicates where the result is presented in your Report.
For example, the comments you write to indicate where the results produced by the commands in the script appear in the report might look like the following:
- The next command generates the bar graph shown in Figure 3.
- The next three commands generate Table 6.
- The next command generates the values of beta_hat and se_beta_hat presented on page 16 of the report.
● Create new files that preserve the results generated by the analysis scripts, and save them in the Results/ folder.
In addition to generating the results you will present in your report, your analysis scripts should also include commands that create and save new files that preserve the results as they are generated.
● Depending on the software you are using, you may use a variety of commands to create and save these files, such as "save", "export", "display", "print", or many others.
In some cases, it may be convenient to save some of your results by writing commands that open a log file just before the command that generates the result and then close the log file just after the command that generates the result.
● The files in which your results are preserved may be stored in a variety of formats, partly depending on the kind of output they contain. For more information, see these examples of possible file formats for results files.
● In the commands that save the files in which your results are preserved, you will need to specify names for the files. Follow these guidelines for naming results files.
● When you write a command that saves a file containing one of your results, you must specify where the file is stored, and you should do so using a relative directory path.
Assuming you have adopted the convention of keeping your Project/ folder set as the working directory at all times, the relative directory path should begin in your Project/ folder and lead to the Results/ folder:
If you have created subfolders for different kinds of results, the relative directory path should lead to the appropriate subfolder. For example:
Don't put commands that process your data in your Analysis Scripts
Your Analysis Scripts should only contain commands that generate results you present in your report.
Your Analysis Scripts should not contain any commands that are necessary to prepare your data for analysis: all commands that execute any parts of your data processing should be in your Processing Scripts.
Naming Your Analysis Scripts
If you write commands that generate all the results you present in your report in a single Analysis Script, give it the name Analysis.yyy.
If you write the commands that execute your analysis in two or more Analysis Scripts, try to give them meaningful names.
For example, you could choose names that indicate the order in which they should be executed, such as Analysis_1.yyy, Analysis_2.yyy, Analysis_3.yyy.
Or you could give them names that reflect different parts of the analysis they execute, such as Regressions.yyy, Simulations.yyy, Robustness.yyy.
NOTE: The extension .yyy represents the filename extension assigned to scripts by the software you are using. (For example: If you are using Stata, .yyy would be replaced by .do; if you are using R, .yyy would be replaced by .R; and if you are using SPSS, .yyy would be replaced by .sps.)