# How to simulate data matrix based on 5-point Likert response in R

by nurul   Last Updated July 12, 2019 07:19 AM

I need your help. Could someone tell me how to simulate matrix data based on Likert-scale response (5-point Likert scale – 1-Extremely Unhappy, 2-Unhappy,3-Neutral,4-Happy,5-Extremely Happy). I need to simulate artificial data for 5 different constructs/domains with 10 items each for sample size, N=100. I also assumed each of the items has factor loading 0.7. I already installed fabricatr, likert and psych packages and I was trying to create this simulated data but wasn’t able to do it. Could one help me how to get this? Thank you in advance.

Tags :

I think you can use the `sample` function in R, to fill matrices to your specifications.

The first argument of `sample` specifies the Likert choices: `1:5`, the second argument specifies the number of values to be returned; the third argument should be `rep=T` because the Likert choices can each be chosen more than once; and the fourth argument is a probability vector giving the frequency with which each Likert value is chosen. (The probability vector can give proportions; R will turn them into probabilities if they don't sum to 1.)

I will make a matrix with 10 columns and 100 rows. The first five columns have different probability vectors than than the last five. This is smaller than the matrix you need, but you can extend the procedure as required.

``````## PROGRAM
set.seed(711)  # for reproducibility
A = matrix(sample(1:5, 5*100, rep=T, prob=c(3,3,3,1,1)), byrow=T, nrow=100)
B = matrix(sample(1:5, 5*100, rep=T, prob=c(1,1,2,4,6)), byrow=T, nrow=100)
DTA = cbind(A, B)   # glue two matrices together to make 10 x 100
head(DTA)           # view first six rows of big matrix

## OUTPUT
[,1] [,2] [,3] [,4] [,5]
[1,]    3    3    3    2    3
[2,]    1    3    1    2    2
[3,]    1    2    5    5    4
[4,]    4    2    2    4    2
[5,]    1    3    3    1    1
[6,]    1    2    2    1    5
[,1] [,2] [,3] [,4] [,5]
[1,]    2    4    5    5    4
[2,]    5    2    5    2    1
[3,]    1    4    5    3    4
[4,]    3    4    3    3    4
[5,]    2    4    4    4    5
[6,]    5    5    4    3    1
DTA = cbind(A, B)   # glue two matrices together to make 10 x 100
head(DTA)           # view first six rows of big matrix
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    3    3    3    2    3    2    4    5    5     4
[2,]    1    3    1    2    2    5    2    5    2     1
[3,]    1    2    5    5    4    1    4    5    3     4
[4,]    4    2    2    4    2    3    4    3    3     4
[5,]    1    3    3    1    1    2    4    4    4     5
[6,]    1    2    2    1    5    5    5    4    3     1

## Average scores
mean(A);  mean(B)
[1] 2.406   # grumpier
[1] 3.906   # cheerier
``````
BruceET
July 12, 2019 07:13 AM

## Related Questions

Updated April 07, 2015 19:08 PM

Updated February 28, 2017 23:19 PM

Updated August 22, 2015 17:08 PM

Updated March 29, 2017 19:19 PM

Updated May 08, 2017 18:19 PM