Skip to content

Example 4

Jonathon Love edited this page Nov 15, 2016 · 1 revision

In the examples so far, we have allowed the user to specify a single dependent variable, for a single t-test. But what if we want to allow the user to provide multiple dependent variables, and perform multiple t-tests.

For example ...

For this, we will make a modification to options in the .a.yaml file:

...
options:
    - name: data
      type: Data

    - name: deps
      title: Dependent variable
      type: Variables

    - name: group
      title: Grouping variable
      type: Variable

    - name: equVar
      title: Equal variances
      type: Bool
      default: true

Here we have changed the dependent option to deps, and changed its type from Variable to Variables. An option type of Variables allows the user to assign multiple variables/columns to the option.

We will also make some small changes to the .r.yaml file. In the previous example, we specified rows of 1, however in this case, we want the number of rows to vary with the number of dependent variables specified. If the user specifies two dependent variables, then the table should have two rows. If the user specifies three dependent variables, the table should have three rows, etc.

We achieve this through 'data binding'. We bind the number of rows to the deps variable:

...

items:
    - name: ttest
      title: Independent Samples T-Test
      type: Table
      rows: (deps)

...

Data binding is achieved by specifying the option name surrounded by (). As the number of variables assigned to the option change, the number of rows in the table change to match.

When rows in a table are data bound in this way, each row is assigned a 'key' equal to the value at that position in the option. For example, if deps was assigned the columns Age, Gender, Height, the first row would have the key Age, the second Gender and the third Height. We can use these key values to automatically populate columns in the table. For example, we could specify the content of the var column as follows:

...
      columns:
        - name: var
          title: ''
          content: ($key)
          type: text
...

Now the cells in that column will contain the name of the variable for that row.

Select Example 04 from the menu in jamovi, and observe the way that the table expands and shrinks as different variables are assigned to Dependent variables. A good data set for this is the Bugs example data set. The variables Lo D. Lo F., Hi D. Lo F., Lo D. Hi F., Hi D. Hi F. are suitable dependent variables for t-tests.

In the next example we will populate this table with results.

[Next >> Example 5](Example 5)

Tutorial

  • [Getting Started](Getting Started)
  • [Example 0](Example 0)
  • [Example 1](Example 1)
  • [Example 2](Example 2)
  • [Example 3](Example 3)
  • [Example 4](Example 4)
  • [Example 5](Example 5)

API

Clone this wiki locally