# Categorical and ordinal feature data representation in regression analysis? [closed]

I am trying to fully understand difference between categorical and ordinal data when doing regression analysis. For now, what is clear:

Categorical feature and data example:
Color: red, white, black
Why categorical: red < white < black is logically incorrect

Ordinal feature and data example:
Condition: old, renovated, new
Why ordinal: old < renovated < new is logically correct

Categorical-to-numeric and ordinal-to-numeric encoding methods:
One-Hot encoding for categorical data
Arbitrary numbers for ordinal data

Categorical data to numeric:

data = {'color': ['blue', 'green', 'green', 'red']}


Numeric format after One-Hot encoding:

   color_blue  color_green  color_red
0           1            0          0
1           0            1          0
2           0            1          0
3           0            0          1


Ordinal data to numeric:

data = {'con': ['old', 'new', 'new', 'renovated']}


Numeric format after using mapping: Old < renovated < new → 0, 1, 2

0    0
1    2
2    2
3    1


In my data I have 'color' feature. As color changes from white to black price increases. From above mentioned rules I probably have to use one-hot encoding for categorical 'color' data. But why I cannot use ordinal representation. Below I provided my observations from where my question arised.

Let me start with introducing formula for linear regression: Let have a look at data representations for color: Let's predict price for 1-st and 2-nd item using formula for both data representations:
One-hot encoding: In this case different thetas for different colors will exist. I assume that thetas already derived from regression (20, 50 and 100). Prediction will be:

Price (1 item) = 0 + 20*1 + 50*0 + 100*0 = 20$(thetas are assumed for example) Price (2 item) = 0 + 20*0 + 50*1 + 100*0 = 50$


Ordinal encoding for color: In this case all colors will have 1 common theta but my assigned multipliers (10, 20, 30) differ:

Price (1 item) = 0 + 20*10 = 200$(theta assumed for example) Price (2 item) = 0 + 20*20 = 400$  (theta assumed for example)


In my model White < Red < Black in prices. Seem to be that correlation works correctly and it is logical predictions in both cases. For ordinal and categorical representations. So I can use any encoding for my regression regardless of the data type (categorical or ordinal)? This division in data representations is just a matter of conventions and software-oriented representations rather than a matter of regression logic?
{"ft_lang_label":"__label__en","ft_lang_prob":0.75212485,"math_prob":0.8907614,"size":2330,"snap":"2021-43-2021-49","text_gpt3_token_len":593,"char_repetition_ratio":0.12768702,"word_repetition_ratio":0.040816326,"special_character_ratio":0.2746781,"punctuation_ratio":0.11415525,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99530417,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,4,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-22T03:37:22Z\",\"WARC-Record-ID\":\"<urn:uuid:af98873f-4f89-478f-a8c3-94bf5c13ed26>\",\"Content-Length\":\"155587\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d94070bf-f6aa-494b-82f5-24857f49862a>\",\"WARC-Concurrent-To\":\"<urn:uuid:05fae6c4-face-4b22-a34a-c41693916b21>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://datascience.stackexchange.com/questions/9202/categorical-and-ordinal-feature-data-representation-in-regression-analysis\",\"WARC-Payload-Digest\":\"sha1:XA4FNEI6CVTKIZCWTSMXIZKV5JZQV2OJ\",\"WARC-Block-Digest\":\"sha1:TRATJ3Q5YRJBX37MDSRZFPCXKVNYRRRJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585450.39_warc_CC-MAIN-20211022021705-20211022051705-00272.warc.gz\"}"}