From b07d17ad56abf76b108e68649c24c852aa39ac88 Mon Sep 17 00:00:00 2001 From: DominiqueMakowski Date: Wed, 10 Jan 2018 10:48:53 +0100 Subject: [PATCH 1/3] Init --- DESCRIPTION | 5 +- R/analyze.stanreg.R | 2 + README.md | 2 +- man/analyze.stanreg.Rd | 2 + psycho.Rproj | 1 + tests/testthat/test-analyze.stanreg.R | 2 +- vignettes/overview.R | 157 ++++++ vignettes/overview.Rmd | 13 +- vignettes/overview.html | 677 ++++++++++++++++++++++++++ 9 files changed, 850 insertions(+), 11 deletions(-) create mode 100644 vignettes/overview.R create mode 100644 vignettes/overview.html diff --git a/DESCRIPTION b/DESCRIPTION index 53b6ade..a3c647f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: psycho Type: Package Title: Efficient and Publishing-Oriented Workflow for Psychological Science -Version: 0.0.7 +Version: 0.0.8 Authors@R: c( person("Dominique", "Makowski", @@ -30,8 +30,6 @@ Imports: dplyr, tidyr, purrr, - tidyverse, - rtf, psych, MASS, nFactors, @@ -42,6 +40,7 @@ Imports: MuMIn, lmerTest Suggests: + tidyverse, knitr, rmarkdown, testthat, diff --git a/R/analyze.stanreg.R b/R/analyze.stanreg.R index bc1e92c..9835594 100644 --- a/R/analyze.stanreg.R +++ b/R/analyze.stanreg.R @@ -11,6 +11,7 @@ #' @return output #' #' @examples +#' \dontrun{ #' library(psycho) #' require(rstanarm) #' fit <- rstanarm::stan_glm(vs ~ mpg * cyl, data=mtcars) @@ -26,6 +27,7 @@ #' summary(results) #' plot(results) #' print(results) +#' } #' #' @author \href{https://dominiquemakowski.github.io/}{Dominique Makowski} #' diff --git a/README.md b/README.md index 1837fa1..cc948c2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ |----------------|---| |Stable|[![CRAN](https://www.r-pkg.org/badges/version/psycho)](https://CRAN.R-project.org/package=psycho)| |Documentation|[![Rdoc](http://www.rdocumentation.org/badges/version/psycho)](http://www.rdocumentation.org/packages/psycho)| -|Examples|[![](https://img.shields.io/badge/vignettes-0.0.2-orange.svg?colorB=FF5722)](https://CRAN.R-project.org/package=psycho/vignettes/overview.html)| +|Examples|[![](https://img.shields.io/badge/vignettes-0.0.8-orange.svg?colorB=FF5722)](https://CRAN.R-project.org/package=psycho/vignettes/overview.html)| |Questions|[![](https://img.shields.io/badge/issue-create-purple.svg?colorB=FF9800)](https://github.com/neuropsychology/psycho.R/issues)| |Authors|[![](https://img.shields.io/badge/CV-D._Makowski-purple.svg?colorB=9C27B0)](https://dominiquemakowski.github.io/)| diff --git a/man/analyze.stanreg.Rd b/man/analyze.stanreg.Rd index 0aa48af..6d43742 100644 --- a/man/analyze.stanreg.Rd +++ b/man/analyze.stanreg.Rd @@ -24,6 +24,7 @@ output Analyze stanreg objects. } \examples{ +\dontrun{ library(psycho) require(rstanarm) fit <- rstanarm::stan_glm(vs ~ mpg * cyl, data=mtcars) @@ -39,6 +40,7 @@ results <- analyze(fit) summary(results) plot(results) print(results) +} } \author{ diff --git a/psycho.Rproj b/psycho.Rproj index f0d6187..e5c3f7c 100644 --- a/psycho.Rproj +++ b/psycho.Rproj @@ -18,4 +18,5 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageCheckArgs: --as-cran PackageRoxygenize: rd,collate,namespace,vignette diff --git a/tests/testthat/test-analyze.stanreg.R b/tests/testthat/test-analyze.stanreg.R index 8ae4e51..1ecf12e 100644 --- a/tests/testthat/test-analyze.stanreg.R +++ b/tests/testthat/test-analyze.stanreg.R @@ -14,7 +14,7 @@ test_that("If it works.", { model <- psycho::analyze(fit) values <- psycho::values(model) - testthat::expect_equal(round(values$mpg$median, 2), -0.64, tolerance = 0.05) + testthat::expect_equal(round(values$mpg$median, 2), -0.64, tolerance = 0.10) fit <- rstanarm::stan_glmer( diff --git a/vignettes/overview.R b/vignettes/overview.R new file mode 100644 index 0000000..2861e6b --- /dev/null +++ b/vignettes/overview.R @@ -0,0 +1,157 @@ +## ---- echo=F, message=FALSE, warning=FALSE------------------------------- +library(knitr) +library(tidyverse) +library(broom) +library(rstanarm) + +## ------------------------------------------------------------------------ +# Do this once (uncomment if needed) +# install.packages("devtools") +# library(devtools) +# devtools::install_github("https://github.com/neuropsychology/psycho.R") + +# Load psycho (at the beginning of every script) +library(psycho) + +## ---- out.width=700, echo = FALSE, eval = TRUE, fig.align='center'------- +knitr::include_graphics("images/workflow.PNG") + +## ---- fig.width=8, eval = TRUE, fig.align='center', results='hide'------- +library(psycho) + +df <- iris + +cor <- psycho::correlation(df, + type = "full", + method = "pearson", + adjust = "none") + +print(cor) + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(print(cor)) + +## ---- fig.width=8, eval = TRUE, fig.align='center'----------------------- +plot(cor) + +## ---- fig.width=8, eval = TRUE, fig.align='center', results='hide'------- +library(psycho) + +df <- iris + +pcor <- psycho::correlation(df, + type = "partial", + method = "pearson", + adjust = "bonferroni") + +print(pcor) + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(print(pcor)) + +## ---- out.width=8, eval = TRUE, fig.align='center', results='markup'----- +library(psycho) +library(tidyverse) + +iris %>% + select(Species, Sepal.Length, Petal.Length) %>% + psycho::normalize() %>% + summary() + +## ---- fig.width=7, fig.height=4.5, eval = TRUE, results='markup', fig.align='center'---- +library(psycho) + +results <- psycho::assess(124, mean=100, sd=15) + +# Print it +print(results) + +# Plot it +plot(results) + +## ----echo=FALSE, message=FALSE, warning=FALSE, results='hide'------------ +results <- attitude %>% + select_if(is.numeric) %>% + psycho::n_factors() + +# Get a summary +summary(results) + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(summary(results)) + +## ----echo=FALSE, message=FALSE, warning=FALSE, results='hide'------------ +psycho::values(results)$methods + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(psycho::values(results)$methods) + +## ---- fig.width=7, fig.height=4.5, eval = TRUE, results='markup', fig.align='center'---- +plot(results) + +## ---- results='hide'----------------------------------------------------- +set.seed(666) +df <- data.frame(Participant = as.factor(rep(1:25, each = 4)), + Item = rep_len(c("i1", "i2", "i3", "i4"), 100), + Condition = rep_len(c("A", "B", "A", "B", "B"), 20), + Error = as.factor(sample(c(0, 1), 100, replace = T)), + RT = rnorm(100, 30, .2), + Stress = runif(100, 3, 5)) + +# Normalize the numeric variables. +df <- psycho::normalize(df) + +# Take a look at the first 10 rows +head(df) + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(head(df)) + +## ----message=FALSE, warning=FALSE, results='markup'---------------------- +# Format data +df_for_anova <- df %>% + dplyr::group_by(Participant, Condition) %>% + dplyr::summarise(RT = mean(RT)) + +# Run the anova +anova <- aov(RT ~ Condition + Error(Participant), df_for_anova) +summary(anova) + +## ----fig.align='center', message=FALSE, warning=FALSE, val=TRUE, results='markup'---- +library(lmerTest) + +fit <- lmerTest::lmer(RT ~ Condition + (1|Participant) + (1|Item), data=df) + +# Traditional output +summary(fit) + +## ---- message=FALSE, results="hide"-------------------------------------- +results <- psycho::analyze(fit) + +# We can extract a formatted summary table +summary(results, round = 2) + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(summary(results, round = 2)) + +## ---- results='markup'--------------------------------------------------- +print(results) + +## ----fig.align='center', message=FALSE, warning=FALSE, val=TRUE, results='hide'---- +library(rstanarm) + +fit <- rstanarm::stan_lmer(RT ~ Condition + (1|Participant) + (1|Item), data=df) + +# Traditional output +results <- psycho::analyze(fit, effsize=T) +summary(results, round=2) + +## ----echo=FALSE, message=FALSE, warning=FALSE---------------------------- +kable(summary(results, round = 2)) + +## ---- results='markup'--------------------------------------------------- +print(results) + +## ---- fig.width=7, fig.height=4.5, eval = TRUE, results='markup', fig.align='center'---- +plot(results) + diff --git a/vignettes/overview.Rmd b/vignettes/overview.Rmd index 9547280..4f918c2 100644 --- a/vignettes/overview.Rmd +++ b/vignettes/overview.Rmd @@ -12,6 +12,7 @@ abstract: | vignette: > %\VignetteIndexEntry{Overview} %\VignetteEngine{knitr::rmarkdown} + %\VignetteDepends{tidyverse} \usepackage[utf8]{inputenc} --- @@ -190,11 +191,11 @@ plot(results) ## Analyze the Mixed-Modelling Framework -This is possibly the most important function of the `psycho` package. Its goal is to transform complex outputs of complex statistical routines into something readable, interpretable, and formatted. It is designed to work with frequentist and Bayesian mixed models, which is the central statistical routine used in psychological science. +This is possibly the most important function of the `psycho` package. Its goal is to transform complex outputs of complex statistical routines into something readable, interpretable, and formatted. It is designed to work with frequentist and Bayesian mixed models, which is the central statistical method for psychological science. ### Data Creation -Let's start by creating a dataframe similar to those find in psychological science. +Let's start by creating a dataframe similar to those found in psychological science. ```{r, results='hide'} set.seed(666) @@ -216,11 +217,11 @@ head(df) kable(head(df)) ``` -This dataframe contains the data of 25 participants (labelled from 1 to 25), that saw 4 items (i1-i4) in two conditions (A and B). We measured, for each item, if the response was correct or not (Error), its reaction time (RT) and the stress associated with the trial. +This dataframe contains the data of 25 participants (labelled from 1 to 25). Each saw 4 different items (i1-i4) in two conditions (A and B). We measured, for each item, if the response was correct or not (Error), its reaction time (RT) and the stress associated with the trial. ### Ancient Approach -In order to investigate the effect of the condition on the reaction time RT, the traditional, ancient and obsolete routines are to compute the mean for each participant, and run an ANOVA. +In order to investigate the effect of the condition on the reaction time RT, the traditional, ancient and obsolete routine is 1) to compute the mean for each participant, and 2) run an ANOVA. ```{r message=FALSE, warning=FALSE, results='markup'} # Format data @@ -233,7 +234,7 @@ anova <- aov(RT ~ Condition + Error(Participant), df_for_anova) summary(anova) ``` -As we can see, the effect of condition is not significant (unsuprisingly, as data was generated randomly). One of the many flaws of this approach is that we lose information about intra-individual and item-related variability. +As we can see, the effect of the condition is not significant (unsuprisingly, as data was generated randomly). One of the many flaws of this approach is that we lose information about intra-individual and item-related variability. ### Mixed Linear Regressions (lme4, lmerTest) @@ -271,7 +272,7 @@ print(results) ### Bayesian Mixed Linear Regressions (rstanarm) -However, as the frequentist framework is criticized, it is advised to switch to a Bayesian framework. However, the interpretation of these models is even more complex and unfamiliar to regular psychologists. But stay calm, because `analyze()` handles this difficulty for you. +However, as the frequentist framework is criticized, it is advised to switch to the Bayesian framework. Unfortunately, interpretation of these models remain unfamiliar to regular psychologists. But stay calm, because `analyze()` handles this for you. ```{r fig.align='center', message=FALSE, warning=FALSE, val=TRUE, results='hide'} library(rstanarm) diff --git a/vignettes/overview.html b/vignettes/overview.html new file mode 100644 index 0000000..2c601f8 --- /dev/null +++ b/vignettes/overview.html @@ -0,0 +1,677 @@ + + + + + + + + + + + + + + + + +psycho for R + + + + + + + + + + + + + + + + + + +

psycho for R

+

Dominique Makowski

+

2018-01-09

+
+

Abstract

+

Psycho is an R package that aims at providing tools for psychologists, neuropsychologists and neuroscientists, to transform statistical outputs into something readable that can be, almost directly, copied and pasted into a report. It also implements various functions useful in psychological science, such as correlation matrices, assessment plot creation or normalization. The package revolves around the psychobject. Main functions from the package return this type, and the analyze() function transforms other R objects into psychobjects. Four functions can then be applied on a psychobject: summary(), print(), plot() and values(). Contrary to many other packages which goal is to produce statistical analyzes, psycho aims at filling the gap between statistical R outputs and statistical report writing, with a focus on APA formatting guidelines, to enhance the standardization of results reporting. Complex outputs, such as those of Bayesian and frequentist mixed models, are automatically transformed into readable text, tables, and plots that illustrate the effects. Thus, the results can easily be incorporated into shareable reports and publications, promoting data exploration, saving time and preventing errors for better, reproducible, science.

+
+ + +
+ +
+ +
+
+

Overview

+
+

Installation

+
# Do this once (uncomment if needed)
+# install.packages("devtools") 
+# library(devtools)
+# devtools::install_github("https://github.com/neuropsychology/psycho.R")
+
+# Load psycho (at the beginning of every script)
+library(psycho)
+
+
+

General Workflow

+

The package mainly revolves around the psychobject. Main functions from the package return this type, and the analyze() function transforms other R objects into psychobjects. Then, 4 functions can be applied on a psychobject: summary(), print(), plot() and values().

+

+ +
+
+
+
+

Examples

+
+

Correlation Table and Plot

+

It is possible to quickly run a correlation analysis on a dataframe with the flexible and powerful correlation() function.

+
+

Basic Correlations

+
library(psycho)
+
+df <- iris
+
+cor <- psycho::correlation(df, 
+                           type = "full",
+                           method = "pearson",
+                           adjust = "none")
+
+print(cor)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sepal.LengthSepal.WidthPetal.Length
Sepal.LengthNANANA
Sepal.Width-0.12NANA
Petal.Length0.87***-0.43***NA
Petal.Width0.82***-0.37***0.96***
+

You can save this correlation matrix using write.csv(print(cor), "correlation_table.csv"). That is very useful to copy/paste it from excel to a paper or a report :)

+

You can also draw a quick visualization:

+
plot(cor)
+

+
+
+

Partial, Corrected, Correlations

+

correlation() offers the possibility to run partial or semi-partial correleations.

+
library(psycho)
+
+df <- iris
+
+pcor <- psycho::correlation(df, 
+                           type = "partial",
+                           method = "pearson",
+                           adjust = "bonferroni")
+
+print(pcor)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sepal.LengthSepal.WidthPetal.Length
Sepal.LengthNANANA
Sepal.Width0.63***NANA
Petal.Length0.72***-0.62***NA
Petal.Width-0.34***0.35***0.87***
+
+
+
+
+

Normalize / Z-score / Scale

+

The normalize() function allows you to easily scale and center all numeric variables of a dataframe. It is similar to the base function scale(), but presents some advantages: it is tidyverse-friendly, data-type friendly (i.e., does not transform it into a matrix) and can handle dataframes with categorical data.

+
library(psycho)
+library(tidyverse)
+
+iris %>% 
+  select(Species, Sepal.Length, Petal.Length) %>% 
+  psycho::normalize() %>% 
+  summary()
+
##        Species    Sepal.Length       Petal.Length    
+##  setosa    :50   Min.   :-1.86378   Min.   :-1.5623  
+##  versicolor:50   1st Qu.:-0.89767   1st Qu.:-1.2225  
+##  virginica :50   Median :-0.05233   Median : 0.3354  
+##                  Mean   : 0.00000   Mean   : 0.0000  
+##                  3rd Qu.: 0.67225   3rd Qu.: 0.7602  
+##                  Max.   : 2.48370   Max.   : 1.7799
+
+
+
+

Assess

+

This function is useful in clinical activity. It is sometimes necessary to show to the patient, his family or other members of staff, a visual representation of his score. The assess() function also computes the percentile and the Z-score, often needed for neuropsychological reports.

+
library(psycho)
+
+results <- psycho::assess(124, mean=100, sd=15)
+
+# Print it
+print(results)
+
## [1] "The participant (score = 124) is positioned at 1.6 standard deviations from the mean (M = 100, SD = 15). The participant's score is greater than 94.43 % of the general population."
+
# Plot it
+plot(results)
+

+
+
+
+

How many factors/components to retain?

+

The n_factors() function is useful in before running principal component (PCA) or factor (FA) analysis. As many statistical methods exists to that purpose, this function gathers them together and gives an overview on the most frequent result. It also draw a nice plot with the eigenvalues and the proportion of explained variance.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
n.Factorsn.MethodsEigenvaluesExp.VarianceCum.Variance
153.71637580.53091080.5309108
231.14092190.16298880.6938997
310.84719150.12102740.8149270
400.61286970.08755280.9024798
500.32367280.04623900.9487188
600.21853060.03121870.9799375
700.14043780.02006251.0000000
+

We can also extract the final result (the optimal number of factors) for each method:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Methodn_optimal
Optimal Coordinates1
Acceleration Factor1
Parallel Analysis1
Eigenvalues (Kaiser Criterion)2
Velicer MAP1
BIC2
Sample Size Adjusted BIC3
VSS Complexity 11
VSS Complexity 22
+

And, of course, plot it :)

