jamovi-amm / jamm

jamovi Advanced Mediation Models
Apache License 2.0
10 stars 5 forks source link

erro using syntax from Jamovi into R #7

Closed BTunca closed 1 year ago

BTunca commented 4 years ago

Hi @mcfanda !

I really like the JAMM module in JAMOVI. I am preparing a Markdown document for my analyses in JAMOVI. I managed to install the JAMM package in R and load it, but when I run the syntax from JAMOVI output I get the following error:

"Error: Argument 'dep' contains '#### end ###' which is not present in the dataset"

image

Here are all other libraries I load

image

I appreciate any help,

Thanks again for your work! /BT

mcfanda commented 4 years ago

The R interface of jAMM is very clumsy. I'm working on it but it requires quite some work to make it work fine

mcfanda commented 4 years ago

At the moment (version 1.0.4) you can make it work in R not using the formula interface. In your example, you should run it like this:

jamm::jammGLM(
  data = data,
  dep = Y,
  mediators = MED,
  covs = "X",
  mediatorsTerms = "X",
  modelTerms = c("MED","X"))

In case X is a categorical one, you need to go like this:

amm::jammGLM(
  data = data,
  dep = Y,
  mediators = MED,
  factors = "X",
  contrasts = list(list(var="X",type="simple")),
  mediatorsTerms = "X",
  modelTerms = c("MED","X"))

I know it's ugly. In the next version one would use the formula interface and it would be much easier