I have a cross-sectional real estate dataset with information on roughly 100000 properties, including rental price, square meter size, number of bedrooms etc. In addition, the dataset contains information about the region for each property. The total number of regions in the dataset is 400.

I would like to play around with different machine learning methods in the caret package to predict rental prices using the relevant features in the dataset. I obviously need to incorporate regional information to capture region-specific price effects.

Update: To be more formal, I have the following two model specifications in mind:

$y_i=\beta_0+\beta_1x_{i,1}+\beta_2x_{i,2}+\beta_3D_{i,1}+\beta_4D_{i,2} + \epsilon_i$

where $y_i$ refers to the rental price of property $i$, $x_{i,1}$ denotes square meter size, $x_{i,2}$ denotes the number of rooms, $D_1$ is a matrix of dummy variables capturing different characteristics like balcony, kitchen, cellar and so on, and $D_2$ is a matrix containing the 399 regional dummies.

Alternatively, the model could be specified as follows:

$y_i=\beta_0+\beta_1x_{i,1}+\beta_2x_{i,2}+\beta_3D_{i,1}+\gamma d_{j} + \epsilon_i$

where $d$ is a vector containing the median or average square meter price in each region $j$. I guess inclusion of interaction effects could also make sense (see comment below by seanv507), but I am not sure about them right now.

The obvious advantage of the last equation is that I only need one variable in my model to proxy for a regional effect. However, I also do not see too much of a problem for the first equation given the relatively large number of observations in the dataset.

I have two questions:

  1. Which of the two specifications would be preferable or are there better alternative ways to deal with this issue?
  2. Which machine learning methods could be promising for this type of model?

1 Answer 1


you need to think about what makes a region similar, and produce an encoding that captures it. 2 things spring to mind: 'legal' hierarchies (council/county/state/ ...), geographic proximity.

legal hierarchies could be done by more dummy variables ( and using regularisation eg L1/L2 regularisation ) to favour high level over low levels in hierarchy.

geographic proximity - I am not so sure, one way would be using distances rather than dummy coding (ie input the distance from each region for each house).

  • 1
    $\begingroup$ Thank you for your valuable ideas! One idea that came to my mind in the meantime is to generate one variable containing the median price in each region which may be taken as a proxy for the regional effect. This way I could avoid using dummy variables at all. $\endgroup$
    – kanimbla
    Commented Aug 19, 2016 at 15:32
  • 3
    $\begingroup$ @kanimbla that makes a lot of sense. why don't you edit your question to write out a model that makes sense to you. eg rental price = median_price_per_sq_meter * sq_meter + no_of_rooms_factor .. Then people here can suggest how to implement it. ( for instance I would imagine though that no of rooms effect would also depend on the region - I would expect the variation between 1 and 5 bedroom in expensive area is bigger than in cheap area. another thought is that perhaps you should predict price per square meter (to remove basic variation) $\endgroup$
    – seanv507
    Commented Aug 19, 2016 at 17:02
  • $\begingroup$ Good suggestion! I updated the post, I hope it's more clear now. $\endgroup$
    – kanimbla
    Commented Aug 20, 2016 at 7:29

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