+
plot(results)
+

+
+
+
+

Analyze the Mixed-Modelling Framework

+

This is possibly the most important function of the psycho package. Its goal is to transform complex outputs of complex statistical routines into something readable, interpretable, and formatted. It is designed to work with frequentist and Bayesian mixed models, which is the central statistical method for psychological science.

+
+

Data Creation

+

Let’s start by creating a dataframe similar to those found in psychological science.

+
set.seed(666)
+df <- data.frame(Participant = as.factor(rep(1:25, each = 4)), 
+                 Item = rep_len(c("i1", "i2", "i3", "i4"), 100), 
+                 Condition = rep_len(c("A", "B", "A", "B", "B"), 20), 
+                 Error = as.factor(sample(c(0, 1), 100, replace = T)),
+                 RT = rnorm(100, 30, .2), 
+                 Stress = runif(100, 3, 5))
+
+# Normalize the numeric variables.
+df <- psycho::normalize(df)
+
+# Take a look  at the first 10 rows
+head(df)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParticipantItemConditionErrorRTStress
1i1A10.2610666-1.5032539
1i2B01.2180393-1.3381086
1i3A1-0.6122813-1.6359922
1i4B0-0.5209097-0.1893384
2i1B0-0.4227089-0.2383872
2i2A1-0.72912771.1834562
+

