Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[paper] finalize #405

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions paper/paper.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- marginal effects
- marginal means
- model predictions
- emmeans
authors:
- name: Dominique Makowski
orcid: 0000-0001-5375-9967
Expand Down Expand Up @@ -160,12 +161,19 @@ Again, the `modelbased` package has a simple function to do so, `estimate_slopes

Until this point we have discussed marginal means and effects as being "averaged" over non-focal predictors, but there are actually various ways of doing so. The `estimate_means()`, `estimate_contrasts()`, and `estimate_slopes()` have an `estimate` argument that determines how predictions are averaged ("marginalized"). The options are:

- **"typical"** (Default): Calculates predictions for a balanced data grid representing all combinations of focal predictor levels (specified in `by`). For non-focal numeric predictors, it uses the mean; for non-focal categorical predictors, it averages over all the levels. This represents a "typical" observation based on the data grid and is useful for comparing groups. It answers: *"What would the average outcome be for a 'typical' observation?"*. This is the default approach when estimating marginal means using the `emmeans` package.
- **"typical"** (default): Calculates predictions for a balanced data grid representing all combinations of focal predictor levels (specified in `by`). For non-focal numeric predictors, it uses the mean; for non-focal categorical predictors, it averages over all the levels. This represents a "typical" observation based on the data grid and is useful for comparing groups. It answers: *"What would the average outcome be for a 'typical' observation?"*. This is the default approach when estimating marginal means using the `emmeans` package.
- **"average"**: Calculates predictions for each observation in the sample and then averages these predictions within each group defined by the focal predictors. This reflects the sample's actual distribution of non-focal predictors, not a balanced grid. It answers: *"What is the predicted value for an average observation in my data?"*.
- **"population"**: "Clones" each observation, creating copies with all possible combinations of focal predictor levels. It then averages the predictions across these "counterfactual" observations (non-observed permutations) within each group. This extrapolates to a hypothetical broader population, considering "what if" scenarios. It answers: *"What is the predicted response for the 'average' observation in a broader possible target population?"*. This approach entails more assumptions about the likelihood of different combinations, but can be more apt to generalize. **[TODO: is that correct?]**
- **"population"**: "Clones" each observation, creating copies with all possible combinations of focal predictor levels. It then averages the predictions across these "counterfactual" observations (non-observed permutations) within each group. This extrapolates to a hypothetical broader population, considering "what if" scenarios. It answers: *"What is the predicted response for the 'average' observation in a broader possible target population?"*. This approach entails more assumptions about the likelihood of different combinations, but can be more apt to generalize.

Setting `estimate = "average"` can be useful to calculate the average expected outcome from those observations _from the sample_ at hand. For analyses emphasizing outcome differences between groups (e.g., when computing contrasts) and particularly when causal effects are being considered, it may be beneficial to model a hypothetical population not directly represented in the sample. This approach, known as *G-computation* [@chatton_rohrer_2024], is implemented by setting `estimate = "population"`.

## Group-level estimates for Mixed Models

The `modelbased` package also provides the `estimate_grouplevel()` function, useful to obtain parameters related to random factors. These are often useful to extract the individual-level parameters (e.g., the value of the effects for each participant) based on mixed models (which can have benefits such as shrinkage and uncertainty quantification). These group-level estimates can be estimated in two manners:

- **"random"** (default): Corresponds to the deviation of each individual group from their fixed effect. As such, a coefficient close to 0 means that the participants' effect is the same as the population-level effect
- **"total"**: Returns the sum of the random effect and its corresponding fixed effects. These are known as BLUPs (Best Linear Unbiased Predictions) and are "absolute" values of the individual-level effects on the same scale as their corresponding fixed effects.


## Technical details

Expand Down
93 changes: 50 additions & 43 deletions paper/paper.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is XeTeX, Version 3.141592653-2.6-0.999996 (MiKTeX 24.4) (preloaded format=xelatex 2025.2.19) 19 FEB 2025 11:22
This is XeTeX, Version 3.141592653-2.6-0.999996 (MiKTeX 24.4) (preloaded format=xelatex 2025.2.19) 19 FEB 2025 12:09
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
Expand Down Expand Up @@ -1208,11 +1208,11 @@ Package fancyhdr Warning: \headheight is too small (62.59596pt):
(fancyhdr) \addtolength{\topmargin}{-0.95425pt}.

LaTeX Font Info: Font shape `TU/lmss/m/it' in size <8> not available
(Font) Font shape `TU/lmss/m/sl' tried instead on input line 372.
(Font) Font shape `TU/lmss/m/sl' tried instead on input line 371.
[1

]
Underfull \hbox (badness 6461) in paragraph at lines 426--426
Underfull \hbox (badness 6461) in paragraph at lines 424--424
[][][]\TU/lmr/m/n/8 These functions can become redundant if the defaults are ch
anged. For instance,
[]
Expand All @@ -1231,6 +1231,12 @@ Package fancyhdr Warning: \headheight is too small (62.59596pt):
(fancyhdr) \addtolength{\topmargin}{-0.95425pt}.

