Serial Mediation for Count Data (with R code)

Warning: Introduction This tutorial shows how to do serial mediation for count data. Complete R code is provided. The following are the theoretical models and conceptual framework, assuming IV, M1, M2 are close to normally distributed, and DV is the count data. Step 1 (Optional): Data Simulation The following is the code to generate the … Read more

Mediation Analysis for Count Data (with R code)

Warning: Introduction This tutorial shows how to do mediation analysis for count data in R. Complete R code and examples are provided. There are two possible ways to consider count data. (1) You can just assume that the residuals are normally distributed. Then, you can just use the commonly used linear regression model. You can … Read more

Mediation Analysis in R from Scratch (with R code)

This tutorial shows you how to do mediation analysis in R from scratch. As we know, quantitatively, mediation analysis is about if the product of a*b is statistically significant (see figure below). If you assume that a*b is normally distributed, you can just directly test the level of significance. If you do not assume normal … Read more

One Variable Chi-square: Definition, examples, and formula

This tutorial explains the definition of One Variable Chi-square, and provides examples for it. Two types of one variable chi-square There are two possible ways of using chi-square tests: Chi-square goodness of fit test: It tests the difference between the observed count values and the expected count values. (see discussion here.) Chi-square test of independence: … Read more

One sample t-test: Definition, Formula, and Examples

This tutorial provides the definition of one sample t-test, the formulas of one sample t-test, examples of manual calculation. Definition and examples of One sample t-test One sample t-test is used to determine whether a mean is different from a specific value. You can calculate a mean based on a sample and compare whether the … Read more

Understanding Interaction Effects in Data Analysis

This tutorial introduces the basic idea of interaction effects in data analysis. This tutorial includes what an interaction effect is, examples of an interaction effect, and the statistical methods to do the analysis. What are interaction effects? (The definition) An interaction effect is when the effect of one variable (e.g., X) on another variable (e.g., Y) is … Read more

How to download CSV files from GitHub

This short tutorial shows how you can download CSV files from GitHub. Note that, this is different from read csv files from GitHub (for that, please refer to my other tutorial). Step 1: Right Click “Raw” First, you can go to a GitHub page with the CSV file and then right click the “raw” (see … Read more

How to Get Current Weekday in Python

This tutorial shows how you can get the current weekday in Python with 2 examples. Method 1: use weekday() Method 2: use isoweekday() Examples of getting current weekday in Python Example 1 for method 1 We can also check which weekday it is using weekday(). It returns the day of the week as an integer, … Read more

How to Interpret Interaction Effects in Linear Regression (4 Steps)

This tutorial shows how to interpret interaction effects in linear regression models. In summary, there are two perspectives, (a) mean difference perspective and (b) slope difference perspective. Interpret Interaction Effect in Linear Regression (a) Mean Difference Perspective: One way to interpret interaction effects in linear regression is based on mean differences. A significant interaction means … Read more