Likert Scales: Ordinal Data or Interval Data

Likert scales are widely used in surveys and questionnaires to assess respondents’ attitudes, opinions, or perceptions. However, there has been ongoing debate regarding whether Likert scales should be classified as ordinal data or interval data. This tutorial aims to explore the nature of Likert scales and provide insights into their appropriate treatment in statistical analysis. … Read more

Relationship between MSE and RSS

Formulas of MSE and RSS Residual Sum of Squares (RSS) is the numerator in the formula of Mean Squared Error (MSE). That is, RSS is part of MSE formula. where, \( n \) is the number of observations. \( \hat{y_i} \) is is estimated value. \( y_i \) is observed value. \( p \) is the is the number of … Read more

How to Change Columns Names in R

There are two ways to change column names in R, one is to change all column names and a specific column name. The following is the R code syntax to change column names. Method 1: Change a specific column name: colnames(df_name)[which(names(df_name) == ‘old_col_name’)] <- ‘new_col_name’ Method 2: Change all column names: colnames(dataframe_name) <- c(“New_col_name_1″,”New_col_name_2”,…) Example … Read more

Categories R

How to Read SPSS Files in R

You can use the read_sav() function from the haven library to read SPSS files in R. The syntax of the function is as follows. read_sav(“file_name.sav”) Step 1: Install haven library The first step is to install the library of “haven” into your local computer. install.packages(‘haven’) Step 2: Library it in R Studio As for other libraries, you need … Read more

Test Homogeneity of Variance in R

This tutorial shows methods test Homogeneity of Variance (or, Equality of Variance) in R. The methods include F-test, Bartlett’s test, Levene’s test, and Fligner-Killeen’s test. F-test: Compare variances of 2 groups. Need assumption of normality. Bartlett’s test: Compare variances of 2 or more groups. Need assumption of normality. Levene’s test: An alternative to Bartlett’s test, … Read more

How to Add Density Line on Histogram in R

This tutorial shows how to add density line on histogram in R. The following is the key part of the syntax, which sets freq=FALSE and add line() on the top of the histogram. hist(data_name, freq =FALSE) lines(density(data_name)) Example 1 We are going to use the New Haven temperature data to plot the histogram and the … Read more

Categories R

How to Increase Bin Density in Histogram in R

This tutorial shows how to increase bin density in histogram in R. You can use breaks in hist() to do so. Below is the basic R syntax of doing so. hist(dataset_name,breaks = 50) Example 1 We are going to use the “Average Yearly Temperatures in New Haven” for the first example to show how to … Read more

Categories R

Test Normality Assumption for ANOVA in R

This tutorial shows how to test normality assumption for ANOVA in R. I will also highlight mistakes that people tend to make when testing normality. Math of Normality assumption for ANOVA Before going to details of how to do that test normality, it is necessary to understand the simple math of testing normality assumption for … Read more

R Code for Serial Mediation

This tutorial shows how you can write R code for serial mediation. Unless you use Hayes’ R code, I am not aware how you can do serial mediation in R. Thus, I am providing this R code here for your convenience. Note that, the current tutorial is for both mediators and the dependent measure Y … Read more

Categories R

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