ࡱ>   fHv &"#$%'41)*+,-./023^_6F89:;<=>?@ABCDE5GHIJKLMNOPQRSTUVWXYZ[]aucdefghi\klmnopqrst`vwxyz{|}~Root Entry F)ZS!WWorkbook6M9_VBA_PROJECT_CUR"4, S`SVBA2 S)㬫S L\pFrank M. Howland Ba= ThisWorkbook=h<%<X@"1Arial1Arial1Arial1Arial1$Arial1 Arial1 Arial1 Arial1Arial"$"#,##0_);\("$"#,##0\)!"$"#,##0_);[Red]\("$"#,##0\)""$"#,##0.00_);\("$"#,##0.00\)'""$"#,##0.00_);[Red]\("$"#,##0.00\)7*2_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_).))_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)?,:_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)6+1_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_) 0.0000 0.000 0.000000.0 0.000000$[$-409]dddd\,\ mmmm\ dd\,\ yyyy 0.00000000 0.000000000 0.0000000000 0.00000000.000000000000 0.00000000000"Yes";"Yes";"No""True";"True";"False""On";"On";"Off"],[$ -2]\ #,##0.00_);[Red]\([$ -2]\ #,##0.00\)0.00_);\(0.00\)0.000_);\(0.000\) 0.0_);\(0.0\) 0_);\(0\)[$-409]mmmm\ d\,\ yyyy;@[$-409]mmmm\-yy;@                + ) , *       H  @ "X  H "P     ` Doc)BrowningDataExample)/ETobitModelsEMAlgorithmforProbitAndLogit.xlsDoc VBA Notes ProbitDataLogitEG ProbitNotesProbitEG ProbitEG2xsIterationTobitYZ ࿮`"Neco253browninbPaperPaper.xlsCodebookList of Variables Histogram Data TablesY$ZHGAEducZ HGAEducZChildZ .Z#?@LessThanFirstGradeZ ?@Z#@@FirsttoFourthGradeZ @@@Z"@@FifthorSixthGradeZ @@@Z&A@SeventhandEighthGradeZ A@@ZA@ NinthGradeZ A@"@ZB@ TenthGradeZ B@$@ZB@ EleventhGradeZ B@&@Z%C@TwelthGradeNoDiplomaZ C@'@ZC@HighSchoolGradZ C@(@Z$D@SomeCollegeNoDegreeZ D@*@Z!D@AssoDegreeOccVocZ D@,@Z#E@AssoDegreeAcademicZ E@,@Z E@BachelorsDegreeZ E@0@ZF@ MastersDegreeZ F@2@Z! F@ProfSchoolDegreeZ F@2@Z !G@DoctorateDegreeZ !G@4@YYYbeta0:beta1:beta2:! epsilon;* HGAtoEducNumeric;! ' HGAtoEducText;!$ NewPredictedProbTableShowOptionsFormsigma:sigmaEM: sigmai: ystar;"T3 A@@   TK&Task is to adapt the Options Form code!pick out which variable is chosen-generate table based on SDs fro this variable use sumproduct to generate table put graph in2Ultimately add % correctly predicted to the Add-InRevised 30 March 2004!and Gauss Newton (for NLLS) code.4This takes care of estimation through producing SEs.7What remains is to get the predicted probability table.FThis is built off of the index value and X variable SD and mean table.0ned to put in either Normdist or Logit function.5use offset to work out where to put the table and to get correct cell refs.\Maximum likelihood following Greene Chapter 19 for likelihood functions and Greene Chapter 5 Wife's Age Wife's Age^2 Husband's AgeHusband's Age^2!Wife's Education (Recode Numeric)Husband's Income (in thousands)Husband's Labor Supply%Number of Children in Family Under 18/Probit Results for Wife's FT/PT Status (Recode)Number of observationsMissing observations Mean of Dep VarCoefficient EstimatesVariableEstimateSElnL Iterations Intercept X VariableMeanSDTStata Probit estimates Number of obs = 25041N LR chi2(8) = 1185.45N Prob > chi2 = 0.0000NLog likelihood = -14013.587 Pseudo R2 = 0.0406N------------------------------------------------------------------------------ DifferenceNwifesftpts~e | Coef. Std. Err. z P>|z| [95% Conf. Interval]In Coef.In SE_cons | wifesage | wifesage2 | husbandsage |husbandsage2 |wifeseduca~c |husbandsin~s |husbandsla~y |numberofc~18 |Predicted Prob Table added.Non contiguous X'sRefEdtsAdded language fixSAdded uninstall language fix and commented out Redim HINV for Excel97 compatibilityuChanged Integer to Long in the entire project to enable the add-in to work with more than 32,768 (2^15) observations.(Added checks for perfect classification.xChanged ML routines to get greater accuracy in cases where cumulative is close to 1. See Davidson and Mackinnon p. 517.jAdded abort check to get rid of troublesome predicted prob button showing up when estimation didn't work..!Slight fixes to previous version.#ProbitNLLS and LogitNLLS functions.LFixed Logit ML routine because an error had crept in. I had two statements:E 'dlnL(k) = dlnL(k) + (Y(i, 1) - F(i)) * X(i, k) ' Old versionM dlnL(k) = dlnL(k) + (Y(i, 1) * G + (1 - Y(i, 1)) * (G - 1)) * X(i, k)&I had not commented out the first one.&This relates to the 22 Jun 2006 fix. MCorrected error in vecmatvecmult which caused Robust Ses to be mis-estimated.hChecked against Mroz data set using Stata. Robust Ses are now correctly estimated for Probit and Logit.Documentation for DDVGN.xlaOI took existing ddv.xla interface and grafted onto it the EM algorithm (for ML)R ,]G<g"7  cc L 9"%&)  dMbP?_*+%MRSamsung ML-1200 SeriesP|o odXX227RLdS1HSamsung ML-1200 Series"dXX??U} m 9 I  J             ~ @ ~ @ 7 8 9~  @ :0!"$%'()*,-./01234678~ !@ ";~ $@ %<~ '@@ (= )> *?~ ,@ -@ .A~ /@ @ 0B 1C 2D 3E 4F~ 6`@ 7G 8H,|PH0(  >@6667 Sheet2 L *o7  dMbP?_*+%"??U} } $ } m                                ~ @t@ % ~  & I[? ' &^ (  ~ @  )  *     +  , -  !;}?K? .[nza|?@pK?`Ak> LL*ӥk  LL   A| ? 0-pH? / ;߫ ? qH? ((d>  f`    *5VIoM þ"? 0 U|oM $D"? ܳY>  @PG_    К  )? 1  0JU)? [  6!>    9Ssǟm? ~3f,!? 2 ;m2OSp? 1zn+!? =e  KHX>    )p/n? ãl? 3 8n? 2il? .;tJ c  imfit<;%? 4vi$0%?(;_>EF@Y-s#@ _?nz?,R&\?QeeB< @@DD4Hp*$22222222 P(  Pr P 0CC],@ ,R9 $<Predicted Probability Table<ton>@ 7 Sheet3 ThisWorkbook((s__SRP_8__SRP_9 Sheet3 *  !"#$%'()+-./0123456789:;<=>@ABDFGHIKLMOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrtuvxz|}~rU hI6#31WIWqW[ X \q\\\!]I]y] )716#4y7y7`` IW<   $ `KFp t! t t>pF`P  P:@]3t6`P6` @"%t! t `c ]@t5`CxM` (%'%'%'%'%: %:@%t! t ``1xt5`Cxm: %lxF %:@ %t! t d H   , P) t5P`(x0 pt`P044PrU @$`U$A`Y nDr"P+#<מED hx FoXcC &OxoXcC &OמED hxME(SLSS6"N0{00020820-0000-0000-C000-000000000046}(%H@h %0 %Xp@@HH0&0FK$*\Rffff*?h460aa2594xAttribute VB_Name = "She@et3" Bast0{00020820- C$0046} |Global!SpacFalse dCreatablPre declaIdTru BExposeTemplateDeriv$Bustom izD2  F  rU hFFF1(4GQAG__SRP_12&__SRP_13 *BSheet2),__SRP_16?` enter the word that Excel irU @nFor example, in Spanish, it is Herramientas.Get the word fDr"P1#<આEHO tF F⁑HH#x⁑HH#આEHO tFMElDR "P P#<5 sI $-Fuk] DZ>zxuk] DZ>zЎ5 sI $-ME0[LSS6"LLLL <4<8<<<N0{00020819-0000-0000-C000-000000000046}(X @`P|kT  `oX `xu%@ %0 %@  &xt@t @p @` @8P @P@ @0 @h @ @ @ @ @ @ @ @8 @ p?@@\T@&0FK$*\Rffff*1r474c4aa8*\R4*#4f*\R4*#4e*\R4*#4d*\R4*#8c*\R1*#6c*\R0*#f*\R1*#d7$*\Rffff*8x4630bb244"" B P "p  " 2   F  @6`x D$M  Nm( x < Check Solver Reference and attempt to add it if not present:\DCheckSolverReferenceLOC Put the Wizard menu item in2uA@oX@+ Delete the new menu command from the ToolsxD menu.check language] !"$WThanks to John Talyor & %$Tools'=it's not English, try to get the word for Tools from the userd(The language of this installation of Excel does not appear to be EnglishUS. Please enter the word that Excel is using for Tools on the main menu across the top of the screen. For example, in Spanish, it is Herramientas.Get the word for TOOLS Herramientas %('kdTools'kDDV Gauss Newton ... Worksheet Menu Bar %*%,%,B@.oxAttribute VB_Name = "ThisWorkbook" Bas0{00020P819-0C$0046} |GlobalSpacFalse dCreatablPredeclaIdTru BExposeTemplateDerivBustomizD2Sub _AddinInstall() ' Check Solver Referensand att;t to add it if not presesu@Nex6 @1cGlanguaglDim my As Sng If Left(Application .Oper@ngSys6, 1)AW" The@'ThanksWJohn TalyorInternal(xlNonEnglishFuncAs) <> zD.)>@'it 'so, trygejwojfB8Nuse&EB K*putBHox(@e L of_is}B2Excel doe$appea"rA#be (US. Ple@q)that #@ using on@e mainAacros@-DtopCe screen. "F@exa le,u }n,` ^s Herrami@as.", "G%OOLS!Ii, #2 mZIf[(".`4,a eHJCcZBars("Azshe@g ").Cohntr\(?("DDV Gau Newt`$...}@dgmmA(SLSS6"N0{00020820-0000-0000-C000-000000000046}(%H@h %2 %Xp@@HH0&0FK$*\Rffff*1p4695f3154xAttribute VB_Name = "She@et2" Bast0{00020820- C$0046} |Global!SpacFalse dCreatablPre declaIdTru BExposeTemplateDeriv$Bustom izD2rU cF)c1(4GQAG`rU @nrU $`$`$`$`__SRP_17CBDDVModule 7+L__SRP_15 b__SRP_14E  p&0FK$*\Rffff*8x4630bb24$*\Rffff*8y4630bb24*\R1*#2ac*\R1*#e8*\R1*#1c8*\R0*#f*\R0*#14*\R1*#dc*\R4*#8c*\R4*#4d*\R4*#4e*\R1*#d7*\R1*#6c*\R4*#4f*\R4*#50*\R4*#30*\R0*#13  ( 2@ x  6 4    0 H 8P      ( >0 p x    $   8 @@ "    8  .0 ,`  $c?"PPxMEH@6 "LLLLLLLl @@\ @BL @D< @F, @H x@J `L`N`P`R`T( \(`kW@^l @R\ `TX h` kf@^l @R\ `TX j8`@k##z@^l @R\ `TX ``k11`Tx`lv `nd `H`| (8@4@%(8@(8@8VZ@ @P `pX@p@h clea@ t an@ @ alu@ Fil@ H:\E@ nk\A@p @(` @@P @X@ %@0  s@, @ @ @ @   x  V`f` @ T @D @4 @ $ @0  @  @H @` @x  @@ @ @ @p help@ 0 @(  @ h@P | h ( '`@l PROF P @@ h x  `@d A@& @ T @ D p@ 4 @( $ @X  @  %@ @H @ @ @ @ @ @0 @` @ p @l @x \ @ L @ < @, @ P h   V`f@8T @ D @4 @ $ @P @ @h @ @ @x @ @ @ @  8@H ` @p| H @l p @h  @d  @T @P @0@ @H0 @` @ @ @  @ @ @ @ @ @8 @P @h| @l @\ @L @< @, @ @ 0p  0HV`f@pT @(D @@4 @X$ @ @ @ @ @ @ @ @  @ @X p0@ X@| @l @h  @d 0 @8T @PD @h4 @$ @ @ @( @ @ @ @p @@ @X @ @ @p @l @\ @L @< @, @ @ P Xx`x0* &x~Z@H` @P @PL @D @4 @$ @ @ @ @ @  @8 @ @h @ @ @ !@`&@  @8p @P` @hP @@ @0 @ @ 8 > 8 ""@ H X 2` : 6"2P px  <|  $ P >4/X&[ N&d 00 &P f` "(  0 H )`      " ( (@ h    l 8 xX     "  (( P h  ~!    (  8 H P h "x D & D HX P   0 68 p "  *"2  8K@ `; D$R (0@,SH 8x<nPs TH B  8 H>pX      x Test did this save? DOCUMENTATION, This add-in does a Dummy Dependent Variable analysis User Input0 It is assumed that the user has a 0/1 dependent. variable in a column and X data in contiguousx columns AUTHOR Humberto Barreto1 Written during 1998/99 Visiting Professor at UCR Profesor Visitante Facultad de Economia Universidad de Costa Rica San Jose, CR" email: hbarreto@cariari.ucr.ac.cr7 phone: 011-506-283-5978 (when calling internationally) Dept.of Economics Wabash College Crawfordsville, IN 47933 E -mail: barretoh@wabash.edu phone: (765) 361-6315 FAX: (765) 361-62779 This work was financially supported by the Wabash Center for Theology and Teaching. DATE April 19991 Makes sure the Dummy Dep Var option is availablePublic Sub auto_open()(In case the user opens the file directly&AddIns.Add("DDV.xla").Installed = TrueEnd Sub7 Run the Dummy Dep Var Analysis by executing this macro2 It will bring up a form which enables the user to input necessary information 8B@:o+ This macro takes user inputted information4 and estimates Probit NLLS or ML or Logit NLLS or ML0 Not used but useful in string manipulation work@](]@Xp'N N 'P'R R  $VChange R+V'T+$A$ R '> T$V!X >'@7 myLeft = Mid(Cells(j, 2).Formula, 2, mypos - 1)($A$ R  + 0.00000001)'F @ T$V!X >'BH myMiddle = Mid(Cells(j, 2).Formula, mypos + 5, myPos2 - mypos - 4) T$V!X B $'H D F J F H'L LA@Z` Cells(j, i).Formula = "=(" & Mid(Cells(j, 2).Formula, 2) & " - " & myNewString & ")/0.00000001"o0]$V!$V$`B@b ^P R T ^  T $V!d ^ RData$f%V!d R T $V!d R T $V(d T R ^o(]h$V !$V$`B@b ^PXiXiPrimeMatrix R T ^ RData$f%V!d ^ TData$f%V!d R T $V(d Second Derivative Matrix ^ $V!d R T $V!d R T $V!d R T $V(d T R ^o] 0$V2$V$`B@b ^P R T ^ +$V!d ^ TData$f%V!d R T/ $V!d R T/ $V(d T R ^oSub StringFind()j = 2mySearchString = "NORMDIST"= mypos = InStr(1, Cells(j, 2).Formula, mySearchString) mySearchString = "))))"> myPos2 = InStr(1, Cells(j, 2).Formula, mySearchString)B myCenter = Mid(Cells(j, 2).Formula, mypos, myPos2 - mypos)I myNewString = "=-(" & myCenter & ")))/((1+" & myCenter & ")))^2)"End Sub) ****************************************/ This macro adds a menu item so the DummyDepVar macro can be run8 define variables]x]]'l$ Make sure the Tools menu is visibleWorksheet Menu Bar$*(pcheck language] !"$WThanks to John Talyor & %$Tools'=it's not English, try to get the word for Tools from the userdThe language of this installation of Excel does not appear to be EnglishUS. Please enter the word that Excel is using for Tools on the main menu across the top of the screen. For example, in Spanish, it is Herramientas.Get the word for TOOLS Herramientas %('k d Tools'k  Worksheet Menu Bar$*%,(p1 Check to see if there is a DummyDepVar menu item'l T Worksheet Menu Bar$*%,!,!r T Worksheet Menu Bar$*%,%,!tDDV Gauss Newton ...MMeans the DummyDepVar menu item is already there, make DummyDepVarIsHere True'ldP ;Means the DummyDepVar menu item is not there, so do nothingk T1 Add the DummyDepVar menu item if it is not there l xl Worksheet Menu Bar$*%,!,%v.n n ShowDDVGNForm9zDDV Gauss Newton ...9tq k ]9You have successfully loaded the DDV Gauss Newton add-in. $~ $~&You may access the macro by executing  : DDV Gauss Newton ... DDV Gauss Newton Add-In$Z'|o8 0 Attribute VB_Name = "DDVModule" Option Explicit ' Test did this save? 2DOCUMENTATIONT@add-in does a Dummy Dependent Variable.analysisMUser InpuuIt l@assumeya"t~e u$haY0/1 dWN vZ }a column and X datacontiguou9'?AUTHOR#Humberto Bar0reto  Writteluring 1998/99 VisitProfessor UUC% # ant{Fa@cultad_ BEIomia0Universid CosZRicSan Jose, -ema@il: hbS@cri.ucr@.ac.crphone: 011-506-283-5978 (wh3call/bi&rna@y)@mt.ofE)cMWabash Colleg4Crawfordsvi, IN 47933DE -C**h@wa.eduA((765) 361 -6315FAX: 277ATAwork wfinanciA. supportby+@eBD@* Theology‡Teach@A.DATEAprilz"9CMaksure oC΍veĸPub Sub aut(o_o(AWInp casAs!filerectly!AddPIns.(.@xla").t<9= Trua= E@+' RunP+ADo $`execuBX|macra^ @pw9d b]upy@'m which e~nA#elx nec@aaryaK Show GNFormA! .Ag!>b t0iᅁ=in ':0imat@6pbit NLLS qMLLogj&A' NotdF ful s`manipulB AQDim mySearchS",posPos2LeftCS!!RighBMiddl}myNeBw As #  NumCoeBfLongLastChangVetiGjE $= 2= E + 26#i@2p6Cells(1, i)2 * (i - 2y- 1) & "c@j@4 > i$`"+$A$"@) `(In@!aj, 2).aJ@2 n .,(r"3  4@"(P+ 0.01)`g!> my +#gb'C myB@  5 -,>4 &i+ 5z)"& T \Msg8Box' if "=(!rmr2&'Qs3()/ES!YMLCoMa:xX, R= "V"8it's not  , try?gword forfromтuseLE .TputBox("p of!Àinstalld Excel doeIappearFbePUS. Please &e$e RthacBus@a.onB mainC`acrosZt op$cree n. Falreadch%, m$# ň!gˣbrr`RsoeAwh INext jAdd_(@;?iYA &0/Q>(S_newI =_@Show ?GN Tm C o?!#Eqbrepspon fiaaX= MsgŸYou havccessfully loade3Tadd-i n U& vr(13) )"! may a ` by execut"& ": `"a, vbIn=mB`3-In"1ÖSubL]3)`L64$vpvx xf kv/p%lHF%L:P%`$ d` HL  ,W$ !dN)`L5$dq:P"%lC#:P%lC q 4 $  $' '0:%N@@@:P&4$:'plHF`:(P^ i64$p`P@0 l0dHHD`L4$p`P@0 R XAl\6/l#,*# *F,2,[\("li%(%$ XAlL6dli%(%$ X='L(" 60<, ,`16&'''M@ 6hD,<L\ ,l0 ,$!`$I`n$ q)rU x$`$1` @!4 A@!8n "1rU~| I"y#IWq\\\DDVGNFormjX__SRP_3__SRP_2+JGeneralW6009FA}#2.0#0#..\..\..\..\..\WINDOWS\system32\FM20.DLL\2#Microsoft Forms 2.0 Object Library*#47*\R0*#2*\R0*#19*\R0*#1a*\R0*#13*\R1*#1da*\R1*#e8*\R1*#2ac*\R0*#14*\R0*#1*\G{CE8ED501-68C1-4DEB-B92B-63CF51034CDA}#1.0#0#..\Forms\RefEdit.exd#Ref Edit Control*#0 <hDHLPTX\`dl@M  " " @ 6xPX`hpxrU~| ) I"y]]]!^I^^!P_ ())q\\\#31WIWqW[ X!])_I]Q_q_ \1 __ b!b `aaH$o$ h qlq q|(p%liP%li%(%$ X:%$ X)6 q$l#,*Fl/,Pli%(%$ XAl\6/l#,*# *F,2,[\("li%(%$ XAlL6dli%(%$ X='L(" 60<, ,`16&'''M@ 6hD,<L\ ,l0 ,(D%($%T$ XT(%(!%$ X$ q)T6($l(4Ph($\(4hlXddl(D%lXi$%T$ XTA4 l(T%\ @: %$  dDA$ \(%lXi%$ XA %\(p%lXiL%l$ XlC ) Tl6TD4$p Xfd \~l l~`<$|l\lTTlTD4$p)(D%($%T$ XT( %(!%$ X$ q)T6($l(4Ph($\(4hlXddl(D%\ @:4 %T$ T dA0 l(T%X@P: %$  dP@A %\(%lXi%$ XC ) TP6T@0 l(D%($%T$ XTAT @\(0%lXi%$ X A \(%lXi%$ XA| l%\(\%lXi<%P$ XP C )TP6T0 |\l Xfd \~l l~p<$|l\lXTPT@0 |l\  (D%($0%T$ XT(%(2%$ X$ q)T6($l(4Ph($\(4hlXddl(D%($+%T$ XTA4 l(T%X@: %$  dDA$ \(%lX/i%$ XA %\(p%lX/iL%l$ XlC ) Tl6TD4$p Xfd \~l l~` <$|l\lTTlTD4$p!4pv2L:P%`$ d` HL )`LKD `$ ` t>DF4$  $:P]3`64$%;4 P"%`$ ` 4c]@`54CH R4 (%'%'%'%'%:%:P%`$ ` 4`1H`54/CHSlHF%L:P%`$ d` HL  , )`LpvnxlHF%L:P%`$ d` HL  ,W4A$")`L64$dsx@lHF%L:P%`$ d` HL  ,4A$:Pt]F"PPtFYxъK9d!;GیGJz`x<`9YE{ VDgOCW~x{ VDgOCW~FYxъK9d!;GMEP@SPSSS8`>" LLLLX668@$P0x 0@0 F @H *&f3X`&hf3x (  68 p</ $@+   ( <0 $H@+X   D  (@ iX ix       |=0 " ^ H  0 5H /`  p 3   ,  P l3`   4  0 8 !X  x    & "y %  ^(        ( 8 ?H     H( 0p    2 <( h"; 44 .  HP h    6  $v(P` h&{p         n+0 J 4Xpx  P p  4444 - 8H,  (p `* (8  (`Ph p- ,  ( `* 0P(p  0 - ,  ( `*8 (   - ,H  ( `*( (  P  X (+h   8 H(+X    &+(   P `&+    " ] (] P@On Error GoTo ErrorHandler:ON 8B@s add-]]]]]]] ]8]P]h]]]]]]]0The actual values go here]h]]]2indicator for mismatch between no of obs in X cols]0 keep track of how many x variables in each area E]8( keep track of how many obs in each area]p' count the number of valid observations]* keep track of which X areas have problems]] index for x variables]"searching through cells in an area]# Check the input for missing ranges !d<You haven't selected a range for the data. Please try again.  Data ProblemA@Zk !d<You haven't selected a range for the data. Please try again.  Data ProblemA@Zk! Check to see where to put output Check the X Var Range/ These checks ensure that we have actual rangesOn Error Resume Next !d$`.] !!r' 6You haven't selected a valid range. Please try again.A@Z (dk !d$`. 6You haven't selected a valid range. Please try again.A@Z (dPkH> Check that we have the same number of rows for both variables'' 0 P R  R %!!r R+ R %!!r R+  R$ ' R R$ R $' R ' R'kk R 3 ^Unfortunately, this Add-In cannot handle more than 51 independent variables. You've selected . Sorry!A@ZHk@ Warning if mismatch is true The number of rows in X area 5 does not equal the number of observations in X area  . Please try again.  Data ProblemA@ZXkPA go through cells in each area (determine how many there will be) labels need to be found$ ' p !!r ' !!r'  hYou must select the same number of rows for both the X variable(s) and the Y variable. Please try again.  Data ProblemA@Zk% Check that we have just one Y column  EYou must select only one column for the Y variable. Please try again.  Data ProblemA@Z(k . Pass this information to the MatrixWork macro Check on labels '   ' R  T R$  ' T'(j - 1) * noxrows(i) + 1  R %%V + $$The X variable label in column I you've chosen is a number. Do you really want the variable label to be  $? Potential Label Problem$Z'  Gjk T R$' $]The Y variable label you've chosen is a number. Do you really want the variable label to be ? Potential Label Problem$Z'  Gjk Start reading the dataA Must read in one row at a time across Y variable and X variables* Data is assumed to be in columnar format!' R 'h Read y data first  '+remember first row is label so must add one5 We are sent to error handling if this isn't a number Now check for blanks R $ + R $$  '  we are going to skip this obs.k' If we've passed, go to the x variables' T   T$ R T$  '  ' On Error GoTo ErrorHandler/ xvalues(countobs, j) = mySelXRange(i + 1, j) Check for empty values  T %%V$  'd  T %%V  +k`  T80  ' R End reading in data   cThere aren't enough observations with non-missing values to obtain parameter estimates. Try again.A@ZX kP C The user has inputted the cell ranges via the DDVGNForm dialog box 8!!d h qq  Logit'k l SelYk " Add the additional options button$!$!$!$! $! !%v Give characteristicsNewPredictedProbTable9zPredicted Probability Table5(dkk ProbitML 8!!d h  " Add the additional options button$!$!$!$! $! !%v Give characteristicsNewPredictedProbTable9zPredicted Probability Table5(dk h(dq'  it's kk ProbitNLLS 8!!d " Add the additional options button$!$!$!$! $! !%v Give characteristicsNewPredictedProbTable9zPredicted Probability Table5(dk'Logit NLLS Estimation failed.A@Z essage alue =Probit NLLS Estimation failed.A@Zk8k0 l esti  any, kkk0 LogitML 8!!d h Matri " Add the additional options button$!$!$!$! $! !%v Give characteristics!NewPredictedProbTable9zPredicted Probability Table5(dqpkh'h:The estimation routines will change this if all goes well.Pr: abort avoids putting down a predicted probability button.koo8$$   $  hA$$   $  hA$$   $  hA$$   $  hA]' This detects estimation that goes awry' To Err'k''h'h k`' Error *****!]H`x'h. Check to see which options have been selected 8!!dG'j@ 8!!dG'jrue 8!!dG'je 8!!dG'jalue]]0HLR]ol]`x d j Pro''''''' 'kpProbit ML Estimation failed.A@ZLogitNLLSFinished = False'kkLogit ML Estimation failed.A@ZProbitNLLSFinished = FalseLogitMLFinished = FalseProbitMLFinished = FalseAttribute VB_Name = "DDVGNForm" " Bas0{53DBC60A-0681-42E9-A7B6-9D0E04C005FA}{B4F05362-021E-48D2-A395-15D33AC8433D} dGlobalSpaco False Cr@eatablPredeclaDIdTru BE`xpose0TemplateDerivCus tomizD Public mySelXRange As  Y <@ Sub CommandButt on1_C,k() 'On Error GoT oHler: .Hidim abortEBoolean ' This detects estimation that goes awryupp`erlef3Daregr9colALongrowsizGG occup anB lowerNPnumx s NumYRoFwL var ColLX label()S;`YVarL nobLxvalu$esDo@e 'The act0ual d hler@tWy YicAI, jCm@ycheck i2s>chFC'i@ndicat Lf`mebetween no of in X 6C nox#Lkeep tra h@Zy xIriAhs ea`wa 5 Vt $lcount?Apbb[e x@6tinwill chtif a@ubw>.Ţ2= )f'`avoids pe!%downt a@,e?1",ability @h` ' CRDtIin+ Bs1`/If XRef`edt.VM"!fen < M sgBox3mpt:="You"4n't seli "a e1d. Pktry again.", #rs:=vb Exsl, TihtleDb.l>es@2 End If } Y p rF  `o e wb to outg3*X `j'bbnsure weNie!ResuNext Set:=(*!lmySTDN =).As.C!]B <> 0?%$,aQt`^ . _$a!_++165$0& 0 { . + xy,/ 6sawr8both{A%@ams`>0GReՁ1 Pd i`iS i)"(i)"lumnV#@RO%Aou&=!S+;i QPi > P h%Nd* - 1)+13d =цwEM: i24V> 5 Y"Untun1ly,@Add-In canHnot0AndmosBnqpen|de#7 ^'#0]" && ". Sorry!,1 66' Wxarnf`s trް\| y0dq!  d! 1@/a kkk\takk'At&hv (rGmine how many there will be) ' labels n@eed toT found numxrows = no(1) - 1 ReDim Xvarz(1 To ^"s) As String NumYRDmySelYRange..CgtP&dCo= &umns) If#d<> [Th en MsgBox "You must s elect{ sameber of "for bothX _@iable(baBnhe Y . Please try again.", Buttons:=vbExclamation, Title:="Dat a Pro+m"9RGo"! E4IfCheckEat wڠave jboY col > only @xrB<66Passis olank@1-%R T+8y(iJq R.Empty(q_ 1).q`unt 'o A gob!o skip .C!RfinisheЊ!%&' P weHpPged, go}fx|41sL= ^j`1mk0ZajH`i_cj_kqsza'(r(t'`RqJSdq ' e@ hj)h 6V= ZElse rv.3t] 9K`eaq< A:osa5ReAKpC-e.wh' qR>nS@Ft6wfh x MsgBox "% q E ma failed.< 9 gZ &'w (  E 'ML_ sY ML/ / MLd eO K_ _ P o ?e trya gain: 1SubqPr@ivate ` User!_Cl0ick((*#8c*\R4*#4d*\R4*#4e*\R4*#4f*\R1*#dc*\R1*#e4*\R1*#e49   "  "(8@(iX Y " "BnPr Rh<e @H P` "hp1x 00*b*b 0"8@1H>h> "1 0"<H p<v  General Module (]@ R R $V R +V Rd(|l"PxME4 6 LLLLLLPL<8<<< X`k `Rtng i `k  (`(k  x%` X!r` Ps `0 Lk% xessi% ` k , rU 1 aV !I"ya"A  y "1 A#1 1 I a!!I!QK LLM TTT!UaV<a a h9 ya `9Da aq Ha a L  P Ta aX 1 \  `  d  l ! @! I `i/MG$pzpppp&! a:]353'd':N0:N 6d&! a:]353'd':N0:N 6d<`'%! a%$ l`4)`5/X4a8 av"q\6$X   lX+'d'': N 6d:%! ,<`'%! a%$ l`8)`5$X   lX~+'d'': N 6d:%! , qHp"l\l\,l\dPi,@X4a8 ``aLLadv"l,l)`L6di,@X4a8 ``aLLadv"l,l)`L6dlHl,lqHl,l,ll,lp"l,ql,q  ,fPlH3W='d''lH#H*#D*F 2HD6d k"^'d':N0l#H*#D*#@l #<*#8*F 2 HD@<86dlqPlH@5X8aav"qL6/X8aav"qD6 lPlL3'd':N0:N 6dlD3'd':N0:N 6dlPq8l8lH4!l80 q,l\d0(l,ld(lql(qyli%,@X4a8 ``aLLd`#Hll@;/H)`L6d%ll@.$@M@ p"-$k"^'d':Nl#H*#D*#@ll@*#<*F^q$2HD@<6dl$ (f(b ,f0K(%X8`1<5(%$ ` A, %( %(%`$ ` `A!%(%L$ LA"(%$ dA"(%$ `AP"@%<$ @  k<+'d'':-N 6d k k+'d'':.N 6d k k+'d'':/N 6d k  k +'d'':0N 6d  tZ t`04l <tp@ H34 - i'12i, 27O i+ l l__SRP_eN __SRP_f&sDocumentationRevisions."%__SRP_18wJ!]I]Q_q_Qcy]c (1(Wch," x$ x xtdlilti%( %lti\%(<%x$ Xx%($ X()x(5 tfl9Y(%(%(\%(<%x$ Xx%($ X()x(5" x$ x x,$ x(\n(l<:@%PT:X%h$ dh HT P ,1in@g D@,ginJwork,"E)yg9@@B/ l| "-e ToHols@5nuO7`b 4sa!2 stuff@?4@`4 Pvalue.#@,-in"whA? exte"ve^.amadeBTa $ wo@uldn'tr8k idbr&A $a"Visu!õ²A"sheet@#a3m HB s!m`Mv8kss`@ial assistanmakCu4abM` A ASo`$i was dm@/GlickDn'ELS`athabookb8 `v closi`Z` mBEJMPaaael w` @. 30@dep varia"sF661`0 obvDXisc @icn0 ordw210^(-6/n3g1 cpor7Ly !well$ A0IP)OvPs /q RB'Pob)kNopog box.!e"Gtx2Y Pr 4pyd0`r! ndard!< R squOPl ct>imple!j],`z2?NORecip pIt` 77: 0 ArBSclo &ZSp# jESr, W`2iapR.ess, Saul A. TeukbkyruT. Vet eVg=BEn Fy1pp. 89-91 d_PEa++6675fĄtechniquQ\@ q?y`P0PXd S24V!j D1(SVD`25=0p {гcaqgfaiTK # ϰPk sp0@Aqour RJS@>E Dad!NQMacKin05 tq"^(1990(553 sV4cocB= toB'a8ˢij_?b k) by (1- htЩzhtQ)PoA#at'tbhago101rӡ"k?"bpVWs`p؀DPece @@YjecnrrXosUe Pnn@ columnX. ^ 𞒊@,adenPaXXTE1s[XIneR- a nKprefl &1de`U#VPpP2@wu0sX * F 4 DH J " 0 8 @ 0H @x X R h Pp    ( B `    , < ,8 Fh >  ( * (P Fx .    : HX < 4 0 8H < "    6 Z8 @ 2 4 .H Rx J 8  X B` \    B( $p   DocumentationRevisions Module All rights reserved., Date of latest modification: 4 October 2006( Revisions modify the estimation methods+ and the way in which SE matrix is computed+ Basic interface and idea come from Barretos. Estimation method in revisions due to Howland) Instead of using Solver, the revised xla. uses the EM algorithm for Probit and Logit ML, and Gauss Newton for Probit and Logit NLLS., These routines also produce asymptotic SEs. Authors: Frank Howland Humberto Barreto Howland: howlandf@wabash.edu 765-361-6317 Barreto: barretoh@wabash.edu 765-361-6315 Both: Department of Economics Wabash College P.O. Box 352 Crawfordsville, IN 47933A Howland (FH) wrote general matrix routines (repeatedly called in= this set of routines) and the robust std error computations.B He also checked the results against Stata for one data set on theO robust std errors (though we ended up using a slightly different measure than- Stata version 4--see below for more on this)= He also modified the RegForm and put in the labels handlers.D In addition he put in computations of OLS estimates of coefficients and SEs.= Barreto (HB) is responsible for the ideas behind the RegForm; including nifty use of Range to get data into the routine,7 the original matrix work, and routines for putting the# Regression line on the Tools menu.? Original versions of this stuff were in his Pvalue.xla add-in,. where extensive matrix computations are made.> This routine wouldn't work if we couldn't bring the data intoD Visual Basic from the worksheet, a problem HB solved in Pvalue.xla. HB also provided essential* assistance in making this into an add-in.* Some validation was done on GlickData.xls: See that workbook for stats on how close this add-in cameR to JMP in estimating a model with ca. 30 indep variables and 6610 obvservations.K Discrepancies on order of 10^(-6) in estimates and proportionally as well.I Also, a tiny comparison was made with Stata's robust std error option on a bivariate problem." This add-in is still in progress:; We eventually want to make this a general-teaching-purpose regression package. Key tasks remaining: (1) Error handling& check for singular X'X matrices6 Use Cholesky decomposition to find them% See MatrixRoutines@ check for non-numeric data in the body of the data matrix7 check that y has same dimensions vertically as X! (2) put in other test statistics$ DW stat, exact P-value for DW" make RSE, DW stats optional? (3) collapsing dialog boxes for entering X matrix and Y vector( (4) add other standard regression stats R squared4 For ideas on how to implement the OLS routines, seeB Numerical Recipes in Fortran 77: The Art of Scientific Computing,5 Second Edition, William H. Press, Saul A. Teukolsky,- William T. Vetterling, and Brian P. Flannery) pp. 89-91 discuss Cholesky decomposition2 pp. 665-675 different techniques for solving OLS.5 They recommend Singular Value Decomposition (SVD) as in principle it can't fail.0 More on the specifics of our Robust Std Error:T Davidson and MacKinnon textbook (1993) p. 553 recommends using a correction factor9 in which one divides the estimate of the standard error+ by (1- ht) where ht is the square root of. the t'th diagonal entry in the "hat matrix".' This hat matrix is sometimes called PK because it projects orthogonally onto the space spanned by the columns ofC X. In this module, we denote P by XXTransposeXInverseXTranspose,1 which is a name reflecting the definition of P.< Stata uses a much simpler correction namely sqrt(N/(N-K)).U Davidson and MacKinnon (553-54) say that Stata's correction is inferior to dividing by (1-ht).< I don't compute the P matrix because it can get too large, with dimensions Nobs x NobsP wAttribute VB_Name = "DocumentationRevis@s" ' h @Module@All rights reserv(ed.paof lst mo dific: 4 October 2006.1x,y the estim5 m@ethods*andway in which SE )rix is compd-Basic'terface !ideae from*\R1*#e4*\R1*#1c8*\R0*#14%  2 X D`   8 N X x 4 8 $ 60 Fh :  8 .@ 0p & B D X 6p & < H X >h <  8 8 $P *x"        0@ Hp  <p0 p   "  4 +  ( 8 " @ H P /h   \#(;$D"PtXxME( > LLPL<,<0<4<8<<< H`` x+@%I `I I viouI  3, 2I" x isI$ `Rxtipl`Ttft(N`pght &`` + <I( ds tI^ n n I* Prob`Rx ,` k@EI. `trixI* se o`Rxto y 2P`h+KI.  SI4 ds sI* elem`Rxecto 6`PkQI8 cMulI* ; I:  intI^ x`Rxto t <tXvectalarreco@` >`MultultVecby @`p k(dI8 H in I hc I* y deI: ixI^  Rec`R(xp. 8 <thold used to >`p ing purpXx B`k**w x % t0 O result  "phng rs these P $lwon'rs which`h`dR` p`T  @ `R`T` D `k11IF  I* 0 IH P IJ `Rx`Tt`p`LP h  d % R`8k T\h H  V@   8 %`R`TH PX %0@`P  0 @ ` @@ \ X  @h X @ @ T h @ P  @ @ @ 0 @ @(  @ @ @( @h  @ @ @ @ @ @ @ @( @x P( ` @ Hh@x(@@d @P\ h( @X P @H P @8 @( @$ (@  8(X @d @0\ ?H 00@X ?p0 @H ?0  ??@8 @( @$ @  H@0 @ @0@hh @@d X@` @@P @@ @0 @ @`@x@h @d @` X0@P @(@ @@0 @ 8p 8@h @Hd ` @` H@P @@ @0 @ @ Hh8@Xpf@\ @L @H @8 @(( @ @ @ X@ @ @ 0@@ X@h @@ h@  @ @ @ @0 H"@X p0"@ X#@ #%0&p  0 hNZ0@` @hP @L @H @D 0@@@ X@H< (@@, @ @ @ @ @ @ @ 8@&`'@p H(@ p(@ @ *@ *@ (,p- 0 p  X 8PND@ 4 @$ @ @` x8@ `@  @ 8 @ @ @ @p H  ` @  @ @  0  &0FK$*\Rffff*1h46065a31*\R1*#2ab*\R0*#15*\R1*#2ac*\R1*#e8*\R1*#dc*\R1*#e4"    .   "  L BX    &  &  '(  @ (P  p x $;   "  4 D 8X   &  &  '   (( H ` &x   " " (  (081@1`1x1 8&FP x  ,L  78P ?h    "  & 6 2 P H`    ( (08@H1Pp   (J   ( 8 @ H +P ` h p6  @,U( X h x"1&F  H  ` p . Matrix Routines ModuleMo, WARNING: pay close attention to dimensions!e of l= Author: Frank Howland (though most all of this is obvious!)esti Date: April 13, 2001he w1 MatMult(result, NumI, NumJ, NumK, MLeft, Mright)G multiplies two matrices MLeft(NumI x NumK) into Mright (NumK x NumJ)ow result is the outcomeg  Finddiag(diag, M, n). u- finds the diagonal elements in M, an n x n, a1 square matrix. Puts results into vector diag. MatVecMult(outcome, n, x, M)E, D/ This routine multiplies (k x n) matrix into e? the transpose of a (1 x n) vector to yield a k x 1 matrixon3 outcome = a k length vector, not an k x 1 matrix ideas SqrtVec(vec, n)he1 finds square roots term by term of elements in' a vector vec of length n and returns S* the new vector back in place of the old MatVecMult(outcome, k, n, x, M)an; multiplies a (1 x n) vector into a square (n x n) matrixx> and then into the transpose of the vector to yield a scalarreco outcome = xMx'0 **** WARNING: I haven't tested MatVecMult ****ai MultVecbyScalar(vec, scalar, n) 6 multiplies each element of a vector vec of length ndsonB by a scalar and returns the new vector back in place of the old choldc 8 obtains the Cholesky decomposition of a square matrix6 based on Numerical Recipes, 2nd Edition, pp. 89-91 Testcholdc()1 used to test choldc--puts stuff on a worksheet TestMult() Purely for testing purposes$ Requires a sheet called TestSheetP Inputs are Mright (NumI by NumK) Mleft (NumK by NumJ) Output is result (NumI by NumJ)* Calling routine dimensions these matricesB This routine won't work for vectors which have only one dimension]]]0 R  T  R T+   R $"  T$$ R T$ R T+  T RoXH- Get the diagonal elements of an n x n matrix] R * R R$^ R+( Ro] R * R$.$0 R+. Ro`]8 R * R$. 4 R+. RoPF This routine multiplies a (1 x n) vector into a square (n x n) matrix< and then into the transpose of the vector to yield a scalar outcome = xMx']]( *<] *> R * R$: R+> R < * * ^ >A@'8 R * 8 R$< R$: '8 Ro0- This routine multiplies (k x n) matrix into> the transpose of a (1 x n) vector to yield a k x 1 matrix1 outcome = a k length vector, not an k x 1 matrix]] <8]@ *> R * R$: R+> R <  * ^ >A@ Here tempv R  R$< R+8 RoX Purely for testing purposes" Requires a sheet called TestSheet]]]8]p]]] TestSheet$f.  %V' %V' %V'     "8  $`]h]] R    R  %V R +"  R T      T %V  T+$  T     " $A@ R  T  R T$ R T ,V T RoP performs Cholesky decomposition/ useful for finding out if matrix is invertible+ and for then efficiently inverting the x'x matrix!A Reference: Numerical Recipes in Fortran, 2nd Edition, pp. 89-91 Dim n As LongDim np As Long!Dim a(1 To np, 1 To np) As DoubleDim p(1 To n) As Double]p ] ] ] ] CholeskyTest$N. R * T * R T$F'L R '  L R $F T $F 'L  ' R T L Help!A@ZP k L$0 R+Jdp L R$J T R+FkH T R R * R$J R ,V T * R T$F R T ,V T RP ox  ]0 ]p ] CholeskyTest$N.]  R T R T %V R T+TMsgBox mat(i, j) T R R+V R T VA@DoP H $Attribute VB_Name = "MaxRoutine@s" ' H L ModuledWARNING: pay close attention to dimens s!\bAuthor: Frank Howland (ugh most all of this obvious!)?Date: April 13, 2001Mult(res, N(umIJK,@ MLeftrightN miplies two mc%(! x%K) iniM :K J$;XthDe comFinddiag(?, nf ; onal (elet|n M, an n3np squareRx. Pu;Ovectorag.8VecH>, xCATYr{IC (k)DB?C!7tosp|@jpa (1 ~yield a k 1C"alengthV 'onxB I Sqrt2(  PErooCterm by 'TaDnZd ret0urnsC :neBw backA pplacxAld Yk)ZȚLaEx(}^C#@$nBb@e a+PI_scalarG]xMx' * xI ha ven't`'sted AAAIbyS" 1 2eachZ-/a 6` " 1?1"1choldc obtain#lCesky des@WiWjCp bas@ `eri` Recipes@Ed, pp. 89-9 Test#(DTu st " C--pwstuff a worksheeta"v$Pure0ly fzin`g puroTRpequim -l S OpIEx@ci S|ub; @?$Inb$I7%KMl$r COut`#%C=As䠀ʘwoX*&bs whiQ\. *oneG Dim i As LoTngjk  F 2i1 Tbo jJAc(i,h j) 0'kK#@k) * /(` + 'Next Fkbj i17 EP-`! !OkCkGeAkW4j^>q6`mQo(iM i# 6 S N` [J0M4arM"=pj &*Qzc, X5zz?dSS?dddJ{dcPtempq)a2DoubqRe2n,31x(_ >@2p11$X@' ׀m 1RMz `9 %@:+a+`* k+, Cߘx2SaZ^!ϘiW noORmV"ro "o 1_oCnl' He0}1 v,]S$S=rec?=@dS+|| |{o{Кa2my}jWe qboR 70zInjJKS`e = ҆s(""V@3T.Cells(J40K5cEb% EA3C/m$5aixm*a wv~A6 ~= {7 + r}?P}ьRB\ = 1 To NumK Mright(k, j)mysheet.Cells(7 + d4 j)vNex t k j MatMultP res ,I J K, MLeftl For iI[jJ il('i End Sub choldc(a, np, pj' performs Cesky decomposition ' useful  finding out if matrix is invertiblea=then efficiently x'x"!Refer@ence: erical RePcipe2 tra`21EdQep. 89-91!w'Dim n As Longp a(nB)ADou1 pJijksumE uWork Set E= s("gTest"@nFiA=, ak@i - @MWhile k > 0/A-k) *@j, k@# kendIf¾j TG< 0'Br@IMsgBox "Help!&"GGo@Leav Ifp(i)SqrF( Elsa(`!/ A# m19ĉ`u1a 51~8! :(GdBPat[3,3\rdWWFhfu*)3#/*%dA Z`:&#&6D<'Gc A#)!rEc'A, &@r(,t@l x@t@l %l 6 pfg tfP2 xfX$ Txh"d`O+x@x@x@l0%l 50 xf`\T$ 0Xxh"d`S/x@x@l PB9 k0%l 5P xf` \X$ PXxh"d`R.x@x@l P@0%l 5P xf`lX$ P0|,&d"t&d"`xd"dX'x@lHBlxl`5H xfXf(`M(`ll(HltMd` 5H (db xd"d &; (lxltk8x@lHb 5H xf [|,8 `E tHT &d"t&d"`xd"dX'x@lHBlxl`5H xfXf(`M(`ll(HltMd` 5Hxd"d &x@lxltk8%l  xf \ 8 `@t%H<1H:L%\$ \ dlH=x)\H1(L %((%\x \"qh\51(L%((%\x \"qd\51(L%((%\x \"q`\5lhldtlhl`pl`ldllhdl`dFliL%li(%\x \Blllp\5 fI f6ldd)l`dLliL%li(%\x \Bllll\5 f f7lM`pM``M@dM(@hM8@tML` lhdldd?liL%li(%llltk%\x \\ f fsH.xtpl\H1L:P%`$ ` dlL=d)`LxP"dDtP"d< x@t@l Bth5lxqplpJohkx@p@l t@p@l Bth6lpqp lxltf ohD+''':P N 6x@mh k,%l6t@x@ohk,x@l%l 5 tf?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdeghijklmnopqrstuvwxyz{|}~//////0 `  ///, `//0 ` )///8! `A ////<I `AY /////$q `8 ` i)////$ `nrU @ `  =!=!@ `  =!=!@ `  =!=!nrU \`$aProbitLogitFunctions*#__SRP_d]__SRP_c>ProbitAndLogitIQ$*\Rffff*2o474c521b*\R1*#2ab*\R1*#e4*\R1*#dc*\R1*#5a*\R0*#1a*\R0*#19*\R1*#1c7*\R1*#d7*\R1*#e8*\R1*#2ac*\R0*#15$*\Rffff*904630bc73$*\Rffff*1h46065a31*\R0*#2*\R0*#13*\R0*#1*\R0*#14*\R1*#1da B  V x <8  Hx hP  , & h  J   D   (@X jp j      ( 8|=HmoE"P<xME,@8` 5=&`l ' `R`H`\`X`T%`d`RE``\ `X`pT` %P `L `XJ `D `0 @ `< `T8`4`2 `,`(`$`|x  d@ `P@ `7P&`(VL`J`D`@`<`T8H`40`(2 `@, ,8`(`<  8G0% P%`@ `hG`(`H%`0``H`````X``$ p% p% Hp%0 8`h  ` ` 8@H( Px`   ``H P(8 -perp p` :0 hHP0`H|`t`p   L   `J J$x    HP J8X P  ( `` `X`| `` x  H p   H! ! ! xp!x!X!x! ! ! "(!`````H`hd``\` <# p#" x8!@## `0" ``" ""`" ### x"% @#`$H$ h$ $ +87`XEo$ UU")% %%)@%H%%i  p%% %%% H"H&0&P& & 6@& @p6 p@6 @8' ( 8 d `' '' ' PG `, `< hW( % (%``W `7`X``X``@(`@)` `(`() X(*[) (8*< * )p**X* h'*** *** `*( )0+P++ (h++P+ x*+ + @*+++ (, +`p(`p+ ,x,,`, X),@@, (,,`0, :p)8-  - 'p- X-`p`8+x`-t- - H,P@. (.H. `*N J+(.... . / (/ )x//`// x-/n// @- (000000P0 `.`H/`,`+`0 )1 1 1 @1 h1 1 1 p02 12 /h2p2P2p2 2 2 `*``)`p.`-h`0`` ,@ 0<333 `3$ `@3 204P4484 `p3 04444 X350545 +`55H5h5 (35555 @6 (65@(9 866@96'6 x@ 8 X@6 @8 @ 3H66 7 + `Ukx7 OOw)77%)77%i  $87@ X@8 @P8 @8 Z@9 @8 1@8 @  |@'@<l @P9` h9(9H@x9\ 9P9H@9X 9x9I@:T (99I @P 8(@N :9Q0:P9R@@:H X::`@h:D :@:`@:@ :h:n@:< ::nx@:8 ::p@8;4 ;:p;:|(;:}P;@:@`;P x;8;@;L ;`;@;H ;;@;D ;;;;<`;@ <@ 8<;@H<< `< <@p<8 <H<@<4 <p<<p<@= <@< @ @= (=<@H= 8==`==@p= =H= @= =p= (=p= h8z 60@= >=)@> (>=)@8> P>>+@> `>8>+(>8>-@ @> >>2@> >>2>>5?=6@ ? 8?>B@X? H? ?Bp? ?E@? ?X?I@? ??I60@? ??L(@@ ??L @?N@0@ H@@S@x@ X@0@Sh@0@V@?W@@ @x@a@@ @@a@@ A@c@(A A@c@A@e@PA| hA(An@Ax xAPAnAPAqA@t@AL AA@AH BA@BD (BA@XB@ 8BBHBBpBA@B4 BXB@B0 BB@B, BB@B( CB@ C$ 8CB@xC  HC CXC ChCBCB@C CxC@C  CCCC@D DC@8D (DDPDD@`D xD8D @D D`D D`D @D DD@D DDED@ E 8ED@ HE E E#@!$0$##X#`%(# &"I0HHF0FFIFGEJF`l  FEG@`F @G @F Z@ @F @F @G @ G @L @ 8($GG @G GG@H ( HG@H @ HG"@HH| @`Hx @xHt @Hp @l  `hHH@I\  IHC@0IX HIIC@XIT pI0ID@IP (IXIDI@L I@J IXILIIM@ID JI[ @ J@ 8JI[p@HJ< `J Ji@pJ8 JHJi@J4 JpJk@K0 JJkJJwJHJx( KI0xF fz60@0Kl HKK@XKh pK0K@Kd KXK@K` KKKKK0K@K\ LK@LX 0LK@@LT XLL0@LP hL@LxL@L@LK@L8 @(N( @L  LL@M ML0ML(@@M XMM @xM hM@M M@M @M MxM>@M MM>@M NM@@XN NM@@pNMB@@N @ @N NXNNlm@N NNNNNQNMR@N ONd@(O ONd@ONg@PO hO(Ok@xO| OPOk@Ox OxOn@Ot OOnOOp@Pp PO~@HPl (PP~8PP`PPO @pPX PHP@PT PpP(@PP PP 6@PL PPQP@ QH 8QP@hQD HQ QXQ QQpP@Q4 QhQ@Q0 QQQQ@Q RQ@R  0RQ@@R XRR@R hR@RxR@RRQ@R RR@R RR@S SR@(S @SS@PS hS(S@S xSPSSPSSSSR@S SS@T SS TS@0T HTT;@hT XT0T;T0T>@T ThTB@T TTBTTD@T UTF@(U UTF@UTH@PU hU(UK@ xUPUKPUNX4/8246p4X44.0531,502-YhXxV`VVYVW(V8]@V` l PV(VW@V @(X @ W Z@ @V @W @8W @PW @\ @ WW x7WW @X XW@Y (XXX@@X @ 0YX"@X| @Xx @Xt @Xp @l  hXY@@Y\ XYYC@hYX Y@YC@YT YhYD@@ZP (YYDP@L @J YYL Z@YMp@0ZD HZZ[@XZ@ pZ0Z[@Z< ZXZi@Z8 ZZi@Z4 ZZk@([0 ZZk[Zw[Zx@[0Z @P[p h[([ @x[l [P[@[h [x[@[d [[[[\P[@\` (\[@8\\ P\\@`\X x\8\@\T \`\\`\@\\@\< @`^, @]$ ]\@P]  (]](h]]Vz 60 @x] ]P]@] ]x]]x]@] ]]:@^ ^]:@(^ @^^<@^ P^(^<@^(^>@x^ @ @^ ^^J@_ ^^J^^M_]N@(_ @__`@`_ P_(_`x_(_c@_ _`_g@_ __g@_| __j@`x `_j(`_l@8`t P``z@`p ``8`zp`8`}`_~@`\ ``@`X ``@`T a`@0aP  a`Ha`@XaL pa0a@aH aXaaXaa`@a8 aa@b4 aaba@(b @bb@Pb hb(b@xb  bPb@b bxbbxbb(b@b cb@c (cb@8c Pcc@`c xc8c@c c`c@c ccccc8ccb@d  dc@@d 0ddXdd@hd d@d6@d dhd6dhd9@d dd=@e dd=ed?@(e @eeA@`e Pe(eAxe(eC@e e`eF@ eeFeIe}fD f(f@ @fPf< hff8 xffff, ff( gg$ (g8g  Pg`g xgg ggggg gh h0h@h Xhxh hhhh hh hhi i#8i (i#Pi&`i xi*i i*i,i i.i i.j0 j 8j3Xj Hj36j_b0xjj87&0FK*\R1*#1c8 " ^ H 0H2`-x 3(0 ,8 hl3x 4 0HxP!p `"v %( 0 *@ p  x    A X p  x H 0    0 H ` 2p <  "8  10 4P   .      (   0 > h  $s     &x      ( 0 @H  P ` n+ &( j 1P0 8 @ PX`hp HPX `,  >   ( 0P!h" 0 HPX `px  `  0 p  8H &`  "&  0 8 H X `h       ((0P X7h  '  v+(08 @H` x 0!!(0HP h  4 > 8@ Jx 4"  @,H :x &(* @ .P($(,(#>( P p >     h0 4",6 @ dP d : ` x  (*  . ($!(,(!(#P!x!>(! ! ! "" " J(" 8x""""""""(*# 8# .H#($x#(,##<##($H$(#`$$>($ $ % 8% 2H% % %%%%%%7%&< & 8& 0P&  F& & @& 0 'P'X'`' x'''  '  '&:' ("(((   @0( p((( ( ((((  )) )><8) ^x)) 0) 2 * X* h* x* **** *(C*+2 +@+  0H+ x++ :+ +(C+,2 ,@, LH, , Z, @- 2@- 4x- .- R- J8. 8. . B. \/ p/ / B/ $/ 0 00000H0  `0 p0 x0 0 0   . 8 11<14+11  # 'X3 4 4 332  -#x"/3% h 332$*@4 232$83 x3 34h4 p   B 4 V4 5  5@5 `555 ,7 $7@+7 8 8 D(8  p8x8888 j8 j89  909 P9 X9 h9p9x9 9 9|=9 :(: "0: X:^h:;; H ; h;;;2;-; ;3;<< ,< <l3<@=H= 4P= =====!= =>>0>@>"vH>%p> > *`?? ? ? ??A?x@@  @ H@ 0A 0A 8A 0PA AA 2A <A  B"8@B 1hB4BBB .B  CC  C (8C XC hC 0C C $sCDD D&x D HD PD `DpDxD D DD  D D Dn+DPEXE &`E l5 %5 "5 25 $6861@6 `6 "66666 666666 7777 7(70787@7H7P7X7 `7x77777,E E77 >E LF :hF 7FF F F F F F \GG G(G0GPG  F pG 8GG &GG H H8H PH"&XH H H H H H HH H I (I HI XI hI (pIIII I7IIJJ 0J @JPJ'XJ pJ Jv+JKK K(K0KHK `K pK K!K"K KLL L(L@LHL`L xLLLLLL 4L .L 0(MXM 8xM!M!MMMNN 0NPNpN 4N >N 8O J@O O4"O OP2P :HP &PPPP(*P Q . Q "PQ"SxQ&UQQQQRR ( R&VHRpR>(R R R R>S HS  hS SSS hS 4"T ,HT xT BT T  *T U(U@U,6`U U dU dV :pVV VV(*V W . W"SPWxWWWWWW 4W R0 2 &V XHX>(`X X X XXX JX 8HYYYYYYYY(*Y Z .Z"SHZpZZZZZZ &Z&U[(,0[ X[&Vh[[<#[[\(\>(@\ \ \  \ Hm\\\\]] 8]H]`]<Lx] ]]7]]]<^ ^ 00^  F`^ ^ @^ 0_0_8_@_ X_p__  _ B_  _&:` 0`"8` P`   X`(h` ` ````  `aa>< a ^`aa 0a 2b @b Pb `b *pbbb b(Cbc2c(c  00c `chc :c c(Ccd2d(d L0d d Zh @8i 2d 4xi .i Ri J8j 8j j Bj \k pk k Bk $k l lll0l Hl hl  xl Fئl dd<d4+de  e (e#8eXe '`ee ee0ee ef f 8fPfhff  f-f#fff"/g%0g Pg`g hgxgg$*g ggg$h (h8h @hPhhhh hhh hh B `m Vpm m mm n0nHn ,`n $pn@+n nn Dn  o o(o@oXo jpo joo oo o p pp p (p 8p|=Hppp "p q^qqq Hq r0rHr2`r-xr r3r(s0s ,8s hsl3xsss 4s 0tHtPtXt`t!t ttttt"vt%u 0u *v8v @v Pv `vpvAv w8w  @w H`w 0w w w 0w (x@x 2Px <x x"8x 1y40yhypy .xy  yy y (y z z 00z `z $szzz z&xz z z {{ { ({ 8{@{  H{ X{ x{n+{{| &| 0|  2| "}@}P}X}`} h}p}x}}}} }}}}}}}}}}}} }~~ ~(~0~,8~ h~~~ >~ L~ :( hpx        8 H 8X &Ѐ  ("&0 X x    ȁ    0 @ (Hpx 7Ђ؂  ('0 H `v+p  8 H X!p" ؄ 8 PX`hx 4 .Ѕ 00 8P!!ȆІ (H 4h > 8 J h4" 2 : &`(* . "("SP&UxЊ؊ (&V H>(`   Ћ>   @ X`h h 4" , P Bp   *ȍ,68 h dx d :H (* ."S(Ph 4 R 2 &V0X>(p  Б  J 8XВؒ(*  .("SXȓГ &&U(,@ h&Vx<# 8>(P    Е ( HXp<L Ȗؖ7< ( 0@  Fp  @З 0@HP h  B  &: @"H `   h(x   ><0 ^pК 0 2 P ` p * ؛(C28  0@ px : ؜(C28 L@  Z @ 28 4p . R؞ J0 8  B \ h  B $Р  ( @ `  p F <4+  #  '(H PX0p Ȣ 0P  h-x#"/У% ( 0@`$*x $Ф  0P p Чxi`O This is Bert Barreto's idea to turn the Logit/Probit procedures into functionsdo] |ctedase trd0 R> 1 | kd Debug.Print Err; Err.Descriptiont @ This is the estimation section]P T']  Debug.Print "nobs"; nobs$On Error Resume Next]x !!r' GoTo tryagainEnd Ifge. '6 I have removed certian warning Messages from the code, j)]@Xange. ]` ']8k]> Check that we have the same number of rows for both variables'' ` < R  R %!!r R+ R %!!r R+  R$ ' R R$ R $' R ' R'kXkP R 3 ^Unfortunately, this Add-In cannot handle more than 51 independent variables. You've selected . Sorry!A@Zk Warning if mismatch is true The number of rows in X area 5 does not equal the number of observations in X area  . Please try again.  Data ProblemA@ZkA go through cells in each area (determine how many there will be) labels need to be found$ ' 8 !!r ' !!r'  hYou must select the same number of rows for both the X variable(s) and the Y variable. Please try again.  Data ProblemA@ZHk@% Check that we have just one Y column  EYou must select only one column for the Y variable. Please try again.  Data ProblemA@ZDlk. Pass this information to the MatrixWork macrolp Check on labels@ '  Dl  xlDl' R   T R$  ' |E> ] R 1l  R %%V +% IlD $$lD $If mycheck = vbNo Then GoTo tryagainI ykX T` Rk@$'5 $]The Y variable label you've chosen is a number. Do you really want the variable label to be ? Potential Label Problem$Z'  GjDl kX Start reading the datalA Must read in one row at a time across Y variable and X variables* Data is assumed to be in columnar format!' R oPt]]] Read y data first  '+remember first row is label so must add oneo5 We are sent to error handling if this isn't a numbero Now check for blankso R $ + - R $$  '  we are going to skip this obs.l@k8' If we've passed, go to the x variablesD' T `  T$ R T$  'l  ' On Error GoTo ErrorHandler]8x ntob Check for empty valuesb  T %%V$  'd  T %%V  +Lk H` T  'ph` R End reading in data   xscThere aren't enough observations with non-missing values to obtain parameter estimates. Try again.A@Zk7 xvalues(countobs, j) = XRange(i + 1, j) This is oldn] ]8]P]h]] ]]] Est.SE+$+, 2)]x ']XIf change > changetol Then( MsgBox = "Convergence not achieved.")End If]]]]kk R |1) = c R$ R +lt$+ + > 0.0)On Error GoTo ErrorHandler 'Error *****!kThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@Ze: coefficent matrix]P]]]] SSR= Sum of Squared Residuals gradient vector stuff:](]`7 Lots of other vectors to follow for Robust Std Errors. ****** LogitN (xvalsdCall LogitNLLSroutine(xvalues(), yvalues(), countobs, numxvars, YVarLabel, Xvarlabel(), nobs, abort)mxrows]]] ]8 ]p ]  Y, X and X' loading       , 1 To 1) robust std error stuff]  X ]`   ]    ( ]0 ]H ]` ]  ]   ]  'd( 'k  :P  0  '|1 Nk tells us the number of parameters to estimate   Y(intI, 1) = ytemp(intI, 1)     +:  +d   $  +:  $:  +k  d` '|      $  +:  $:  +  k! *** Test for invertibility here]  | | ] |  | |   :A@]  |J` R | R R+J R'  | J A (X'X)-1 work Fkk'    $ '   '  | # gradient vector |   |  |] |X]` |$: | $$A | | | |-Here's where the Logit stuff must begin *****7 At this point we put in the Gauss Newton NLLS material2Step 1: Begin with starting values for b0 and b1.D At this point all the data is loaded and we call the routine to get first round estimates  | $$:$$ $Az  Get the predicted y's']the index for computing logit4Step 2: Compute residuals using values of b0 and b1.Step 3: Compute gradient vector R '  |  $ R $: ' (not yet equipped to handle no intercept! $ $  R+ R$ R$ R+ R$ $  R+  | R$ R $: R +&gradient vector R $  R+  R] 0changetol is tolerance to determine when to stop Compute gradient vector '''    aStep 4: Regress the residuals on the gradient vector;do not include an additional intercept term.  | $$$$ $Az ==='  |  $ '9 $ $ + ^Step 5: Check for convergence (small values for changes in b0 and b1 or small changes in SSR).^Step 6: Add the computed coefficients to the previous values of b0 and b1 and return to Step 24Step 2: Compute residuals using values of b0 and b1. R '  |  $ R $: ' (not yet equipped to handle no intercept! $ $  R+ R$ R$ R+ R$ $  R+  | R$ R $: R +&gradient vectori R $  R+  R  'D Compute the variance covariance matrix using robust standard errors1 get the gradient vector (phiX) and the residuals]8P''' R '  |:  $ R $: ' (not yet equipped to handle no intercept! $ $  R+ R$ R$ R+ R$ R+  R$   '- tss added here  R$ '  R$ ' R$ $  R+  | R$ R $: R +&gradient vector R $  R+UUU 2 F(i) = Exp(predY(i)) / (1 + Exp(predY(i)))+ Ff = (phi(i) ^ 2) / (F(i) * (1 - F(i)))K R 'k]h***   ' ] | |   | |   A@K]  !%' Get S0 matrix* It has the same dimensions as XTransposeX@ First , following Davidson and MacKinnnon, p. 553, divide each esq by (1-ht)YYY9 to get ht, multiply the intI'th row of X into X'XInverse* and the transpose of the intI'th row of X]] |`  sss  |  $ + """ |$$$'d  |  A@6k9 VecMatVecMult temph, Nk, phixt, phiXTransposephiXInverse  + $ $  + ]h] | |  |  |'    $  $ $   +(WS0(intJ, intk) = phiX(intI, intJ) * phiX(intI, intk) * esq(intI) + store '* esqht(intI)  $') robust SE using Davidson and MacKinnon's, "better approach" (p. 553) implemented here   $ Form the NOBS * X'X -1 S0 matrix.] | |8 |$$+d  | | |  A@k) Form the RSE = X'X -1 S0 X'X - 1 matrix.]@ | |4 phiXTransposephiXInverseS0 |$$+d  | | |  A@-kE Now get the robust standard errors, square roots of diagonal entriesT Davidson and MacKinnon textbook (1993) p. 553 recommends using a correction factor9 in which one divides the estimate of the standard error+ by (1- ht) where ht is the square root of??. the t'th diagonal entry in the "hat matrix".' This hat matrix is sometimes called PK because it projects orthogonally onto the space spanned by the columns ofC X. In this module, we denote P by XXTransposeXInverseXTranspose,1 which is a name reflecting the definition of P.< Stata uses a much simpler correction namely sqrt(N/(N-K)).U Davidson and MacKinnon (553-54) say that Stata's correction is inferior to dividing by (1-ht).< I don't compute the P matrix because it can get too large, with dimensions Nobs x Nobs] |  |  $ +d  $$0 +k  mycheck = MsgBox("The X variable label in column " & xvari & " you've chosen is a number. Do you really want the variable label to be " & Xvarlabel(xvari) & "?", vbYesNo, Title:="Potential Label Problem")ts. <2< !4A@Z*An unexpected error has occurred. Bye now.A@Z<Sub LogitNLLSroutine(xvalues() As Double, Y() As Double, nobs As Long, numxvars As Long, YVarLabel As String, Xvarlabel() As String, numxrows As Long, abort As Boolean)Ih6 + R | R | R RR+ 5d5 Intercept+ + R$ R + | " R R | +SSR+Rsquare+ R$ R +Variable+Estimate+ R $ R +N/A R +N/A R +84$O This is Bert Barreto's idea to turn the Logit/Probit procedures into functions]0 @Xp]]0H]`x]  (hen ('MsgBo+ Gradient vector is phi(1 to nobs, 1 to nk)ta. Pl This is a diganostic sectiontion] PNLLSCheck$f.LogitN End Diagnostic Section Data comes from the RegForm]t:]]8]X]p]]]]]]]0]H]`]x]]]]P]]] coefficent matrix]]H]]]] ]X] !!r' 6You haven't selected a valid range. Please try again.A@Z4k4> Check that we have the same number of rows for both variables''  p R  R %!!r R+ R %!!r R+  R$ ' R R$ R $' R ' R'kX3kP3 R 3 ^Unfortunately, this Add-In cannot handle more than 51 independent variables. You've selected . Sorry!A@Z2k2 Warning if mismatch is true The number of rows in X area 5 does not equal the number of observations in X area  . Please try again.  Data ProblemA@Z1k1A go through cells in each area (determine how many there will be) labels need to be found$ '  !!r ' !!r'  hYou must select the same number of rows for both the X variable(s) and the Y variable. Please try again.  Data ProblemA@ZH0k@0% Check that we have just one Y column  EYou must select only one column for the Y variable. Please try again.  Data ProblemA@Z/k/. Pass this information to the MatrixWork macro Check on labels ']8]h  X ' R  T R$  ' T'  R %%V + $$ mycheck = MsgBox("The X variable label in column " & xvari & " you've chosen is a number. Do you really want the variable label to be " & Xvarlabel(xvari) & "?", vbYesNo, Title:="Potential Label Problem") $If mycheck = vbNo Then GoTo tryagaink8- T R$' $]The Y variable label you've chosen is a number. Do you really want the variable label to be ? Potential Label Problem$Z'  Gjk8, Start reading the dataA Must read in one row at a time across Y variable and X variables* Data is assumed to be in columnar format!' R )On Error GoTo ErrorHandler 'Error *****! Read y data first  '+remember first row is label so must add one5 We are sent to error handling if this isn't a number Now check for blanks R $ + R $$  '  we are going to skip this obs.*k*' If we've passed, go to the x variables' T   T$ R T$  '  ' On Error GoTo ErrorHandler* xvalues(countobs, j) = XRange(i + 1, j) Check for empty values  T %%V$  '(d(  T %%V  +k(  TX(P(  '8(0( R End reading in data   cThere aren't enough observations with non-missing values to obtain parameter estimates. Try again.A@Zx'kp' This is the estimation section] SSR= Sum of Squared Residualses() gradient vector stuff:l,7 Lots of other vectors to follow for Robust Std Errors.luEIf RegForm.InterceptCheckBox.Value = False Then NumXVar = NumXVar - 1Stri4 *************** Intercept Issue ****************ean)]]]]P]h Y, X and X' loading] d  'dp! 'k`!  :    '| S1 Nk tells us the number of parameters to estimate   Y(intI, 1) = ytemp(intI, 1) f  |rs.   +:  +d   $  +:   $:  +Hk h 1 To 1d '|  uff    $  +:  $:  +p  k! *** Test for invertibility here] | |@]H |   | |   :A@]` |J R | R R+J R'  | J A n (X'X)-1 workto e  kThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@ZFkPkH'  +:  $ '   '     , 1 To 1) robust std error stuff]  p ]x ]  tibili @]H]`]x]] ( .If RegForm.InterceptCheckBox.Value = True Then' Intercept Issue *******************  |h # gradient vector |  ar-per1 Nk tells us the number of parameters to estimate | Z | ]  |8!]@! |!$: | $$A | |!0 | |! .Here's where the Probit stuff must begin *****7 At this point we put in the Gauss Newton NLLS materialCo2Step 1: Begin with starting values for b0 and b1.D At this point all the data is loaded and we call the routine to get | first round estimatesR  | $$:$$ $Az ed t Get the predicted y's ']""%the index for computing logit R4Step 2: Compute residuals using values of b0 and b1. |Step 3: Compute gradient vector R ient v'  | R+  $ R $: ' 0ch(not yet equipped to handle no intercept! Need to install probit here   !%B'`  !%B R+th R$di ` R+includd8 ` R+k!resids(i, 1) = Y(i, 1) - predY(i)  !%B R+  | R$ R $: R +&gradient vector R $  R+for e (sma Rfor ch]0"0changetol is tolerance to determine when to stopAd Compute gradient vector t ' of b0''    aStep 4: Regress the residuals on the gradient vector;do not include an additional intercept term.  | $$$$ $Az %This is diagnostic material *********inte For k = 1 To Nk$< check.Cells(numiter, k + 9) = changecoefestmat(k, 1) Next k$ End diagnostic material *********** R '  |&gr  $ ' $ $ + '^Step 5: Check for convergence (small values for changes in b0 and b1 or small changes in SSR).he g^Step 6: Add the computed coefficients to the previous values of b0 and b1 and return to Step 24Step 2: Compute residuals using values of b0 and b1.$: R '  |handle  $ R $: ' +(not yet equipped to handle no intercept!  !%B'`$ ` R+ R$ ` R+dp ` R+kP- Here is the old material COMMENTED OUT *****  !%B R+|  |  R$ R $: R +&gradient vector R $  R+idso innnon R divid  ' D Compute the variance covariance matrix using robust standard errors(1 get the gradient vector (phiX) and the residuals]H"`"!''' R  |'  |+  $ R $: ' (not yet equipped to handle no intercept!  !%B'`, Nk,  ` R+phiX R$ ` R+$d ` R+k  Here is the old material *****  !%B R+| R$ R$ R+ *****  !%B R+ R$ R+ p  R$   '- tss added hereqht(  R$ '  R$ 'ng D  |non's R$ R $: R +&gradient vector R $  R+ ( ROBS * d 'k]x"***   ' ]" | | " | |+  R E = X'$  R$ R$ +  R d  | |   A@sek](#  !%' Get S0 matrix* It has the same dimensions as XTransposeX@ First , following Davidson and MacKinnnon, p. 553, divide eachtr esq by (1-ht)X9 to get ht, multiply the intI'th row of X into X'XInverse* and the transpose of the intI'th row of X]@#]X# |"error   where  |root o  $ + entry ; VecMatVecMult temph, Nk, phixt, phiXTransposephiXInversed P |use $$$'e d  |  A@6kh  +du $ $  + ]#]# | |$initio  |@  |simple'  /(N-K)  $  $ $   +'s(WS0(intJ, intk) = phiX(intI, intJ) * phiX(intI, intk) * esq(intI) + store '* esqht(intI)e  $'se it ) robust SE using Davidson and MacKinnon's, "better approach" (p. 553) implemented here"    $ Form the NOBS * X'X -1 S0 matrix.$]$ | |% |te p$$+d  | | |  A@k) Form the RSE = X'X -1 S0 X'X - 1 matrix.]% | |& 4 phiXTransposephiXInverseS0  |$$+d  | | |  A@kE Now get the robust standard errors, square roots of diagonal entriesThen+ by (1- ht) where ht is the square root ofIf02( !4A@Z*An unexpected error has occurred. Bye now.A@Z]0$ |$d | $kp :0yE> Convergence not achieved. $(dkVariable+Estimate+Est.SE+SSR+ +Rsquare+ + |$+$+d R | R$ R + R$ R + Rk  Intercept+ R | R $ R + Rd R | R$ R + Rk | R |N/A R +N/A R + Rk80 'i T Davidson and MacKinnon textbook (1993) p. 553 recommends using a correction factor count9 in which one divides the estimate of the standard error. the t'th diagonal entry in the "hat matrix".le, ' This hat matrix is sometimes called PtrK because it projects orthogonally onto the space spanned by the columns ofC X. In this module, we denote P by XXTransposeXInverseXTranspose,1 which is a name reflecting the definition of P.< Stata uses a much simpler correction namely sqrt(N/(N-K)).U Davidson and MacKinnon (553-54) say that Stata's correction is inferior to dividing by (1-ht).< I don't compute the P matrix because it can get too large, with dimensions Nobs x Nobs]& |h&  |  $$0 +    k(jiSub ProbitNLLSroutine(xvals() As Double, Y() As Double, nobs As Long, Numxvar As Long, YVarLabel As String, Xvarlabel() As String, numxrows As Long, abort As Boolean) {87O This is Bert Barreto's idea to turn the Logit/Probit procedures into functions]] ](@Xp]] !!r' 6You haven't selected a valid range. Please try again.A@Zqkq> Check that we have the same number of rows for both variables''   R  R %!!r R+ R %!!r R+  R$ ' R R$ R $' R ' R'kPpkHp R 3 ^Unfortunately, this Add-In cannot handle more than 51 independent variables. You've selected . Sorry!A@Zoko Warning if mismatch is true The number of rows in X area 5 does not equal the number of observations in X area  . Please try again.  Data ProblemA@ZnknA go through cells in each area (determine how many there will be) labels need to be found$ '  !!r ' !!r'  hYou must select the same number of rows for both the X variable(s) and the Y variable. Please try again.  Data ProblemA@Z@mk8m% Check that we have just one Y column  EYou must select only one column for the Y variable. Please try again.  Data ProblemA@Zlkxl. Pass this information to the MatrixWork macro Check on labels ']h']'  ' (' R  T R$  ' T'  R %%V + $$ mycheck = MsgBox("The X variable label in column " & xvari & " you've chosen is a number. Do you really want the variable label to be " & Xvarlabel(xvari) & "?", vbYesNo, Title:="Potential Label Problem") $If mycheck = vbNo Then GoTo tryagaink0j T R$' $]The Y variable label you've chosen is a number. Do you really want the variable label to be ? Potential Label Problem$Z'  Gjk0i Start reading the dataA Must read in one row at a time across Y variable and X variables* Data is assumed to be in columnar format!' R )On Error GoTo ErrorHandler 'Error *****! Read y data first  '+remember first row is label so must add one5 We are sent to error handling if this isn't a number Now check for blanks R $ + R $$  '  we are going to skip this obs.gkf' If we've passed, go to the x variables' T   T$ R T$  '  ' On Error GoTo ErrorHandler* xvalues(countobs, j) = XRange(i + 1, j) Check for empty values  T %%V$  'ede  T %%V  +kxe  TPeHe  '0e(e R End reading in data   cThere aren't enough observations with non-missing values to obtain parameter estimates. Try again.A@Zpdkhd This is the estimation sectionSub ProbitNLLSroutine(xvals() As Double, Y() As Double, nobs As Long, Numxvar As Long, YVarLabel As String, Xvarlabel() As String, numxrows As Long, abort As Boolean)+ Gradient vector is phi(1 to nobs, 1 to nk) Data comes from the RegForm]@(X(]p(](](](](](])]()]@)]X)]p)])])])])]*]@*]x*]*]*]+ coefficent matrix]8+]p+]+]+],]0, SSR= Sum of Squared Residuals gradient vector stuff:]H,],7 Lots of other vectors to follow for Robust Std Errors.EIf RegForm.InterceptCheckBox.Value = False Then NumXVar = NumXVar - 14 *************** Intercept Issue ****************],],]-]@-]x-]- Y, X and X' loading]-   'd_ 'k_  :-  .   '|1 Nk tells us the number of parameters to estimate   Y(intI, 1) = ytemp(intI, 1)  |   +:  +d^   $  +:  $:  +kX^  d0^ '|      $  +:  $:  +  k]! *** Test for invertibility here]. | |h.]p. |  | |   :A@]. |J. R | R R+J R'  | J A (X'X)-1 work kThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@ZFk[k['    $ '   ' .  / @/ , 1 To 1) robust std error stuff]H/ /]/ /]/ H0 h0]p0]0]0]00]0 81.If RegForm.InterceptCheckBox.Value = True Then' Intercept Issue *******************  |`1# gradient vector | 11 Nk tells us the number of parameters to estimate |1 |1]1 |02]82 |2$: | $$A | |2 | |2.Here's where the Probit stuff must begin *****7 At this point we put in the Gauss Newton NLLS material2Step 1: Begin with starting values for b0 and b1.D At this point all the data is loaded and we call the routine to get first round estimates  | $$:$$ $Az  Get the predicted y's']22%the index for computing logit4Step 2: Compute residuals using values of b0 and b1.Step 3: Compute gradient vector R '  |  $ R $: ' (not yet equipped to handle no intercept! Need to install probit here  !%B'`  !%B R+ R$ ` R+dU ` R+kT!resids(i, 1) = Y(i, 1) - predY(i)  !%B R+  | R$ R $: R +&gradient vector R $  R+  R]30changetol is tolerance to determine when to stop Compute gradient vector '''    aStep 4: Regress the residuals on the gradient vector;do not include an additional intercept term.  | $$$$ $Az %This is diagnostic material ********* For k = 1 To Nk< check.Cells(numiter, k + 9) = changecoefestmat(k, 1) Next k$ End diagnostic material ***********'  |  $ ' $ $ + ^Step 5: Check for convergence (small values for changes in b0 and b1 or small changes in SSR).^Step 6: Add the computed coefficients to the previous values of b0 and b1 and return to Step 24Step 2: Compute residuals using values of b0 and b1. R '  |  $ R $: ' (not yet equipped to handle no intercept!  !%B'` ` R+ R$ ` R+d8O ` R+kO+ resids(i, 1) = yvalues(i, 1) - predY(i)*****- Here is the old material COMMENTED OUT *****  !%B R+  | R$ R $: R +&gradient vector R $  R+  R  'MD Compute the variance covariance matrix using robust standard errors1 get the gradient vector (phiX) and the residuals](3@3''' R '  |  $ R $: ' (not yet equipped to handle no intercept!  !%B'` ` R+ R$ ` R+dK ` R+kK Here is the old material *****  !%B R+ R$ R$ R+ *****  !%B R+ R$ R+  R$   '- tss added here  R$ '  R$ '  | R$ R $: R +&gradient vector R $  R+  R  'kI]X3***   ' ]p3 | | 3 |+  R $  R$ R$ +  RdH  | |   A@kH]3  !%' Get S0 matrix* It has the same dimensions as XTransposeX@ First , following Davidson and MacKinnnon, p. 553, divide each esq by (1-ht)9 to get ht, multiply the intI'th row of X into X'XInverse* and the transpose of the intI'th row of X]3]4 |P4    |  $ + ; VecMatVecMult temph, Nk, phixt, phiXTransposephiXInverse |$$$'dxF  |  A@6kXF  + $ $  + ]X4]p4 | |4  |  |'    $  $ $   +(WS0(intJ, intk) = phiX(intI, intJ) * phiX(intI, intk) * esq(intI) + store '* esqht(intI)  $') robust SE using Davidson and MacKinnon's, "better approach" (p. 553) implemented here   $ Form the NOBS * X'X -1 S0 matrix.]4 | |(5 |$$+dC  | | |  A@kC) Form the RSE = X'X -1 S0 X'X - 1 matrix.]05 | |54 phiXTransposephiXInverseS0 |$$+dB  | | |  A@kBE Now get the robust standard errors, square roots of diagonal entriesT Davidson and MacKinnon textbook (1993) p. 553 recommends using a correction factor9 in which one divides the estimate of the standard error+ by (1- ht) where ht is the square root of. the t'th diagonal entry in the "hat matrix".' This hat matrix is sometimes called PK because it projects orthogonally onto the space spanned by the columns ofC X. In this module, we denote P by XXTransposeXInverseXTranspose,1 which is a name reflecting the definition of P.< Stata uses a much simpler correction namely sqrt(N/(N-K)).U Davidson and MacKinnon (553-54) say that Stata's correction is inferior to dividing by (1-ht).< I don't compute the P matrix because it can get too large, with dimensions Nobs x Nobs]5 |5  |  $$0 +    k`<X<2P< !4A@Z*An unexpected error has occurred. Bye now.A@Z<]6 |7d; | 07k; :0yE> Convergence not achieved. $(dk@;Variable+Estimate+Est.SE+SSR+ +Rsquare+ + |$+$+d0: R | R$ R + R$ R + Rk9  Intercept+ R | R $ R + Rd09 R | R$ R + Rk8 | R |N/A R +N/A R + Rk`8X8 ' iH8K predY(i) = Application.WorksheetFunction.NormDist(indexval, 0, 1, True)+ resids(i, 1) = yvalues(i, 1) - predY(i)K predY(i) = Application.WorksheetFunction.NormDist(indexval, 0, 1, True)7? MsgBox "This is probably a case of perfect classification."de? MsgBox "This is probably a case of perfect classification."On Error Resume Nextof perXApplication.Volatile FalseIf Err <> 0 ThenNeC MsgBox "You haven't selected a valid range. Please try again."of per(X '& '(  & $ ('*   k`<X<2P< !4A@Z*An unexpected error has occurred. Bye now.A@Z<]6 |7d; | 07k; :0yE> Convergence not achieved. $(dk@;Variable+Estimate+Est.SE+SSR+ +Rsquare+ + |$+$+d0: R | R$ R + R$ R + Rk9  Intercept+ R | R $ R + Rd09 R | R$ R + Rk8 | R |N/A R +N/A R + Rk`8X8 ' iH8K predY(i) = Application.WorksheetFunction.NormDist(indexval, 0, 1, True)+ resids(i, 1) = yvalues(i, 1) - predY(i)K predY(i) = Application.WorksheetFunction.NormDist(indexval, 0, 1, True)7? MsgBox "This is probably a case of perfect classification."de? MsgBox "This is probably a case of perfect classification."On Error Resume Nextof perX0 perApplication.Volatile Falseخ8nobs obabخ !4er[ !4"If Err <> 0 ThenNeC MsgBox "You haven't selected a valid range. Please try again."of per Qssification."Qz t s Yx Fu { v Dq r q ?v 4} ?w x * ~   pq lt g| ?s nr mw ?Ss t y r x ?w } nr cw r Zu Sv | Yz v 9x } k} v .r ?w | w | u ? s {x s Nv ps Gr v 4s > } yr 7r t s x t ?lr Et ?'s v kr z 's ?>s x s e} r x q r s ~ q su ?w r %r ǀ r 5 } s r { mt ?t ms } N x z x s u |r s t I{ x w Hs t ?xt w ?oy b} ?r z uq | q lq } r x s r s u  >x x Iq Iq s $ q q ?sq u #w x  v r r ?w v | r q ?z y kz y x ~ t v y 7v Fq r !r { z { z w Sr x r  u r ?r Kx t w t r *v t q{ 5r r ?3x r ???s  v v s x >~ u u  u u | s u " r ~ } ??r q w s 6t w ?Xs s + rs ??~ r Zq } = r { 8w Rr x {t Ir u /r Sq r v ~ \z ?x ?~ y  Ā v q @q r G q Ur jv r vx t :t u uq { u y ~y ?t vr z ?s t  t q vv Zv ?} $} ??u u ?z 4} ?t wz gy ( r z q y v r ,r w  u t t z v ?z y w hr s s t cu ? w r 6 Iq  ??K;u w v nq r X~  v r y z ۀ rt . } y v s q ev   t r u z d{ r x r w w r iq x ~ r q t s uq r r t t { qx ?q t u q z v &t y q u w | "s x Xv { s s v ;| s r u { z t  w $t r hu ${ 2w q Eq  -u { ڀ r `w v s v t /y s y kw v or Pr t s ~ } u Y{ { +z r r Ks y y zw vw y  w v t z r qr q q x .w @w Jq z | z 8x } 0w r r |w G| ~x y q r q nt fy q 3{ u ?{ Vt s r `x zu v r y q t r s Uv u x Kr r v }q ]q .| r tw s x *u j} )v { uw q v ! r t lq s sx w  t ;r w >w .t v Y x x py *r x } Eu v ]v | r Jv 5~ } w [s q mu q } z } t s s { x u b{ z Dw } gy { 9r z Z{ >q kt 'z r x r ow v gs s r } r u q !w 2s 8r w u q r w zw Vx ~ q Հ Jy x q =w | s Mr Mw v %r wx /v v r t q w t  v~ r x sr } q t lv r x s 1| \v u w s z r v y |x Fw }  wq s v r Ys z s }} oq t } x v $ } 7s x ;y s r x qr -x q My t Tz r s 9x r Bq Av \s y Qq uq q { Kz Oz u| q r{ 9u r s Ws u e Fs w B} r z q z sx y )w Uq q { } q s q Xv x q~ Mw zq #t )v s u r yr r j} 4z s 3~ { Lr z q It x Cs q t &r } Fz q s r t z r /v s { s y t | kw s s s t xu } x Jx )x v s !} iv ]s e| 7~ X| { 8{ {r vr Tq qs w} v u { q u \t 3 | s r t q v z | \s  Attribute VB_Name = "ProbitLogitFunction@s" Op$ ExplicitP x XNLLS(xRan@ge As , y al IncludeIntercept4Boolean True)Variano' This Bert Barreto'dea to turn the/ procedure(n%f ' I have removed c-7 warning Messagfrom.codeApBa.Voll@e FalsDim mismatchcl, numxvars Long, i@myarea #badonctwo(row(NumYRLj# Colger#obA&m#y*jcelln!mycheck F;YoLabelAS@ngou@c C8n'On Error ResuNexŸEK$= .AO.C@hDebug.Print;.Descri² If <> 0@en MsgBox "Youn't @selecta valid r!. Pse try agahin.'AGdoTryB@E nd If7 CMthat wesvberP of xf@bothblesB= 0 J =ReAnoxc(1 "qDN)  F iqi  i)/(i)0lumns`<_ AUEd=e+ GC `7i > `h7E-  ; - 1)<(& o=tnq`%;eaU i AE>L 5)MUn`Stad!Id0pM!PA&P? iaBE[*8' twG@HлdqGmF+ar1Q0I!6cF%='Y"np";rC٩‚$bJH0 lP 'S* 'ad y  firsP A'rem|ema"52x so oaddA_y!Weэ4eݒh1 tc;:qNЂblankMQ T,x(i !/E mpty( )0 = True Then countobs(- 1 ' we are going to skip this \.GoTo finished,End I0f ' 've passed,NKthe x variabllesLx0AFor j1 gmya 0>+k+noxco`ls(j) /c ellnoi *  + k #D+ 1 'On ErrOHandler'7lues(!, j)=XR@ange(i:1/ l' Check f.empty#@@If IsE(x'.Areax.Cr:u)8C~=  zElse ?@ri#,KÅNextjnj ' d:KbsMsgBpox "@@n't enoughervations withn-miss vaAobta@parameter estim@ates. yH ag."Gtdry *ATz`Ord` seca Call LogitNLLSroutine(`A(), yA,, YVarLabelh, X{lAan`, abort!t'Sub A`s Dou ()Long'AStr(*5rowsa Boolean@=`3bpDim %4T)iant r no intIA&J.IlastR8owUC mystart umnMendstoY5 coef`!C6yfito@ldbetaVpCinvc,Ff!F C/@A'efficent hrix#@C chA9phipre,dY?k+/SS&R`' = Sum of S$qud idual@P' grhadiav w@sptuffNXoQTranspose'8t~Hf opAr 3sGfollowiRobust StdpsXà;rmse  residsymP8lnL+MY> y X' long ReA'Dp=ct,Ї1C '(' ruCs@ece|sq #ah1P6 `_l`{s (;iZwIsI}Qi!h# ,Z =L Fm Faact.W0 SvIncl udeIn@cept0,[UyIs3XG  #02k4( cĹ9nkp& ' Nk t u;bЂPDb=ZRi=/A 4Y`Y(P )ytJ c%5Xa1aQ, PI  AJ 9o|a* WuntJcIA !kp r^S Jx_t25P*** ertibili1pher!AXT_/(MatMultXn1ߒ70f p MG >pB"2p(R  R ҹchUctV(P p+vlLe) ' (X'X)-1 work If invertible = False Then  MsgBox "Dre is perfect or near-multicolli,ity thfndepent vaHriahs.busregression fails."yGoTo skip: End If ymean0 FintI 1 3nobsB$+ yv@alues(, 1NextTLtI(/ #ReDim phiX(05k) ' gradie3oor>TransposekTAcoefestmatShangeTx() As Dou  0k sd  Call F indXM@]SD(X(), n1I, DA@E Cr< 25\4: @s 6s$]cd;doclude adHditalG aC<}0}/I \0@SS"Q0 44^ 23 =7(P%o8 'B5Bheck#dHgen"(smVtF1[ s 7GSSR)q]6: AddcSN>Q ficq~0o7vioM1_returR+r@ ORlsORf 1i*(#MoP#2oPxxt oPoPoPI=OoPali+PI1oPoPoPVV-03oPLoPqoP+riH+ HNE31.cori"xt#robast0ard errPOf(s_`sp?6_2se s ' NO |1~y8stard error!squaNrootsQ|diagonal ene9:tsbook^993) c; recomP;ds?a c orPa facUbin which on1esti!e w0f)0A itW At y`@"hat$?"(P$ThW!some` es callIPPecaupirojecrthfoponЖspacPpann AcolumnX. In@ module, wenote PQXWE%,RS a nArefl X1defini@PbStata[0 apsXrP sqrt(N/(N-K))- _"S"(0-54)Ar'pW! inferidi b GaI dct` mpupA PD bcanrtoo large-i N x}3b/4HHH(dHh(h FEI) < 0 T>spy= \_Sqr(SH PIq0Cr' change > tol P2 MsgBox"CoqHgen 0.* |ieved."  Goskip endnow:  DErr.De`scrip)v"An unexp ,3KBoccupEd. Bye ?0 espsArray RI25 `A2!+ 1!dYcRe"r  z2ETQ P~=D ".SE 4SSR}2\A "^Rcbral O bcoefp^`^s37PultsArray(3, 2) = RSE(1) Else For id1 To nkP`Res2,H+ 1coefestmat(i,$di 2vivWNext ind If If IncludeInterceptTrue Then] j1"0"%2LXvarlabel(i -eQ,|nk \> s`4"N/A5 M`tryagain: LogitNLLSaI]lFunctio@e  Prob (xRan@ge As ,$ y Opal~ Boolea nĀ)Vari@ant 'is Bert Barreto'@dea to turn the 1/C% pro@cedure n5@ fD1s@1Di m mis@ch , numx@sLongS(myarea  badon? twoArowHNumYRHACol# ger#obkA&iGy*jE cellnmycheck5Y,LaStringou&i#`XD"CB"= A.A$.Ca}Err <> 0{MsgBox "You haven't selected a valid r!J. PCsej V V._A`G^o eZ猡GCbthat we" Esamea=berP of 3fbothOble E B= 0 B fF= FabRBe@noxc`7(b! %i ii*(i)*lumns+ !M%\=]+ GC`i,!  `:<a(&! dg=@`nh`E$eeAE> 5*f MUn`Stam d~Id0pM!PA&P? iaBE[*98' tG@Humeڷd to be in columnar form@at! countobs = 0 For i01 To n`L'On Err2Go*Handlerh '2*' Read y data firsths+ 1 'remembP2 row is label so must add one ' We ar@e sentehing if th>isnb' nu-NA+check @blanksAyvalues(N, 1)yRange(i U If IsEm0pty( True Then- 1 ' 2wego\sklip_. finished End IfkHwe've passed, gothe x variableD:#x8}A~jB~myWa " k nox0s(j)cellno@ i * @Rk "'@ ojbXo(' C}epGA$HxxA.Area9.C5B7){$z=Dڀ}A PwElsE;@ri#,K%H Next 3bjI:+ ?` ResumeYZ iZ.dznb @3- sQ=foll! RobџStd rgs@.@`6.InZcept;_.V@H"EaRX @Rx* su*6X Z#rms*,e0^symWc!lnL&Yp^ X' lopTngUact^`CInclude=`n=wbi@$qReA#X]] Xw"kqa?B P nk R ' Nk tQ u(0@1ƀR*GQ="V=4 `Y(@ ytpۡJ n1PXTap*Q,tI _A !QӠIJ 59oha"usntJcI sobP(n*u!FsIgFw+ "_t2: @I ҄Rkertibility here  Dim XTX() As Double Re1 To nk,  )xinvertih|Boolean If^ >` heMatMhult,nobs,ran`spose \p p( For 8i =Asp(i)iNex t  = TruzCall choldctest(Vp, ' (X'X)-1 work1| -False TsgBox " re is perfect cnear-micolli ityA thAndepent varia$s.3usregression fails."N>Goskip: End If ympM0 UntI@\@k  + yvalues(i@ H[ / } Cyfits@/idsD1 predY '' robust std err@Vstuf9Aesq9 htQ @ DS C phiH4HixLong Achange numitDer lnL ,Z @LI FFEJ' [Reg@Bm.In cept Check`Y.V?D!i]' @ IssueO*oR& X$:nk) ' gradie!^`eorQ=Te散J' Nk tells d%b%of parame`go ~imat coef`@, gQ16xAkQ-CJk$OxsdRFindXMqvSD(,> $ CVC?$q5'Here's whkBPmilk mAnbegin c=B At o we punGauss Newt`NLL S A/ l 'Step 1: BB withz2ang! f!@{b0 ab1. Adataaloaded  crout to getfir EBs ".Run`a(umxtj()فHD)`s, )@3' \Ge!%#@id y'@Ax= ౫aH`=e@ lzG( 'xb#co m-i&logiC!*2: C"ez Vupj1q\ p1zb3g8bb " >ks3+ 81=) * X(i, *QfT'not y`equippǀRdle`gs-K!C@Ae3intst p,-#G Applicatt.W~she@etFuncNormDi-E , 0K,rA ?j҈ueXw):s`1G E1 = - 1t0/k1Q'lY@- 5 3k  "0@0 '/bxb`$ # $r6]|to706WpMegceCdqdmD0R0NoKopE6N @0 ^ (-12 j}3C Whi->B U0< 25;4: Ksid2?`WCL ;doQZ cludeR addi.alg4urm@WQQGOp& ?0c[R'ThP diagnosti~cVcsgg!$N/`Bp` c.C !($@E + 93@#",' l**S`].Q0PbP^ 2=T(  w5 _d߈gen.(smSbqx s! cAÃSSR)z)6: AddҀjYQ fic2!*Fvioj1|retur"7r@ nBn32 1吔#UKDcqפ2l@;llog8ljrkjj|xval, 0, 1, True) predY(i) = 1 - GTIf yues(itThen<p`resid<pEXlseF`1E nd If)' Here is the old material COMMENTED OUT *1 'Application.WorksheetFuncNormDist(inde& hI- 6 Zphi4=Fa For kToX nk2Xk8*  'gradient v ectorTranspose(8k, GC NeXxt @iGn8umi_$E+ !mWendA^Co mputeBjvahnce co@nrix using robust s     ( !"#$%&')*+,-./0123456789:;<=>?@ABCDEGJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~tandard errorbsget 1 r()) euK Dim tss As Double, ysq SSR@-0 = KXi1 Xob E Ac +>efest=Y1) g Y@'not y=equipped to h@:le no in@]cehpt!G%d-?E$c,b_|= GS|{y*cyyy'eA`Ozn.zesqc qJ^ 2CT+ (ymeanD)  '^addEh[+l& a+ ?C6\!oߍߍۍ IncludeIE_@^b( %  !rsquarealt'%I h( ~/)D!b)ARe nk@/ Ϡ`" 2𓧁5+ *( - *R1 _{MatMu,i40T,{C&~?hiXInverseVRdt.= PY~>Mdzb{' rGWS0 j' ItXcsame dimensps as XvFXFirm, follow1nHDavon2kMacKinnnon. 553, @e each28 by (01-ht >o Apht, mpiplyo aI'th`tw of X1bo X'tr>tatemphy.xt(//W. *ntIs.t0 P@ntk0.`#)PV\ec(Q)t , N7"x#%S9Q60 R(| t D h34S3 +,  5Sht`tI" S&D/@'0z I nPLPpLongAS0 "` C""1T!J"_Q#pseX) { (J'(JQ+P+*AtF+0orN 'OPPbrOp1Ф$ '+EeKB\SEKK'2"betapproK" (p.1M) impleRtZ9y%xeX %vJQZ 'p NOBS1'X -1 [.s)3se}}7,rC# #B/YD Cxߠܡ dxPnPj x,0 End If ' Form the RSE = X'X -1 S0$ 1 mat0rix. DimXsq() As Doub$le4Re81 To nk,)D' phiXTranspose InverseS0:IfOcYhen1-f)B("* (1PElsgMatMult1,fh4,0X' Now getrobust standard errors, square roots of diago@nal ene0s 'av@idson  MacKinntextbook (1993) p. 553 recommends using a cor@ti factorin which0 onees+esti@e$'A .by@- (ht)e1ht| iCH5B t'thK8y @ "hat"@ThGsome%(called P"ecause it projecRrthoBRly7toB5@space @nn@0colu mnA_BX. In modu le, wGen@ote P @ X퇱XİG,BCU a namxefl&bdefilniBc}PA< S0tatal8a mufsimplero@5sqrt(N/(N-K,))AV(`B-54) say - 's `inf@erior %diA`(1- = "I don'tmpu"P8 b2canc`oo largZe#i"A@Ts Rs@ebs x B(Đd{ JtI#aD`A(intISqr(`!,z)h Nkã change > tol T@V MsgBox "W *Qbab5pa@T=perf A class ifica@."$ gGo@skip xnow: D Err.Descrip"An unexp` `[ haZccu@d. Bye ` A a ` b,essArray-Variant u052 (nk + &+lnL`-0.0 FR.Value>"CoAgen}v achieve ,O߁b`@ 2a E 3.SE) *4SSR`2BRSR*!"R-"ral`/ bcoef^^3t2 3&t60nk6iBi/R( &=aiT992)IncludeInt@ercept@Trp s9~ "Q 2  Xvarlabel(i -2,q& _79>&1 0Ð& "N/A'zp% tr@yagainDPitNLLSPCFunccK 7a(xRGUp, y OrOn@Boolre g=  L'ZAns BertH BaPQto@pidea!oturqe Logit/c !cedur y10bo f$ Smis3z'(umx!sALongemy`Ycba@ueGQtwonrowNumYRsQColrA.hgero v,j iy jcellnxmycheckA, YpL0QSngount_he= .Area8s.C1"Mo <8> 0Dw1+5wYouoveaseіppa valid `geP!px0+ B+pA5w-WF C2t!haveФᝐ.b@}f0bo aq s16#= FaBrnoxs @u?RX4Kid9(i)`1&.= +  [Ji0| vJKox0T1=Y3= Xq4wņM > 5 &Un0tuna`tely, EAxdd- !pd`le mo@#nqindepݷp)PsP)+'$V+" && ". Sy!Z*Pa ' Warning if mismatch is true D IP= TL Then MsgBox "* number of rows in X area " & b adone" does not equal the:obser@vationBtwoB. Pleasey again.", Butt5:=vb`ExclaE, Title:="Data Pr@oblem"GoTo$# End Ifg hrough cellGeaj(determijhow manyere wil l be)!labeneed to found x=(1) - 1 ReDim Xvar(1 Ps) As Str NumYR= y@Range..C1t%Co@ÆumnsBxq"<> FyxYou must @selectms am o4for bothX -ia\(.aV{YFrDrVqCheck"at we have jA1AY col@CA9J> @\F?only urBn`'On Err?"JHlp '*0' Read y 1 first6W@'remem"!4Q so#nadd]9WeA@o4o e h1 1PtW`sn't u8qN@S>qlankLP R+|(i  ! .Emptn=g8!' Gradi v@As phi@0QdSQnk3#jcomfrDom2RegEmucT`Q FiPSnew0QetshOa rsRܡܡintIJIOJ\lastUsy#d mys%row As Long Dim mystart@column end*\storeDoublecoefest() 0yfioldbeta.`VCinvV@ariantsFf llabelBs-Stri  ' Pficent ma x[ ihange#lphipredY intk#WSSR`  ' = Sum of Squa$ ResidualsbgraDdiavec stuff:eFXFhiXTra@nspose' tsother s to foll@for Robust Std Erro rs. C'If@'gForm.InterceptCheckBox.Value = F.e Then NumXh#E- 15 * C Iss=L* 7rmsHNrXE8ymeȧŁclnLq ' Y, X and X' loGlCA actsnumxvarsRIncludeG>= Tr>N D = b+REls  EIf ReX(1 To nobs, Bk )Hd  !%nkA' Nk te lls uQhe bSbparame@MTirdP lI "K Y()ytemp+AJkg`Y!X ! `[iU,"p_G9 `Hls j 0aJ+Ee NextJIA9 92cA .Dc'+?.4gŖ, TPr@#vertibility RlT쎁 $p@Ukhk! l"Bool7l`->AvFQMatMult XTX, n2=Ip aG pdAgB1 4+i?3 sLcCa ll chct5( ple' (X'X)-1 wor8b8u eA Msg h "Sis Pperfs lnPear-mi@liaqin cpdepva3@s.`l$Ireg@csion f@ails."GoUskipy4ud= 0 /1nt8/\a9&"&QcDo' '(' rstd eÈuesq%ah졓Pwa+`_Qs1qixx}1;jig, --L;Fm >FwP' ] aQ!%Onk)ܥ-WE{{Хp?t{(P()axm sd`JFindXMWSD(\UU, x# sdD @ՔVCV'Here's wdHP6it5 mbeg`J" AtaNo@ we puzGauss NewtJNLLS eMl lStep@ 1: B"withpp GImb0b1']!Sdata @edc0routPVge' firp%!PRunReg(1dkw()(@Q("9, #' G.eihd |y' !FoNr k = 1 To nk indexval(+ coefestmat(k, 1) * X(i, k)r Next 'not yet equipped to handle no intercept!:' Ne#install probit here"GApplication.WorksheetFuncNormDist(-, 0, TruepredY(i)'M&If yueshenYresidG ElsCk - 1nd If' %b-iphioFa'DKFoT~RD 'gradient vector&: Transpo|seBbAQBi Dim c@getol As Doub@ 'IGislecedemine wdAstop ' Com pute ) @r0 ^ (-12Bnumi:0 iWhis! > )@nE < 25Step 4: RegrQ+he tu@\ 0on t %;d @otclude an add.i :. ZCRun(nobs,4umr@ a), /s( #(~`lnL, y fit()C'Th.@diagn@ostic eri`*A.@?JIN'Aacheck.Cells(D& + 9t.b Ib' E/**$ 8@:v] bQ#bE2C =5 '"G5: C !% frconv ergen](s^m>sF b0`Fd b1 SSR)F 6: AdPcCddBficaykBT@vious $of @ZturYo " 2 do^usingQ  a2i@4#@Y ##7 ٿ٦__@HH1@D/D}{bkG?gA,1' H@xF `>Iold7>COMMENTED OUT ?9 O{O{@{ov2{RB ;wo!LpFpr};2Sҏ (ppqpQp 2@pS%e= +W8endmva3pXAcoYri x 37ust ndard errorsapvhC(a )Ebk1ztssybsq9 F:a= @Wy_>eckn/>U-Xs"V/>ߨߨߨר/>oc 1o@=/>=@"(|3<"O5O5? <'5E '_=Y=esq9^ {#*Q+ ( ymean)~ ' Aʃ-Q+0Q+ s.07B/FFqFQOFG`fIn2Igڀ2 T=r  qʱrsquarealt@b QUh- (Q/S 7j )DARehiX(Ac{T nC a1bՒI _s+Ҷ'P0~*3xqMatMudC C ɷ Dim phiXTranspose`Inverse As Variant  = Application.Workshe@etFunc"ME()  ' Get S0 matrixo' It has the same dimensas X-0First , following Davidson and MacKinnnon, p. 553, *e each!esq by (1-htN' to gMht, multiplyIintI'th row@ of X o X'Xu '{:_t  temphDouble xt() Re 1 To nk! ForCI = obsj k k Y$k)h(',C Next B'VecM,atA@F /, NkWhixLQCCAIf0&xhenE=a*1) *Ҭ(EFEDElsoTR0ne0EIf-IhtRAU0@@ /q - /[IG@A}nnkL8ong@ S0 %@D,EtDJC/Hc a'(Gastore@ 0KA SiOJO aH"$BJ?GV* *+ "m ''#N") D '*3$robuSE uson'@z' "better appro" (c) imple@ted her^ J"hEJ@9m NOBSc@q@ -1a.S7`*{ Yx1aeALJ@M ,g,`&od ',RA=D,- y -Ϣ'-sq5t(\1?VmSd>@o \iUt 2seS0"i%P' N|az 9stard errors, squaNroots!}diago@nal enЋe_: tol Tr+ MsgBpox "+(blab7a*perfp classif" ! Goskip endn ow: Err.Descrip#v"An unexp-E"occu?d. Bye .'0_es@hsAprray/Y n IB50Z!2?7V#@+ 1!uSlnL0.0`FRAa.ValuQ"Coagen>P; @ieve@z{/@"0Ӡ 2{1EQ 0 =D ".SE 4SSR2)SR\"Rbral "/q bcoef^^(7z 3Ϣ601 To nk ResultsArray(2, i + 1) = coefestmat(i,H3dRSE(i)PNext i End If If IncludeInte rceptdTrue Then4 1, 2"0""%For= 2 >Xvarlabel(i -eQlse,1,|nk > )s`4"N/nA 5tryagain: ProbitNLLSaalFunctioe\ 6$   l +''':'N 6* qdpjl\ l\ `l\dj`@Ha8  aav"il`lR) 6j`@Ha8  aav"il`lR) 6ldil`l"qd5l`l`ll`l@pjl`qXl`qT `fld3m='''ld#|*#x*F 2|x6* kj^'':N0lX#|*#x*#tlT#p*#l*F 2 |xtpl6*l("qPldh2Ha  av"qL 6-Ha  av"pJ 6 lPlL3'':N0: N 6* kJ3'':N0: N 6*lPqDlDlddrU~|  -A !  y " A#  % <I"y#! 2a"Q1 ,A,R BR1-S P (1(NP$P,Ha8  av"q\ 6 qdpjl\ l\ `l\dj`@Ha8  aav"il`lR) 6j`@Ha8  aav"il`lR) 6ldil`l"qd5l`l`ll`l@pjl`qXl`qT `fld3='''ld#*#*F 269 kj^'':N0lX#*#*#lT#*#*F 2 69l("qPld|2Ha  av"qL 6-Ha  av"pJ 6 lPlL]3'':N0: N 69 kJ3'':N0: N 69lPqDlDldh!lDd q@`l\d\8l`l"dTl@q@l8q4vl4i%`@Ha8  a`#l@l|;/) 6%l@l|.P@M@ pN-PkN 8fT# `f\ (%H`1,5,M@ pA'': N l,*#*F^Rp2/6k2p9 q(`lDdDl(q(8l`i%(%HBl(ld51l`i%(%H 5l(q( q@8l\d<$l8l"d4(l`il8ll$i"q45l@q@sl4i%8@Ha8  a ) 6l(q(xl4i%8@Ha8  aBl(l@lh) 6 $f4R 8f<8l(q(  `fD l(ld+''':N 69lDqPlD!lDlDlDlDlD|lDlDX ldqTldqTlDlTlTlDl(qD  ldq lDdL lddD l llllll &lllhlll llllll fD fLf  ldq lDd< ldd4 lllhlll llllll f4I f<6 l l 0l  7M `M`DMl@ M@ M@0M` l `l dD l`l`l `f- p.'.Ml @M` M@0M`  k. +''':N 6#tlDd olldt f olDtlDl l lD!l !l l l D  l l l l  "ddd D $td`lDdmt$l d *ol$ll`l$lt $fW $m tm ol`l,l`ldl`ll`l#m tl`lol`l$l dc(l`ll`l$ll`l$l l`l$ll$l`l $f `f< t qltpopoll"dd D $tp$l d>opl$lϫtp6l$ll$ll$l $f`lDdt$l d*ol$ll`l$lt $fl$m tm ol`l,l`ldl`ll`l#m tl`lol`l$l dx(l`ll`l$ll`l$l l`l$ll$l`l $f& `fQllqlttt`lDdbt$l d*ol$ll`l$lt $f$m tm ol`l,l`ldl`ll`ll`ll`l#ol`ldoϫtol`ldϫtol`lt#m tl`lol`l$l dxX(l`ll`l$ll`l$l l`l$ll$l`l $fx `f uotootpl l l7M `M`DMl@ M@ M@lM` F  6+''':N 6l W# 'l  : l:!l:"l:#lokl:$lopkll -lkl#lkl`l d/l`lkl`l%l`lkl`l `f :%l`l d*l`l|Fl`l `fR`l d$l`l|Fl`l `fl 7`l d7:&l`l:&l`l `flM lPz'l|dh,8 lP\0X|@ P $ @,Ha8  av"q!lD` q@`l\dX@8l`l"dP6l@q@l8q4vl4i%`@Ha8  a`#|l@lh;/|) 6%l@lh.L@M@ pJ-LkJ* 8fPy `fX_(%H`1,5,M@ A'': N l,*#|*F^Rp2/|6k2* q(`lDd@l(q(8l`i%(%HBl(l`51l`i%(%H 5ol(q( q@8l\d8$l8l"d0(l`il8ll$i"q45l@q@sl4i%8@Ha8  a ) 6gl(q(xl4i%8@Ha8  aBl(l@ld) 6 $f0 8f8l(q(  `f@ l(ldV+''':N 6*K%  $  $ "  $   1:(% $  d)l=*,) ldqpldqplDlplplD  ldq lDdh l d` l llllll &llldlll llllll f`z fhg  ldq lDdX lddP llldlll llllll fPD fX1 l l Ll  7M(`M8`DM@ M@ M@LM` l $`l d? l`l`l$ `f( pJ'JM @$M` M@LM`  kJ +''':N 6t|lDd o|ll`t| f o|lDt|lD!lDlDlDlD lDlDlDlDl l lD!l !l l l D  l l l l  "`d D $t`lDdt$l dH*ol$ll`l$lt $fSok%k%k8%c% $  %ABt) 5U@k%k%c(% $  %ABl`l) 5l`l`#ol`l?ol`lV@k%k%f(% $  %ABl`l) 5$l d(l`ll`l$ll`l$l l`l$ll$l`l $f `f t qtool"d D $t$l dol$lϫt6l$ll$ll$l $fx`lDd|t$l dt9*ol$ll`l$lt $ftSok%k%k8%c% $  %ABt) 5ol`ll`l`ol`lol`lV@k%k%f(% $  %ABl`l) 5$l dl(l`ll`l$ll`l$l l`l$ll$l`l $flV `f|lq%ttdt\`lDdTt$l dL?*ol$ll`l$lt $fL Sok%k%k8%c% $  %ABt) 5ol`ll`l`ol`lol`lU@k%k%c(% $  %ABl`l) 5,l`l`l`ll`lV@k%k%f(% $  %ABl`l) 5l`ll`l#odl`l`o|ϫtdo\l`l`ϫt\ol`lt$l dD(l`ll`l$ll`l$l l`l$ll$l`l $fDN `fT o\tdoodt<l l 8l l8`lDd0}Ll8l`ll`ll8 `f0'7M(`M8`DM@ M@ M@8M`  f+l l l :C(% lkBl5n2M8`  M@ M@ M@M` l l l Clk(% Bl52 M8` M@ M@ M@M` l l djlll ll fC oov<'''|   ,>|F  6+''':N 6l # A'l  ot:0yE>q:+%lC,: l:!l:"l:#lokl:$lo|F  6+''':N 6l # 'l  ox:0yE>:+%lC,: l:!l:"l:#lokl:$lo@kll -lkl#lkl`l d/l`lkl`l%l`lkl`l `f- :%l`l d*l`lhFl`l `f@`l d@$l`lhFl`l `fl `l d:&l`l:&l`l `fclM l*l `d,<($P h@ L|xtpl a G&0FK$*\Rffff*904630bc73*\R1*#2ab*\R0*#19*\R1*#e4*\R1*#dc*\G{AC2DE821-36A2-11CF-8053-00AA006009FA}#2.0#0#..\..\..\..\..\WINDOWS\system32\FM20.DLL\2#Microsoft Forms 2.0 Object Library*#47*\R1*#d7*\R1*#e8*\R0*#f*\R0*#19*\R0*#13*\R1*#10*\R1*#1c8*\R1*#e4*\R1*#e4*\R1*#dc*\R0*#14*\G{AC2DE821-36A2-11CF-8053-00AA006009FA}#2.0#0#..\..\..\..\..\WINDOWS\system32\FM20.DLL\2#Microsoft Forms 2.0 Object Library*#47$*\Rffff*8y4630bb24*\R1*#5a*\R1*#1c7*\R1*#d7*\R1*#e8*\R1*#2ac$F9U"PBxMEp@ > LLLLLLLLLPLLL"LL \`@T`t0;XC`t,C`N 10``h*|, t&% @`O8oS () i8Xi~Xi8PG#`\`<L H% 5D%`p5@`<`R0I8`4`60`,`P6(`p$` ```` `|5 h ` x 06( 8`H ` P    X@ Hx``  0 hP` : 0```@ h X `hV J(8 @ `    P Laune 20048 X   x   `` v` est`T d:` the`P! !ain all them!! `pred ! " @" h"  "COLlication"" 8!# G# # @# h#  xHH`@ co`myco`! int` !xt i  !8$ | $@$ `# `# X[$%et estim$$ `$t XT h!8%k, noseXInve %@% #% R+%% `% |A@%& #X&$ R @&`& `h$p`(&xor G`(p` "h`"$`+ G`$$Xi(1 `&%P`(&Hom t`*x @``.'( D`(^k') '']  ')((0(8 oefficen (iP(0 i~p(Sum iP(( g) (( ots of o (i$Id Er`t'`<d `8)****% \X)%`XXeckB`Tn Nu`RHP`L*** `GH****`D `8@ `< Y`(8`*4`0P ``),p `)$`| ror )* ] * )+( + )P+ ] 8+ + ]p+ * +dH+ `*  *, +`D8* @)`,lls  parametH,  +,  Y(intI, ), ,` ) x) - $-`X+  :,p-X- )-'|-` `0,`@-+-  . ,px. |`.. `+n | Jh,.R R R.. / 8/ X/ P*/ndens the re// / -(0$000 x-0ctor h00`H.p`/ |` *`T/`+$`1 | *h1 |P1p1 1 01ton 2St11 0@2is pa is loa(2H2 F+2stim ~$22 H-2cted]x22 `J- als L2h3nd bep 3: CoP3p3 `(-3 3 @xIT ` 3$`2 ` 1 `"h2`$0`&@`((4$`*P0R `R81nt v`T@4 `.`.4X ``rop500o) 55 5)5566 5i67i~06i6P6) 66 | p6i$0I`t$`<d `6^St% '\7(sma%`'Xand `Tin S`RIP: Ad`Licie`(Hvalu`Dretu`(@4St`<als `68nd b`74 `0` 7, `7$:`|0(  68ed trcept!8 78 $ 8 79$  8 p(H9$:09 X8 9nt v$ h9 `J7 `8 p89D Cnce cova9`D7tand 98:1 gvector ( : 8p:'X: h7: |:`6R V::t yet eq:`R@8t!`N9 87`; RH;`9 R :9;$ '; P7; R ';`$`: `X; |`Z;R `;h< < :<<dY(iedY(i)))<< `9: J@:`=]H=h= = = = 8 >e same d>(> H>  <>ch-ht)>> 8<>rseranspose>>`<`=`7`Th>`;`x?$ HP<?  ? L`?|@tVec? FP9xH@0@`h;t`\;l h@h@@@@ A  A @A ?dAAA ?`AAA `*>X0B XB ^ATBBB 4(8PCBC `<`?` hA`"Z|`$H?t`&Zl`(HCd`Z``.C ,E`[kHD**I hDI ``x tD% bpDD`dDl`fj `hEd`j``lHD\`nXE `GkE%%IF FI* (FIJ HFI `Rx`Tt`p`L(Fh FdF%Di$HxHG%) #pGi$Gih( C@05DEp'HhFFFFFEHFI3H8J#@HP @HL HHH@PIH hIHih( ih( ih( @D PJPI6@I4 @I$ @I @J @I (@ J @ @ 0 `JPI H!K L(K@8KP  PKK@`KL xK8K@@KH K`K @@KD KK @KK @K@ LK@< LK8LK0XL8K,\h`h`MMMMLM LN Z@M( @0M @HM @`M @xM @ @M @@ @(N @N NM<@PN @NN<@ hNN>@xN NPNE@N NxNE@N NNG@ NNGONIxNJ` `   x[OOOSXZ(P[@P 8Zz@ Wx p@Ph @QX @RH @PPD hP(Pn@xP@ PPPn@P< PxPp@P8 PPpPPxQPPy@Q4 (QP~@8Q0 PQQ~@`Q, xQ8Q@ R( Q`QQ`Q8RQ@Q @Q @Q @R @@Z @HR `R R@R pRHRRHR@R @@ @R RR@S SR(SR@8S PSS@`S xS8S@S S`S@S| SS TSO60,Nf`\@t (@Tp 0TS@`Tl @TTPTTxT8S@T` T`TT@T\ TTTT@TX UT@UT HUT@XUP ~`X0=NpUU@UL UXUUXU@UH UU@VD UUUUVT@(V0 @VV@PV, hV(V@xV( VPV@V$ VxVVxV@V  VV@8W WVWVPW(V@ @`W xW8W@W W`W@W WW@W WWWW"X`W.@ X 8XW3@HX `X X3@pX XHX5@X XpX5@X XX7@Y XX7XX=YpX>0Y X?@@Y XYYk@xY hY@YkY@Yq@Yh YxYy@Yd YYyYY{@Z` ZY@([\ 0ZZ%pZZ@L (@H `ZXZ [([Y`?0C`B=,0;`DB$`F@``ZS`dr8 @@[@ @< `0 !``8[@[@[@8 pE(ED@EXEhDDD]x\(]\\\`\\fpx\@]T @P @\L \\ @]H ]\ @@]8 (@4 @X]$ @p] @] @ (@ @ ]\@] ^]@ ^]]BBP@0?CCxC0Ux:C`C0C@ZCcf^^_xeh@_8hX_ 8Zz@cx @(_ @`p @a` @h_\ _@_A@_X _h_A@_T __C@`P __C__K`h_L@(`L @``Q@P`H h`(`Q@x`D `P`S@8a@ `x`S`x`VPa(`W@`( @` @a @ a @c @`a xa8ab@a a`aba`ad@a @ @a bao@(b bao@baq@PbH hb(b@xbD N\bPb@b@ bxb@b< bb@b8 cb@Hc4 cb(cb8cb`cPb@pc cHc@c  dpc@ @c @g @ @d dc)-P(P*)(0())( )x)'('*O8N8KHPNxPThP@d {?ed@e 28?0ed@e 32?@eePeeed^P@,Nf`\0@e @ epc@e ee@f fe0fe@@f Xff@hf f@f@f fhf@g ffff g@f@f @ @0g gHgg @hg Xg0g g0g@gT *?ghg.@PhP gg.(hg0@g@ @g0 @ @ `E?hhhb `e`dr8b@xh hPh@ hxhxh483305p4X4.,54(44X4phiii8nqi`qi 8Zz@8ox @i @Hk @ l @i ji? @j 0ji?@@j XjjA@j hj@jAxj@jIjiJ@j jjO@j| jjO@kx kjQ@kt (kkQ8kkTkjU?@`k\ @xkL o?@k< @k, @Hq &?@k lka @Pl lkahlkc@8l @ @xl lPln @l lxlnlxlp@lx ll@mt N\ml@(mp @mm@Pml hm(m@xmh mPm@md mxmmxm@m(mml @m` nm@Pn\ hnmPiP@,Nf`\@oT @xnP nPn@nL nxn@nH nn@PoD nnon(oxn@< hom@8 @xo4 oPo@o0 oxooxo@o, oo@p( po@(p$ @pp@pp  Pp(p`p(ppo@p ppp@p ppqp@ @q (qp@r 8qqqq@xq  n0`dr8@q @q @qp @` f\@\ `rq@(rT @rr:@P Pr(r:(rC@'"h%$X'&&%&&8&!p[('~s`s0s}s~s f8Z@Hsx @ud @` @xs @u| @sx ssW@st ssW@tp  tsY@Ptl 0ttY@ttahtsb@xth tPtg(@td txtg@t` tti@u\ ttiutlp4uxtm0@(uD 5@@u4 4@Xu$ @pu @@w @u 0vuuyZ@v uuy0vu{@v @ @@v Xvv@v hv@vv@vsz60,N\``@v| vv@vx vv@wt  wv@pwp 0wwww@Xw` @P @wL wpw@wH ?ww wwwv@x<  xw @@x8 0xxXxx@hx4 x@x@x0 xhx@x, xx@x( xxyx@y$ 0yx@`y  @yyPyyxyhx@y  y`y!@y yy!@y yy#@z zy#(zy%@8z Pzz7@z `z8z7@pz8z:\zy<,Nf@z zzF@z zzFzzH@{  {z[@0{ H{{[@X{ p{0{\@{ {X{\{X{_({{k@{ {{p@{ |{p@| 0|{r@@| X||r@h| |@|t@| |h|t|h|z||{|{|@| }|@ } }|(8}|@H}< `} }@}8 p}H}}H}@}4 }} @ ~0 }}p}}@, `8~} xvdr8`@H~$ `~ ~ @  p~H~ H~@ J:pCx~E G*\Rffff*1h46065a31*\R0*#15  (" H h $ X`hp & 8 ,H Nx : F "P  x J      D8 & B   7@  `  x<  P @P(?h 2 7  420 h x   " G  X %H "6 2X " 6666 666666x6 p6h6`6X6P6H6@68606(6 666 555555,5 5x5p5 >05(5 55 24 L4 :@4 8404(4  4 4 4 3 3!3"3 p3h3P3H303(332 222222222-2p2h2`2X2822 -2 1 811 &x1`1 P181 1 1"&0 0 0 0 0 0 00 h0 H0 (0 0 0 0 (//// /7x/p/X/@/ 0/ //'/ . .v+`.X.P.H.@. 8. .. - -0--!x-!X-P-8-0-- , ,+ 4, >`, 8(, J+ x+4"@+  ++,* :* &*h*`*H*(* * * .)($)(,)(#h)P)>() ( ( (>( p(  X( P(H(0( h' 4"''p'P',6 ' ' d& d@& :&% %%(*% % .`%($8%(,%(#$$>($ p$ `$ P$@$8$ J# 8#####p#h#P#(*(# # ."($"(,"x"<#8"""(#!!>(! `! P! 8! 2  .    x p P 70 ( <  0  F h @( 0   x  h&:@ 8"    @ (  `H  0(>< ^pX 0( 2    *h X(C0(2  0  :h X(C0(2 L  ZH @ 2 4 .h R J 8  B8 \   Bp $H @ 80         (X8   x` P @ 0   L @x (P 0 j     p6D8( F+ND^L02DF2D"Jx,DHF( 2D$D$D&Dx DXF8 ,&DF&DFx`&D8 0"K&V "L (    x p h ` X P H @  !0   P h P H 0 .Y .Z .Z   2RX (R0 (R     (Q ,\p (RH ( 4[ 4\ 4\x  h 2D0 F 2R,R*Rx `  3  8p <0 <4+ " %  " 6" 667777 7(7@7H7`7 x77 7 7777 7  8 (8 @8N P888 88 8 8 P8" @9H9 %P9 "`9 2p9 $R1@  "99999 9:::: :(: 0:8:@:H:P:X:`:h:p:x:::: ::::::,: ;(;0; >8; Lx; :; <<<  < (< 0< 8< X<-`<x<<<<<< -< < 8=@= &X== === ="&= > (> 0> @> P> X>`> x> > > > > > (> ?(?H? P?7`???? ? ??'? ? @v+ @@@@@@@ @ @ A! A"@A hAAAAAAAA BBBB B0B8BPB 4XB .B 0BB 8C!HC!hCCCCC C C C D "D *@D 6pD .D D *D &(E 8PE <E E E E FF0F 4PF >F 8F JG PG4"pG GG2 :G &(HPHhHpH(*H H .H "H"S&UIH8( (@I&VhII>(I I J J>(J hJ  J JJJ hJ 4"0K , з B Q  *hKpKK,6K K dK dPL :LL MM(*0M XM .hM "SMвP P8P@PX 8 &U (,x Q 0س  :Q <X&VMN>( N < `N N NNN JN 8O@OPOXO`OhOOO(*O O .O"SM(`@ &p&U(,H &VXPP<#PPQQ>(0Q pQ Q  R.R0R8R@RXRpRxR RRR<LR S(S70SPSXS<`S xS 0S  FS T @ T 0`TTTT TTT  U BU  XU&:hU U"U U   U(U U VVV0V  HV`VhV><V ^V W 08W 2hW W W W *WXX (X(C8X`X2hXX  0X XX :X (Y(C8Y`Y2hYY LY Y ZY @HZ 2Z 4Z .Z R([ J[ 8[ \ B\ \X\ \ \ B\ $ ] H] P]X]`]x] ] ]] ]]]@] ^ ^ (0^X^x^^^^^ ^ ^^^__ _8_ P_ `_ p_ __M +6D_+GNDh(`++ `L_2DP`F`2D`"J`,DaF8a 2DXa$Da$Da&Da DbF(b ,Hb&DxbFb&DbFbc&D c Hc"KPcxc&Vc"Lc(ccccdddd d(d0d8d !@d Pd pd d Pd e e 0e8e.YPe.Ze.Ze ee2Re (R(f(RPf xffff(Qf,\f(Rg (8g4[`g4\g4\g h2DhFPh2Rph,Rh*Rh i i 3i i 8i <j Pj`jhj<pj4+jj "j %j  "j j Pj" Hk , Xk 0xk (k %k "k "kl(l0l8l@lHlPlXl`lhlpl xllllllllllllll lmmmm m(m0m8m@mHm Pm pm-xmmmmmmm -mn 8 nXn &pnn nnn n"&n o @o Ho Xo ho poxo o o o o o p (p8p@p`p hp7xpppp p pp'p q (qv+8qqqqqqq r r  r8r!Prprxrrrrrrrrrsss s 48s 8ps!sssss t(t0tHt`tt "tttttt4"u Pu puxuu  uuu 4uu v v8v Pv hv xv v 4vv4,v2,xw:1 w`w B@bTw JIw x (x<A8x xx x Hx x<x 8y Hy /Xyxy*yy *yy(,y z (z8z@z Xzhz42z z zz z ({({H{`{x{{{{09{ | (|8| P|h| p|x||@| ||RT|_(+д(}P خND(+\L0} D}F}2D}F~2D(~"J`~,D~F~ 2D~$D$D8D`&DF,DF&D0 X"K`&V {*`.f ((@HPX`hpx ! {  ȁ P X p .Y.Z؂.Z 8@2RH (R(R Ѓ؃(Q,\84ph (4[Ȅ4\4\8 p2DF2R؅,R*R@ 3p <4+ " %  " "  , %( "8 "Hp ȇ Ї؇ (08@ H`hpx Ȉ ؈ -(08@` -  8 &  8H` x"&  Ȋ Њ    0 P p  (ȋ 7 (@ X hx'  v+Pk8@HPXp  !؍08PXpxȎЎ  "8 8`! ؏  @`h   Jؐ ( 4"H     Б   4(` x  В  4  P 0   Ъ ت `8 4(WxBtX,edMP0! H V`dNؔ HH 8 HNR`   & h  p "@ $ &@ (h 4  Г  Hȕ  ( 8Xp<x 8 Ж*( *0`(,x  ȗ 42 @ P V=h` h H 64( ` 0p N   (@` x .Ț Кؚ@  0RTP(`+Э  (8ND8(+pг HV_h(X+p H X h $8 \L DF(2DHF2D"J؜,DF0 2DP$D$DD؝&DF ,D@Fp&D О"K؞&V 0$M@h.fp(ȟП؟ ! ( H h P ؠ  .Y(.ZX.Z 2Rȡ (R(R( PX`x(Q,\4p ( 4[H4\4\ 2DF82RX,R*R 3 <4+(` "h %x  "  " ȥХإ $ \0 P >` (jx  Ц  ئ  ( 0 8 H X  `h px  "   ا (  ,8 >h Ȩ .Ш 0H X (Jh    Щ ة  6( 0 @ PXxPublic noaddedsheetsLast Modified 11 June 2004](]]]0 ~x] ]]] `(]h ]]] vector of coefficient estimates Needed:% (1) Run the regression [done]H (2) Obtain the residuals; call them e [handle multivariate case]3 (3) Obtain squared residuals; call them esq.? (4) Check on what to do if there is no intercept [to do] (1) a) Get the Y variables Run the regressionCOLSestimates = Application.WorksheetFunction.LinEst(Y(), x(), 0, 1) 2) X'X work Get X'XIf NumXVar < 15 Then> mycoefs = Application.WorksheetFunction.LinEst(Y, X, 0, 1) For intJ = 1 To NumXVar + 1< coefestmat(intJ, 1) = mycoefs(1, NumXVar + 2 - intJ) Next intJElse] | |`  | |   :A@ (X'X)-1 work Get (X'X)-1]h  !%'      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopstuxyz{|}~ Get estimates] | IMatMult XTransposeXInverseX, Nk, nobs, Nk, XTransposeXInverse, XTranspose | R $ R$ R+ RdX  |  |  A@k0  |   A@ R  R+  | R$ $ R $: R+  Rop ( 8 (endn (6$*An unexpected error has occurred. Bye now.A@Zor i !4A@Zs,2$x$Next icome6 Sheets(sheetstring).Cells(6 + i, 11) = predY(i, 1)1 Sheets(sheetstring).Cells(6 + i, 10) = phi(i)For i = 1 To nobsA:A$(0~Sheets(sheetstring).Cells(9 + 2 * Nk + 3, 1).Formula = "=Sumproduct(B9:B" & 8 + Nk & ",B" & 12 + Nk & ":B" & 11 + 2 * Nk & ")" S Put in sumproductSD |   $f,VMean |   $f,Vow f X Variable |   $f,VLLS' | $f,V****Number of X Variables $f,Vnterce R.Value R$ R |   $f,V**** R$ R |   $f,V $ R |   $f,Vand " Put the averages of the X's table R$ R  $f,V R$ R  $f,Vt st $ R  $f,V R . ' R |k '. |   $f,V |   $f,V Intercept |   $f,V8d '.$ |   $f,V$ |   $f,V$ |   $f,V | ~ the n] Next intJate Next intkI Sheets(sheetstring).Cells(8 + intJ, 7 + intk) = RSEsq(intJ, intk) For intk = 1 To Nk For intJ = 1 To Nk  Write out the VC matrix \B@v: qP9t r9p9n9l9j9h9f d9b `9^ \A9:C9$`B@H~$  $f,V$  $f,Vk$  $f,V* Testd` Intercept  $f,V| | ~   $f,V  R Squared $f,V  $f,V Iterations $f,V%Sheets(sheetstring).Cells(5, 2) = lnL  $f,V perSSR $f,V Robust SE  $f,VhuEstimate  $f,VVariable  $f,V Coefficient Estimates  $f,V  $f,VMean of Dep Var $f,V     $f,VMissing observations  $f,V  $f,V Number of observations $f,V |<Logit Non Linear Least Squares Results; Dependent Variable:  $f,V**k'h2This is probably a case of perfect classification. $f,Vit \!:(<ue  $f,Vis pD5:D7$`B@HoaConvergence not achieved. $f,Vou   'h  (:End If  GoTo skip:d MsgBox "Something has gone wrong. The routine is adding too many worksheets. We will stop now."duals If noaddedsheets > 4 Then!noaddedsheets = noaddedsheets + 1 N!v.E Use application.value function to convert text to a numerical value.'  A, Add the new sheet & $ ('* R$ '(  '& '$ R$  '  R$ " ' R '('&'$  ' Rient v  R$ ' R  ']]`x0ch]termin! we know ymean; we need F(i) mean Compute pseudo R2 k  $$0 +d +du  $ ct  |an add |term.]  with dimensions Nobs x Nobs< I don't compute the P matrix because it can get too large, by (1-ht).U Davidson and MacKinnon (553-54) say that Stata's correction is inferior to dividingr sm< Stata uses a much simpler correction namely sqrt(N/(N-K)).s to t1 which is a name reflecting the definition of P.C X. In this module, we denote P by XXTransposeXInverseXTranspose,K because it projects orthogonally onto the space spanned by the columns of' This hat matrix is sometimes called P. the t'th diagonal entry in the "hat matrix". + by (1- ht) where ht is the square root of 9 in which one divides the estimate of the standard errorT Davidson and MacKinnon textbook (1993) p. 553 recommends using a correction factorE Now get the robust standard errors, square roots of diagonal entriestandk  | | |  A@t dh$$+ |4 phiXTransposephiXInverseS0 | |x$:]) Form the RSE = X'X -1 S0 X'X - 1 matrix.k  | | |  A@dh$$+ | | |8]$ Form the NOBS * X'X -1 S0 matrix.e $ '  , "better approach" (p. 553) implemented here ) robust SE using Davidson and MacKinnon's  $'ient v(WS0(intJ, intk) = phiX(intI, intJ) * phiX(intI, intk) * esq(intI) + store '* esqht(intI)1  $  $ $   +))  '  |  |** | |8' ]@]x  H $ $  +  +9 VecMatVecMult temph, Nk, phixt, phiXTransposephiXInversekx  |  A@6dX $$$'53 |ch  by (1  $ +  |I'th r  verse |nspose]]* and the transpose of the intI'th row of X9 to get ht, multiply the intI'th row of X into X'XInverse esq by (1-ht)@ First , following Davidson and MacKinnnon, p. 553, divide each* It has the same dimensions as XTransposeX Get S0 matrixrans  !%']  | |   A@  | | 8 ]@    ' H]x *** |k ' 8!!d R + Ff = (phi(i) ^ 2) / (F(i) * (1 - F(i)))  2 F(i) = Exp(predY(i)) / (1 + Exp(predY(i))) I, int R $  R+qht( R$ R $: R +&gradient vectorn  |0 R$ $  R+  R$ '  R$ '  R$   '' tss added here R$ R+ R$ R$ R+ $ $  R+(not yet equipped to handle no intercept!0 trix.  $ R $: '  | ' R nverse''']  1 get the gradient vector (phiX) and the residualsD Compute the variance covariance matrix using robust standard errors diagoX  ' Rvidson nnon t R $  R+ends R$ R $: R +&gradient vectorhe  |tandar R$ $  R+ R$ R$ R+ $ $  R+(not yet equipped to handle no intercept! cause  $ R $: '  |umns o' R s modu4Step 2: Compute residuals using values of b0 and b1.0^Step 6: Add the computed coefficients to the previous values of b0 and b1 and return to Step 2 nam^Step 5: Check for convergence (small values for changes in b0 and b1 or small changes in SSR).ior g $ $ +n't  $ 't  |'  | ~$$$$ $Az aStep 4: Regress the residuals on the gradient vector;do not include an additional intercept term.    '' 'pute p Compute gradient vectorwe] 0changetol is tolerance to determine when to stop R   R $  R+ R$ R $: R +&gradient vector  | R$ $  R+ R$ R$ R+ $ $  R+(not yet equipped to handle no intercept!et ,  $ R $: '  | numer' R .Step 3: Compute gradient vector14Step 2: Compute residuals using values of b0 and b1.g has ] the index for computing logitwork' Get the predicted y's  | ~$$:$$ $Az  first round estimatesri   4) 'h | | ,VkD At this point all the data is loaded and we call the routine to getable: 2Step 1: Begin with starting values for b0 and b1.7 At this point we put in the Gauss Newton NLLS material-Here's where the Logit stuff must begin ***** | |8 ,V$: | $$A |X ]`  | ]  | $ |8 le  | `    | # gradient vector  '   $ '  f,'kkF'hkThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@Z   (X'X)-1 work  | J A' R R R+J R |  |J ]  | |   :A@ | ]  | | ]( ! *** Test for invertibility herek  r  $:  +  $  +:ix  ~ = 1 T   Fo ~'|d@  Sh stringk  $:  +intJ   $  +:d  +|  +:(   ~  Y(intI, 1) = ytemp(intI, 1)   1 Nk tells us the number of parameters to estimate ~ '| 8!!d,V     : | k ~'dx ~ ' 8!!d] ]   ] ]8 P ]h ] ] ]   R  $f] Xrages ]`  ] robust std error stuff  , 1 To 1)  0  P  Y, X and X' loading]X]p]]]]4 *************** Intercept Issue **************** | EIf RegForm.InterceptCheckBox.Value = False Then NumXVar = NumXVar - 1, ****************************************** LogitNLLS' ']H7 Lots of other vectors to follow for Robust Std Errors.Nk]`] gradient vector stuff:] SSR= Sum of Squared Residualsobs]]]8]p] coefficent matrix]]]0]h]]]]H]`]x]]]]]]] ]8]P]h]]]] (o @]]]]]] T |': R  : R T$: ': R :  T+ Second pass to get the SD T '>'@ R  R T$: T$ '< < > '> < < @ '@ R @ > >    '@2SD Corrected two-pass formula. @$0 T+d@ T+k( ToISub ProbitNLLSroutine(ByVal SelXRange As Range, ByVal SelYRange As Range)05  ( (+ Gradient vector is phi(1 to nobs, 1 to nk) Data comes from the RegForm]]]]]]0]H]`]x]]]]]]] ]8]P]]]]0]h] coefficent matrix]]](]`]] SSR= Sum of Squared Residuals gradient vector stuff:]]7 Lots of other vectors to follow for Robust Std Errors.EIf RegForm.InterceptCheckBox.Value = False Then NumXVar = NumXVar - 14 *************** Intercept Issue ****************]8]p]]]] Y, X and X' loading]( 8!!d ~ 'dp ~'k`  :`   8!!d ~ '|1 Nk tells us the number of parameters to estimate   Y(intI, 1) = ytemp(intI, 1)  |   +:  +d    $  +:  $:  +k  d ~'|    ~  $  +:  $:  +  k! *** Test for invertibility here] | |] |  | |   :A@] |JX R | R R+J R'  | J A (X'X)-1 work kThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@Z'hFk'    $ '   ' x   , 1 To 1) robust std error stuff]  ]  p ]x     ] ]!] !]8!]P!h!]! !]!.If RegForm.InterceptCheckBox.Value = True Then' Intercept Issue *******************  |"# gradient vector | 8"1 Nk tells us the number of parameters to estimate |`" |"]" |"]" |8#$: | $$AElse Nk = NumXVarReDim X(1 To nobs, 1 To Nk)$ReDim XTranspose(1 To Nk, 1 To nobs)0ReDim phiX(1 To nobs, 1 To Nk) ' gradient vector'ReDim phiXTranspose(1 To Nk, 1 To nobs) For intI = 1 To nobs# Y(intI, 1) = ytemp(intI, 1) For intJ = 1 To NumXVar1 X(intI, intJ) = xtemp(intI, intJ)6 XTranspose(intJ, intI) = X(intI, intJ) Next intJ Next intIEnd If | |`# | |#.Here's where the Probit stuff must begin *****7 At this point we put in the Gauss Newton NLLS material2Step 1: Begin with starting values for b0 and b1.D At this point all the data is loaded and we call the routine to get first round estimates  | ~$$:$$ $Az  Get the predicted y's' \!:(<lo4Step 2: Compute residuals using values of b0 and b1.Step 3: Compute gradient vector R '  |  $ R $: ' (not yet equipped to handle no intercept! Need to install probit here  !%B R+!resids(i, 1) = Y(i, 1) - predY(i)  !%B R+  | R$ R $: R +&gradient vector R $  R+  R]#0changetol is tolerance to determine when to stop Compute gradient vector '''   d aStep 4: Regress the residuals on the gradient vector;do not include an additional intercept term.  | ~$$$$ $Az '  |  $ ' $ $ + ^Step 5: Check for convergence (small values for changes in b0 and b1 or small changes in SSR).^Step 6: Add the computed coefficients to the previous values of b0 and b1 and return to Step 24Step 2: Compute residuals using values of b0 and b1. R '  |  $ R $: ' (not yet equipped to handle no intercept!  !%B'` ` R+%'h  !%B R+  | R$ R $: R +&gradient vector R $  R+  R  '(1D Compute the variance covariance matrix using robust standard errors1 get the gradient vector (phiX) and the residuals]##''' R '  |  $ R $: ' (not yet equipped to handle no intercept! R$% ` R+R d ` R+  !%B R+ R$ R+  R$   '' tss added here  R$ '  R$ '  | R$ R $: R +&gradient vector R $  R+ 3check.Cells(i + (numiter * nobs + 2), 9) = indexval!% Next k ****** (1]p R 8!!d 'k-]#***   ' ]$ | | `$ |+  R $  R$ R$ +  Rd,  | |   A@k,]h$  !%' Get S0 matrix* It has the same dimensions as XTransposeX@ First , following Davidson and MacKinnnon, p. 553, divide each esq by (1-ht)9 to get ht, multiply the intI'th row of X into X'XInverse* and the transpose of the intI'th row of X]$]$ |$    |  $ + ; VecMatVecMult temph, Nk, phixt, phiXTransposephiXInverse |$$$'d@*  |  A@6k *  + $ $  + ]$]% | |`%  |  |'    $  $ $   +(WS0(intJ, intk) = phiX(intI, intJ) * phiX(intI, intk) * esq(intI) + store '* esqht(intI)  $') robust SE using Davidson and MacKinnon's, "better approach" (p. 553) implemented here   $ Form the NOBS * X'X -1 S0 matrix.]h% | |% |$$+dp'  | | |  A@kH') Form the RSE = X'X -1 S0 X'X - 1 matrix.]% | | &4 phiXTransposephiXInverseS0 |$$+dp&  | | |  A@kH&E Now get the robust standard errors, square roots of diagonal entriesT Davidson and MacKinnon textbook (1993) p. 553 recommends using a correction factor9 in which one divides the estimate of the standard error+ by (1- ht) where ht is the square root of. the t'th diagonal entry in the "hat matrix".' This hat matrix is sometimes called PK because it projects orthogonally onto the space spanned by the columns ofC X. In this module, we denote P by XXTransposeXInverseXTranspose,1 which is a name reflecting the definition of P.< Stata uses a much simpler correction namely sqrt(N/(N-K)).U Davidson and MacKinnon (553-54) say that Stata's correction is inferior to dividing by (1-ht).< I don't compute the P matrix because it can get too large, with dimensions Nobs x Nobs](& |x&  |  $$0 + ]& ' ProbitNLLS'  A, N!v.  ( Compute pseudo R2! we know ymean; we need F(i) mean]&&&&]&'(']@'' R   R$ ' R  ''$'&'( R  R$ " ' R$  '  '$  '& '( R & $ ('*Convergence not achieved. $f,V'h=Probit Non Linear Least Squares Results; Dependent Variable:  $f,VNumber of observations $f,V  $f,VMissing observations  $f,V    $f,VMean of Dep Var $f,V  $f,VCoefficient Estimates  $f,VVariable  $f,VEstimate  $f,V Robust SE  $f,VSSR $f,V  $f,V%Sheets(sheetstring).Cells(5, 2) = lnL Iterations $f,V  $f,V R Squared $f,V  $f,V | ~  Intercept  $f,VdP$  $f,Vk $  $f,V$  $f,VA9:C9$`B@H \ `9^ d9b9f9h9j9l9n r9p9tq` \B@v Write out the VC matrix For intJ = 1 To Nk For intk = 1 To NkI Sheets(sheetstring).Cells(8 + intJ, 7 + intk) = RSEsq(intJ, intk) Next intk Next intJ]X' | ~ $ |   $f,V$ |   $f,V$ |   $f,V'.d Intercept |   $f,V |   $f,V |   $f,V'.k R | R . ' $ R  $f,V R$ R  $f,V R$ R  $f,V" Put the averages of the X's table $ R |   $f,V R$ R |   $f,V R$ R |   $f,V RNumber of X Variables $f,V | $f,V X Variable |   $f,VMean |   $f,VSD |   $f,V Put in sumproduct~Sheets(sheetstring).Cells(9 + 2 * Nk + 3, 1).Formula = "=Sumproduct(B9:B" & 8 + Nk & ",B" & 12 + Nk & ":B" & 11 + 2 * Nk & ")"A:A$(0For i = 1 To nobs1 Sheets(sheetstring).Cells(6 + i, 10) = phi(i)6 Sheets(sheetstring).Cells(6 + i, 11) = predY(i, 1)Next i820 !4A@Z*An unexpected error has occurred. Bye now.A@Z (6 8 ( (oISub MatrixWorkLogitML(ByVal SelXRange As Range, ByVal SelYRange As Range)'hOn Error GoTo endnow) The other version uses the EM algorithm;! This version uses Max Likelihood  ( ( Data comes from the RegForm]()] )]@)]`)]x)])])])])])]*] *]8*]P*]h*]*]*]*]*] +]X+]+]+]+], coefficent matrix]0,]h,],],],](-]@-]x-]-]- Y, X and X' loading]- 8!!d ~ 'd ~'k  :.  @. 8!!d ~ '|1 Nk tells us the number of parameters to estimate   Y(intI, 1) = ytemp(intI, 1)  |   +:  +d   $  +:  $:  +kX  d0 ~'|    ~  $  +:  $:  +  k! *** Test for invertibility here]H. | |.]. |  | |   :A@]. |J/ R | R R+J R'  | J A (X'X)-1 work kThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@Z'hFk '    $ '   ' 0/ P/ x/]/ / /]/ H0]P0 0]0]0]0]0]1 1]81 1.If RegForm.InterceptCheckBox.Value = True Then1 Nk tells us the number of parameters to estimate |1]1 |2]2 |`2$: | $$A]h2 |F2]2**** | |H3] 3ReDim HInv(1 To Nk, 1 To Nk)]83 |L3]3 | |3 | |3  | ~$$:$$ $Az  Get the predicted y's''' :0yE>  '  '. Initialize the dlnL vector and Hessian matrix R | R+F T |  | T +H  T R. Computing dlnLdbeta vector and Hessian matrix R  R$$ R$$  R+ R$$ R$$  R+  | R$$ R$$ '`+F T | R$ R T$: R $: T $H T +H T  R$ R$ R$$ $P 'N  N ' RA To compute the next step, use matrix times vector multiplication Invert Hessian H !%'J2VC = Application.WorksheetFunction.MInverse(VCinv) |$J$F+Ld L | | F JA@k#Sub MatVecMult(outcome, k, n, X, M)  | $ $L +    ' ' R  R+  | R$ $ R $: R+  R Compute the pseudo R^2! we know ymean; we need F(i) mean]4(4@4X4]p444]444' |= 1 DiagnosticmeanF 'R   $P'T R  R$ T T$ $P 'N R N 'R R  R '* Put down results]5'LogitML'  A, N!v.  ( :0yE> /Convergence not achieved. Last Change in LnL =  $f,Vk9Logit Maximum Likelihood Results For Dependent Variable:  $f,VlnL $f,V  $f,VNumber of observations $f,V  $f,VMissing observations  $f,V    $f,VMean of Dep Var $f,V  $f,VCoefficient Estimates  $f,VVariable  $f,VEstimate  $f,VSE  $f,V Iterations $f,V  $f,VPseudo R Squared $f,V * $f,V | ~  Intercept  $f,Vd}$  $f,Vk}$  $f,V$J$0  $f,Vd|$J$0  $f,Vk|A9:C9$`B@H \ `9^ d9b9f9h9j9l9n r9p9tq0| \B@v Write out the VC matrix For intJ = 1 To Nk For intk = 1 To NkI Sheets(sheetstring).Cells(8 + intJ, 7 + intk) = RSEsq(intJ, intk) Next intk Next intJ]5 | ~ $ |   $f,V$ |   $f,V$ |   $f,V'.dz Intercept |   $f,V |   $f,V |   $f,V'.ky R | R . ' $ R  $f,V R$ R  $f,V R R$J$0 R  $f,V" Put the averages of the X's table $ R |   $f,V R$ R |   $f,V R$ R |   $f,V RNumber of X Variables $f,V | $f,V X Variable |   $f,VMean |   $f,VSD |   $f,VA:A$(08w20w !4A@Z*An unexpected error has occurred. Bye now.A@Zv (6 8 ( (ovp'  ( ( Data comes from the RegForm]66]6]7] 7]87]P7]h7]7]7]7]7]7]7]8](8]@8]X8]p8]8]8]9]P9]9]9]9]9 coefficent matrix]:]@:]x:]:]:];];]0;]h;];];];]<] <8< Y, X and X' loading]P< 8!!d ~ 'dt ~'kt  :<  < 8!!d ~ '|1 Nk tells us the number of parameters to estimate   Y(intI, 1) = ytemp(intI, 1)  |   +:  +d@s   $  +:  $:  +kr  dr ~'|    ~  $  +:  $:  +  k(r! *** Test for invertibility here]< | |=]= |  | |   :A@]0= |J= R | R R+J R'  | J A (X'X)-1 work kThere is perfect or near-perfect multicollinearity in the independent variables. Thus the regression fails.A@ZFkxpkpp'    $ '   ' = = =]= @> `>]h> >]> ?]?]0?]H?]`?]x??]?]?]@]P@]h@]@ @ | |H@ |LA |F8AReDim HInv(1 To Nk, 1 To Nk)1 Nk tells us the number of parameters to estimate |`A]hA |A]A |B$: | $$A]B | |PB | |xB]B ^B]B 4(CDim RSE() As DoubleReDim RSE(1 To Nk)D At this point all the data is loaded and we call the routine to get first round estimates  | ~$$:$$ $Az  Get the predicted y's'd'' Create new y's (1) phi vector :0yE>  '  '. Initialize the dlnL vector and Hessian matrix R | R+F T |  | T +H  T R. Computing dlnLdbeta vector and Hessian matrix R ]ZZZZZ End If R$ !%B R+ If F(i) = 1 ThenIf yfi End Ifkk'h' We must abort d R$^ R$^ R$  R+4  |  R$ R$$P  R$  `$P 'i, changelnL = 0.000000001 T | R$4 R T$: R $: T $H T +H T  R$G R$ !%B R+j  End If RA To compute the next step, use matrix times vector multiplication Invert Hessian |HInv(1) = 1 / H(1, 1)$H'\d@g H !%'Jk g2VC = Application.WorksheetFunction.MInverse(VCinv) | \$F+Ldf L | | F JA@kf#Sub MatVecMult(outcome, k, n, X, M)  | $ $L +    ' ' R  R+  | R$ $ R $: R+  RPe Compute the pseudo R^2'R theBF(i) = Application.WorksheetFunction.NormDist(yfit(i), 0, 1, True) $P'X  $P'Z R  R$ X R$  Z 'N R N 'R)Y(i, 1) * yfit(i) - Log(1 + Exp(yfit(i)))H lnL = lnL + Y(i, 1) * Log(F(i)) + (1 - Y(i, 1)) * Log(1 - F(i)) R  R '*! we know ymean; we need F(i) mean]0CHC`CxC]CCC Work out pseudo R2 here' Compute the variance covariance matrix]C'ProbitML'  A, N!v.  ( Put down results :0yE> If abortedhigh = 1 ThenLa Range("D7").SelectEnd If,V'tkb:Probit Maximum Likelihood Results for Dependent Variable:  $f,VlnL $f,V  $f,VNumber of observations $f,V  $f,VMissing observations  $f,V    $f,VMean of Dep Var $f,V  $f,VCoefficient Estimates  $f,VVariable  $f,VEstimate  $f,VSE  $f,V Iterations $f,V  $f,VPseudo R Squared $f,V * $f,V | ~  Intercept  $f,Vd^$  $f,Vk^$  $f,V | \$0  $f,VdH^$J$0  $f,Vk^A9:C9$`B@H \ `9^ d9b9f9h9j9l9n r9p9tq] \B@v Write out the VC matrix For intJ = 1 To Nk For intk = 1 To NkI Sheets(sheetstring).Cells(8 + intJ, 7 + intk) = RSEsq(intJ, intk) Next intk Next intJ]C | ~ $ |   $f,V$ |   $f,V$ |   $f,V'.d[ Intercept |   $f,V |   $f,V |   $f,V'.kX[ R | R . ' $ R  $f,V R$ R  $f,V R R$J$0 R  $f,V" Put the averages of the X's table $ R |   $f,V R$ R |   $f,V R$ R |   $f,V RNumber of X Variables $f,V | $f,V X Variable |   $f,VMean |   $f,VSD |   $f,VA:A$(0X2X !4A@Z*An unexpected error has occurred. Bye now.A@ZPX (6 8 ( (oXD]D]D]D]D]E](E]@E]XEpE f!r'` `bE n ` n$f! $  j 'j n$f!'l n$f! l  $p j+bkW n'f j 'd'h f n j n$b dX  d 'd'hkV n h'f'hdHV'fk8V0V j  d'kVoVE Dim n As LongDim np As Long!Dim a(1 To np, 1 To np) As DoubleDim p(1 To n) As Double%Calling: choldc weights, nvar, np, r8 This routine is designed to test for multicollinearity]hF]F]F]F]F(Set mysheet = Worksheets("CholeskyTest") R * T * R T$F'L R '  L R $F T $F 'L  'T R T LHz> 'PSkS L$0 R+JdS L R$J T R+FkS T RP`SoXS abortedhigh = 1 GoTo endthis:t'h'h New material''B End revised B  kk]'tkcutoff = 10 ^ -7  E> D6$`B@Hrfectl \!:(<ao d If& .>' At least 6 observations predicted perfectly. Estimation aborted.A@Z  |ion ab'hkcutoff2 = cutoff / 10This is the revised sectionT \!:(<P MsgBox "The model likely predicts success (dep var = 1) perfectly for some observations. Thus, estimation is being shut down."trap If Abs(yfit(i)) > 6.3 Then perfprob = perfprob + 1la! If Abs(yfit(i)) > 20 Then  !%B'`D7$`B@Hf, \!:(<On Error Resume Next 'Error!n]0U'X&On Error Resume Next '****** Error!!!!trap R$ d At least $ observations completely determined. $f,V t $L 't-- t{Gz? wn.D7$`B@HV&On Error Resume Next '***** Error fix Selection.Font.Bold = Truees sD8$`B@H$f ` R+  !%B'`'` R$ !%B'` ` R+k- extraperfprob = extraperfprob + 1lnL ` R+ R$ R$ R$ R$  R$ `  R+^. Avoid problems when F is too close to 0 or 1: "Th  |!%'h R$ 0 ` R+ ` R+kP dlnL(k) = dlnL(k) + ((Y(i, 1) - F(i)) / (F(i) * (1 - F(i)))) * phi(i) * X(i, k) $F R$ R$  R$ ` R$ R $: +F  !%B R+) R$ R$ R+ Here is the old material *****ue *****(  !%B R+ ` R+]X[p[%the index for computing logit Data comes from the RegFormfect c  (n.*****2This is probably a case of perfect classification. $f,V t $L 'tHk* Trying to figure out what is going wrong: Write out the results  t{Gz? /Convergence not achieved. Last Change in LnL =  $f,V \!:(<caD6$`B@Hsifica \!:(<Q Sheets(sheetstring).Cells(7, 4) = "Estimation aborted--last estimates shown."1WARNING: This is a case of perfect classification $f,V1WARNING: This is a case of perfect classification $f,VP]@XnL $F R$ ` R$  `   R $: +F+ Gradient vector is phi(1 to nobs, 1 to nk)VbCall RunReg(nobs, Nk, Numxvar, phiXTranspose(), phiX(), resids(), changecoefestmat(), lnL, yfit()) This is a diganostic section ver End Diagnostic SectionR PNLLSCheck$f. D5:D7$`B@H R$ R$ R+$ End diagnostic material *********** For k = 1 To Nk %This is diagnostic material ********* R1 Here is the old material NOT COMMENTED OUT *****5check.Cells(i + numiter * nobs + 2, 8) = resids(i, 1)inde< check.Cells(numiter, k + 9) = changecoefestmat(k, 1) ,5check.Cells(i + (numiter * nobs + 2), k) = phiX(i, k)EOn Error GoTo endnowter * <dlnL(k) = dlnL(k) + (Y(i, 1) - F(i)) * X(i, k) ' Old version< pFowter * <dlnL(k) = dlnL(k) + (Y(i, 1) - F(i)) * X(i, k) ' Old version< Feck.Cells(numiter, k + 9) = changecoefestmat(k, 1) ,5check.Cells(i + (numiter * nobs + 2), k) = phiX(i, k)EEedY(i) = Application.WorksheetFunction.NormDist(indexval, 0, 1, True)HEz???V??????????????????????????????????? s>>ƕģ? M4y?Q؎>[*% ?+a?g<6^u?z P?pxj?kZ:>!pV> ?JT$?`?hI? Ճ8ř>_~>C,{>HZ??"\O>ݖ`>kNu>9lx?]u^P ?%e~>>fLg?n/i?@>Hξ }?Z.~?ݺQ ?PX?JM?C֔~>9= qH?*??ۦ?9v?|E?+j0 ?\_mXR?ErC?#c?SPF? !?<(@?FQ{Z᧻?k] e?0<dƔu#_>ayz?Hk7^?Z1?I?m0:PX;"w:? 2=Hg-h>w>f녧?k]!=E)=x9=*6u!+?:ps_ ?DR ;Dكrـ;2@ߵl=d!e? U(`>%<mv=Se?>_2?f-;,:Ggqk?$n?UT>Г.?Nwx?,ӯ5<A>#?& .Q>C3?UPׂ?Q{?m)?&@<?*??㝍??xkO? !?w6H?wa?$?Vs??éŖ???q0@G?5?BI7x??O???lGG?qAttribute VB_Name = "ProbitAndLogit" Option Explicit 'Pub( noaddedsheets,Last Modified 11 June 2004 Sub RunReg(nobs As Long, nk NumxvarXTranspose()Doye, X Y coefestmat lnLQ Dyfi )aCallS, NkK, phi I(), residschan$ge A, <, S72 4Orror ResuNext ' E !Dim iW Å9i Re 1 Tobs: esq  intLtemphAh P@ߍ @S "JGA storeMmyA\Varian! vec of Af@entj ieb Nee: (1) theugSs [done] 2) Obtain uals; cAm e [dle multi@iacas3squarGpsq. 4) Check what to do if$Iis rercept [0 :a) Ge`Y bl##a!a vE!OLS(Appa .WorkBFunc"LinEsDt(t, xad0, 1`R' 2 X'X w`aa' If `X@; < 15 Then%?= ,  Fp@$JO + 1D H aρ(1b+ 2 -a.J"`B{ Else  aAh牊Czcd(! MatML Ad?f` ' (-)-10 #!1$LInversspah6M(h/P=+XX(,@',',%@A@3#i0[= "[%RR GO , i)o|*(BUi)) v$np End Ifu=5304C/X, Y/4u0 qkkC1>+a= _(i, k)01 0ÍҒNLLSroutine(lj@ m"͏Y4Label1SX0Z.lAenrowxabortBoolean 'FGoendnow𝯈t '2* IUcuLla1]xlM anjScre enUpdngFqOQUGradix$zj@7j5S 1lnA1' Datames from"iФmmissip=TPHJnewijsL|noqBsBss\_I!W`IOJlRowUsTmystart tcolumnn yPm oǻ4=i.6(SoldbetaVCinvoVC3Ffq cCq' p'|rixt  #+ p@zɓSSR@J' = Shum S`idQ g3stuff)nUv;'tso rDs7follow faobuStd 2spnPlengt33.8= 9 2R+' * s?0.Int㭢Box.ValuF벢֣=-|a Iss*!wjO#rmC$?l bjbym?[&c#)S' Yw awX' ~lQ8Ío{bs) ReDim resids(1 To nobs, P1 predY|) '' robust std erroruff esq() As Doub|le,og*ht)( H]5_#8phih !Wivar2Longchange eC A@ g/7Au.nk= 5' Nk tells us the Sbtof p`arameNo estimat@V intIF 'Y(-)ytempY J %; FjIX jWA ,?. G<) @Bls - AIaw G"aEGaaNhextJI: :3c /a=QEntJ7! 'j@K*** TP f@invertibility0 herSXTXA Dr@Vkj.k! lBopoleaP,>FPMatMult , n bcg , X* p=p%3%cnk2 iVi#C'cÚ Call chct&(&p_'le' (X'X)-1 xwor BnFa ǤMsg " re is perfect 2near-m#icolli4inbindepent dia s.@ dreg`sion fails."abort #Go`skip:GEh ym70 d^ CEs+ K )7k>/3%pt^nk0 gradiePor]_q$6UcoefPX"+׉za(xA(#1sdm x`&F@XMSD(7410,b)ՏVCp+  OfH?'s wÁ?"%Logi mQbeg&0C**1' At*o0` we puUGauss Newt 'NLLS nrialStep 1: B"witheaGng+s!"Ib0 a[b1.@8udata!3loaded crout2 to getafir p"xs=RunRe|g(a#TtPG7%)(@YA! `, yfi@' Ge!`i@C0d y'= ?04!;p ' rcom:ilAP 2: CeAqrvs 0:b3g~4R&56 R 1>4+c+ hab) * p, ZbAtY'not yequi\pp@d0dno{er!C#ria\Ex\@P) / .+ JP{A ti7tA8U< 25-4: 8qk?"EB2. E2L ;dAHclude@@ addit@oalg# LqVo?c,>ps@b.{@qP?"Q03  1)2S*5=/7(S8z'BB5@BGgen"(smUF+ s Fd b1 or small changes in SSR). 'Step 6: Add the computed efficients to8previous valuof b0 an return\B22: CX residuals usingJ Fi = 1 To nobs  dex0+:k+k) *in+lestmat(k, 1) * X(i, k)Next "'not yet equippcdleJ0tercept!AdY(i)FExp(:) / (1 + 7fs@E= J- &-hi,1)phi:(? 'gradA| vectorCAR TransposeM8AQNBPiGnumiJE+ 1 Wepnd AvariancjrixDrob@ust st@ard errorq' gj1 :(*) Dim tss As Doubl@e, ysq -@ = AYͨK AOoc ? ?l)Te]=esqTy Z^ a '+ (\ymeanD)  'B1addlhere {-+c 3+ >e bkR' aoh, N4ose0ht `%D- ` EI 1 n{LongPAS0C!d! C JF"x`_QO#psГeߠXI( 'J'Qm"JE#'k!I+`ot[O"?3O0$ '*y%+eK1BDSED/KK'b"betapp4roK"L) impleQ'y%xeX %JY 'EࣀX NOBSq'X -1 [[.s)o7seooA, OG# l0N G gGv 8wBjx,_0(R =d e -qpsШobƘY  O:Rv*;(1QP2 sposephiXInverseS0, pTra"n End If ' Now get the robust standard errors, squar), ^ π1!*  %&$=  ` / F * #)A 4dn'(MsgBox " S!hhas e wrong` tuti ddtmanHy w Wi$llopDw.&"@ Goskip:epe.+b)9 abortFa? change > tolhD2s().Cel@ls(5, X= "Cgen0ie achiev,ed 1R("D5:D7").Sed# 63 V.Fon@t.Bold TruTL7 xc`vbabgaC&kperfm classif&0A eyO_U17Log@}N0L`ar Lea PSqAs Results; D ep Vari e: " & YLabel_242Numbv` Eerv3s   2bCIq3Mi t umxrows J_@4VPcQ0tP B9uCoef iQEԤe1_`W /  "e// вPRslabel(1(=2=xmean-93sdn= 1 Else/b"Intercept" *b;(|_02^End If For i{2 Toj ii=- A` )0jii_j7coefestmxat(%:(i' Put the averages ofX's tablm%h68á)r 8xG6d"berA@X Varia sP[Bn };}bu5%  ">M@u#"SD#@in sumproductC%'952 *X NkB.`cmulac"=S& (B9:B" & & ",12 Bd )  Columns("A: A"Widthaq2A'Es@sobsw6f0phia`(ABpredYEo' LGo`skip endnow: MsgBox Err.Descriptio"An unexpected errha qccur . Bye ` ."a ` Applica .Display@Alerts`"T ruv)Calc'3xlAudto`ic(iScreenUpd9 ng Sub FindXPSD(X()Dou,d`2%, #{ou!iejaaCs ep-{IGj@GDx = Ta?&byGQ7+ X!j@ H(jQ'/+' SeDcofpasWo geYSD0 j >fwqv  a#1 -j) 1Rs3e-Eq=s A; K(- *A#) / (nq"t) 'SD?C0b1two-BftorF.'#SqrT GqF;E} jZ-C-ProbitNLLSroutine( ByVallX`Range$,:Y{ 0Y3 3%4Y-LQS", genrowr1, abortBooldp LOnJGRe`ey _D2G2ZDM`anualDFabYGradi`ent v@O0is 1X1 t[q3Th a diganostpic sbTaBcheck WorkI3s= 4]T"PC" ' Q Diag471R 1' Dat a compfrDomReg4mFmissT0iant newB  shOA»QR@I!/A @IOJJ[lastRowUsi'mysptart%+tcoz`qyPm storr6]PQ3#yfit_oldbetaVCinvoVC3Ffq Y ?C. fic.vrix t #chFu2CDBn!{8SSR QgSR p2umSquae @id=g<;stuff!& XTranspose;' kort@"of@ollow p^ Robust StdIsP_'@p]8.f=.Xue0JG"1X @ϠT@f *  Issue * Dim XTranspose() As @Doublelrhmse LX LPe0sids 2ymean G4cha@ngelnL  ' Y, X and X' l@oadingLactualnum xvars:LoIf DDVGNForm.InterceptCheckBox.Val= TrThen #&= N, + 1 ElsRIf Re(1 To nobs, 0~)# /n\nk j' Nk tells us the Sber of parameNo estimat@V in|tIB,'j@Y(-)ytempYA"Jk8@hAXD A@hHA ,B, GvI  ls - 1c K;ENext+J ͅIq+ r dA\[=G-7ibJ TO for"vertibility her$RO× dqTXqkMik!in lBBoolBm,>wPMatMult`X, n bb|g?@* pkpE$"4Qb@hV~ic 'cCall choldct '(XTpA3e' (X'X)-1 worqpf"= Fa gMsg "re is perfect 4near-m%icolli6inindepent dias. regression fails."abort'%Go skxip:cEk= 0 alA + G /@t /At#Nyfit;C@-㦦QApre$dY 'H' robust s@td err -stuf@Mesq?KM#  htm Pxzphi3i 7{!Sm ii`hj,Z /LF?m F ak'p0Reg"mJ Ö Mq"&IDCk) 'h gre15orS-WH}m}t}coefC uS**xm 3!xsd`KMFCXM`ZS )@nE < 'Step 4: ReFgr+he uu\ on tL%;d^ot include an addial@@%cept m. OCal l Run(nobs,n, Numr, [a)(#sAC4coefestmatlnL, yfi'Th@]diagno stic erzi&*\N w'check.Cells(ńL,@+ 9N"}1>' E^**$ 8@3v]+ N5 G5:$ C!% frconvergen](sm= uesbesC b0@Fd b1 aSSR)F 6: AddPcCddBficaykvious $of a/returYo "^" 2 do^usingQ  a2i@4 Y ##7 @ /g[7Ɨ IK'not yet equippe$o `,d`no p!pCG ˟1@Dȿο*ӳAY' Here #}old|NOT COMMENTED OUT ~ G*''~ya%to figu ou t`aTs gowrong:ItWr]  )u8lts# fIi + J * U2SJ%(`, 8N0 Z/|ωω/|l T/|/|/|-|/  $g7/`?7r 1= +Wend73}vah!RcoCjrix cGrobust st`Kard error' Nx4 ( )2U"idc{Ctssrsq V0fa= yNrJBkP_N`+ e_N3_NtPNMϳij2 - M+?@$?yM"Ma\89>?0LIIT/n.ï@ esqsEJ|^ dc)QpN y`mean)э 0ph@ac,Q+VS/Q+C,06Id+ şdlEc/ EtDDVGN 0m.In|Box.Value'BU݁= @ 1aqrsquarealt?p Q-- (a/1 &)YDRehi|X(TA^TnDC4`11iIcQr +<P_*Rq=MatMoykn@Pyзs, phiXTranspose End If,Dim Inverse As Vari8antX P= Application.WorksheetFun*cMQ(A)   ' Get S0 matrixo' It has the same dimensas X-0First , following Davidson ayMacKinnnon. 553 , *e each!esq by (1-htN@' to gMht, multiplyIintI'th row of X o X'Xu ':=_tÁ  AtemphD`ouble xt() Re 1 To nk ForCI = obs@5|DkFk$k)h(',C NextB'VecMatA@F /, NkxLT>gFAIf0&henE=*p1) *H(EFEHElsTR0ne0 /ChtRAU0C@@ / - w/[I@A}nnkLong@ S0 %D $D,DB%:aBJC/Hc a'(Gastore@ 0KA SiOJ߄O ;"$BJ?GɠV* *+ "{m '#N") D '*3$!robuSE uson'@z' "better appro " (p.a) imple@ted her^ Jo"hEJ@9m NOBS@q@ -1a.S7`*{ Yx1aeALJ@M ,g,`&d $[',RA=D,- y -'-sq5?"\1?V4\Sd>g@ose&(\Ut 2seS0"i%P' N|'az9stard errorsquaNroots!}diago@nal enЋe_:)Ek`eng ͓8L˒s;ng@"P?itNLLS" $ Cp+ N!NewS(, 0SnewBs.Add =.Copseudo LR2Ap,knPIy@mean; ne0F(i) ! s‘FW, Fdiff Y F1ssFZsFY9sYpsu`edor2= #s"+0@edY  / n r msr0*C= j- b^ (C*  =  /F abodrt Fa"uchange > tol T"(s(#).Cel@ls(5, B= "Convergence not achieved." Selection.Font.Bold = True|heets(s tring).Cells(7, 4)V"This probably a case of perf^ class`ificaj{Range("D5:D7").v abortEn@d If 1(, 1Pit Non Linear Least Squares Results; Dependent Vari^e: " & YLabel9S28Numberyobservts2Xnn35Ming 4 5umxrows R-bs]4Fean7LK,ymn9Coef@ieEst imateR10r( B(" B3BRobuE 5&SSR! $; f'מ lnLq`ucIter_S{ numi] 8Rld@ " rsralt If nkixvv+ 1 T(hen1fIn!cept XEls>fX l~(1)@¤6xcVestU&(b?, bIRSE DA9:C9LWith Ƶ A.HorizalAlignmg= xlCerVert@BottomWrapTexFa'B OrrH`40AddI= LlSh kToF!ReadOrd "Ma !&C&. ' WrZ out the VC 6rixA For in tJ Oo Nk? Tu8 +b , 7#kQ?sq(a ,kN' N0J# Dim myadd As Longeg< egs|11 P7+ %f0 u0~x_&-p0xsdv = 1O aDRvwwt[ "Md@#p"SD'  in sumxduc@|9qP2 *PU31).1mula1"=S(B9:&Bq Nkp",12;40& ")  Columns(0"A:A uWiBdt= 22'9\RXKK6q30A\phi("?K4predY(7'E&GoA@skip pnow: MsgBox Err.Descriptv"An unexped errkhas occurP. B:yw1߱0ApplDisplayAlsCalcaAucq9ScreenU1.F(MatMult XTX, nk4=JspOG pA/1 4q+i3I = L pl chkctn &pale' (X'X)-1 ~w75B #Q MsgT "Ppv perfect near*-mpizli#ain in8dep{lP[ia`zs.`DHreg re`fails." abo 0.01 AЅ6< 20? PS P= ' Initialize[!cHQZril%ilQjWk H(j, khabYjZCNomputing dlnLdbeta vector and Hessian matrix F\i = 1 To nobs !F(i)*Ex@p(yfit) / (1 + &)ZGT-V,phi$\ ^ 2kdke'(k + (Y(i, 1) - c) * X' Oldrsion#1"* G{}- ,((G/1).'jWYH(j, X-Oj%8*Next jmyterm9}* b@)LogUn$A$+  i  'ce the n!ste@p, use timesmultiplicatY' InvertŞ HApF .WorksheetFunc .MB se("H'VC' VCinv If n DheD{diffe(@= !A*@ ElseXCall MatVecM@4(Dn,,EIfLSubI houtOe@| , X, M@ γcoefest@$(k= - 0kIchanger- oldLnLc@(~%F= 0AF'%+on @K@Wend ALCKpseudo R^ ' we know ymean;needz A Dim"F As Dohubl`-F$ Y F'sFsFYisYpsuedor2bas0 F1 -%s.f= v#-} )G A-  9G%O- !M/ 8Put down resea3namelengthLong h= 7 ~Fsр= "i@tML" BpN NewS(G, `"Setw*s.AdLneC.  abo= Fai> 0<.0s().Cells (6, 4"CBogencot achieved. Last Cv in t " & Cf(TruR|("@D6").S+ct#c.Font.B> sIsum0P2WB(?@"= + AbsQx?>??s(75WARNING: This  a c6 of perfp cla ffP#-7P;1Z+_ximum Likelihood RE1 qDepOent Varia)J: YLaxbel.%%58 2(/#72uNu0mber!ervb|stGo 3Mi`?= umxrows0_BEU4Vd QX1k!rku9uC})iEs@atee10" /:  "e// 3yrJSE8"~I` *p*0" numiP'#8EP Squar|ed j  pG,xvarGoGoGs(1w!.CshnoBf#QursrQsiCwk{IJ?OJ\lastRowUs0.TmysptartPtcor65yPm store(>tc*yfit_oldbetaVCic.SVCfq JFf # nP'`&eff@icent =r 3phiOpGj;c !k 7" # baseHlnL myЋmYXTransposermsXoresidsy}chang m ln+`',X0' YI aX' 0load<-ac>tB1JhDD(VGN@.֜Checkb.Valdue4W T=S+ 0sRe1!X(2XvSk_aҺ t r_0 v9, ' tA u0parame$o Ri-`!ƮI Y!I 3Q(mpu~ V%1p0qXTa4*GQRI w Cw )86QG 1e1Ӣ@cIsA/ c?bsU=Eq_ _nt_"g4 u zfЅ_@ibility her(6TJ5}8k4UlwPTE>q&(ИMultX, 3ٷnobs, XTranspose Dim p() As @DoubleXRe`1 To nk)TFor i8 = *(p(i).i"Next invertiTru_Call choldctest(XTX,c, p , .r' (X'X)-1 wodrk[If#RFalse ThenMsgBox "re is perfect _near-multicolli ity- thndepent var$ia_s.3usregression fails.">aborNtvGGoskip:End If ymean0 ntIA+ Y(i, 1 /  uyfit(@3idspre|dY@exfQa$xsdR“FindXM@rSD(X()㓃$, g! psuedor2,cVC@6H,VCqA lambda$CdB$ "edhighInte ger = 'RSEk >g" =At@o a!dataAloaded awe Ylout to get ' first rou Bs!W3RunPReg(#2nMNxumx{i6b7YO!hI9X, ")!'' Gee id y' sE ㅠ0@#~$ Cre!W new' P(1) `~to+` Whi"lbs( ) > 0.01 Ae< 2A Av#g%+ 1a'Initialize+dHkfp5rixgfvAS}aij]ak H(j, kdaDzjtj r@@' Comp gb 1dbe# EepzlSAa~proba-^, raocutxoffa\<,< G$P0 ^ -7&20/ 1!#~' Avoi d(o`ms w Ѝ F3too cl201GApplic$at`.WsheetFunc@NormDi-r/iP00 _, Q @0F1 - .G#D0en e01rl3R"((@` ) *a7!/2 ) +O8 (-T/ (G)@AR-* (+Ci1_0 'B,(0"5V - P G * X(i4=&) $ >0w<4 j @w >?LQҬLog(? zGT '!*Phr'' We mucl:1[V0BS$oh model likelyEcs succU (q09_fsome qp>erv:dJst1sbeing shut downQ this?ruİT`Brevizsvsϐ Aǰg9g6.3=QKe0o2CBXO;u J 'Q b cbsnBn stepu@b Pesw@!_VRq @ 4q @ nl$ 'Ql15*./o1E4@YkYMse(H-fVC0/ z diffvec(1) = Hinvscalar * dlnL Else  Call MatVecMult(, nkf, HInv)nnd If 'Sub jout@come, h, X, M-For k1 ToOpcoefestmat(, -kFNext k=hangeV- old8LnL  ?i?obs@yfit(i0S+ U* X(i|TVi If _raperfprob > 0 Then=MsgBox "At least " 4& &[ervations predictedectly.` Esti abor."CcHK0.01qendthis: Wu Compute the pseudo R^2 bas]@M'@ FQ@Applic(.Workshee tFunc-.NormDist(Q, 0, 1, TrueMln`ymeanejLXog( 0D1 - Ewmytherm Ye@*b + ()@9E+ MT'ń- A-1@ + Exp9)q0 'AG+ P)M&-  Epsuedor293A/ + ' we know%;neF - Dim"F As DoublwF Y NF'sFsFYisYD fL2 her`'*Pvaria8ncenF@]rixnamelength Long h= 8  Qstring @&"PpitML @dbN@NewSeaV(g, 9Set new\s.AddD. Put down res`bu@Fauus( ).Cell@s(8, 4A"Converge¬ achieved. LC" in s#Ra("D8").rS-ctc.Font.B@ E$šLsumH`ҧB2= oҰ H= + Abs(kmc)/")(a(7e(WA@RNING:iDs @a c ofŮ clasxsif`I|7'7?'.'@6Edgd@{ple@tely d`rmin" e6 gou;ea edhigh URQ? ,fm--`t oes0: 5n2 B+  '' 1 u kҊDximum LikelihooHd R= fDep uent V+ALU:}YLaxbel44qG/= =5Pr"=^ 2_O2uNumberQ-9vtnP3Mi2X umxro|ws_]4V QBq[!adu9u6C0@iT+es1q"//:  "e// 3yRSE73.I`3??" num~iP/!+!jd4ԥ SquapµnƐ,xGP^rs(1label(1p$=2xmean3sdn Else/b"Intercept" *b1*/0 KE/End If |2nii= i -+Cs0jii_j7coefestpmat(%:Sqr(-HInv i)@' Put the averages ofX's tabl_p'8;CidHHB;x@+%63"pber X Varia s@QiBD;v5%  |"Mv#" SD" Columns("A:A"Widtha_2AqGoskip endnow: MsgBox Err.Descri0ptio@"An unexpected err haLccurred. Bye: ` .`a ` Ap plica .DisplayAlerts Tru R)CalculxlAut2o eiciScreenUpdng @~Sub NameN$ew(nlength, ŃtotalGshWorksuffix()ASnewCbtay!0Bool=cfailcLe8, i"gi= c.CountBRec(r£/ hK LPeft( (#)r.,, '+ɂ s9" T[ascs5+ $== n sca!Righ ,^H g EbQsF #!sq= C+3= I = `gWhile  s-5W TC@&()  <Q*1 ?e4 F8tkY WK#Sc > 0I(w & #qSC@ chold0Ost(aQ., p7n0vti0u('5n8p a(b7n"CDouyBp4K`Pl`:  weA.sP rRThis r@outine B @designZto test f0[multicol0e@qty!.sHVi7 1 jksum myaXR'Set,= jCeskyT ""1@.wC1j< = aj!1Q!#8k!G[#Q-*j, k(akqh('i j')@< 0.0` }^Pi$.zL>e@ *2p(>iOa [5a(` R/ !#r>j >!|QB1__SRP_7$w__SRP_6fPredictedProbabilityTable4@__SRP_4X< oTo\o\춯tTmT lt lt tfL@($ $(#K% x$ x $x" x$ x x1`:dP%x$ x dl`=t)x`-x$ Ox  cd]3x5qqll-x$ Ox  cd]3x5q4dt0ldll0l4l0ll0l4l&l4l0 l4l0l l4l0ll0l4l 0flh 4ftUq4dd0d\| l4l0 l4l0l l4l0ll0l4l 0f\2 4fdllXl7M`M`lM$@M4@MD@XMd` l8ld- l8l8l 8fpV'VM$ @M4`MD@XMd`  kV+'''|:d N 6|("t4dol4t 4f ot!ll!l!llll llll "lll $t8dxtldp=*olll8llt fp Sokd%k4%k%c`%`x$ x `%ABt)x`5U@kD%k$%c%`x$ x `%ABl8l)x`5l8ol8l4ol8lV@kD%k$%f%`x$ x `r@rU~| S2 I"y#B aV1 %! <! q (1(iO))B66B Di**A++ ,A,A B,)B1-i---9.i... /A/// 0q00001a"Q12332I 4A4'Y(IE:y<y6I)I*y,,:: W P@@d p l \ X87lM`lM`l M@lM@lM@8M(` 8Fh x6hH+'''H:X:Nhh 6hH" x$ x x% x$ x $x" x$ x x$D`F#Hd $`T\(8xhHX(tdL$tlxdDRollxlt tl xfD0olltlt t\tTxd<lxlt lttd odo\t\ododoTtT xf%ABl8l)x`5ldH(l8ll8lll8ll l8llll8l fH 8fx t@ qtoo@ld; "ll $tld8ollϫt6llllll f8m8d0( tld(. *olll8llt f(Sokd%k4%k%c`%`x$ x `%ABt)x`5ol8ll8 ol8l ol8lU@kD%k$%c%`x$ x `%ABl8l)x`5,l8l8ll8lV@kD%k$%f%`x$ x `%ABl8l)x`5ld  (l8ll8lll8ll l8llll8l f 8f0lqttt8d tld *olll8llt f Sokd%k4%k%c`%`x$ x `%ABt)x`5ol8ll8K ol8lg ol8lU@kD%k$%c%`x$ x `%ABl8l)x`5,l8l8ll8lV@kD%k$%f%`x$ x `%ABl8l)x`5l8ll8l#ol8oϫtol8ϫtol8ltld(l8ll8lll8ll l8llll8l f 8ff .x$ Ox  fd]3x5Votootllll8dLll8ll8ll 8fR7M`M`lM$@M4@MD@Md` F x6|+'''|:d:N 6|" x$ x x% x$ x $x" x$ x x$`(#dJ$,LXH<Dt(x`|0% x$ x $x" x$ x x-x$ Ox  c]3x5qqll-x$ Ox  c]3x5q LdHl dlHklLlHllHlLl&lLlH lLlHl lLlHllHlLl Hf2 LfPq Ld|PHdtF lLlH lLlHl lLlHllHlLl Hft Lf|l l pl i7M`M,`lM<@ ML@ M\@pM` l Pl d lPlPl Pfpn'nM< @ML` M\@pM`  kng+''': N 6(xtLdolLt Lf ot!!l l l l  l l l l l l l l   "ll l $ qtto:0yE>l tlqPl dtP lPll dlFl dd<lll fd fl  PftPd\,lPl tTlPl oTlPl,lPl9 tTlPl9 oTt|1lPl tTlPl oT϶lPll dLTlllPo|lPo|믳lPlllll dDIlPllPlllPllllllll fDf fLAlPl tToT9 >ttPd& 9m tToT9 >ts T(\%(<%Co#*F%8lTF%x$ x d8/)x85((x'\%:H%$ xx+c%x $ xWCx5tl d ollt f o{Gz?[ D(\%(<%:E%8lTF%x$ x d8)x8((x'\%:F%$ xx+c%x $ xWCx5L(\%(<%N*F%8lTF%x$ x d8)x85D(\%(<%:J%8lTF%x$ x d8)x8F(\%(<%ok%8lTF%x$ x d8)x8D(\%(<%:%8lTF%x$ x d8)x8F(\%(<%i%8lTF%x$ x d8)x8D(\%(<%:%8lTF%x$ x d8)x8J(\%(<%$i%8lTF%x$ x d8)x8D(\%(<%:%8lTF%x$ x d8)x8F(\%(<%ok%8lTF%x$ x d8)x8D(\ %(<%:%8lTF%x$ x d8)x8D(\ %(<%: %8lTF%x$ x d8)x8D(\ %(<%:!%8lTF%x$ x d8)x8D(\ %(<%:K%8lTF%x$ x d8)x8D(\%(<%:$%8lTF%x$ x d8)x8F(\%(<%li%8lTF%x$ x d8)x8D(\%(<%:L%8lTF%x$ x d8)x8F(\%(<%ok%8lTF%x$ x d8)x8l RD(\ %(<%:&%8lTF%x$ x d8)x8K(\ %(<% F%8lTF%x$ x d8)x8V(\ %(<%lk%8lTF%x$ x d8)x8l h`(< %(%(%̔B9 k%8lTFL%x$ x d8)x85f( %(%(L%(%̔B9 kp%8lTF,%x$ x d8)x85(x'\%:'%$ xxx $ Qx\%\(%\)f%\*(%\+f%\,(%\-f%\.v%\/f%\0c\!x $ x1xl Y l i\%(<% F%8lTF%x$ x d8)x8Z l i\%(<%lk%8lTF%x$ x d8)x8Z l i\%(<%lk%8lTF%x$ x d8)x8 qXR l i\%(<%:&%8lTF%x$ x d8)x8R l i\%(<%(%8lTF%x$ x d8)x8R l i\%(<%(%8lTF%x$ x d8)x8 qXPl dPYlPlXqQ lPi\%(<%l F%8lTF%x$ x d8)x8\ lPi\%(<%lPlk%8lTF%x$ x d8)x8p lPi<%(%P@P@̔B9 k%8lTFL%x$ x d8)x85[ lPl i\%(<%l F%8lTF%x$ x d8)x8\ lPl i\%(<%lPlk%8lTF%x$ x d8)x8\ lPl i\%(<%lPlk%8lTF%x$ x d8)x8 PfP D(\%(<%:2%8lTF%x$ x d8)x8F(\%(<%l i%8lTF%x$ x d8)x8Rl i\%(<%:3%8lTF%x$ x d8)x8Rl i\%(<%:4%8lTF%x$ x d8)x8Rl i\%(<%:5%8lTF%x$ x d8)x83(L%:6%x$ `xC7x5x<''' 8xx ,9>F x6+'''::N 6" x$ x x% x$ x $x" x$ x x$,$ \d p`T\(x8p% x$ x $x" x$ x x-x$  x  cp]3x5qqll-x$  x  cp]3x5q LdXHl dPlHklLlHllHlLl&lLlH lLlHl lLlHllHlLl HfP2 LfXPq LdHPHd@F lLlH lLlHl lLlHllHlLl Hf@ LfHl l <l i7M`M`lM@ M@ M(@l tlqPl dD lPlxl d<{tl d4qlltl tf4S f<@ PfD! q0 q,Pd WlPlkp%k%k%c%x$ x %ABt)x5olPlhlPlhdlPl.@@k(%k%c%x$ x %A-BlPlh)x5elPl.@@k(%k%f%x$ x %A-BlPl)x5MlPlPllPlhlPlPlolPlT!lPlTlPlTlPllPlPtl d* NltlxlPlPlhlPlholPllPltlltlxl d HlPlPlPlllPltllltllltl f tfmRlPlh >tm >tolPolPot Pf l  ltl tt m >to9 >tPd 4lPolPot oot Pf ootX q`BCTTM(@`Mp@ @ '%'%'(%'p%x$ x (l=`)x lT` L(o:0yE>P T((%(%Co#*F%lTFp%x$ x d/)x5((x'(%:pD%$ xx+cp%x $ xWCx5tXtl dP oXltl|tX tfPm oX{Gz?8D((%(%:E%lTFp%x$ x d)x((x'(%:pF%$ xx+cp%x $ xWCx5l0_((%(%@l0#*#G*F%lTFp%x$ x d2)x5(x'(%:pH%$ xx+cp%x $ xWCx5L((%(%I*F%lTFp%x$ x d)x5D((%(%:J%lTFp%x$ x d)xF((%(%ok%lTFp%x$ x d)xD((%(%:%lTFp%x$ x d)xF((%(%i%lTFp%x$ x d)xD((%(%:%lTFp%x$ x d)xJ((%(%$i%lTFp%x$ x d)xD((%(%:%lTFp%x$ x d)xF((%(%ok%lTFp%x$ x d)xD(( %(%:%lTFp%x$ x d)xD(( %(%: %lTFp%x$ x d)xD(( %(%:!%lTFp%x$ x d)xD(( %(%:K%lTFp%x$ x d)xD((%(%:$%lTFp%x$ x d)xF((%(%li%lTFp%x$ x d)xD((%(%:L%lTFp%x$ x d)xF((%(%oXk%lTFp%x$ x d)xl D(( %(%:&%lTFp%x$ x d)x>K(( %(% F%lTFp%x$ x d)xV(( %(%lk%lTFp%x$ x d)xl M(( %(%ol9 k%lTFp%x$ x d)x\f( %(%(%(p%`B9 k0%lTF%x$ x d)x5(x'(%:p'%$ xxx $ Qxp%(p%)fp%*(p%+fp%,(p%-fp%.pv%/fp%0c!x $ x1xl Y l i(%(% F%lTFp%x$ x d)xZ l i(%(%ldk%lTFp%x$ x d)xZ l i(%(%l`k%lTFp%x$ x d)x qR l i(%(%:&%lTFp%x$ x d)xR l i(%(%(%lTFp%x$ x d)xR l i(%(%(%lTFp%x$ x d)x qPl dlPlqQ lPi(%(%l F%lTFp%x$ x d)x\ lPi(%(%lPlk%lTFp%x$ x d)xp lPi%(%P@P@`B9 k%lTF%x$ x d)x5[ lPl i(%(%l F%lTFp%x$ x d)x\ lPl i(%(%lPldk%lTFp%x$ x d)x\ lPl i(%(%lPl`k%lTFp%x$ x d)x PfD((%(%:2%lTFp%x$ x d)xF((%(%l i%lTFp%x$ x d)xRl i(%(%:3%lTFp%x$ x d)xRl i(%(%:4%lTFp%x$ x d)xRl i(%(%:5%lTFp%x$ x d)x3(%:p6%x$ `xC7x5<'''` 8xx ,9>F x6`+'''`:p:N 6`" x$ x x% x$ x $x" x$ x x$lp@( T`|dx d<`T\hP0 x`D$PT$ T 0lPqxTlxpXlxdHn\4lXi8%T$ T d4W$; "$ < 3)T46$bl`q`>4lXi8%T$ T d4W$;"q\)T45$j4lXi8%T$ T d4W;l\i $" = `#l`lp;/)T46 XfHPpjl`ql qd kjXl`dlXlpll#0/llql qd Xfld pj qdpjl`>lli8$b D4tp l$T4$lxT"dLgtT"dD] x@t@l $Bth5$lxqplpJohkx@p@l $t@p@l Bth6$lpqp` lxltohHz> fTbgx@mh k4%lQ6t@x@ohk4x@l$%l 5$ tfD2 xfL"ql(d$H(((kkkk+kP` )aa9kk((0p(#D`ak((kkP` )aa9kk((0p(#P!` )aa9kk((0p(#PI` )aa9kk((0p(#,q`//8` )9////nrU $`ny2rU~| 2l ˀ Lqx L kLb08@HPX`h:   " $ /H `px5   (~+0 0.S  $PIx+084@ Xx4 ( " (@X pxL D    ( I8 $CX 9    $          " ( :      "#$%&'()*+,-./0245679:;<=>?ABCDEFGHIJKLMNOPSTUVWYZ[\^+8 x    <+    . B6 6` "6 6  "C "D "D0  X Bh  J B  J  (`  &>0dX JDR.>(2>X0>< >?0?H`h?p >Y&N  `  ^&NLz h  7x ^. &;(.P"Ih/82P(HH !`2p !>7 "  47(5@ X `h xx]@]X]p]]]]]]]]P]h]]]]]]]](]@]X]p]]]]]]]]0]H]`]x]]]]]]0]H]]]0H`]x Predicted probabilities for a range of values for a particular X variable are calculated, holding all other included Xs at their means.9The algorithm assumes we have found the optimal solution.%Predicted Probability Table and Graph $Z'| | ~|k Get the name of the sheet !'+ Make sure you're on the sheetA1 %`B@Hst]li]Logit'|A1 %`!d'  '@ @ Probit'  '@ @Rwe've got ProbitProbit'dsWe can't determine what estimation method you are using. Please make sure cell A1 contains either Probit or Logit.A@ZHk@d8Logit'k ) Get the exo var to be used for pred prob]Click on a single cell in column A with an exogenous variable name (not coefficient number) to be used in calculating predicted probabilities. To be meaningful, the variable should be a continuous variable.8Choosing an Exogenous Variable for Predicted Probability %(. A check -- value must be text !d !% You clicked on a cell that contains the coefficient value itself. Please click on a cell that contains the NAME of the exogenous variable.A@ZpFk$V'N Get myExoVar as a string] '$VT1"PxMEP@(`6 LLLL*hD[han`@X@e]`B<`P8`4 |`0`D,pose`F( Nk,`H$ XTr`J `L(``R` |` `p `R` R`| |`  % %``endn`***`x (`ent `obs, @x Dhe RegFo` ]`H``` `H`XP `0trix` ` `xquar` g`:`7 L H to %`. `XLogi, @`    `Hdterc`(`****`@X `< rp%0(0` 8Ph p Z V~`'@h 6@p @` @P l@@ lt@0 @ q @  @X @( @@ ~ @ l@H l@   p a f@`   a @  llx mll@0 @ fT@ l @t l @ p M@ l  M ` ` @ h  l d `l(@ \ NM@ X PM@ T +'@ P  @8 L @H d \f@ D `D춨 h lD@ 8  @4  D @8 0 l@ lD@h  lD@P lD@ @  `8% P @ `  H@&0FK$*\Rffff*1e460659d3*\R1*#1c8*\R0*#1*\R0*#14*\R1*#2ac*\R1*#e8*\R1*#d7*\R1*#1c7*\R0*#f*\R1*#dc*\R1*#3c*\R1*#db*\R1*#15*\R1*#78*\R1*#2aa*\R1*#246*\R1*#1f0*\R1*#1c*\R1*#19*\R1*#261 " (08@HPX`hpx('v ! Get the labels of the other exos]( NxNo other X variables+ic noad N  N  N 'R T N  T$V!d !d= skip this one since it's the Exo var for the Pred Prob table T'  N  ' vd R 'Rst T$V!d R+% T N  $V R+ T$V R+k` Tl themkH Get where to put the results (3)RInput the range of the cell where you want to put the Predicted Probability table. $~ $~1You may move this dialog box if it is in the way.l %(.at !'tion !'nctiP''   '   ' check for room on the sheetIf  Th/Not enough rows to display results. Try again.A@ZLinEstkx  r in2Not enough columns to display results. Try again.A@Zmyco k  $V  $V$`.DEl+Values of Exogenous Variables Held Constant ,V :Variable ,V Coeff. Est. ,V Value ,Vstim R N R$ R  ,Vult XT R$ R  ,VTransp R$ R  ,V R  %V!'$ N  %V!' %V!'  N  %V!'] %V!$'  '| Sumproduct N  ,V =Sumproduct( : ,  : ) N  %V(X N  %V!'Changing Exogenous Variable: !d N  ,VValue (Std Units) N  ,VValue (Regular Units) N  ,VPredicted Prob Y = 1 N  ,V N  %V N  %V$`B@H \9fq %VB@H $V!' $V!']]( $V!' R  R ? N R  ,V N R  %V!' Probit =Normdist( + * ,0,1,1) N R  %V(Xdx =1/(1+Exp(-( + * ))) N R  %V(Xk N R  %V!'=  +  *  N R  %V(X RH B@v  ( # N  %V N  %V $f%`  B@   B@ 9Predicted Probability5!(d  7( !d  7!!(d  7(9qH  N  %! !!r %(  %! !!r %(8 !!r %B@  %!B@H \B@. !B@H \B@  %B@H  %99q(  (.' Select a cell that shows the table and graph   %VB@H $(0 o Attribute VB_Name = "PredictedProbabilityTable" Option Explicit Sub New j\() Dim i A@s Longj k myNumCoefObs LastCha@ngeCol S@tartMaxEndKK$XArray() S'dmysheet ActiveSXVarSearch.po} >Posv2 3 R"eQLef4Cente.Righ Middle@9CDF PXb OneTermZeroSAverag) responsB @qian@myoutputRA Juppe rlDU, my.r BcrowGsizB  @ lowl PmyOthe@rXmean\Dou ~estadd"s1#;, dSfhSf4g5p 6p7p8gx "!0xH ;= MsgBox(prompt:=g @ies for a C9of valuBpicul}X ria are0 cal@, holding all o0 included @Xs at `ir !3s." & "Thegorithm assum`we have und o`mal solu.", _ Tit,leh aAGraphButt_:=vbOKCancelIf H&2 n Exit Sub If` ' G ` n`%a my)= .Make su'}`m'HIj("A1").SeXlectssbD, @`Dmethod@Logit` )VaDa= Inf(1,F ), 1c-m:y#0-"obBa< !U1H'we'%got "a1'-Else!q35 "W0n't deemine wh.pimaO$2us2.@ PleaWm p(p1 contains e01 O# 9.1GoTo tryag*.1* G* ,exo= to be us0;ApvqBGEp0R Choose0:$t`#pA.IndIH"Ck .aN Q0uBin@lumn A w@: genousF6(nPc0f0`| number)y TIH! 2N0HpfHul,FvaMshouldaRinu 1H"Qao4 "s0g2U֤&DH, 8@1'check --0W musbttexP?-A!XWork"GFun on.IsQ(my@.9)a@True0+You c">t+&(AI2a itself.%,BS/NAME dR-, %E*w= Cells(6x, 22X a0f Q*PI!`+K =+q6Nu2ylapbels 3n sLr5I= YIRe] oM1"Novwys B?m (rW-2XA1[{epBi'0 FpKj1BP+ESKjb+@,A-\ skip%i'@WDce)'s'@qC7a!87 Nt5Tmy= jq0p !+ `5u + 3gV11 + i<iQp')a1y+24NDӌw eATZ"Аult-SW]t]ŘbCB_߲?BqwPIR3Chr(X13)"LmayѶ move this dialog box if it inle way.", _ Ty@pe:=8)4col = upperleft.C olumnProw 60size880F5`lower#b+> !I + ? ' check for!om osheet 65536 TheZpMsgB"Not e noughs tosplay results. Try again."/ GoTo try  End IfσAgA25 @ADFSet @myrangdR(Cells(ŀU,A^), B-BB)) '.C 1, 1)@o"Values of ExogSs VariablHeld ConstantP] 2 U 3Coeff. Estc2&F@i,1 nmyNum - 17uiE'myOther8LabeNiA WDF B Xmean(G B8 estF Nex)add s12+3, 2).A 2n+ 93q 3s 4} Dim'^ As Stri8ng,!)Lo$ngcmya= Mid( BPIe [+ 2A_4) FPSumproducSUlC&Jmula@ "=(" & 4& ":2`(3!I4)V5` j?E9CwCh".0w: imy^."|}(4x (Std Units@Au (Reg`*r@@tCPredicted Prob Y &1(Z13))@.SelecWith io@.WrapT!v=ue#'!(Yi >6@ímyxwY|7qn9w73 910=b  V93U ,4i$$$-2(iY) p* 0.4t9]+ ]Mypmethod0""it" ?Normdi@[=5<++@*9!,00,1,12El~s#11/(1+Exp(6-H 0 ))T8_vuV1b  l HD6 "88- 7#'iis Nr@R Active.RA xlXYScatterLinesNoMa`rkers+SourceDatDa :=S1s@j).G!8+ 5=oief=1NIPlotBy:=xl3 Lo0 @I W0xlAsObj L, Namɐmy 2Mb;.HasTitl!TrUMa Xrs.P6YYabilitVydYAM( ategory, xlPrimarllip%(0%: %a   5!l*#"*#\l*#X#*#Tl*#P"*#Ll*#H$*F`%llip%(0%a  @C%2\XTPLH 6`@Jllip%(0%a  `A@`1 6`@RlliP%(%:p&a`%a@   6@`>llip%(0%:'%a   5>llip%(0%:(%a   5>llip%(0%:)%a   5llip%(0%a  @lli%(%a` p @$ p) p6`@  $ Q D cp%D*cD>(p%(0%a  @  6@?lip%(0% $ X A``1 6`?lip%(0% $ X A``1 6`?lip%(0% $ X A``1< 6`x d4Ylllxip%(0%lx?k%a   5Nlllxip%(0%a  `A@`1@ 6`@ l 0M+l*#,*#\l<*#X-*#Tl@*#P.*F`%lllxip%(0%a  @C%2 \XTP 6`@/l*#,*#\l<*#X-*#Tl@*#P0*F`%lllxip%(0%a  @C%2 \XTP 6`@Nlllxip%(0%a  `A@`1 6`@z1l*#2*#\l*#X-*#Tl*F`%lllxip%(0%a  @C%2\XT 6`@ xf47 '%'0%'P%'p% $ \ (3) K $ , 4 llip%(0%a  @%lli%(%a` %0lLF%p$ p d30 %[ $ , l4) p0 6 `@ .lLFp% $ , 4)  $ ,Q   p4;:p5%  4 a[6,) 5.cP% p% 4 7 Ia`% p% 4 W8=@9C: 6`@/fP% p% 4 7   h4clllip% $ @ ;A <%$ @W`=A@>%p$ @p=C<) p6 `@ lip% $ @ ?A @%$ @W`=A@>%p$ @p=C@) p6 `@ P $ @ W=A`>%$ @ =A) 6` H p% $ , 4W`B ) 5`! $  C 2  $ , 4) ! $  D > p% $ , 4 ) 7 p% $ , 4Q (p%E(p%Fc"  $   7@@ $ @ `G  5`5(0%lip% $ ` CH 5d0D,<@ 8P(0$Hd<DL@4 TX\XTPLH p0 `@ tkmax, and min T$ $ no < T$  '<t co  T$  G T$ 'julat  T$  G T$ 'jmean < *'ho Second pass to get the SD'< T$ $ re T$   '< < > '>( < < @ '@ck -  @ > > *  * '@$SD Corrected two-pass formula. c @$0'ef The SD is the sample SD.% The Population SD is Sqr(n/(n-1))*SDxogeohx]8]P]h]] find n G$ $   '*' First pass to get the mean. the l T$ $  < T$  '< < *' Second pass to get the SD'< T$ $  T$   '< < > '> < < @ '@ @ > > *  * '@$SD Corrected two-pass formula. @$0' The SD is the sample SD.% The Population SD is Sqr(n/(n-1))*SDo@8Attribute VB_Name = "SDModule" ' Source:(http://www.ulib.org/webRoot/Books/Numerical_Recipes/b.cpdf.htmlA clever way to minimize roundoff erro@r, espCally6for large samples, is?use the corrected two-pass algorithm BGiven a rr{of data(),%?tinCeturns it Tage, Mea4n,d$@ standard deviatioQSD.6IMo k outNskewneInd kurtos9cul froBmcode2TyjSDr9/'b PopSqr(n/(n-@1))*SD!BatoFeb 2001 OpU Explicit+Pub Sub Bas(icF}(CG A0s DoAAEA N, SDCaxin)To Ca4macroe8getDM K Min you mus@' 1) DIM>f xn^MAXIN a" @}#B Sli ng!; no numbersH nebesign)hese variab2#*loa`d a v@that h@ EA 03) C@ likis$S:=myA@3I7:=8:=HANX:@INExû follo0w be@lDim nAgLong jsnepMVarI! ' fiTn n(UBrA) - L +@8\ `B!s!?A2Xe M6|fiHrst-lu@[M|ax Kk IC=rni F | aM;AtmaS8@ zF`7j aV+ D ss +jрIf a<%nnBDQ>@qNex]=b / +A%Seco`-w03j4 `@>= ep =*"Y #E(!- *) /X (n>u'C;Ϭ@m = `㔀r3jE#SSD'Wj@ee # _e_e X)?Wנ.WM?bf&]> ^2= &&&&(&&n}&a`&j?s=s& @ ,` " t%"P%xME(6 < <8  x`k@--)  x] `I > fI the I I@ `*xs it`Tt`<lrd d`>d? I`@\ss a `Lk!!<)  n SD*SD ivi `*x `Tt`<l:`>dB`@\Jx8%`0H@L ``@H PP `@@D `0P`@4 ``@$ `X``@@h  pp@!```@ h!```h%`P0 ```P8hXp@X X D@T   @P @L 0x&0FK$*\Rffff*1r4695f315*\R0*#15]  H :X D L &0 FX  ,   "  @  J` L . $0 JX   "  &(Ph  0$)$) 8@ Ppx   N 0 @ ,` "  "  "(H ` h x   N  X h ,  Source:pB http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf.html4 A clever way to minimize roundoff error, especially> for large samples, is to use the corrected two-pass algorithmF Given an array of data(), this routine returns its average, Mean, and sample standard deviation, SD.? I took out the skewness and kurtosis calculation from the code` The SD is the sample SD.% The Population SD is Sqr(n/(n-1))*SD Barreto Feb 20019 To use this macro to get Mean, SD, Max, and Min you mustD 1) DIM the four arguments MEAN, SD, MAX, MIN as Double in th L kLb Lt dDollt tl4lt kL]glt kLb4lt kL]tlt kLb tfDYollxkLbtl Lt d7lt kL4$Btl olodtdololo\t\ tf o\ododlx춯lxt\m\ kLb `l$ $ ˀ Lqx Lt dTMollt tl tfT3 ollx춈tl Lt dLlt tl olodtdololo\t\ tfLz o\ododlx춯lxt\ m\ 0$ frU <`k////4` k++n-0* pHdDDVGaussNewtonD@  _VBA_PROJECT1dir1__SRP_0!VC__SRP_1stdole`MSFormsCOfficeu ThisWorkbook| _EvaluateWorkbook_AddinInstall(AddDummyDepVarMenuItem(GWorkbook_AddinUninstallmyTools=' Application*OperatingSystem[ Internationalxl