Basic moves in JASP
the toolbox — dragging and R side by side
The toolbox
What this page is for: the moves that lie underneath every analysis. Adding a column, shifting a zero point. Not a lesson — a reference. You open it the moment an exercise asks for it, and close it again afterwards.
This toolbox is not full yet. There are three moves in it for now: making a computed column, filtering and centring.
Everything below runs on the diamonds: the twelve stones from the book. Twelve rows you can take in at a glance, and enough columns to practise everything on.
⬇ Download the data — stones.csv
| column | what |
|---|---|
name |
Anna, Bram, Cees … Leen |
carat |
the weight of the stone |
shine |
0–100 |
smoothness |
0–10, how well it is cut |
brand |
ripple or star |
D |
1 if it is a star, otherwise 0 |
DxS |
D × smoothness — the product, for moderation |
taken |
1 if the crow picked the stone up that night, otherwise 0 |
beautiful |
1 if the shine is above 50, otherwise 0 |
That is the shortest list there is, and enough to get going. If you want to know where this file or any of the others comes from, what the units are and exactly what is in it, open The datasets.
Two routes, one move
JASP is a point-and-click program, but there is a back door into R — and it is simply left open. Every computed column starts the same way: click the + at the far right of your data, next to the last column. You fill in a name, choose a data type, and then choose one of two icons:
- the hand icon — the drag route. You build the rule out of blocks that you pull from the lists at the edge into the middle. You cannot make a typing error in a column name this way, because you do not type it.
- the R — the R box. You write the rule as one R expression.
Then you click Create Column, and once the rule is in place: Compute column. If you later want to change a column you have already made, double-click the header of that column (that is where the fx symbol is); that takes you back into the window.
One difference to know: in the drag box you type text without quotes — high, not "high" — because JASP puts them around it there itself. If you type them anyway, JASP looks for a word with quotes in it, and it never finds one. In the R box you do type them.
Both routes make exactly the same column. They differ only in how you write the rule down — and in how far they reach: the R box can do everything the drag route can do, but the drag route cannot do everything the R box can.
In the R exercise book you type a new column like this:
d$high <- ifelse(d$shine >= 50, "high", "low")In JASP’s R box you write only the right-hand part of that:
ifelse(shine >= 50, "high", "low")Two things are gone, and both for the same reason: the dialogue window already has them. The name high you filled in at the top, so the assignment <- is no longer needed. And d$ is not needed, because JASP has one table open at a time — you call the columns by their bare names, as plain lists of numbers.
That makes this box a pleasant place to cross over. Whoever goes on to R later mainly has to learn what is added, not what is different.
Filtering rows
A filter lets some of your rows take part and puts the rest aside for a while. Nothing disappears from your file: take the filter away, and all the rows take part again. In the exercises you put one line in it each time, such as species != "Chinstrap". With the stones it goes like this:
- Click the funnel at the top left of the data table, above the row numbers (if you hover over it, it says Show filter). The filter window opens.
- The window starts with blocks to drag, with no R box yet. Click the small R button at the bottom left (Switch to the R filter); now you see the R box. If you have used the R box before, the filter opens straight into it, and you skip this step.
- In it there are first a few lines of explanation from JASP, each with a
#in front. Leave those. At the bottom is the linegeneratedFilter: remove it and type your line in its place,brand == "star". (Right at the top, in grey, there is also a line that starts withgeneratedFilter <-. That is the code JASP makes itself; you leave it alone.) - Click Apply pass-through filter.
Below the data it now says how many rows take part: Data has 12 rows, 6 (~50%) passed through filter. If it still says 12 of the 12, your line has not been applied.
Taking the filter away again. In the filter window, click the eraser to the left of Apply pass-through filter (Reset to default filter). Then all the rows take part again. Clicking the funnel once more only folds the window shut; the filter then simply stays on.
The signs. == means is equal to, != is not equal to, and <, <=, > and >= do what you expect. A word goes between quotes (brand == "star"), a number does not (carat > 1.5).
Centring
Centring is one subtraction: you take the mean off every value. That is all it is. Your data stay exactly the same — the same distances, the same order, the same spread — and yet your output is going to look different. What you shift is not the data but the zero, and zero is the place where your model begins its story.
Name carat_c, type Scale, the hand icon, Create Column.
- Drag
caratinto the middle box. - Click the
−sign. - In the function list on the right, find the
mean(y)button and click it. - Drag
caratonto the empty spot inside thatmean( ). - Compute column.
The box now reads carat - mean(carat).
carat - mean(carat)Put carat_c in Descriptives: the mean should be 0. That is no coincidence but the definition — you have just taken the mean off. If it says something like -1.1e-16, that is simply zero with some arithmetic dust around it; a computer that works with decimal numbers rarely comes out exactly.
Build in small moments like this to check. You have just done something, you know what should come out, and you look to see whether it is there — that is all. Whoever writes down the expected answer only afterwards has checked nothing, because then every number is right.
mean means something different here from what you think
In the drag box, mean(y) takes one column and gives you the mean of that column, across all rows. That is exactly what you need here.
But it is not what you need if you ever want to make a scale score — the mean of ten questions, per person. That is a mean straight across columns. The drag box has a block of its own for that, rowMean, and in the R box it goes like this:
rowMeans(data.frame(v1, v2, v3))Anyone who skipped one of the questions gets no score this way, rather than a score from fewer questions — and that is on purpose. Why, and what to do with a reversed question, is under the questionnaires.
Two means that have nothing to do with each other, with almost the same name. Here it is the first one that matters: one column, one number.
What shifts, and what does not
Run the same regression twice — Regression → Linear Regression, shine as Dependent Variable — first with carat under Covariates, then with carat_c:
| intercept | b for carat | |
|---|---|---|
raw (carat) |
−1.43 | 32.14 |
centred (carat_c) |
50.00 | 32.14 |
The slope does not move. 32.14 shine points per carat, whether you centre or not — and so it should be, because you have not touched the stones.
The intercept does move house, and that is the whole gain. Raw, it says −1.43: the predicted shine of a stone of zero carats. Such a stone does not exist, and a negative shine even less so — it is a neatly worked-out answer to a question nobody asks. Centred, it says 50.00, and that is the average shine of an average stone. From a nonsense number to a number you can read out loud.