[56b1e1]: mle_results.m Maximize Restore History

Download this file

mle_results.m    110 lines (99 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
# Copyright (C) 2003,2004 Michael Creel michael.creel@uab.es
# under the terms of the GNU General Public License.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 2003 Michael Creel michael.creel@uab.es
# under the terms of the GNU General Public License.
# The GPL license is in the file COPYING
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 2003 Michael Creel michael.creel@uab.es
# under the terms of the GNU General Public License.
# The GPL license is in the file COPYING
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# report results
function [theta, V, obj_value, infocrit] = mle_results(theta, data, model, modelargs, names, title, unscale, control)
if nargin < 8
[theta, obj_value, convergence] = mle_estimate(theta, data, model, modelargs);
else
[theta, obj_value, convergence] = mle_estimate(theta, data, model, modelargs, control);
endif
V = mle_variance(theta, data, model, modelargs);
# unscale results if argument has been passed
# this puts coefficients into scale corresponding to the original modelargs
if (nargin > 5)
if iscell(unscale) # don't try it if unscale is simply a placeholder
[theta, V] = unscale_parameters(theta, V, unscale);
endif
endif
[theta, V] = delta_method("parameterize", theta, {data, model, modelargs}, V);
n = rows(data);
k = rows(V);
se = sqrt(diag(V));
if convergence == 1
convergence="Normal convergence";
elseif convergence == 2
convergence="No convergence";
elseif convergence == -1
convergence = "Max. iters. exceeded";
endif
printf("\n\n******************************************************\n");
disp(title);
printf("\nMLE Estimation Results\n");
printf("BFGS convergence: %s\n\n", convergence);
printf("Average Log-L: %f\n", obj_value);
printf("Observations: %d\n", n);
a =[theta, se, theta./se, 2 - 2*normal_cdf(abs(theta ./ se))];
clabels = str2mat("estimate", "st. err", "t-stat", "p-value");
printf("\n");
if names !=0
prettyprint(a, names, clabels);
else prettyprint_c(a, clabels);
endif
printf("\nInformation Criteria \n");
caic = -2*n*obj_value + rows(theta)*(log(n)+1);
bic = -2*n*obj_value + rows(theta)*log(n);
aic = -2*n*obj_value + 2*rows(theta);
infocrit = [caic, bic, aic];
printf("CAIC : %8.4f Avg. CAIC: %8.4f\n", caic, caic/n);
printf(" BIC : %8.4f Avg. BIC: %8.4f\n", bic, bic/n);
printf(" AIC : %8.4f Avg. AIC: %8.4f\n", aic, aic/n);
printf("******************************************************\n");
endfunction