This dataframe contains the data of 25 participants (labelled from 1 to 25). Each saw 4 different items (i1-i4) in two conditions (A and B). We measured, for each item, if the response was correct or not (Error), its reaction time (RT) and the stress associated with the trial.

+
+
+

Ancient Approach

+

In order to investigate the effect of the condition on the reaction time RT, the traditional, ancient and obsolete routine is 1) to compute the mean for each participant, and 2) run an ANOVA.

+
# Format data
+df_for_anova <- df %>% 
+  dplyr::group_by(Participant, Condition) %>% 
+  dplyr::summarise(RT = mean(RT))
+
+# Run the anova
+anova <- aov(RT ~ Condition + Error(Participant), df_for_anova)
+summary(anova)
+
## 
+## Error: Participant
+##           Df Sum Sq Mean Sq F value Pr(>F)
+## Residuals 24  15.13  0.6304               
+## 
+## Error: Within
+##           Df Sum Sq Mean Sq F value Pr(>F)
+## Condition  1  0.725  0.7254   1.102  0.304
+## Residuals 24 15.793  0.6580
+

As we can see, the effect of the condition is not significant (unsuprisingly, as data was generated randomly). One of the many flaws of this approach is that we lose information about intra-individual and item-related variability.

+
+
+

Mixed Linear Regressions (lme4, lmerTest)

