Computing new variables — recycling code

Discuss the jamovi platform, possible improvements, etc.
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Computing new variables — recycling code

Post by leehw »

I'm hugely grateful to the Jamovi team for what they've achieved already. My whole department (40 staff and nearly 1000 students) is seriously considering switching to Jamovi instead of SPSS in the near future. There are a few features we would miss from SPSS though. This is the main one at the moment, for me, unless someone can tell me how...

Because we often use the same psychometric measures in studies, we often need to compute variables using some simple algorithm (sum, sum of products, weighted sum, or such), and so we have a bank of syntax that we use for this in SPSS. We can then paste this from one project into the next, for those scales we need. I don't seem to be able to find out how to do this in jamovi. Any ideas?

I've tried turning on syntax mode when using the 'compute' features in jamovi, but no syntax comes out (that would be nice).

I've also tried this kind of thing in Rj editor:

Code: Select all

data$test <- data$Sepal.Length + data$Sepal.Width
That doesn't seem to write the new variable to the dataset. Is there a way to do that in Rj editor?
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Computing new variables — recycling code

Post by jonathon »

hi,
Because we often use the same psychometric measures in studies, we often need to compute variables using some simple algorithm (sum, sum of products, weighted sum, or such), and so we have a bank of syntax that we use for this in SPSS. We can then paste this from one project into the next, for those scales we need. I don't seem to be able to find out how to do this in jamovi. Any ideas?
so with SPSS, you have some bank/file of syntax you copy/paste from/into spss to compute these new variables. can you not do the same thing with jamovi's computed variables? you copy/paste jamovi formulas from/to into jamovi?

(granted, it's not a sexy solution).
That doesn't seem to write the new variable to the dataset. Is there a way to do that in Rj editor?
no, the Rj Editor can't alter that spreadsheet data at this time.

kind regards

jonathon
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Re: Computing new variables — recycling code

Post by leehw »

We can, of course, but it's much more time consuming to click compute and paste each little code snippet, rather than just dumping in a chunk of code that creates maybe 20 computed variables.

Rj Editor being able to alter the dataset might be really useful for some other functions too, so I for one would appreciate it.

Thanks for the quick replies, and keep up the good work!
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Computing new variables — recycling code

Post by jonathon »

ah wait, so do your data sets conform to a similar pattern each time? i.e. consistent column names? (i assume so, otherwise being able to reuse spss syntax wouldn't work?)

in which case you can use jamovi templates:

https://blog.jamovi.org/2019/03/27/import.html

this is our user-friendly alternative to scripting.

jonathon
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Re: Computing new variables — recycling code

Post by leehw »

I'd be intrigued to know whether use of templates is possible. We might have groups of up to 50 variables, named in a consistent way...

AAQ_1
AAQ_2
AAQ_3
...
BDI_1
BDI_2
BDI_3
...
SRF_1
SRF_2
SRF_3
...

But in a given dataset we might only have a subset of those, e.g. SRF, AAQ, but not BDI. The subset of those variables varies depending on which measures were used in each research project.

Have I made sense?
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Computing new variables — recycling code

Post by jonathon »

oh yup. you could still use templates in this situation. say with the columns

AAQ_SUM
BDI_SUM
SRF_SUM

summing the items together.

if you import a data set into the template which lacks the BDI columns, then the BDI_SUM column would end up blank.

would that be ok? or is there really too many of these optional columns for this not to be unwieldy?

kind regards

jonathon
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Re: Computing new variables — recycling code

Post by leehw »

Hi. Sorry for the delay. Yes, in truth this would be unwieldy for our use case. We have maybe 50 different measures we repeatedly use, and any given project might include 10 of these. We currently have ~50 syntax files, and just copy and paste the syntax from the ~10 we need into the code for the given project. I can see how we could do the same thing in Jamovi, as you suggest, but the different syntax files tend to be written by the members of our team who use those measures the most. There's relatively little added overhead in each maintaining half a dozen syntax files and sharing them when needed. It seems to me that it might not be as straightforward if we need a single Jamovi file, owing to the inability to copy and paste code.

On the one hand, I can see that our set-up might be relatively unusual. On the other, I'm inclined to think that most psychologists use psychometric scales where there's standardized scoring.

Thanks for continuing to develop what is shaping up to be a very nice piece of software.

Lee
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Computing new variables — recycling code

Post by jonathon »

yeah ok, i'll give it some thought.

jonathon
RaphaelHuber
Posts: 6
Joined: Mon Nov 30, 2020 2:16 pm

Re: Computing new variables — recycling code

Post by RaphaelHuber »

Hi

I'd have something to add here.

traceability

If I use STATA or SPSS or R, I can send other researchers my raw data, plus syntax file and they can reconstruct every single step or change them.

It is good and in some places common research practice to create a syntax file for all steps done with the Raw-Data even when using a graphical interface like SPSS.

Jamovi, for now, does not allow for that, because the typical first step, transforming, inverting variables, creating sums, means etc. is not being spewed out as syntax and syntax can not be used to make jamovi do that stuff.

So, this is really the one thing, that prohibits me, from a professional researcher standpoint, from using Jamovi. Which is otherwise totally awesome!
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Re: Computing new variables — recycling code

Post by leehw »

I'm afraid I agree with RaphaelHuber here. I think if it were possible to insert an R code chunk wherein one could write variables back to the dataset, and have that R code appear in the output pane for clarity, then it would go a long way to addressing this issue.

I have started using Jamovi for teaching and students absolutely love it by comparison with SPSS. And don't even get them (or me) started on AMOS. The potential in Jamovi's approach is enormous, and the progress being made is truly mind blowing, but there are a few 'power features' missing and that's holding me back from using it as my go-to for my own research. This is one of the main ones.
Post Reply