Technical details
When you run the script you will be asked to specify:
- The weight variables. These must be contained within a Number - Multi question.
- The Significance level (alpha) for the significance testing for these tables. Results will be shown as significant when their p-values are less than or equal to this value. Note that this testing will NOT use any settings from the Statistical Assumptions tab in the Project Options or Table Options.
- The questions to show in the charts. Any Pick One - Multi, Pick Any - Grid, and Number - Grid questions will be flattened into a single column the charts.
If using Q 4.7, the charts should be changed to Line charts in the Show Data as menu once the script is complete. It is best to avoid converting the charts created by this script into tables - to view tables use Weighting - Create Tables with Different Weights for Each Time Period instead.
Chart Creation Process
To generate a line chart, this script generates a new Pick Any question with one category for each time period in the weight question. The script first builds a table with the selected question in the Brown drop-down and the time-periods in the Blue drop-down. The statistics in each row of the table (i.e. for each time period) are obtained by
- Generating a SUMMARY table for the question selected in the Brown drop-down.
- Applying the appropriate weight for that period.
- Copying the relevant statistics to the main table.
It is necessary for the time periods to be rows in the table, so they are shown on the X axis when the table is converted to a chart. Once the table is constructed it is converted into a chart, and the type of chart can be selected from the Show Data as drop-down menu.
Statistics Used
The JavaScript copies statistics from a SUMMARY table into a crosstab. As such, some statistics that are available in the SUMMARY are not available in the crosstab.
The statistics that are copied across from the SUMMARY tables which have different names on the chart are:
Name on Chart | Name on SUMMARY |
---|---|
Row % | % |
Row n | Base n |
Row Population | Population |
% Row Share | % Share |
The Standard Error statistic from the SUMMARY table is copied into the Standard Error on the chart when viewing a Number or Number - Multi question, and it is copied into the Column Standard Error when viewing a Pick One or Pick Any question.
Statistics that retain their name from the SUMMARY tables (that is, are copied across using the same name) are:
- Average
- Standard Deviation
- Minimum
- Maximum
- 5th/25th/75th/95th Percentile
- Median
- Mode
- Trimmed Average
- Interquartile Range
- Sum
- n
- Missing n
- Population
If a statistic does not make sense for this chart then you will be warned if you try to select it from the Statistics menu.
Significance Testing
In the charts that are generated by this QScript the significance test compares each cell with the cell in the previous time period. The tests assume that the sample for each time period is independent of the other time periods. When viewed as a line chart each data point is compared with the data point to the left. If viewed as a table each cell is compared with the cell in the row above. Due to the way the table is converted into a chart, these are equivalent.
Results that are significantly high according to the test used are marked with a '+' and results that are significantly low are marked with a '-'.
IMPORTANT: The testing used on these generated tables does NOT employ any of the settings that have been set in the Statistical Assumptions. Consequently, changing these settings will have no impact on the results displayed in the table. The significance level that is used in the tests is specified when the script is run, and if you want to use a different level then you should run the script again.
Proportions
When the table shows proportions (that is, when the question selected for the Blue drop-down is a Pick One or Pick Any question) then the test used to compare between cells is the Independent Complex Samples Z-Test - Comparing Two Proportions. This test uses the proportions shown in the Row % on the chart and the Column Standard Error shown in the chart. These in turn correspond to results shown in the % and Standard Error on the SUMMARY tables that were used to construct the columns.
Averages
When the table shows averages (that is, when the question selected for the Blue drop-down is a Number or Number - Multi question) then the cells are compared using Independent Complex Samples t-Test - Comparing Two Means with the Bessel's correction. This test uses the Average, Standard Error, and Row n statistics that are displayed on the chart.
How to apply this QScript
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Click on the QScript when it appears in the QScripts and Rules section of the search results.
OR
- Select Automate > Browse Online Library.
- Select this QScript from the list.
Customizing the QScript
This QScript is written in JavaScript and can be customized by copying and modifying the JavaScript.
Customizing QScripts in Q4.11 and more recent versions
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Hover your mouse over the QScript when it appears in the QScripts and Rules section of the search results.
- Press Edit a Copy (bottom-left corner of the preview).
- Modify the JavaScript (see QScripts for more detail on this).
- Either:
- Run the QScript, by pressing the blue triangle button.
- Save the QScript and run it at a later time, using Automate > Run QScript (Macro) from File.
Customizing QScripts in older versions
- Contact support@q-researchsoftware.com to obtain a copy of the JavaScript code.
- Create a new text file, giving it a file extension of .QScript. See here for more information about how to do this.
- Modify the JavaScript (see QScripts for more detail on this).
- Run the file using Automate > Run QScript (Macro) from File.
Prior to the 15th of December, 2015, this page was known as Create Plots - Different Weight for Each Time Period
See also
- QScript for more general information about QScripts.
- QScript Examples Library for other examples.
- Online JavaScript Libraries for the libraries of functions that can be used when writing QScripts.
- QScript Reference for information about how QScript can manipulate the different elements of a project.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.