
A3.5 An example 93
// set sample size
m_cT = rows(m_mY);
if (m_cT <= 2)
{ println("\n*** Error: only ", m_cT, " observations.");
return FALSE;
}
// get names of variables
GetGroupNames(Y_VAR, &m_asY);
GetGroupNames(X_VAR, &m_asX);
GetGroupNames(W_VAR, &m_asW);
GetGroupNames(SEL_VAR, &m_asSel);
// update status: data processed successsfully
m_iModelStatus = MS_DATA;
return TRUE;
}
BprobitEx::DoEstimation(vP)
{
// do the maximization using BFGS
if (m_iMethod == M_PROBIT)
m_iResult = MaxBFGS(fProbit, &vP, &m_dLogLik, 0, FALSE);
else if (m_iMethod == M_LOGIT)
println("\n*** Error: not implemented");
else if (m_iMethod == M_POISSON)
println("\n*** Error: not implemented");
else if (m_iMethod == M_NEGBIN)
println("\n*** Error: not implemented");
// maximization is done in terms of loglik/T
m_dLogLik *= m_cT;
// may need to do more processing if estimation succeeded
if (m_iResult <= MAX_WEAK_CONV)
{
++m_iModel;
}
return {vP, "BFGS", FALSE}; // three return values
}
BprobitEx::Output()
{
Buffering(11); // set text marker
Buffering(1); // start buffering
// print the header even if estimation failed
OutputHeader(GetMethodLabel());
if (m_iModelStatus != MS_ESTIMATED)
return;
// output the rest
OutputPar();
OutputLogLik();
Komentarze do niniejszej Instrukcji