I am wondering if someone can explain to me why the LASSO sometimes will choose no variables if there are many candidate variables in a model and choose more when fewer variables (a subset of the former) are included. I don't understand how this could happen.
Here's an example with data:
If I run:
lars en a3 e3 l3 d2 rs sizeavg, a(lasso)
Then LASSO chooses a3, e3, rs, and sizeavg.
But adding age to the candidates, using:
lars en a3 e3 l3 d2 rs sizeavg age, a(lasso)
The LASSO chooses no candidate variables.
Here's an example with data:
If I run:
lars en a3 e3 l3 d2 rs sizeavg, a(lasso)
Then LASSO chooses a3, e3, rs, and sizeavg.
But adding age to the candidates, using:
lars en a3 e3 l3 d2 rs sizeavg age, a(lasso)
The LASSO chooses no candidate variables.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(a3 e3 l3 d2 age rs sizeavg en) 35 11 18.6 6 4 1 736 47021.41 49 11.3 22 6 6 1 670 82373.56 30 11 13.7 6 5 1 736 58144.61 31 11.3 14.7 6 5 1 606 47947.14 8 5 15 1 3 0 504 28261.64 30 8 13 8 5 1 745 32253.55 30 12 25 6 6 1 575 70050.37 11 11.7 4.7 3 15 1 553 67029.66 30 12 15 6 5 1 755 72386.39 33 10.4 5.6 6 5 1 692 58593.08 28 10.6 8.8 6 4 1 755 96065.57 31 11.3 12.5 6 6 1 660 96112.35 38 11 13 6 5 1 598 88737.84 22 11 16 8 4 1 811 75900.375 31 10.2 12 6 4 1 737 85583.16 38 11.3 18 6 6 1 670 52297.74 22 10.6 15 6 3 1 850 104180.3 34 12.5 10.6 8 4.5 1 696 38965.18 24 9.6 6.6 8 5 1 593 40038.34 30 11.6 9 6 6 1 755 123999.98 30 11 14 6 5 1 648 40243.81 22 11 11 6 4 1 696 58989.97 26 12.5 7.6 8 3 1 690.5 81369.8 38 10.6 19 6 5 1 667 59163.72 30 8 13 8 5 1 677 76445.72 30 11 20 6 5 1 710 58538.94 49 10.2 10.6 6 6 1 688 29591.23 30 8 19 6 6 1 736 68110.875 38 8 17 8 5 1 711 82417.18 30 12 18 8 5 1 774 78911.65 27 12.8 11.7 6 5 1 625 25993.42 49 8.5 15.9 6 6 1 788 27619.146 31 10.4 6.9 6 6 1 692 14386.373 38 11 12.7 8 5 1 688 13170.033 30 12 13 6 6 1 760 70203.625 38 8 22.5 8 5 1 677 57646.82 38 7.9 12.9 8 5 1 667 45465.28 30 11 14 8 4 1 738 56925.07 49 10.2 14.6 6 6 1 688 23870.637 22 11 12.5 6 4 1 662 92508.52 30 11 15 8 5 1 763 53747.79 36 14 17 8 5 1 600 38685.676 30 11.7 18 6 5 1 667 80511.63 30 11 16 8 5 1 731 23874.104 38 11 22 6 5 1 606 44018.17 30 8 20 6 5 1 732 43041.18 30 11 15 6 3 1 639 38779.184 end
Comment