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.

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)
head(A); head(B) # view first six rows of each matrix
DTA = cbind(A, B) # glue two matrices together to make 10 x 100
head(DTA) # view first six rows of big matrix
## OUTPUT
head(A); head(B) # view first six rows of each matrix
[,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
```

Updated February 28, 2017 23:19 PM

Updated May 08, 2017 18:19 PM

- Serverfault Query
- Superuser Query
- Ubuntu Query
- Webapps Query
- Webmasters Query
- Programmers Query
- Dba Query
- Drupal Query
- Wordpress Query
- Magento Query
- Joomla Query
- Android Query
- Apple Query
- Game Query
- Gaming Query
- Blender Query
- Ux Query
- Cooking Query
- Photo Query
- Stats Query
- Math Query
- Diy Query
- Gis Query
- Tex Query
- Meta Query
- Electronics Query
- Stackoverflow Query
- Bitcoin Query
- Ethereum Query