# How to constrain cumulative Gaussian parameters so that the function will intersect one given point?

I am analyzing data from one study where participants had to choose (between two stimuli) the one with higher intensity. One way to look at the data is to fit the proportion of correct choices as a function of the absolute difference between the 2 intensities (let's call it delta $$\Delta$$).

This gives me a function that predict the probability p of correct choice for any value of $$\Delta$$. I use a cumulative Gaussian function, scaled so that the predicted probability is between $$0.5$$ (chance, meaning pure guessing) and $$1$$. Below there is a plot of a sample of data.

The problem is that often the best fitting function predict a probability higher than $$0.5$$ even at $$\Delta=0$$, which does not make much sense. The function should approach $$0.5$$ as $$\Delta$$ approach $$0$$, because for very small values of $$\Delta$$ participants are necessarily at chance (that is $$lim_{\Delta\to0}p=0.5$$).

I would like to constrain the parameters so that the function will pass in $$(0, 0.5)$$, but I don't know how to do it. Can anyone help with this? Any help is appreciated, thanks!

Please note that the desired function needs to predict a probability between 0.5 and 1 (probability of correct choice cannot be less than chance here), and that it needs to have both location and scale as free parameters. This is required to account also for cases where (differently from the plot below, which is presented only to demonstrate the problem stated above) the proportion of correct choices stays at chance until quite large values of $$\Delta$$ and then increase rapidly (with slope similar as the plot below or even more steep).

It doesn't have to be necessarily a cumulative Gaussian, also another sigmoidal function could work (if using another function makes it easier to put the constraints).

I use R, and this is the code I use for fitting. This gives the cumulative Gaussian function, scaled so that the lower asymptote is at 0.5:

pnorm2AFC <- function(x,...){
0.5 + 0.5*pnorm(x,...)
}


and I use this to compute the negative log-likelihood. d is a dataframe with the number of correct and error responses (nnyes and nno) for each values of delta. p here indicates the parameters (mean and standard deviation).

lnorm_2AFC <- function (p, d) {
-sum(d$$nyes * log(pnorm2AFC((d$$delta - p)/p))
+ d$$nno * log(1-pnorm2AFC((d$$delta - p)/p)))
}


Then I find the parameters using optim()

par <- optim(par = c(0.2, 0.2), lnorm_2AFC, d= data)

• The Gaussian (or perhaps it's an Error function, if it truly is cumulative) looks like a poor fit. Why not use logistic regression? Constraining that to go through $(0, .5)$ is easy: simply drop the constant term.
– whuber
Jul 30, 2015 at 20:06
• the problem with using a logistic without constant term (if I understood correctly) is that it would not be "s-shaped" (not for positive values of $\Delta$), so it would be a poor fit for cases where the proportion of correct choices stay at chance for a large range of $\Delta$, and increases only for very high values Jul 31, 2015 at 11:05
• about the fit, yes it is cumulative (basically is a glm with probit link, only that the predicted probability is scaled between $.5$ and $1$) and the data are averaged in bins only for the plot (identical values of $\Delta$ are actually rare) so I think is difficult to judge the fit simply from the plot Jul 31, 2015 at 11:10
• What do the size of the circles represent? Jul 31, 2015 at 15:06
• Assuming, as you write, that the response is proportions of correct choices, then the graph alone is enough to demonstrate a poor fit. What you need to recognize is that a given discrepancy between data and curve has a different meaning depending on the elevation of the curve. The model you are proposing will not deal with that correctly. If you're interested in good results (and not just a nice-looking fit), then I recommend editing this post to explain your data better and to describe the motivation for the shape of the curve you are suggesting.
– whuber
Jul 31, 2015 at 18:47

Why wouldn't you just fit a probit GLM without intercept?

Then $E(Y) = \Phi(0+b\Delta)$ and

$E(Y|\Delta=0) = \Phi(0)=0.5$.

Isn't that a solution to the posted problem?

Here's a plot for a model I fitted by transforming $p$ using an inverse normal cdf ($y=Φ^{-1}(p)$), then fitting a linear regression with no constant term, then transforming back: It, too satisfies the conditions mentioned in the question

• yes it is a solution, but it doesn't fit well cases where the proportion of correct choices stays around $0.5$ until relatively large values of $\Delta$. In these cases the derivative of the best fitting function should increase and then decrease, so it would be better to have the whole sigmoidal curve over positive values of $\Delta$, not only half of it (I should have stated this point more clearly in the question, sorry). This can be done with my solution of using a cumulative Weibull function. Jul 31, 2015 at 14:26
• My answer is a solution to the problem you have posted. If you want a solution to a different problem, why not post that one? i.e. Why isn't this information that alters what you asked in your question? Jul 31, 2015 at 15:05
• The question was how to constrain a specific function, one that predicts probabilities within 0.5 and 1 (i.e. it has the lower asymptote at 0.5) to go through (0, 0.5). You proposed the same approach that @whuber proposed in his comment (use a GLM without constant term), which results in a different function with a different shape (is not sigmoidal anymore over the range in which my variable $\Delta$ takes values), and involves a loss of generality (it cannot fit correctly other cases, for example the one I illustrate in my previous comment) Aug 1, 2015 at 11:28
• I don't understand your response at all. Your question - quite explicitly - seems to be asking for a way to make the fit pass through (0,0.5) (which I did). Now you seem to contradict that explicit request by claiming you actually want a curve that asymptotes to 0.5. Unless you plan for it to dip below 0.5 and come back up again, the two are contradictory'; it can't be monotonic (e.g. S-shaped) and pass through y=0.5 and also asymptote to it. I expect you mean something different from what you've said, which will probably necessitate a change to your question. Aug 1, 2015 at 12:08
• Let me clarify. The word "asymptote" really doesn't mean what you think it does. I asked what you thought it meant so that I could figure out how to briefly clarify what it does mean, rather than just referring you to the wikipedia page on "Asymptote". Please take a look at it and correct any references to the term in your question so that your question is answerable. [Further, if you don't actually require a Gaussian, it probably shouldn't be prominently stated in your title.] Aug 2, 2015 at 12:12

In the meantime I found one solution to my question so I will post it here.

One way to constrain the function to pass in $(0, .5)$ is to use a cumulative Weibull function instead of a cumulative Gaussian. The Weibull is defined only for positive values, so that at $0$ the predicted probability is necessarily $0$. When scaled as described in the question above, the predicted probability at $0$ will be necessarily $0.5$.

• More generally, for whatever function and parameterization you're fitting, you can use constrained optimization software to impose constraints, such as forcing the fitted equation to go through a specific point, or constraining parameters being fitted (i.e., optimization variables) as needed. Jul 31, 2015 at 19:21
• Thanks, this sounds exactly what I was looking for. Do you know how to impose this kind of constraints in R? Aug 1, 2015 at 11:03
• I'm not an R person, so I will not vouch for this, but you can look at cran.r-project.org/web/packages/alabama/alabama.pdf . You may not find it easy to use. Given the state of affairs, MATLAB or OCTAVE are a much better environment nowadays for optimization than R. If you have no experience in optimization (and I'm not talking gradient descent crap), you may not find it an easy go. A forum comment is no substitute for taking a course. Aug 1, 2015 at 11:36