<p>Some terms that might help you:</p>
<p>It's common for accuracy to follow a <em><a href="https://en.wikipedia.org/wiki/Sigmoid_function" rel="nofollow noreferrer">sigmoidal</a></em> curve; the <em><a href="https://en.wikipedia.org/wiki/Logistic_function" rel="nofollow noreferrer">logistic function</a></em> is one example.</p>
<p>Binary outcomes are modeled well using a <em><a href="https://en.wikipedia.org/wiki/Binomial_distribution" rel="nofollow noreferrer">binomial</a></em> distribution (or <a href="https://en.wikipedia.org/wiki/Bernoulli_distribution" rel="nofollow noreferrer">Bernoulli for a single trial</a>).</p>
<p>So, what you likely want to do is to:</p>
<ol>
<li><p>choose some sigmoidal function that represents &quot;average accuracy&quot; over your predictor variable <em>x</em>.</p>
</li>
<li><p>at values of x, simulate Bernoulli trials or represent multiple Bernoulli trials with a random number from the binomial distribution, using the average probability from your chosen value of <em>x</em> and function from (1).</p>
</li>
</ol>
<p>I won't write the R code for you, but that should be enough to get you started with some search terms for example code that works towards these steps.</p>

CC BY-SA 4.0
2022-11-23T15:57:56.657Z
2022-11-23T15:57:56.657Z
Bryan Krause
<p>I'm trying to illustrate a proof-of-concept by simulating some data in RStudio, but I'm not totally sure how to go about the first part of the simulation -- modelling response accuracy.</p>
<p>Basically: I have one predictor variable (X) that varies across 'trials', and I want simulated response accuracy to increase along side X (so that when X is very large, accuracy on that trial is very likely to = 1, but when X is very small, accuracy on that trial is very likely to = 0).</p>
<p>My initial thought was to generate a 'probability of correct response' variable that is positively correlated with X; then, I'd recode anything &gt; .5 as a 1, and anything &lt; .5 as a 0. But, I'm not totally sure if this approach is justifiable, or if there's a better way to go.</p>
<p>Any help would be appreciated! Thanks so much in advance.</p>

<cognitive-psychology><cognitive-modeling><computational-modeling>
Simulating accuracy according to a predictor variable? (R)
0demo1
# Simulating accuracy according to a predictor variable? (R)

(Asked by: username_0 on 2022-11-23)

I'm trying to illustrate a proof-of-concept by simulating some data in RStudio, but I'm not totally sure how to go about the first part of the simulation -- modelling response accuracy.

Basically: I have one predictor variable (X) that varies across 'trials', and I want simulated response accuracy to increase along side X (so that when X is very large, accuracy on that trial is very likely to = 1, but when X is very small, accuracy on that trial is very likely to = 0).

My initial thought was to generate a 'probability of correct response' variable that is positively correlated with X; then, I'd recode anything > .5 as a 1, and anything < .5 as a 0. But, I'm not totally sure if this approach is justifiable, or if there's a better way to go.

Any help would be appreciated! Thanks so much in advance.

**Tags:** cognitive-psychology, cognitive-modeling, computational-modeling


---

## 1 answers

### Answer by username_1 on 2022-11-23. Score: 1

Some terms that might help you:

It's common for accuracy to follow a *[sigmoidal](https://en.wikipedia.org/wiki/Sigmoid_function)* curve; the *[logistic function](https://en.wikipedia.org/wiki/Logistic_function)* is one example.

Binary outcomes are modeled well using a *[binomial](https://en.wikipedia.org/wiki/Binomial_distribution)* distribution (or [Bernoulli for a single trial](https://en.wikipedia.org/wiki/Bernoulli_distribution)).

So, what you likely want to do is to:

1. choose some sigmoidal function that represents "average accuracy" over your predictor variable *x*.
2. at values of x, simulate Bernoulli trials or represent multiple Bernoulli trials with a random number from the binomial distribution, using the average probability from your chosen value of *x* and function from (1).

I won't write the R code for you, but that should be enough to get you started with some search terms for example code that works towards these steps.


---

