# modelling the standard deviation as a function of x?

This may be very simple. Consider the following figure, minus the robot. How can I model the standard deviation of Speed as a function of Rep

I can chop the rep up into arbitrary pieces (e.g. 2000 Rep's), calculate the sd, and then draw a regression line between de standard deviations, I also thought about moving window but that doesn't seem right. Is there a better, more continuous way, irrespective of arbitrary binning, to model standard deviation as a function of x?

• Sure, any GLM using a conditional distribution $y|x$ where the variance $\sigma_{y|x}^2$ depends on the mean $\langle{y|x}\rangle$ will do this. For example lognormal distribution, equivalent to doing standard linear regression on $\log[y]$ vs. $x$. You can first do some binning (or 2D KDE) to get an idea of what distribution may be appropriate. Dec 14, 2016 at 1:07
• Forgot to mention, you may also consider logging the predictor $x$, for either regression or binning/KDE. (From the looks of the plot, this would help to make the distribution more uniform, i.e. a uniform $\log[x]$ grid may have more similar $N$'s in each bin.) Dec 14, 2016 at 1:20
• You would need to estimate the standard deviation and the mean together in general (and certainly for GLM). If your error variance changes with $x$, but you estimate the mean $\langle{y}\mid{x}\rangle$ ignoring this, then your baseline regression curve will be biased. Dec 15, 2016 at 1:47