# Fit regression model from a fan-shaped relation, in R

I get a fan-shaped scatter plot of the relation between two different quantitative variables:

I am trying to fit a linear model for this relation. I think I should apply some kind of transformation to the variables in order to unify the ascent variance in the relation before fitting a linear regression model, but I can't find the way to do it. Or maybe, there is a better model to use in these cases, I can't either find it.

I have tried rlm, but the residuals still have heteroscedasticity. I have also tried to apply a SD ratio calculated from all the y of each x and other similar erratic approaches.

My questions:

• Is there any typical way of fitting a model for a fan-shaped relation or a typical model to use in these cases?
• Is there any typical transformation that could be applied to the variables in order to reduce its variance?
• This looks suspicious. I think there is an important covariate that isn't considered in your model or you even have repeated measures. Also, I see that your response variable is in the interval [0, 1]. Is it by chance a probability? You might need a generalized linear model. Anyway, function gls in package nlme allows specifying a heteroscedasticity structure. Jun 12, 2015 at 12:50
• Can you say anything more about the data? The functional relationship appears to be about equal on average, and the heteroscedasticity only biases the standard errors. Is there some sort of functional dependence for the two variables? Is there a potential omitted variable that interacts with the X axis variable? Jun 12, 2015 at 12:52
• Thanks! @AndyW It is the a relation between two ways of measure media audience. @Roland The variables are [0,1] because I've scaled them just to show it simpler, but both are quantitative variables. I am trying to fit a model for prediction purposes. I've tried weights with lm, but I don't know how to take advantage of them. I'll try gls, too, thanks @Roland. The relation is weaker for higher values of the predictor, but I don't know how to figure out the heteroscedasticity structure in order to apply it to the weights or pre-transform the data. I am really lost with this. Jun 12, 2015 at 14:13
• Cf. also your post at stats.stackexchange.com/questions/156661/… It's not the same data, but is it in essence the same question? Jun 12, 2015 at 15:30
• @Nick Yes, my mistake. I'll try to remove that one, sorry. Jun 12, 2015 at 15:45

Here's two fan-shaped plots generated by different methods:

These in turn suggest two different approaches for modelling data that looks more or less like this:

1. Take logs, and fit a linear model with the coefficient restricted to 1 (also called an offset)

2. divide $y$ by $x$ and then fit a constant-only model.

There will be other ways to generate data like this, and other ways to fit data like this. For example, some other possibilities are:

1. fit a gamma glm with identity link (and perhaps without an intercept)

2. since the variance is proportional to $x^2$, use this fact to construct a weighted regression using weights proportional to $1/x^2$. [For a simple straight line through the origin, this should give the same result as 2.]

--

[AndyW's comment about a possible missing covariate is important. However, I'm just going to deal with the question of modelling fan-shaped relationships since it's an interesting topic on its own; in practice you would want to investigate his suggestion that there appears to be potential missing covariates as well.]

• +1 - The reason I mentioned a missing covariate in a comment is because of the visible ray at the top of the point cloud that separates from the main cloud at around x = 0.3 - which looks like a it might be a separate mixture to me. Reminds me a bit of the scatterplot in this project of mine. Jun 12, 2015 at 14:50
• @AndyW It's certainly a possibility, though it's also possible to get one or more rays without a missing covariate; for example like this: x2 = sqrt(runif(5000)); y2 = x2*(6-sqrt(rpois(5000,3))); plot(x2,y2,cex=.5,pch=21) Jun 12, 2015 at 15:32
• @Glen_b There's a lot of useful information in that few lines. I am trying to understand and test everything, and I'll be back with the result. Thanks so much! Jun 12, 2015 at 15:32
• @AndyW Yes, there is some kind of mixture here that I also need to analyze. The link to your project seems very useful, too, and I'll expend some more time on it later. Thanks! Jun 12, 2015 at 15:33
• WIth a fan-shape that converges to a point at the origin, the spread is increasing in proportion with $x$; if the shape of the distribution of $Y|X=x$ doesn't change with $x$, then the standard deviation (a specific measure of spread) will also be proportional to $x$. Its square, the variance, must then be proportional to $x^2$. May 12, 2022 at 16:29