' LM test of the null that the distribution is Logistic against the alternative that is is Burr Type 2 (and hence skewed - to the left or to the right)
'Illlustrative code with 2 covariates and an intercept. The notation and construction of the LM test statistic follows the exposition in Thomas (1993)
' References:
' J. M. Thomas (1993), "On Testing the Logistic Assumption in Binary 'Dependent Variable Models" Empirical Economics, 1993, 18:381-392
' D. J. Poirier (1980), " A Lagrange Multiplier Test for Skewness in Binary Logit Models. Economics Letters", 5, 141-143
'================================================================
' Code written by David Giles, Dept. of Economics, University of Victoria, March 2010
'================================================================
' Adjust the sample size to suit
!n=5000
smpl 1 !n
series bf
series sf
series sr
series dee
series r2
series one=1
' Modify the covariates in the group and in the Logit model, as appropriate
' Note that Y is the binary (zero-one) dependent variable
group xx one x1 x2
equation eq1.logit(h) y xx
matrix x=@convert(xx)
fit(i) xbeta
dee=one+exp(xbeta)
bf=1/dee
sf=(dee-1)/dee^2
sr=y*@sqrt(bf/(1-bf)) -(1-y)*@sqrt((1-bf)/bf)
series scalefac=sf/@sqrt((one-bf)*bf)
stom(scalefac, scalev)
matrix r1m=@scale(x, scalev)
mtos(r1m,r1)
r2=log(dee)*@sqrt(bf/(one-bf))
group bigr r1 r2
equation eq2.ls sr bigr
fit fitted
series f2=fitted*fitted
scalar lm=@sum(f2)
' The LM statistic is asymptotically Chi Square with one degree of freedom, under the null of an underlying Logistic specification, so calculate the (asymptotic) p-value:
scalar p_val=1-@cchisq(lm,1)