+

The use of the mixed-modelling framework allows us to add the items as random factors.

+
library(lmerTest)
+
+fit <- lmerTest::lmer(RT ~ Condition + (1|Participant) + (1|Item), data=df)
+
+# Traditional output
+summary(fit)
+
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
+##   to degrees of freedom [lmerMod]
+## Formula: RT ~ Condition + (1 | Participant) + (1 | Item)
+##    Data: df
+## 
+## REML criterion at convergence: 282.3
+## 
+## Scaled residuals: 
+##     Min      1Q  Median      3Q     Max 
+## -2.8414 -0.6905 -0.0882  0.7010  2.4840 
+## 
+## Random effects:
+##  Groups      Name        Variance Std.Dev.
+##  Participant (Intercept) 0.0000   0.0000  
+##  Item        (Intercept) 0.1036   0.3219  
+##  Residual                0.9251   0.9618  
+## Number of obs: 100, groups:  Participant, 25; Item, 4
+## 
+## Fixed effects:
+##             Estimate Std. Error       df t value Pr(>|t|)
+## (Intercept)  0.09239    0.22142  5.81000   0.417    0.691
+## ConditionB  -0.15398    0.19633 95.00000  -0.784    0.435
+## 
+## Correlation of Fixed Effects:
+##            (Intr)
+## ConditionB -0.532
+

