Permalink
Browse files

finalized mixed vignette

  • Loading branch information...
1 parent c90fe38 commit 3766a261ff0016a8967ec96fdc001edbd1787e8a @singmann committed Apr 4, 2017
Showing with 333 additions and 45 deletions.
  1. +1 −0 afex.Rproj
  2. +9 −9 inst/doc/anova_posthoc.html
  3. +29 −2 inst/doc/mixed_example_1.R
  4. +72 −10 inst/doc/mixed_example_1.Rmd
  5. +150 −14 inst/doc/mixed_example_1.html
  6. +72 −10 vignettes/mixed_example_1.Rmd
View
@@ -14,3 +14,4 @@ LaTeX: pdfLaTeX
BuildType: Package
PackageInstallArgs: --no-multiarch --with-keep.source
+PackageCheckArgs: --no-tests
@@ -12,7 +12,7 @@
<meta name="author" content="Henrik Singmann" />
-<meta name="date" content="2017-04-02" />
+<meta name="date" content="2017-04-04" />
<title>ANOVA and Post-Hoc Contrasts: Reanalysis of Singmann and Klauer (2011)</title>
@@ -70,7 +70,7 @@
<h1 class="title toc-ignore">ANOVA and Post-Hoc Contrasts: Reanalysis of Singmann and Klauer (2011)</h1>
<h4 class="author"><em>Henrik Singmann</em></h4>
-<h4 class="date"><em>2017-04-02</em></h4>
+<h4 class="date"><em>2017-04-04</em></h4>
@@ -242,7 +242,7 @@ <h4 class="date"><em>2017-04-02</em></h4>
<p>Alternatively, the <code>anova</code> method for <code>afex_aov</code> objects returns a <code>data.frame</code> of class <code>anova</code> that can be passed to, for example, <code>xtable</code> for nice formatting:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">print</span>(xtable::<span class="kw">xtable</span>(<span class="kw">anova</span>(a1), <span class="dt">digits =</span> <span class="kw">c</span>(<span class="kw">rep</span>(<span class="dv">2</span>, <span class="dv">5</span>), <span class="dv">3</span>, <span class="dv">4</span>)), <span class="dt">type =</span> <span class="st">&quot;html&quot;</span>)</code></pre></div>
<!-- html table generated in R 3.3.3 by xtable 1.8-2 package -->
-<!-- Sun Apr 2 23:49:13 2017 -->
+<!-- Tue Apr 4 11:41:00 2017 -->
<table border="1">
<tr>
<th>
@@ -468,12 +468,12 @@ <h4 class="date"><em>2017-04-02</em></h4>
##
## Linear Hypotheses:
## Estimate Std. Error t value Pr(&gt;|t|)
-## MP - MT == 0 10.831 4.612 2.349 0.068842 .
-## MP - AC == 0 18.100 4.612 3.925 0.000788 ***
+## MP - MT == 0 10.831 4.612 2.349 0.068913 .
+## MP - AC == 0 18.100 4.612 3.925 0.000763 ***
## MP - DA == 0 4.556 4.612 0.988 0.325273
-## MT - AC == 0 7.269 4.612 1.576 0.281747
+## MT - AC == 0 7.269 4.612 1.576 0.281917
## MT - DA == 0 -6.275 4.612 -1.361 0.296932
-## AC - DA == 0 -13.544 4.612 -2.937 0.017788 *
+## AC - DA == 0 -13.544 4.612 -2.937 0.017960 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- free method)</code></pre>
@@ -713,8 +713,8 @@ <h4 class="date"><em>2017-04-02</em></h4>
## Linear Hypotheses:
## Estimate Std. Error t value Pr(&gt;|t|)
## diff_1 == 0 4.175 8.500 0.491 0.623874
-## diff_2 == 0 34.925 8.500 4.109 0.000224 ***
-## diff_3 == 0 -23.600 8.500 -2.777 0.017382 *
+## diff_2 == 0 34.925 8.500 4.109 0.000219 ***
+## diff_3 == 0 -23.600 8.500 -2.777 0.017300 *
## diff_4 == 0 -8.100 8.500 -0.953 0.564739
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
View
@@ -59,7 +59,6 @@ xyplot(mean ~ density:frequency|task+stimulus, agg_p, jitter.x = TRUE, pch = 20,
}) +
bwplot(mean ~ density:frequency|task+stimulus, agg_p, pch="|", do.out = FALSE)
-
## ---- fig.width=7, fig.height=6---------------------------------------------------------
agg_i <- fhch %>% group_by(item, task, stimulus, density, frequency) %>%
summarise(mean = mean(log_rt)) %>%
@@ -73,7 +72,6 @@ xyplot(mean ~ density:frequency|task+stimulus, agg_i, jitter.x = TRUE, pch = 20,
}) +
bwplot(mean ~ density:frequency|task+stimulus, agg_i, pch="|", do.out = FALSE)
-
## ---- eval = FALSE----------------------------------------------------------------------
#
# m1s <- mixed(log_rt ~ task*stimulus*density*frequency + (stimulus*density*frequency|id)+
@@ -120,7 +118,36 @@ res_lrt
## ---------------------------------------------------------------------------------------
nice_lrt[[2]]
+## ---------------------------------------------------------------------------------------
+lsm.options(lmer.df = "asymptotic") # also possible: 'satterthwaite', 'kenward-roger'
+emm_i1 <- lsmeans(m2s, "frequency", by = c("stimulus", "task"))
+emm_i1
+
+## ---------------------------------------------------------------------------------------
+contrast(pairs(emm_i1), by = NULL, adjust = "holm")
+
+## ---------------------------------------------------------------------------------------
+emm_i1b <- summary(contrast(emm_i1, by = NULL))
+emm_i1b[,c("estimate", "SE")] <- exp(emm_i1b[,c("estimate", "SE")])
+emm_i1b
+
+## ---------------------------------------------------------------------------------------
+emm_i2 <- lsmeans(m2s, c("density", "frequency"), by = c("stimulus", "task"))
+con1 <- contrast(emm_i2, "trt.vs.ctrl1", by = c("frequency", "stimulus", "task")) # density
+con2 <- contrast(con1, "trt.vs.ctrl1", by = c("contrast", "stimulus", "task"))
+test(con2, joint = TRUE, by = c("stimulus", "task"))
+
+## ---------------------------------------------------------------------------------------
+emm_i2
+# desired contrats:
+des_c <- list(
+ ll_hl = c(1, -1, 0, 0),
+ lh_hh = c(0, 0, 1, -1)
+ )
+contrast(contrast(emm_i2, des_c), by = NULL, adjust = "holm")
+
## ---- echo=FALSE, eval = FALSE----------------------------------------------------------
+# ### OLD STUFF BELOW. PLEASE IGNORE.
# load("freeman_models.rda")
# load("../freeman_models_all.rda")
# m1lrt$restricted_models <- list(NULL)
Oops, something went wrong.

0 comments on commit 3766a26

Please sign in to comment.