title: How to do a marginal model analysis in R?
body: <p><strong>Problem.</strong> I'd like to do a marginal model analysis in R--I think it is sometimes called population averaged model, marginal multilevel model or marginal linear regression model. However, I can't find any information on stackoverflow, Google, or Youtube about how to do this specifically in R.</p>
  
  <p><strong>Background.</strong> I'm talking about marginal models as described by <em>The Analysis Factor</em> <a href="https://www.theanalysisfactor.com/repeated-measures-approaches/" rel="nofollow noreferrer">here</a> and <a href="https://www.theanalysisfactor.com/repeated-and-random-2/" rel="nofollow noreferrer">here</a> and as described on these <a href="http://linguistics.arts.sfu.ca/nwav45/wp-content/uploads/2017/02/2016-MarginalModels-NWAV45.pptx" rel="nofollow noreferrer">PowerPoint slides</a>. There's <a href="https://stats.stackexchange.com/questions/363782/marginal-model-in-r-and-spss">one person on CrossValidated</a> who mentions this analysis in SPSS and R but he doesn't show his actual code, and his question hasn't been answered. Not sure if should be done in <code>nlme</code> package or not.</p>
  
  <p><strong>SPSS Code.</strong> I've described the nature of this data <a href="https://stats.stackexchange.com/questions/384963/is-my-repeated-measures-multilevel-model-correctly-specified-in-r">elsewhere on CrossValidated</a>, but basically, we're interested in predicting participants emotion (measured twice in 2 different conditions) via personality (measured once). Here's the code I used in SPSS.</p>
  
  <pre><code>MIXED emotion BY condition WITH centeredPersonality
      /FIXED=condition centeredPersonality condition*centeredPersonality
      /METHOD = REML
      /REPEATED= condition | SUBJECT (ID) COVTYPE(UN)
      /PRINT=SOLUTION.
  </code></pre>
  
  <p><strong>Question.</strong> How to do this in R?</p>