As the output is a bit messy, the analyze() function will munge this into something nicely formatted.

+
results <- psycho::analyze(fit)
+
+# We can extract a formatted summary table
+summary(results, round = 2)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Effect_SizeCoefSEtdfCoef.stdSE.stdp
(Intercept)Very Small0.090.220.425.810.000.00.69
ConditionBVery Small-0.150.20-0.7895.00-0.080.10.43
+

We can also print it in a text format!

+
print(results)
+
## [1] "The overall model predicting ... successfully converged and explained 10.57% of the variance of the endogen (the conditional R2). The variance explained by the fixed effects was of 0.56% (the marginal R2) and the one explained by the random effects of 10.01%."
+## [2] "The effect of (Intercept) was [NOT] significant (beta = 0.092, SE = 0.22, t(5.81) = 0.42, p > .1) and can be considered as very small (std. beta = 0, std. SE = 0)."                                                                                                
+## [3] "The effect of ConditionB was [NOT] significant (beta = -0.15, SE = 0.20, t(95.00) = -0.78, p > .1) and can be considered as very small (std. beta = -0.076, std. SE = 0.097)."
+
+
+

Bayesian Mixed Linear Regressions (rstanarm)

+

However, as the frequentist framework is criticized, it is advised to switch to the Bayesian framework. Unfortunately, interpretation of these models remain unfamiliar to regular psychologists. But stay calm, because analyze() handles this for you.

