> For the complete documentation index, see [llms.txt](https://help.imotions.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.imotions.com/lab/analysis/facial-expression-analysis/affdex/r-notebooks-fea-affdex-raw-data-statistics-export.md).

# R Notebooks (FEA): AFFDEX Raw Data Statistics Export

Export mean, variance, quantile, skewness and kurtosis statistics of raw AFFDEX signals per stimulus, scene or annotation with this R notebook.

The R Notebook is called: AFFDEX Raw Data Statistics Export. It produces file export for AFFDEX Statistics on raw data. The notebook calculates parametric (mean, var, sd), robust (quantiles, IQR) and moment (moment, skewness, kurtoses) statistics for chosen stimuli, scenes, annotations and/or fragments. Please note that you can directly go export data from iMotions UI, without adding an additional R Notebook in the Signal Processing section. This will be explained more later in [How to Export in iMotions Desktop.](#id-2.-how-to-export-in-imotions-desktop)

This article includes:

1\. [Prerequisites](#id-1.-prerequisites)

2\. [How to Export in iMotions Desktop](#id-2.-how-to-export-in-imotions-desktop)

3\. [Outputs:](#id-3.-outputs-exported-files-and-basics-of-each-statistics) [Exported files and some basics of each statistics](#id-3.-outputs-exported-files-and-basics-of-each-statistics)

## 1. Prerequisites

Supported signals: AFFDEX

## 2. How to Export in iMotions Desktop

[Create your analysis](https://help.imotions.com/lab/getting-started/analysis-overview.md) that includes your respondents and stimuli of interest. When creating your Analysis under your Study, you do NOT need to add any additional R Notebook under the "Signal Processing" section if you only want to export AFFDEX statistics.

![mceclip0.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-652375a1f1d1636de4dae7b904bfbef7e28c6b83%2Fd7fd900991_twmspndmaeiy2dnwnas6gmceclip0.webp?alt=media)

*Leaving the "Active flows" blank is fine if you only need to export AFFDEX statistics.*

Then proceed to Export button from the bottom menu when in the analysis level. You find the export selection for the "Affdex Raw Data Statistics Export" under the tab "R PROCESSING", and can then choose the export settings you need. Export by clicking "Export" in the upper right corner.

![1.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-358e76512446a88db957a8db0a238e63de8bd03e%2Fa246264428_1-2-.webp?alt=media)

### Export Settings Explained:

**Included statistic**s: Choose one or more types of statistics to be included in your export file.

**Percentiles for parametric in range 0-1**: The wanted percentiles to be calculated for statistics "quantiles".

**Order of moment**: The order of moment wanted to be calculated for statistics "moment". You can choose multiple moments (above or equal to order 5) at once for the export.

**Include events**: choose stimulus types you would like to calculate the statistics from - Stimulus, Scene, Annotations, and with or without fragments.

## 3. Outputs: Exported files and basics of each statistics

The exported file with everything included will look like this:

![2.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-27d1e660457cd5208769617518596859cbdf0405%2Fe62037bf55_2-2-.png?alt=media)

**More about the statistics***:*

*It is highly recommended that you are fully aware of the mechanism behind the statistics that you are planning to use before you apply them in your research analysis.*

***Parametric Statistics:***

**mean**: The arithmetic mean, also known as arithmetic average, is a central value of a finite set of numbers - here the probability scores of each facial marker within that chosen stimulus duration. *(*[*resources*](https://en.wikipedia.org/wiki/Mean)*)*

**standard deviation**: *The standard deviation is a measure of the amount of variation or dispersion of a set of values - here the probability scores of each facial marker within that chosen stimulus duration. A low standard deviation indicates that the values tend to be close to the mean of the set, while a high standard deviation indicates that the values are spread out over a wider range. (*[*resources*](https://en.wikipedia.org/wiki/Standard_deviation)*)*

**variance**: Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers - here the probability scores of each facial marker within that chosen stimulus duration, spread out from their average value. *(*[*resources*](https://en.wikipedia.org/wiki/Variance)*)*

***Robust Statistics:***

**nth percentile**: Percentile is a number where a certain percentage of scores fall below that number. For example, the 50th percentile is the score of that facial marker at or below which 50% of the scores in the distribution may be found. Percentiles are expressed in the same unit of measurement as the input scores (here the probability scores of each facial marker).

One example: you might observe during one stimulus recording, that one respondent scored 40 at one point, for Joy. But that figure has no real meaning when you want to compare and see if this is a high or low score for this respondent during this whole recording - unless you know what percentile it falls into - If you know that this 40 score is in the 75th percentile, that means this 40 scored better than 75% of all other data points for this stimulus recording. *(*[*resources*](https://en.wikipedia.org/wiki/Percentile)*)*

**Interquartile range**: The interquartile range (IQR) is a measure of statistical dispersion. It is the spread of the dataset - here the probability scores of each facial marker within that chosen stimulus duration. It is defined as the spread difference between the 75th and 25th percentiles of the dataset. The primary use of the IQR is to represent the spread difference between the upper and lower quartiles of a data set. This can be used as an indicator of the variability of the dataset. *(*[*resources*](https://en.wikipedia.org/wiki/Interquartile_range)*)*

***Moment Statistics:***

**nth-order moment**: In mathematics, the moments of a probability distribution are quantitative measures related to the shape of the probability distribution.

*Moments up to the 4th order*: The first raw moment is the mean. The variance is the second central moment (the moment about the mean). Skewness and kurtosis are the third and fourth central moments divided by the standard deviation to the power of three and four. The export reports skewness, and kurtosis as Pearson's kurtosis (3 for a normal distribution). The **nth-order moment** values in the export are raw moments (moments about zero), not central moments, so they are not the same as the variance, skewness or kurtosis.

*Higher-order moments* involve non-linear combinations of the data and can be used for the description or estimation of further shape parameters. The higher the moment, the harder it is to estimate, in the sense that larger samples are required in order to obtain estimates of similar quality. Please make sure you are fully informed of the relevant statistics knowledge before you use it. *(*[*resources*](https://en.wikipedia.org/wiki/Moment_\(mathematics\))*)*

**skewness**: skewness is the measure of the lopsidedness of the distribution: A distribution that is skewed to the left (the tail of the distribution is longer on the left) will have negative skewness. A distribution that is skewed to the right (the tail of the distribution is longer on the right), will have positive skewness. *(*[*resources*](https://en.wikipedia.org/wiki/Skewness)*)*

![mceclip1.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-f2c8702c30f5af5cb1e2a46ea778ceab1f1d4551%2Ff047aeee8b_po9v4taeu0spivtbypsqgmceclip1.webp?alt=media)

*negative skew*: The left tail is longer; the mass of the distribution is concentrated on the right of the figure. *positive skew*: The right tail is longer; the mass of the distribution is concentrated on the left of the figure. (resource from [*Wikipedia*](https://en.wikipedia.org/wiki/Skewness))

**kurtosis**: kurtosis is a measure of the heaviness of the tail of the distribution, compared to the normal distribution of the same variance. E.g., for a given amount of dispersion, higher kurtosis corresponds to thicker tails, while lower kurtosis corresponds to broader shoulders. *(*[*resources*](https://en.wikipedia.org/wiki/Kurtosis)*)*

![mceclip3.png](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2Fgit-blob-c16a15729ce3879869242660a9d8e96fffdc6d2d%2Fd03c756270_oov5lmc06mp1a3bconzgmceclip3.webp?alt=media)

Probability density functions for selected distributions with mean 0, variance 1 and different excess kurtosis: one can see from the plot, the higher kurtosis corresponds to thicker tails (red line), while lower kurtosis corresponds to broader shoulders (pink line).

(resource from [*Wikipedia*](https://en.wikipedia.org/wiki/Kurtosis))


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.imotions.com/lab/analysis/facial-expression-analysis/affdex/r-notebooks-fea-affdex-raw-data-statistics-export.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
