<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
>
  <channel>
    <title>Chang ,JX</title>
    <link>http://peacelovekenzie.life-and-things.com/</link>
    <description>&Ntilde;&ETH;&deg;&Ntilde;&Ntilde;&ETH;&ordm;&ETH;&deg;&ETH;&middot; &ETH;&cedil; &Ntilde;&ETH;&middot;&Ntilde;&ETH;&ordm;</description>
    <language>zh-tw</language>    <item>
      <title>probit ml in stata as well as R</title>
      <link>http://peacelovekenzie.life-and-things.com/2008/09/16/probit-ml-in-stata-and-r.html</link>
      <description>/* Stata */
clear
set obs 1000
gen x=invnorm(uniform())
gen e=invnorm(uniform())
gen y=0.5+0.4*x+e
replace y=0 if y&lt;=0
replace y=1 if y&gt;0

capture program drop myprobit
program myprobit /* to utilize maximum likelihood method to estimate the probit model */
version 10
args lnf theta1
quietly replace `lnf&#8217; = ln(normal(`theta1&#8242;)) if $ML_y1==1
quietly replace `lnf&#8217; = ln(normal(-`theta1&#8242;)) if $ML_y1==0
end
ml model lf myprobit (y = x) /* to estimate the basic probit model using method lf */
ml check /* to verify that the log-likelihood evaluator you have written seems to work */
ml search /* to find a better initial value so that the convergence of log-likelihood takes less time*/
ml maximize
ml graph /* to graph the log-likelihood values against
the iteration number to verify the process of convergence */
# R
n&lt;-1000;
e&lt;-rnorm(n);
x&lt;-rnorm(n);
a&lt;-0.5
b&lt;-0.4
y&lt;-a+b*x+e;
y&lt;-ifelse(y&lt;=0,0,1)
#Define Likelihood
# Probit LL
llik.probit &lt;- function(par, X, y){
Y &lt;- as.matrix(y)
X &lt;- cbind(1,X)
phi &lt;- pnorm(ifelse(Y == 0, -1, 1) * X%*%par, log.p = TRUE)
sum(phi)
}
# another probit function
#probit.ll &lt;- function(beta,X,y){
#X&lt;-cbind(1,X)
#    phi &lt;- pnorm(X %*% beta)
#    out &lt;- sum(y * log(phi) + (1-y) * log(1-phi))
#}
# Maximize LL
out &lt;- optim(par = c(0,1), llik.probit , y = y, X = x, method=&#8221;BFGS&#8221;,
control=list(fnscale = -1), hessian = T)
# Calculate standard errors
se &lt;- sqrt(diag(solve(-optim.out$hessian)))
VCV &lt;- solve(-optim.out$hessian)
Zv&lt;-out$par/se
pv&lt;-2*(1-pnorm(Zv))
result&lt;-cbind(out$par,se,Zv,pv)
colnames(result)&lt;-c(&#8221;Coef&#8221;,&#8221;Std.err&#8221;,&#8221;Zvalue&#8221;,&#8221;P-value&#8221;)
rownames(result)&lt;-c(&#8221;Intercept&#8221;,&#8221;x&#8221;)
round(result,4)
# check with canned function; an estimated identical
out &lt;- glm(y ~ x, family=binomial(link=&#8221;probit&#8221;))
summary(out)
# library(car);lfp&lt;-recode(lfp,&#8221; &#8216;yes&#8217;=1;&#8217;no&#8217;=0 &#8220;, as.factor=F)
</description>
      <pubDate>Tue, 16 Sep 2008 19:33:41 -0400</pubDate>
      <dc:creator>peacelovekenzie</dc:creator>
    </item></channel></rss>