function [beta,std_beta,prop]=logit_mle(t,v) %LOGIT is based on a logit model: % prob(t=1|v)=exp{v'*beta}/(1+exp{v'*beta}. % Input: t- N by 1 indicator vector, 1's and 0's % v- N by k covariates matrix % Output: beta- k by 1 estimated coefficient % using Newton's method % std_beta- k by 1 standard errors of beta. % prop - estimated probabilities of t=1 % N by 1 vector dimv=min(size(v)); beta=zeros(100,dimv); beta_old=zeros(dimv,1); c=0.00001; for i=1:100 Lambda=exp(v*beta_old)./(1+exp(v*beta_old)); frstder=v'*(t-Lambda); scndder=v'*(((Lambda.*(1-Lambda))*ones(1,dimv)).*v); beta_new=beta_old+inv(scndder)*frstder; if sum(abs(beta_new-beta_old))