+
library(rstanarm)
+
+fit <- rstanarm::stan_lmer(RT ~ Condition + (1|Participant) + (1|Item), data=df)
+
+# Traditional output
+results <- psycho::analyze(fit, effsize=T)
+summary(results, round=2)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VariableMPEMedianMADMeanSD95_CI_lower95_CI_higherVery_LargeLargeMediumSmallVery_SmallOpposite
(Intercept)64.550.090.260.090.31-0.510.7300.020.050.270.310.35
ConditionB79.38-0.160.20-0.160.19-0.510.2300.000.030.390.370.21
+
print(results)
+
## [1] "We fitted a Markov Chain Monte Carlo [type] model to predict[Y] with [X] (formula = RT ~ Condition + (1 | Participant) + (1 | Item)).Priors were set as follow: [INSERT INFO ABOUT PRIORS]."                                                                                                                                                
+## [2] "Concerning the effect of (Intercept), there is a probability of 64.55% that its coefficient is between 0 and 1.62 (Median = 0.092, MAD = 0.26, 95% CI [-0.51, 0.73], MPE = 64.55%)."                                                                                                                                                        
+## [3] "Based on Cohen (1988) recommandations, there is a probability of 0.20% that this effect size is very large, 1.55% that this effect size is large, 5.10% that this effect size is medium, 26.82% that this effect size is small, 30.88% that this effect is very small and 35.45% that it has an opposite direction (between 0 and 0.00025)."
+## [4] "Concerning the effect of ConditionB, there is a probability of 79.38% that its coefficient is between -0.93 and 0 (Median = -0.16, MAD = 0.20, 95% CI [-0.51, 0.23], MPE = 79.38%)."                                                                                                                                                        
+## [5] "Based on Cohen (1988) recommandations, there is a probability of 0% that this effect size is very large, 0.050% that this effect size is large, 3.43% that this effect size is medium, 38.88% that this effect size is small, 37.03% that this effect is very small and 20.62% that it has an opposite direction (between 0 and 0.56)."
+

