1
$\begingroup$

This question already has an answer here:

This is probably a fairly simple question but it occurred to me, when trying to go through some data, that I wasn't sure how.

Say you have some numeric variable vs. arc degrees-- like the price of real estate when looking in any direction. You want to see if there is a quadratic correlation between these two. In other words, the hypothesis is that land is most expensive in one direction, then gets less expensive -180 degrees away.

What's the standard way to treat or transform degrees, i.e. a repeating or circular variable?

There is a somewhat related question here but it also involves other things, and I don't see how the scale function in R applies here.

$\endgroup$

marked as duplicate by Nick Cox, kjetil b halvorsen, mdewey, Peter Flom Nov 2 '17 at 12:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
$\begingroup$

There are three ways to approach this:

  1. Predict direction by price
  2. Predict price by direction
  3. Compute a circular-linear correlation coefficient

The first requires circular regression, the second a transformation of the circular variable and any ordinary linear regression, and the third is not implemented in any statistical package as far as I'm aware but can proceed as described in this paper.

The second approach seems most appropriate (as interest is in price most likely), so I'll describe it here. Denote the directional outcome as $\theta,$ and compute two transformed variables $\cos(\theta)$ and $\sin(\theta).$ Then, simply perform a linear regression where $\cos(\theta)$ and $\sin(\theta)$ are the predictor variables, so where $$\hat{y} = \alpha + \beta_1 \cos(\theta) + \beta_2 \sin(\theta),$$ where $\alpha$ is an intercept. The expained variance $R^2$ can be treated as an analogue to the squared correlation coefficient.

$\endgroup$
  • $\begingroup$ $R^2$ is a squared correlation coefficient, the correlation being between observed and predicted. This model is for situations in which one direction has the highest prices; it follows from the definitions of sine and cosine that the opposite direction is predicted to have the lowest prices. In practice with house price data I'd expect to work with logarithm of price. Nothing stops you adding (e.g.) sine and cosine of 2$\theta$, etc. if that seems appropriate. $\endgroup$ – Nick Cox Nov 2 '17 at 10:01
1
$\begingroup$

Kees' answer is the standard way I was taught to transform a cyclic variable, although note you pay for the transformation with extra parameters to estimate.

I just wanted to add that I've seen the Wrapped Cauchy Distribution used in an application in animal ecology, modelling the turning directions of wildebeest (they tend to make turns relative to the direction they are already facing, i.e 180 degree turn is very unlikely).

This distrbution can work directly with your angles, no transformation required. Although I'm not sure if it's useful to your specific example above.

EDIT: Should have mentioned that there are other wrapped distributions out there. See https://en.wikipedia.org/wiki/Wrapped_distribution

$\endgroup$
  • $\begingroup$ This could be relevant if there was central interest in the distribution of directions. It's not so obvious that it bears upon the question of modelling price as a function of direction. $\endgroup$ – Nick Cox Nov 2 '17 at 12:02
  • $\begingroup$ Yes you are correct. I had flipped the question in my mind to ask in which directions the rich houses are likely to be. I suppose this might be of interest but its not the question here. In the UK you might see a westerly distribution, the wind blowing from the Atlantic meant the rich parts of town were more westerly to be upwind from the industrial areas. This is why the "west end" is often a desireable place to live in many cities. Im new to this site - should I delete/edit my response? I have not answered the question which is a breach of rules I think. $\endgroup$ – ASeaton Nov 2 '17 at 12:10
  • $\begingroup$ It's not a breach of rules to be a little marginal to the question. I'd leave the answer as it is. It could be helpful to people interested in the thread. $\endgroup$ – Nick Cox Nov 2 '17 at 12:46

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