VariableSupplier: restrict content variables

Everything related to the development of modules in jamovi
Post Reply
JavierMG
Posts: 6
Joined: Mon Feb 24, 2025 11:30 am

VariableSupplier: restrict content variables

Post by JavierMG »

Hi,

I'm trying to create a preprocessing step where only covariate (continuous) variables are normalized, however Variable supplier passes all variables not just the specified covariates. Is it possible to restrict the content to just a subset of all the variables? Thank you in advance!

This is my analysis file:

Code: Select all

 
    - name: stdCovs
      title: Standard Scaling
      type: Array
      items: (covs)
      default: [[]]
      template: 
        type: Variables
        name: var
This is my ui file:

Code: Select all

  - type: CollapseBox
    collapsed: true
    label: Preprocessing
    style: list
    stretchFactor: 1
    children:
      - type: VariableSupplier
        persistentItems: false
        stretchFactor: 1
        children:
          - type: TargetLayoutBox
            label: Standard Scaling
            children:
              - type: ListBox
                name: stdCovs
                label: Standard Scaling
                showColumnHeaders: false
                stretchFactor: 1
                fullRowSelect: true
                columns:
                  - name: var
                    stretchFactor: 1
                    template:
                      type: VariablesListBox
                      isTarget: true
User avatar
jonathon
Posts: 2847
Joined: Fri Jan 27, 2017 10:04 am

Re: VariableSupplier: restrict content variables

Post by jonathon »

hi,

so take a look at the linear regression from jmv, you'll see we have separate boxes for covariates and factors. that's the recommended way of handling this. we discourage analyses which infer how variables should be treated based on their types. as per our docs:
Avoid inferring how the user wants to treat the variable based on its type, i.e. avoid an ‘independent variables’ option, where if the user assigns a nominal variable, it is treated as a factor, and if the user assigns a continuous variable, it is treated as a covariate – this is implied behaviour, and users make mistakes.
https://dev.jamovi.org/tuts0202-handling-data.html
Screenshot 2025-02-26 at 10.53.21.png
Screenshot 2025-02-26 at 10.53.21.png (36.07 KiB) Viewed 116878 times
JavierMG
Posts: 6
Joined: Mon Feb 24, 2025 11:30 am

Re: VariableSupplier: restrict content variables

Post by JavierMG »

Hi Jonathon,

Thank you very much for your quick reply!

I think I might not have expressed myself correctly. What I want is another Variable Supplier under a collapse box where only the Covariates appear (they don't necessarily have to be numerical, although they should really). eg. if the user specifies B as a Covariate, then the new box under the collapse box should only have the variable B as an option, right now I have all A, B, and C irrespectively if they are specified as Dependent Variable, Covariates or Factors (again, doesn't matter if they are continous or categorical although it shouldn't). Can this be implemented or should I avoid such an approach?

Thank you in advance!
User avatar
jonathon
Posts: 2847
Joined: Fri Jan 27, 2017 10:04 am

Re: VariableSupplier: restrict content variables

Post by jonathon »

ah ok ... sorry, i inferred (incorrectly) what i thought you were trying to do.

you're after something like the following from GAMLj3 (i.e. where the user specifies factors and covariates, and only factors appear in the 'Components' supplier further down? [although in your case, you want to do the opposite, with only the covariates appearing])

jonathon


Screenshot 2025-02-27 at 10.17.15.png
Screenshot 2025-02-27 at 10.17.15.png (74.44 KiB) Viewed 115344 times
JavierMG
Posts: 6
Joined: Mon Feb 24, 2025 11:30 am

Re: VariableSupplier: restrict content variables

Post by JavierMG »

Hi Jonathon,

Don't worry, my bad. Yes this is exactly what I want! How could it be achieved? Sorry if its trivial, I'm new to this. Thank you.

Javier
User avatar
jonathon
Posts: 2847
Joined: Fri Jan 27, 2017 10:04 am

Re: VariableSupplier: restrict content variables

Post by jonathon »

i don't actually know myself ... but i'll ask damo and/or marcello to chip in. expect to hear from them soon.

cheers

jonathon
dropmann
Posts: 84
Joined: Thu Feb 02, 2017 10:26 am

Re: VariableSupplier: restrict content variables

Post by dropmann »

Hi Javier,

To implement this you'll need to do more than just the y.yaml. This link will give you some insights https://dev.jamovi.org/ui-advanced-customisation.html. In jamovi an example is in the ANOVA. Here is a link to the js file for the ANOVA where the model supplier is populated https://github.com/jamovi/jmv/blob/0a41 ... ova.js#L24. Let me know if you need any more assistance.

kind regards,
Damian
JavierMG
Posts: 6
Joined: Mon Feb 24, 2025 11:30 am

Re: VariableSupplier: restrict content variables

Post by JavierMG »

Hi,

Thank you very much Damian, I will have a look!

cheers,

Javier
Post Reply