We can also plot the effects:

+
plot(results)
+

+

Obviously, you need to learn more about Bayesian analyses before running them. You can find more information in the rstanarm’s vignettes.

+
+
+
+ + + + + + + + From b57ca210f6a7ad0a1e6d7448b48234ed494b8d09 Mon Sep 17 00:00:00 2001 From: Dominique Makowski Date: Wed, 10 Jan 2018 12:05:22 +0100 Subject: [PATCH 2/3] Vignette fix --- vignettes/overview.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/overview.Rmd b/vignettes/overview.Rmd index 4f918c2..4d8147a 100644 --- a/vignettes/overview.Rmd +++ b/vignettes/overview.Rmd @@ -157,7 +157,7 @@ plot(results) The `n_factors()` function is useful in before running principal component (PCA) or factor (FA) analysis. As many statistical methods exists to that purpose, this function gathers them together and gives an overview on the most frequent result. It also draw a nice plot with the eigenvalues and the proportion of explained variance. -```{r echo=FALSE, message=FALSE, warning=FALSE, results='hide'} +```{r echo=T, message=FALSE, warning=FALSE, results='hide'} results <- attitude %>% select_if(is.numeric) %>% psycho::n_factors() From 900c643b0aa2dacc55ae24deb8f950824c2606cc Mon Sep 17 00:00:00 2001 From: Dominique Makowski Date: Wed, 10 Jan 2018 13:05:12 +0100 Subject: [PATCH 3/3] hotfix --- vignettes/overview.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/overview.Rmd b/vignettes/overview.Rmd index 4d8147a..a0ebc61 100644 --- a/vignettes/overview.Rmd +++ b/vignettes/overview.Rmd @@ -157,7 +157,7 @@ plot(results) The `n_factors()` function is useful in before running principal component (PCA) or factor (FA) analysis. As many statistical methods exists to that purpose, this function gathers them together and gives an overview on the most frequent result. It also draw a nice plot with the eigenvalues and the proportion of explained variance. -```{r echo=T, message=FALSE, warning=FALSE, results='hide'} +```{r echo=TRUE, message=FALSE, warning=FALSE, results='hide'} results <- attitude %>% select_if(is.numeric) %>% psycho::n_factors()