代码拉取完成,页面将自动刷新
clear all
global datafolder
********************************************************************************
*** Prostate data ***
*** comparison with glmnet ***
********************************************************************************
$loadprostate
gen ybin = lpsa > 2
lassologit ybin lcavol-pgg45, lam(10 1 0.1 0.05 0.03 0.01) lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0.501461115822691,0.603583899226737,0.651411524139352,0.826374502058559 \ 0,0,0.466224946596217,1.02233825499837,1.19858862440819,1.48996763937638 \ 0,0,0,0,0,-0.0264071147625507 \ 0,0,0,0.0232111786772005,0.0977733878125449,0.234278942429968 \ 0,0,0,0.347557333713614,0.818269071194786,2.19023312954913 \ 0,0,0,0,0,-0.20284502575343 \ 0,0,0.274327168187838,0.639999602733867,0.804810602155823,1.21666269887086 \ 0,0,0,0,0,-0.00227895781755522 \ 0.755667537541278,0.755667537541278,-3.37053747374121,-7.92940124760532,-9.73475850480416,-12.1358873874818 )
di mreldif(S,G)
assert mreldif(S,G)<0.01
lassologit ybin lcavol-pgg45, nostd l(10 1 0.1 0.05 0.03 0.01) lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0.49000229764977,0.769318675648317,0.85526320111666,0.906069187273262 \ 0,0,0,0,0.315948623488018,1.21721663534913 \ 0,0,0.00568091171074165,0,-0.00508198583263728,-0.0318566587040123 \ 0,0,0.0633097982098456,0.208509405869272,0.239053556251706,0.283238055284736 \ 0,0,0,0,0,1.14829028427382 \ 0,0,0,0,0,-0.143667092495639 \ 0,0,0,0,0.325877300407054,1.22138220662723 \ 0,0.0230961215196978,0.0219472306702984,0.0182648564510364,0.0111575320234226,-0.00506567179207975 \ 0.755667537541278,0.27535477007396,-0.630396562134161,-0.517881010344681,-3.45041705660254,-10.8034348672065 )
di mreldif(S,G)
assert mreldif(S,G)<0.01
lassologit ybin lcavol-pgg45, nocons l(10 1 0.1 0.05 0.03 0.01) lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0.597904154552661,0.726122023990401,0.798790726486026,0.921752657257945 \ 0,0,0.0135028969542606,0,0.171947048951238,0.49056370807684 \ 0,0,0,-0.00300756283054592,-0.0158227880543364,-0.060846846460528 \ 0,0,0,0.175476249674279,0.259990447474341,0.405507212738994 \ 0,0,0,0.665451061416816,1.15151187861837,2.33678717583705 \ 0,0,0,0,0,-0.0347040277832361 \ 0,0.0559752315024908,0,0,5.66530864443488e-05,0.227283007307124 \ 0,0,0,0.00123728745272919,0.00458124613535244,0.0056859742231097 )
di mreldif(S,G)
assert mreldif(S,G)<0.01
lassologit ybin lcavol-pgg45, nostd nocons l(10 1 0.1 0.05 0.03 0.01) lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0.480318888302968,0.766488329771494,0.901293514420413,0.994357503579643 \ 0,0,0,0,0.0675008486192263,0.471956582881281 \ 0.00208320818573869,0.00315326759834838,-0.00374253486037605,-0.00798207623817391,-0.013826952207498,-0.0604790391537946 \ 0,0,0.0794801700546684,0.221208787323384,0.283793361154338,0.405919890396927 \ 0,0,0,0,0,1.17906428190479 \ 0,0,0,0,0,-0.0688739335594197 \ 0,0,0,0,0.000169219253455043,0.210870371872184 \ 0,0.0245128044360127,0.0219880300010344,0.018475718697768,0.0173742626600768,0.0117069696335417 )
di mreldif(S,G)
assert mreldif(S,G)<0.01
// penalization and standardization
lassologit ybin lcavol-pgg45, l(10)
mat bdense=e(beta_dense)
mat psi=e(Psi)
mat spsi=e(sPsi)
lassologit ybin lcavol-pgg45, l(10) stdfly
assert mreldif(bdense,e(beta_dense))<0.001
lassologit ybin lcavol-pgg45, l(10) psi(psi)
assert mreldif(bdense,e(beta_dense))<0.001
lassologit ybin lcavol-pgg45, l(10) spsi(spsi)
assert mreldif(bdense,e(beta_dense))<0.001
// vs notpen
mat psi0=psi
mat psi0[1,1]=0
mat spsi0=spsi
mat spsi0[1,1]=0
lassologit ybin lcavol-pgg45, l(10) notpen(lcavol)
mat bdense=e(beta_dense)
lassologit ybin lcavol-pgg45, l(10) psi(psi0)
assert mreldif(bdense,e(beta_dense))<0.001
lassologit ybin lcavol-pgg45, l(10) spsi(spsi0)
assert mreldif(bdense,e(beta_dense))<0.001
********************************************************************************
*** Spam data ***
*** comparison with glmnet ***
********************************************************************************
$loadspam
lassologit v58 v1-v57 , ///
l(0.18 .1 .05 .01 0.005 0.001) lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0,0,-0.0422529146575627,-0.272031262707042 \ 0,0,0,-0.00373203418724297,-0.0512671410498323,-0.125632626238845 \ 0,0,0,0.101141846279635,0.11883214230586,0.139109364166967 \ 0,0,0,0.0173756561991167,0.0526745401803319,0.195886595110133 \ 0,0,0.172804595227024,0.429605013071812,0.484763002454668,0.526731240528818 \ 0,0,0.215391390316697,0.439944587424189,0.491919474006125,0.638892239188151 \ 0,0.541244393029207,1.14272230384219,2.06887558871726,2.23002699666492,2.30014269388336 \ 0,0,0.136927707286204,0.480868178278047,0.531197496280493,0.55864194969041 \ 0,0,0.119571529292932,0.3601313065449,0.428423569813396,0.571760019260457 \ 0,0,0,0.0363964738545447,0.0661874609011232,0.0988644526800415 \ 0,0,0,0,0,-0.0886237382535084 \ 0,0,0,-0.0308097278466257,-0.089081775600141,-0.134749875433312 \ 0,0,0,0,0,0 \ 0,0,0,0,0.00795793603714984,0.0959052969098513 \ 0,0,0,0,0.187956709982398,0.766748734310841 \ 0,0.0569499824412161,0.261053578737326,0.474455181680385,0.582556859865158,0.992084036782018 \ 0,0,0.163352298428151,0.537635721901667,0.666555390326264,0.849404169191338 \ 0,0,0.0186179136972665,0.223578006225662,0.232610416364506,0.152792625551643 \ 0,0,0.0354864953419262,0.0684739350799352,0.0744387727276772,0.0809881016277326 \ 0,0,0.0623296656451264,0.30237957050336,0.401066076630547,0.680630170947902 \ 0.0251657497800995,0.244816018569017,0.285089535713845,0.231235215294809,0.21751235961023,0.226819320440981 \ 0,0,0,0.152438807435518,0.212558463696679,0.248079809754775 \ 0,0.512678317278518,0.908939351449302,1.62189944870526,1.88098268266277,2.25700936855849 \ 0,0,0.136512396818573,0.502377361626912,0.553687448356407,0.540585164364761 \ 0,-0.00711373831549181,-0.119341797786071,-0.650488655022833,-0.947791899988904,-1.5422976600939 \ 0,0,-0.0365713377744791,-0.311724419804555,-0.476376985691428,-0.865174810478425 \ 0,0,-0.00214239923991577,-0.150103996240846,-0.464229167129705,-1.43091728235785 \ 0,0,0,0,0,0.299518215687398 \ 0,0,0,0,-0.11287556060371,-0.970189677158865 \ 0,0,0,0,0,-0.213188194988553 \ 0,0,0,0,0,-0.15111484640071 \ 0,0,0,0,0,0 \ 0,0,0,-0.264763346644653,-0.465222166671986,-0.763495947479959 \ 0,0,0,0,0,0 \ 0,0,0,0,-0.0635939140607186,-0.963847734942651 \ 0,0,0,0,0,0.666907685726506 \ 0,0,0,-0.125014730751495,-0.0889334412435665,-0.011300721151613 \ 0,0,0,0,-0.00632977917857363,-0.436818510247387 \ 0,0,0,-0.106301779679491,-0.224438789391816,-0.586944463758824 \ 0,0,0,0,0,-0.358234655091931 \ 0,0,0,0,-0.299579530075859,-2.10564311868802 \ 0,0,0,-0.44588873213617,-0.708035508405983,-1.46655172058406 \ 0,0,0,-0.116295099407099,-0.271023655797981,-0.707676526963956 \ 0,0,0,-0.128692659562944,-0.373788716012293,-1.04867026256564 \ 0,0,0,-0.300713167088696,-0.432600838003125,-0.673078767971861 \ 0,0,0,-0.4173345191239,-0.704321130319187,-1.21019326162314 \ 0,0,0,-0.150587748961614,-0.714086849502039,-1.59652543630244 \ 0,0,0,-0.164230301991611,-0.586985955993564,-2.06052061918955 \ 0,0,0,-0.318945414490126,-0.61863047152071,-1.0603371670279 \ 0,0,0,0,0,-0.12810459024372 \ 0,0,0,0,-0.136996306452528,-0.671500830778917 \ 0,0,0.183754285937407,0.452118980142298,0.458172676826618,0.419905830636866 \ 0,0.631023867075545,1.57316434164323,3.76088285698889,4.4075093667459,5.07598763000083 \ 0,0,0,0,0,1.04898040886094 \ 0,0,0,0,0,0 \ 0,0,0,0.00137880130961895,0.00227997634698044,0.00463646241774424 \ 0,2.66765929383284e-05,0.000281563589013347,0.000466850681408009,0.000506933757806273,0.000609848729430626 \ -0.450811556523643,-0.816852292048691,-1.33465923808859,-1.67080357834546,-1.60068995272926,-1.53391838418534 )
di mreldif(S,G)
assert mreldif(S,G)<0.01
lassologit v58 v1-v57 , ///
l(.15 .1 .05 .025 0.01 0.005) nocons lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0,0,-0.0200867422123263,-0.180963081874258 \ 0,0,0,-0.0439725562644103,-0.115450410602825,-0.157305593166378 \ 0,0,0,0,0,0 \ 0,0,0,0,0,0.0248737630594846 \ 0,0,0,0.0667434523874724,0.195672120448769,0.259593231810163 \ 0,0,0,0.00222441489484255,0.116547135797629,0.199900956245658 \ 0,0.265014956681658,0.793520363853869,1.24314797930455,1.70013010830079,1.91290049195925 \ 0,0,0,0.152197580164138,0.296452514725046,0.357887094370555 \ 0,0,0,0.0250243043582219,0.137697541543941,0.222761802503909 \ 0,0,0,0,0,0 \ 0,0,0,0,0,0 \ 0,0,-0.0630453430573573,-0.195111020480451,-0.291546951127566,-0.314161971862145 \ 0,0,0,0,0,-0.08756211017273 \ 0,0,0,0,0,0 \ 0,0,0,0,0.120424279364554,0.354187006038407 \ 0,0,0.106750439452276,0.21245760092625,0.328425173653119,0.500696339873835 \ 0,0,0.0709425995331555,0.217156375324238,0.420379234649733,0.56920674322488 \ 0,0,0,0,0.048629175049587,0.057696989533041 \ 0,0,0,0,-0.020789895089672,-0.0436000934364041 \ 0,0,0.0239005584077038,0.149615451999137,0.292733534056024,0.398108722332453 \ 0,0.00243201716946116,0.0680387538806802,0.083328722308754,0.0894534268473376,0.105425668464145 \ 0,0,0,0,0.0775090077892467,0.142075075770615 \ 0,0.275009205461234,0.72537916118375,1.06698790895246,1.44280441321528,1.72027974501352 \ 0,0,0.0479845894262583,0.217738196069698,0.394705684203277,0.472496250592033 \ -0.0223440877877455,-0.132668414169889,-0.313488233648016,-0.54838389731916,-0.936938075822474,-1.23481713891759 \ 0,-0.0609006144400859,-0.177568921138646,-0.277026881054149,-0.464709312028651,-0.63142026128668 \ 0,-0.0103741892860181,-0.070161267233627,-0.127904803022036,-0.257652912101769,-0.517338734762027 \ 0,0,0,0,0,0 \ 0,0,0,0,-0.0450461646744678,-0.359265300176881 \ 0,0,0,0,0,-0.161867521620582 \ 0,0,0,0,0,-0.046122253319544 \ 0,0,0,0,0,0 \ 0,0,-0.0828692104212642,-0.285316225156789,-0.58997916306237,-0.791695735414731 \ 0,0,0,0,0,0 \ 0,0,0,0,-0.0918778074927649,-0.219650592530303 \ 0,0,0,0,0,0 \ 0,-0.0630371681660719,-0.307539958672982,-0.384470440494363,-0.358372967333063,-0.314884147985183 \ 0,0,0,0,0,-0.191588425277942 \ 0,0,0,-0.0403046841400879,-0.211868440351775,-0.352145422328576 \ 0,0,0,0,0,-0.0483661679280512 \ 0,0,0,0,-0.10331814625645,-0.406815105529768 \ 0,0,-0.103710299079598,-0.305807487194226,-0.659857431681319,-0.964166817374027 \ 0,0,0,-0.037295524567914,-0.330160931322528,-0.57400332534841 \ 0,0,0,-0.126478415974642,-0.436418725123807,-0.762901014782063 \ 0,0,-0.168444091298225,-0.369421777328527,-0.603931392308208,-0.737816371222742 \ 0,0,-0.159895066345096,-0.397474317934418,-0.800796674646007,-1.11051462265085 \ 0,0,0,0,-0.511551026426417,-0.901980884578981 \ 0,0,0,-0.0967782082998046,-0.492401520570917,-0.927186765734769 \ 0,0,0,-0.120380350625124,-0.558716653197135,-0.851922825943988 \ 0,0,-0.256214350603698,-0.734193287497686,-1.08003814069837,-1.1074304761778 \ 0,0,0,0,-0.624291484186726,-1.19610720319507 \ 0,0,0.0245878706303293,0.11327052634246,0.196926767089997,0.227467498113895 \ 0,0.209570688353242,1.18953467225439,2.1372473049678,3.28631916741697,3.94944398020316 \ 0,0,0,0,0,0 \ 0,0,0,0,0,0 \ 0,0,0,0.000450775511481365,0.000949618067924462,0.00150040170166375 \ 0,0,0,4.22564218203648e-05,0.000141854663994748,0.000213631540830992 )
di mreldif(S,G)
assert mreldif(S,G)<0.03
lassologit v58 v1-v57 , ///
l(10 0.1 0.05 0.01 .005 0.001) nostd lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0,0,0,-0.196606830871361 \ 0,0,0,-0.0263959141205755,-0.0627951579638412,-0.118426808731766 \ 0,0,0,0,0,0.102694111984808 \ 0,0,0,0.00516845136302719,0.0433845100498495,0.255066666352933 \ 0,0,0,0.377850977275016,0.456724641505493,0.551590006500719 \ 0,0,0,0,0.269285747828233,0.621688751483009 \ 0,0,0,1.10087981403029,1.54368806896071,2.13177925264091 \ 0,0,0,0.320728980387188,0.445263521331234,0.544826963080417 \ 0,0,0,0,0,0.443649074799542 \ 0,0,0,0,0.0204087663270599,0.100911255476619 \ 0,0,0,0,0,0 \ 0,0,0,-0.0531937638595258,-0.110026127046077,-0.144729540552861 \ 0,0,0,0,0,0 \ 0,0,0,0,0,0.0541979592970806 \ 0,0,0,0,0,0.115097436073612 \ 0,0,0.219337625782819,0.728276302338932,0.828344228043666,0.936568757145528 \ 0,0,0,0.235627862792052,0.459662402282917,0.794066489512141 \ 0,0,0,0.0896053571721042,0.148727268825427,0.141156832349543 \ 0,0.109401406887508,0.12949040110083,0.109114656531446,0.100431962365842,0.088465900027753 \ 0,0,0,0.0960780992452676,0.217083256616456,0.56966154977343 \ 0,0.155863471226981,0.288325708867917,0.295300028640053,0.2642762693284,0.227564580072034 \ 0,0,0,0.0573220238010432,0.0897145232657215,0.233672717839671 \ 0,0,0,0.899098761929624,1.23558597332666,1.84929666229257 \ 0,0,0,0.213989045389802,0.395496066797918,0.50471797450479 \ 0,-0.137633831311825,-0.428258460781284,-1.18581357954125,-1.42295663664892,-1.78665244112237 \ 0,0,0,-0.0457689200355376,-0.229636533094445,-0.693978642684788 \ 0,-0.0487632571003764,-0.147039973104196,-0.816361941819738,-1.33920940706366,-3.83283619415318 \ 0,0,0,0,0,0.221839810370222 \ 0,0,0,0,0,-0.571676198017221 \ 0,0,0,0,0,-0.034641955163953 \ 0,0,0,0,0,0 \ 0,0,0,0,0,0 \ 0,0,0,-0.0939506854962543,-0.277644336330768,-0.660202193225169 \ 0,0,0,0,0,0 \ 0,0,0,0,0,-0.375211673639146 \ 0,0,0,0,0,0.462589340216143 \ 0,0,0,0,0,-0.0233857855396148 \ 0,0,0,0,0,-0.13273040571758 \ 0,0,0,0,0,-0.432952185786407 \ 0,0,0,0,0,0 \ 0,0,0,0,0,-0.47832595201352 \ 0,0,0,-0.368318040619443,-0.622511232094226,-1.37637221332031 \ 0,0,0,0,0,-0.139810725682437 \ 0,0,0,-0.0174002302406321,-0.181242700957882,-0.891323650902357 \ 0,0,0,-0.269149657094932,-0.380150922271061,-0.616870622105827 \ 0,0,0,-0.546281049241329,-0.864630097661637,-1.32512423900005 \ 0,0,0,0,0,0 \ 0,0,0,0,0,-0.783172594822248 \ 0,0,0,0,-0.0417654564340482,-0.762406591054006 \ 0,0,0,0,0,0 \ 0,0,0,0,0,0 \ 0,0,0.0388465427763881,0.391143596322809,0.400821242459232,0.401755305686915 \ 0,0,0,0.299926255332921,1.528093609498,4.15578120724715 \ 0,0,0,0,0,0.224049518522976 \ 0,0,0.00228751649055222,0,-0.00149114153314493,-0.0126854106956653 \ 0.000251176249855191,0.0211531130365377,0.0190977387878989,0.0123128199830305,0.0102571927074542,0.0087378756648603 \ 0.00116904746155995,0.000153035327786397,0.000242754480855713,0.000412991010293585,0.000429815225601432,0.000473779800524816 \ -0.752661384082521,-1.40386117252347,-1.47716148408643,-1.56003952656892,-1.55744581223666,-1.5298166412315 )
di mreldif(S,G)
assert mreldif(S,G)<0.03 // 3% deviation!
lassologit v58 v1-v57 , ///
l(40 10 1 0.1 0.05) nocons nostd lambdan
mat S = e(betas)'
mat list S
mat G = ( 0,0,0,0,0 \ 0,0,0,0,-0.00388390194575201 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,-0.0608399932100172 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0.0641514339556632 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0.0793813559307355 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,-0.433326247098604,-0.826496410034253 \ 0,0,0,0,0 \ 0,0,0,-0.144784796466159,-0.270173956885227 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,-0.000744445387214381 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,-0.148578232510563 \ 0,0,0,0,-0.187291134609176 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,0,0 \ 0,0,0,-0.00636951077256207,-0.0140453997113308 \ 0,0,0.00561069230547681,0.00927731836362141,0.01054896589884 \ 3.41081748400473e-05,0.000381523296092164,-8.95105672525863e-07,-4.26170125134684e-05,0 )
di mreldif(S,G)
assert mreldif(S,G)<0.01
********************************************************************************
*** Verify largest lambda value: Spam data ***
*** comparison with glmnet ***
********************************************************************************
$loadspam
// OK
lassologit v58 v1-v57 , lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],0.1872651)<10e-5
// OK
lassologit v58 v1-v57 , nostd lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],73.81646)<10e-5
// OK
lassologit v58 v1-v57 , nocons lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],0.1602859)<10e-5
// OK
lassologit v58 v1-v57 , nocons nostd lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],43.80048)<10e-5
********************************************************************************
*** Verify largest lambda value: Prostate data ***
*** comparison with glmnet ***
********************************************************************************
$loadprostate
gen ybin = lpsa > 2
// OK
lassologit ybin lcavol-pgg45 , lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],0.2479347)<10e-5
// OK
lassologit ybin lcavol-pgg45 , nostd lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],4.286853)<10e-5
// OK
lassologit ybin lcavol-pgg45, nocons lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],1.887063)<10e-5
// OK
lassologit ybin lcavol-pgg45 , nocons nostd lambdan lcount(3)
mat L= e(lambdas)
di L[1,1]
assert reldif(L[1,1],12.14948)<10e-5
********************************************************************************
*** plotting ***
********************************************************************************
clear all
$loadprostate
gen ybin = lpsa > 2
lassologit ybin lcavol-pgg45, plotpath(lambda)
lassologit ybin lcavol-pgg45, plotpath(lnlambda) plotvar(age svi)
lassologit ybin lcavol-pgg45, plotpath(norm)
********************************************************************************
*** verify post-logit and log-lik value ***
********************************************************************************
clear all
$loadspam
foreach lam of numlist 0.187 0.1 0.07 0.05 0.01 0.005 {
lassologit v58 v1-v57, l(`lam') postl lambdan
mat b1 = e(b)
local L1 = e(ll)
local sel = e(selected)
di "lambda=`lam'; selected=`sel'"
logit v58 `sel', iterate(100)
mat b2 = e(b)
local L2 = e(ll)
di mreldif(b1,b2)
assert mreldif(b1,b2)<0.0001
// verify loglik
assert reldif(`L1',`L2')<0.01
}
//
********************************************************************************
*** compare results: single vs multiple lambdas ***
********************************************************************************
clear all
$loadspam
*******
lassologit v58 v1-v57, l(0.187 0.1 0.07 0.05 0.01 ) lambdan quadp noseqr tolopt(1e-14)
mat B = e(betas)
local j = 1
foreach lam of numlist 0.187 0.1 0.07 0.05 0.01 {
lassologit v58 v1-v57, l(`lam') lambdan quadp noseqr tolopt(1e-14)
mat bj = e(beta)
mat Bj = B[`j',1..58]
di "lambda=`lam'"
di mreldif(bj,Bj)
assert mreldif(bj,Bj)<0.001
local j = `j' + 1
}
//
*******
lassologit v58 v1-v57, l(0.187 0.1 0.07 0.05 0.01 ) postl lambdan quadp noseqr tolopt(1e-14)
mat B = e(betas)
local j = 1
foreach lam of numlist 0.187 0.1 0.07 0.05 0.01 {
lassologit v58 v1-v57, l(`lam') postl lambdan quadp noseqr tolopt(1e-14)
mat bj = e(beta_post)
mat Bj = B[`j',1..58]
di "lambda=`lam'"
di mreldif(bj,Bj)
assert mreldif(bj,Bj)<1e-10
local j = `j' + 1
}
//
*******
lassologit v58 v1-v57, l(0.1 0.07 0.05 0.01 0.005 ) nocons lambdan quadp noseqr tolopt(1e-14)
mat B = e(betas)
local j = 1
foreach lam of numlist 0.1 0.07 0.05 0.01 0.005 {
di "lambda=`lam'"
lassologit v58 v1-v57, l(`lam') nocons lambdan quadp noseqr tolopt(1e-14)
mat bj = e(beta)
mat Bj = B[`j',1..57]
di mreldif(bj,Bj)
assert mreldif(bj,Bj)<1e-5
local j = `j' + 1
}
//
*******
lassologit v58 v1-v57, l(0.187 0.16 0.12 0.1 ) nostd lambdan quadp noseqr tolopt(1e-14)
mat B = e(betas)
local j = 1
foreach lam of numlist 0.187 0.16 0.12 0.1 {
lassologit v58 v1-v57, l(`lam') nostd lambdan quadp noseqr tolopt(1e-14)
mat bj = e(beta)
mat Bj = B[`j',1..58]
di "lambda=`lam'"
di mreldif(bj,Bj)
assert mreldif(bj,Bj)<0.001
local j = `j' + 1
}
//
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。