Skip to content

Issue with inclusion of "weights" #74

Description

@edubwalsh

Greetings, when running the program with lmer function (and formula for multilevel modeling), the output changes based on the inclusion (or exclusion) of "weights").

For example, when running the following, the mean, +1SD, -1SD will be incorrectly calculated:

Example 1:

      mod_jn <- lmer(IDAS_illtemper_SUM_final ~ LupTime + BL_Mean_BOLD_RPut_FB_Slow_Win + 
                       fMRI_Diff_RPut_FB_Slow_Win + age + BL_Mean_BOLD_RPut_FB_Slow_Win * 
                       LupTime + fMRI_Diff_RPut_FB_Slow_Win * LupTime + (1 | Subject), 
                       data = mod_pred, weights = weights, REML = TRUE) 

      # JN analysis and plots:
      jn <- probe_interaction(model=mod_jn, 
                       pred = LupTime,
                       modx = fMRI_Diff_RPut_FB_Slow_Win,
                       digits = getOption("jtools-digits", 2),
                       jnplot = TRUE,
                       confint = TRUE
                       )

Slope of LupTime when fMRI_Diff_RPut_FB_Slow_Win = 0.2538121 (- 1 SD): 

   Est.   S.E.    2.5%   97.5%   t val.      p
------- ------ ------- ------- -------- ------
  -0.28   0.09   -0.46   -0.09    -2.97   0.00

Slope of LupTime when fMRI_Diff_RPut_FB_Slow_Win = 0.5633464 (Mean): 

   Est.   S.E.    2.5%   97.5%   t val.      p
------- ------ ------- ------- -------- ------
  -0.45   0.06   -0.57   -0.33    -7.20   0.00

Slope of LupTime when fMRI_Diff_RPut_FB_Slow_Win = 0.8728807 (+ 1 SD): 

   Est.   S.E.    2.5%   97.5%   t val.      p
------- ------ ------- ------- -------- ------
  -0.62   0.12   -0.86   -0.38    -5.14   0.00

If I remove "weights" from the code, the mean, +1SD, -1SD will be CORRECTLY calculated and the plot appears as expected. this doesn't represent the complete formula for my model. Additionally, weighting seems most appropriate.

Example 2:

      mod_jn <- lmer(IDAS_illtemper_SUM_final ~ LupTime + BL_Mean_BOLD_RPut_FB_Slow_Win + 
                       fMRI_Diff_RPut_FB_Slow_Win + age + BL_Mean_BOLD_RPut_FB_Slow_Win * 
                       LupTime + fMRI_Diff_RPut_FB_Slow_Win * LupTime + (1 | Subject), 
                       data = mod_pred, REML = TRUE) 

Slope of LupTime when fMRI_Diff_RPut_FB_Slow_Win = -0.36811581 (- 1 SD): 

   Est.   S.E.    2.5%   97.5%   t val.      p
------- ------ ------- ------- -------- ------
  -0.12   0.14   -0.39    0.14    -0.91   0.37

Slope of LupTime when fMRI_Diff_RPut_FB_Slow_Win =  0.07231536 (Mean): 

  Est.   S.E.    2.5%   97.5%   t val.      p
------ ------ ------- ------- -------- ------
  0.05   0.07   -0.09    0.20     0.73   0.47

Slope of LupTime when fMRI_Diff_RPut_FB_Slow_Win =  0.51274654 (+ 1 SD): 

  Est.   S.E.    2.5%   97.5%   t val.      p
------ ------ ------- ------- -------- ------
  0.23   0.14   -0.04    0.50     1.69   0.09

Finally, if I leave the full formula and attempt to fix the mod.x values, the lines appear flipped -- that is, where -1 SD should be, +1 SD is, and vice versa, on the interaction plot. This is in contrast to both Example 2 (above) and ggplots (accounting for weights).

Example 3:

      jn <- probe_interaction(model=mod_jn, 
                       pred = LupTime,
                       modx = fMRI_Diff_RPut_FB_Slow_Win,
                       modx.values = c(-0.37, 0.07, 0.51),
                       modx.labels = c("-1 SD", "Mean", "+1 SD"),
                       digits = getOption("jtools-digits", 2),
                       jnplot = TRUE,
                       confint = TRUE
                       )

Any insight on what might be driving this discrepancy when using "weights" in the formula? Thank you for your time!

example2
example3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions