0
$\begingroup$

I am sorry if this question is confusing, but I am stats newbie!! I am trying to simulate a composite variable which takes values ranging from 0 to 40. The composite variable is made of the sum of 8 questions which could take values between 0 and 5. I am aware that I cannot use rnorm, since it will also give me negative values, and the original data is right skewed. I have the probabilities for each score (o to 5) occurring for each of the compositor variables, so I have considered generating each of them separately using the sample function, and then summing them to create my sum variable. However, I am afraid that they probably would be correlated, and I haven't been able to find a way to simulate them simultaneously while also accounting for correlation. Essentially, to make it easier to imagine, the paper contrasts the use of 2 languages in different scenarios, so those same questions are asked twice to each participant for each language. Therefore, the variables might also be correlated between conditions. Is there a way to deal with that, or would it be best to simulate the total score variable directly? From what I understand, although I am not sure if I am correct, I could use the rpois function to do this? Or another solution I could thin of is simulate the data using rnorm, and then square it to make a right skew? Any opinion would be very useful!!! Thank you in advance!!

I have tried using rpois and simulating each compositor variable separately.

$\endgroup$
4
  • 1
    $\begingroup$ I think this is more of a Cross-validated question. In that forum, you should say what you know about the joint distribution of the 8 items, and they should be able to tell you statistical distributions that match your needs. $\endgroup$ Dec 5, 2022 at 19:19
  • $\begingroup$ What is the purpose of the simulation and what quantitative facts do you know or assume about the correlations among the questions? $\endgroup$
    – whuber
    Dec 5, 2022 at 21:55
  • $\begingroup$ Hi, thanks for replying and sorry if my question was confusing. Essentially, there are two within-subject language categories (English and French) and the 8 item questionnaire was filled out for each of the languages separately. The questions were about amount of exposure to each language in different contexts. This is why I presume that the questions would be correlated within and between languages (language exposure in certain contexts might increase or decrease likelihood of exposure in other contexts; additionally greater exposure to eg English might result in lesser exposure to French) $\endgroup$ Dec 5, 2022 at 23:20
  • $\begingroup$ The purpose is to simulate this and other variables, which I will then use to run a GLMM and then a power analysis. I have the dataset used in the original analysis, so I have created correlation matrices for each language separately, so I have calculated their correlations, but am unaware if it would be possible to include them when simulating the data. I also do not know how to create a correlation matrix that displays the item correlations for both languages together (if that makes any sense at all). Again, sorry if this is very confusing, I am really bad at explaining $\endgroup$ Dec 5, 2022 at 23:29

1 Answer 1

1
$\begingroup$

Easy enough with the the base R sample function using the probability parameter. Example:

# first generate dummy probabilities
x <- runif(41) #41 possible outcomes 0 to 40
probs <- x / sum(x) # normalize the probability vector to 1
samples <- sample(0:40, 1000, replace = TRUE, prob = probs) # generate 1000 prob weighted realizations
$\endgroup$
1
  • $\begingroup$ Could you explain how this correctly models eight questions and correlations among them? $\endgroup$
    – whuber
    Dec 5, 2022 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.