Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Back transforming logarithmic regression prediction with Duan's smearing estimate

    Hi

    I am running an income regression in Stata 12.

    Due to the non-linear relationship between income and its determinants I use the logarithm of income in the OLS regression, therefore the predicted values (lsincome) are also in logarithmic form. I need to transform these back into non-logarithmic form, and at first I used a simple formula:

    Code:
    reg logincome i.educ age age2 married male black hispan1 speakengwell i.occ state1-state51 if choice == 1 & empstat == 1 , nocons robust
    
    scalar RMSE = e(rmse)
    
    predict lsincome, xb
    
    gen predincome = exp(lsincome)*exp(RMSE^2/2)
    However, I found out that the residuals need to be normally distributed for this to work, and mine are NOT. I read about Duan's smearing estimator here: https://davegiles.blogspot.com/2014/12/s.html, which is supposed to work even if the residuals are not normally distributed. My question is how do I implement this in Stata?

    Many thanks

    Stella

    ​​​​​​
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long serial float logincome byte(educ age) float age2 byte(married male black) float hispan1 byte speakengwell float occ
     27 10.985292 5 28  784 0 0 1 0 1 18
     32 10.778956 3 33 1089 0 1 0 0 1 24
     46  9.998797 5 28  784 0 1 0 0 1  5
     53 11.112448 5 31  961 0 0 0 0 1  5
     54    10.859 4 35 1225 0 0 0 0 1 10
     58 9.1049795 4 30  900 1 0 0 0 1 15
     64 10.819778 4 34 1156 1 1 1 0 1 23
     77  9.392662 5 27  729 0 0 0 0 1 10
     80  10.83958 5 31  961 1 0 0 0 1 12
     89  9.714746 3 20  400 0 0 1 0 1 19
    109  8.556414 3 24  576 0 1 1 0 1 15
    110  9.480368 4 19  361 0 1 0 0 1 23
    133  9.350102 3 26  676 0 0 1 0 1  8
    134 10.596635 5 30  900 1 0 0 0 1 12
    142  10.22557 5 27  729 0 0 0 0 1 10
    159 10.819778 3 31  961 1 1 0 0 1 23
    161  10.37349 3 31  961 1 1 0 0 1 23
    175  9.852194 4 27  729 0 1 1 0 1 24
    180 10.404263 3 25  625 1 1 0 0 1 23
    184 10.714417 3 35 1225 0 0 0 1 0 19
    188  9.952278 5 29  841 0 1 0 0 1 24
    196  9.836279 4 24  576 0 0 1 0 1 12
    200 10.596635 4 23  529 1 1 0 0 1 19
    201 10.308952 4 34 1156 0 1 1 0 1 24
    215  10.23996 3 30  900 1 1 1 0 1 14
    249 10.714417 5 28  784 1 1 0 0 1  4
    257  9.546813 6 24  576 0 1 0 0 1 19
    272  9.903487 3 34 1156 1 0 0 0 1 24
    286 10.071963 4 30  900 0 0 1 0 1 13
    294 10.714417 3 26  676 1 1 0 0 1 25
    314  9.615806 4 33 1089 1 0 0 0 1 18
    326  12.25009 5 27  729 0 0 0 0 1  2
    332 10.341743 4 23  529 0 1 0 0 1  4
    339  9.680344 4 25  625 0 1 0 0 1 19
    358  9.574984 3 35 1225 0 1 0 0 1 17
    359 10.911446 5 32 1024 1 0 0 0 1 12
    361 10.778956 5 26  676 1 0 0 0 1 12
    376 10.819778 5 34 1156 0 1 0 0 1 21
    378  9.952278 3 25  625 0 1 1 0 1 24
    380  10.23996 4 28  784 0 1 1 0 1 14
    382  10.04325 4 30  900 1 1 0 0 1 19
    387  10.04325 3 35 1225 1 1 0 0 1 24
    399 10.518673 4 25  625 0 1 1 0 1 14
    403 10.460242 3 32 1024 0 0 1 0 1 13
    406  9.615806 4 35 1225 0 0 1 0 1 19
    407  9.472705 5 30  900 0 0 0 0 1 10
    417  10.23996 5 29  841 1 1 0 0 1 25
    431  8.006368 5 25  625 0 0 1 0 1 15
    434 10.341743 4 22  484 1 1 1 0 1 19
    446 10.434115 5 34 1156 0 0 0 0 1 19
    456 9.1049795 3 33 1089 1 0 1 0 1 18
    469 10.668956 5 25  625 1 1 0 0 1 19
    474  9.798127 5 31  961 0 0 0 0 1 19
    476  9.903487 5 27  729 1 1 0 0 1 25
    479   11.0021 3 33 1089 1 1 0 0 1 23
    484 10.308952 3 23  529 1 1 0 0 1 11
    490    10.859 5 28  784 0 1 0 0 1 18
    491 10.819778 3 33 1089 0 1 0 0 1 23
    498 10.518673 5 23  529 0 0 0 0 1 19
    500  9.472705 3 28  784 1 0 0 0 1 18
    538 10.878047 4 28  784 0 1 0 0 1  4
    562  11.03489 6 35 1225 1 0 0 0 1  1
    564 10.586837 4 25  625 0 1 0 0 1 23
    586  7.244227 4 21  441 0 0 1 0 1 24
    594 11.440354 4 35 1225 1 1 0 0 1 19
    598  9.903487 1 31  961 1 1 0 1 0 21
    599   11.0021 4 33 1089 1 1 0 0 1 14
    609  9.740969 4 34 1156 0 0 1 0 1 13
    610 11.326596 3 34 1156 1 1 0 0 1  1
    625 10.596635 5 24  576 0 0 0 0 1  9
    627  8.881836 4 33 1089 0 0 0 0 1 18
    635 10.596635 5 31  961 1 0 0 0 1 12
    652 10.341743 5 30  900 0 1 0 0 0  3
    659 10.553205 6 32 1024 0 0 0 0 1 10
    662 10.434115 4 27  729 0 1 0 0 1 23
    663 10.165852 5 30  900 1 0 0 0 1 11
    675  9.769957 4 21  441 0 1 0 0 1 25
    687 10.292146 4 34 1156 0 0 1 0 1 19
    699 10.491274 5 26  676 1 1 0 0 1  3
    703 10.621327 5 25  625 0 0 0 0 1 18
    712 11.571195 6 29  841 0 0 0 0 1  9
    720  10.89859 5 29  841 1 1 0 0 1 12
    734  10.91509 3 31  961 1 1 0 1 0  1
    738  9.952278 3 21  441 0 1 0 0 1 26
    742  7.937375 5 34 1156 1 0 0 0 1 10
    745 10.714417 4 24  576 0 1 0 0 1 24
    769 10.714417 5 33 1089 1 0 1 0 1 12
    783  9.667766 5 27  729 1 0 0 0 1 19
    792 11.512925 3 32 1024 0 1 1 0 1 24
    799 10.668956 5 27  729 1 1 0 0 1  4
    809 10.308952 3 30  900 0 0 1 0 1 13
    811  9.409191 1 34 1156 0 0 1 0 1 18
    816 10.308952 6 34 1156 1 0 0 0 1  5
    820  10.08581 4 27  729 0 1 0 0 1  1
    833  9.126959 4 34 1156 0 0 1 0 1 13
    858  10.12663 4 31  961 1 1 0 0 1 16
    872   7.17012 4 34 1156 1 0 0 0 1 19
    874  10.08581 4 33 1089 1 1 0 0 1 24
    877 11.711777 6 28  784 1 0 0 0 1 12
    901 10.106428 5 24  576 1 1 0 0 1 18
    end
    label values educ educ
    label def educ 1 "No high school", modify
    label def educ 3 "High school graduate", modify
    label def educ 4 "Some college", modify
    label def educ 5 "College graduate", modify
    label def educ 6 "Post graduate", modify
    label values age AGE
    label def AGE 19 "19", modify
    label def AGE 20 "20", modify
    label def AGE 21 "21", modify
    label def AGE 22 "22", modify
    label def AGE 23 "23", modify
    label def AGE 24 "24", modify
    label def AGE 25 "25", modify
    label def AGE 26 "26", modify
    label def AGE 27 "27", modify
    label def AGE 28 "28", modify
    label def AGE 29 "29", modify
    label def AGE 30 "30", modify
    label def AGE 31 "31", modify
    label def AGE 32 "32", modify
    label def AGE 33 "33", modify
    label def AGE 34 "34", modify
    label def AGE 35 "35", modify
    label values occ occ
    label def occ 1 "Management, Business, Science, and Arts", modify
    label def occ 2 "Business Operations Specialists", modify
    label def occ 3 "Financial Specialists", modify
    label def occ 4 "Computer and Mathematical", modify
    label def occ 5 "Architecture and Engineering", modify
    label def occ 8 "Community and Social Services", modify
    label def occ 9 "Legal", modify
    label def occ 10 "Education, Training, and Library", modify
    label def occ 11 "Arts, Design, Entertainment, Sports, and Media", modify
    label def occ 12 "Healthcare Practitioners and Technicians", modify
    label def occ 13 "Healthcare Support", modify
    label def occ 14 "Protective Service", modify
    label def occ 15 "Food Preparation and Serving", modify
    label def occ 16 "Building and Grounds Cleaning and Maintenance", modify
    label def occ 17 "Personal Care and Service", modify
    label def occ 18 "Sales and Related", modify
    label def occ 19 "Office and Administrative Support", modify
    label def occ 21 "Construction", modify
    label def occ 23 "Installation, Maintenance, and Repair", modify
    label def occ 24 "Production", modify
    label def occ 25 "Transportation and Material Moving", modify
    label def occ 26 "Military Specific", modify
Working...
X