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

Simulate Data for Poisson Regression in R

This tutorial shows how to simulate a dataset for Poisson regression in R. Step 1: Determine the model Suppose that the following is the model with known population parameters, namely known regression coefficients of 0.2 and 0.08. Of course, in reality, the most likely result is that we do not know such parameters and we … 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

ANOVA Assumptions

There are 3 assumption for ANOVA: Normality – The responses for each factor level have a normal population distribution. Equal variances (Homogeneity of Variance) – These distributions have the same variance. Independence – The data are independent. You can use R to test the assumptions of normality and equality variances (The following are the two tutorials). In contrast, … Read more

Bootstrapping Mediation Analysis in R from Scratch

This tutorial explains how to write code for boostrapping mediation analysis in R from scratch. Mediation analysis is often used in academic research to understand the underlying mechanism. Often, you also need to report a bootstrapping confidence interval for the indirect effect. Steps of Bootstrapping Mediation Analysis in R The following shows the steps. (1) … Read more

Categories R

Logistic Regression in R

This tutorial is to show how to do logistic regression in R with examples. The following is the key syntax for logistic regression in R. glm(Y~ X1 + X2, data = data_frame_name, family = “binomial”) Steps of logistic regression in R Step 1: Read data and determine model In this tutorial, we are going to … Read more

Categories R

Syntax for chi-square test in SPSS

In some situations, the syntax is easier than the visual menu to use in SPSS. This tutorial provides examples of syntax for chi-square test in SPSS. 2 Examples of Syntax for chi-square test in SPSS Example 1: One variable The first example is the one variable chi-square test. The following is example data for one … Read more

One Variable Chi-Square in SPSS

This tutorial shows how you can do one variable chi-square in SPSS with detailed examples. The following shows two examples, one using Syntax and one using a menu interface. Examples of One Variable Chi-Square in SPSS Example 1 A school is offering 3 courses, and you would like to see whether the number of students … 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

Logistic Regression in SPSS

This tutorial shows how you can do logistic regression in SPSS step by step. Logistic regression is a model testing the relationship between Y (which is a binary variable) and X (X can be more than one). logistic regression is also called logit regression. In this tutorial, we are going to use a dataset posted on the UCLA … Read more