[2]
Underfull \hbox (badness 1484) in paragraph at lines 506--512
\TU/lmr/m/n/10 Until this point we have discussed marginal means and effects as
being “aver-
[]



File: C:/Users/mail/AppData/Local/R/win-library/4.4/rticles/rmarkdown/templates
/joss/resources/JOSS-logo.png Graphic file (type bmp)
Expand Down Expand Up @@ -1258,61 +1264,75 @@ Package fancyhdr Warning: \headheight is too small (62.59596pt):

[4]
LaTeX Font Info: Font shape `TU/lmtt/bx/n' in size <10> not available
(Font) Font shape `TU/lmtt/b/n' tried instead on input line 634.
(Font) Font shape `TU/lmtt/b/n' tried instead on input line 650.

Overfull \hbox (16.91139pt too wide) in paragraph at lines 644--644
Overfull \hbox (16.91139pt too wide) in paragraph at lines 660--660
[]\TU/lmtt/m/n/10 #> Parameter | Coefficient |
95% CI | p
[]


Overfull \hbox (16.91139pt too wide) in paragraph at lines 645--645
Overfull \hbox (16.91139pt too wide) in paragraph at lines 661--661
[]\TU/lmtt/m/n/10 #> ----------------------------------------------------------
----------------[]
[]


Overfull \hbox (11.66139pt too wide) in paragraph at lines 646--646
Overfull \hbox (11.66139pt too wide) in paragraph at lines 662--662
[]\TU/lmtt/m/n/10 #> (Intercept) | -0.05 | [-0.47
, 0.38] | 0.823[]
[]


Overfull \hbox (11.66139pt too wide) in paragraph at lines 647--647
Overfull \hbox (11.66139pt too wide) in paragraph at lines 663--663
[]\TU/lmtt/m/n/10 #> Petal Length | 0.20 | [-0.09
, 0.49] | 0.170[]
[]


Overfull \hbox (11.66139pt too wide) in paragraph at lines 648--648
Overfull \hbox (11.66139pt too wide) in paragraph at lines 664--664
[]\TU/lmtt/m/n/10 #> Species [versicolor] | -0.04 | [-0.66
, 0.59] | 0.909[]
[]


Overfull \hbox (16.91139pt too wide) in paragraph at lines 649--649
Overfull \hbox (16.91139pt too wide) in paragraph at lines 665--665
[]\TU/lmtt/m/n/10 #> Species [virginica] | 1.18 | [ 0.52
, 1.84] | < .001[]
[]


Overfull \hbox (11.66139pt too wide) in paragraph at lines 650--650
Overfull \hbox (11.66139pt too wide) in paragraph at lines 666--666
[]\TU/lmtt/m/n/10 #> Petal Length × Species [versicolor] | 0.13 | [-0.18
, 0.44] | 0.405[]
[]


Overfull \hbox (11.66139pt too wide) in paragraph at lines 651--651
Overfull \hbox (11.66139pt too wide) in paragraph at lines 667--667
[]\TU/lmtt/m/n/10 #> Petal Length × Species [virginica] | -0.04 | [-0.34
, 0.26] | 0.789[]
[]


Overfull \hbox (1.16139pt too wide) in paragraph at lines 656--656
Overfull \hbox (1.16139pt too wide) in paragraph at lines 672--672
[]\TU/lmtt/m/n/10 #> Uncertainty intervals (equal-tailed) and p-values (two-tai
led) computed[]
[]



File: C:/Users/mail/AppData/Local/R/win-library/4.4/rticles/rmarkdown/templates
/joss/resources/JOSS-logo.png Graphic file (type bmp)
<C:/Users/mail/AppData/Local/R/win-library/4.4/rticles/rmarkdown/templates/joss
/resources/JOSS-logo.png>

Package fancyhdr Warning: \headheight is too small (62.59596pt):
(fancyhdr) Make it at least 63.55022pt, for example:
(fancyhdr) \setlength{\headheight}{63.55022pt}.
(fancyhdr) You might also make \topmargin smaller:
(fancyhdr) \addtolength{\topmargin}{-0.95425pt}.

[5]
File: paper_files/figure-latex/fig1-1.pdf Graphic file (type pdf)
<use paper_files/figure-latex/fig1-1.pdf>

Expand All @@ -1328,75 +1348,62 @@ Package fancyhdr Warning: \headheight is too small (62.59596pt):
(fancyhdr) You might also make \topmargin smaller:
(fancyhdr) \addtolength{\topmargin}{-0.95425pt}.

[5]
Overfull \hbox (32.66139pt too wide) in paragraph at lines 725--725
[6]
Overfull \hbox (32.66139pt too wide) in paragraph at lines 741--741
[]\TU/lmtt/m/n/10 #> Level1 | Level2 | Difference | SE | 95% C
I | t(144) | p[]
[]


Overfull \hbox (32.66139pt too wide) in paragraph at lines 726--726
Overfull \hbox (32.66139pt too wide) in paragraph at lines 742--742
[]\TU/lmtt/m/n/10 #> ----------------------------------------------------------
-------------------[]
[]


Overfull \hbox (32.66139pt too wide) in paragraph at lines 727--727
Overfull \hbox (32.66139pt too wide) in paragraph at lines 743--743
[]\TU/lmtt/m/n/10 #> versicolor | setosa | 0.45 | 0.34 | [-0.22, 1.12
] | 1.34 | 0.183[]
[]



File: C:/Users/mail/AppData/Local/R/win-library/4.4/rticles/rmarkdown/templates
/joss/resources/JOSS-logo.png Graphic file (type bmp)
<C:/Users/mail/AppData/Local/R/win-library/4.4/rticles/rmarkdown/templates/joss
/resources/JOSS-logo.png>

Package fancyhdr Warning: \headheight is too small (62.59596pt):
(fancyhdr) Make it at least 63.55022pt, for example:
(fancyhdr) \setlength{\headheight}{63.55022pt}.
(fancyhdr) You might also make \topmargin smaller:
(fancyhdr) \addtolength{\topmargin}{-0.95425pt}.

[6]
Overfull \hbox (32.66139pt too wide) in paragraph at lines 728--728
Overfull \hbox (32.66139pt too wide) in paragraph at lines 744--744
[]\TU/lmtt/m/n/10 #> virginica | setosa | 1.03 | 0.35 | [ 0.35, 1.72
] | 2.97 | 0.003[]
[]


Overfull \hbox (32.66139pt too wide) in paragraph at lines 729--729
Overfull \hbox (32.66139pt too wide) in paragraph at lines 745--745
[]\TU/lmtt/m/n/10 #> virginica | versicolor | 0.58 | 0.09 | [ 0.39, 0.76
] | 6.18 | < .001[]
[]


Overfull \hbox (27.41139pt too wide) in paragraph at lines 783--783
Overfull \hbox (27.41139pt too wide) in paragraph at lines 799--799
[]\TU/lmtt/m/n/10 #> Level1 | Level2 | Difference | SE | 95%
CI | t | p[]
[]


Overfull \hbox (27.41139pt too wide) in paragraph at lines 784--784
Overfull \hbox (27.41139pt too wide) in paragraph at lines 800--800
[]\TU/lmtt/m/n/10 #> ----------------------------------------------------------
------------------[]
[]


Overfull \hbox (27.41139pt too wide) in paragraph at lines 785--785
Overfull \hbox (27.41139pt too wide) in paragraph at lines 801--801
[]\TU/lmtt/m/n/10 #> versicolor | setosa | 0.13 | 0.16 | [-0.17, 0.4
3] | 0.83 | 0.404[]
[]


Overfull \hbox (27.41139pt too wide) in paragraph at lines 786--786
Overfull \hbox (27.41139pt too wide) in paragraph at lines 802--802
[]\TU/lmtt/m/n/10 #> virginica | setosa | -0.04 | 0.15 | [-0.34, 0.2
6] | -0.27 | 0.789[]
[]


Overfull \hbox (27.41139pt too wide) in paragraph at lines 787--787
Overfull \hbox (27.41139pt too wide) in paragraph at lines 803--803
[]\TU/lmtt/m/n/10 #> virginica | versicolor | -0.17 | 0.07 | [-0.31, -0.0
3] | -2.41 | 0.016[]
[]
Expand All @@ -1415,7 +1422,7 @@ Package fancyhdr Warning: \headheight is too small (62.59596pt):
(fancyhdr) \addtolength{\topmargin}{-0.95425pt}.

[7]
Overfull \hbox (1.9914pt too wide) in paragraph at lines 822--831
Overfull \hbox (1.9914pt too wide) in paragraph at lines 838--847
\TU/lmtt/m/n/10 install.packages("modelbased", repos = "https://easystats.r-uni
verse.dev")\TU/lmr/m/n/10 .
[]
Expand Down Expand Up @@ -1452,16 +1459,16 @@ LaTeX2e <2024-06-01> patch level 2
L3 programming layer <2024-08-30>
***********
Package rerunfilecheck Info: File `paper.out' has not changed.
(rerunfilecheck) Checksum: CDD81DED7CD156DDF269E26F78E78400;3651.
(rerunfilecheck) Checksum: E4451A03596B26A17E9835E249B53FEC;3494.
Package logreq Info: Writing requests to 'paper.run.xml'.
\openout1 = `paper.run.xml'.

)
Here is how much of TeX's memory you used:
36936 strings out of 409029
743771 string characters out of 5756944
1640538 words of memory out of 5000000
59122 multiletter control sequences out of 15000+600000
36935 strings out of 409029
743744 string characters out of 5756944
1640322 words of memory out of 5000000
59121 multiletter control sequences out of 15000+600000
564973 words of font info for 88 fonts, out of 8000000 for 9000
1348 hyphenation exceptions out of 8191
84i,13n,87p,1196b,850s stack positions out of 10000i,1000n,20000p,200000b,200000s
Expand Down
Loading
Loading