changeset 2961:e23b10b8855a octave-forge

minor cleanup
author mcreel
date Wed, 24 Jan 2007 10:51:22 +0000
parents 13356b38f959
children 18fae735987a
files main/econometrics/inst/gmm_estimate.m main/econometrics/inst/mle_estimate.m main/econometrics/inst/nls_obj.m
diffstat 3 files changed, 34 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/main/econometrics/inst/gmm_estimate.m	Tue Jan 23 22:05:01 2007 +0000
+++ b/main/econometrics/inst/gmm_estimate.m	Wed Jan 24 10:51:22 2007 +0000
@@ -1,20 +1,20 @@
 # Copyright (C) 2003,2004,2005 Michael Creel <michael.creel@uab.es>
-# 
+#
 # 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
 
-# usage: [theta, obj_value, convergence, iters] = 
+# usage: [theta, obj_value, convergence, iters] =
 #           gmm_estimate(theta, data, weight, moments, momentargs, control, nslaves)
 #
 # inputs:
@@ -26,7 +26,7 @@
 # momentargs: (cell) additional inputs needed to compute moments.
 # 	      May be empty ("")
 #    control: (optional) BFGS or SA controls (see bfgsmin and samin).
-#             May be empty (""). 
+#             May be empty ("").
 #    nslaves: (optional) number of slaves if executed in parallel
 #             (requires MPITB)
 #
@@ -57,20 +57,20 @@
 
 	# bfgs or sa?
 	if (size(control,1)*size(control,2) == 0) # use default bfgs if no control
-		control = {Inf,0,1,1};	
-	  method = "bfgs";
+		control = {Inf,0,1,1};
+		method = "bfgs";
 	elseif (size(control,1)*size(control,2) < 11)
 		method = "bfgs";
-	else method = "sa";	
+	else method = "sa";
 	endif
-	
+
 
 	if strcmp(method, "bfgs")
 		[theta, obj_value, convergence, iters] = bfgsmin("gmm_obj", {theta, data, weight, moments, momentargs}, control);
-	elseif strcmp(method, "sa") 	
+	elseif strcmp(method, "sa")
 	  	[theta, obj_value, convergence] = samin("gmm_obj", {theta, data, weight, moments, momentargs}, control);
-	endif	
+	endif
 
-	if nslaves > 0 LAM_Finalize; endif # clean up		
+	if nslaves > 0 LAM_Finalize; endif # clean up
 
-endfunction	
+endfunction
--- a/main/econometrics/inst/mle_estimate.m	Tue Jan 23 22:05:01 2007 +0000
+++ b/main/econometrics/inst/mle_estimate.m	Wed Jan 24 10:51:22 2007 +0000
@@ -4,25 +4,25 @@
 ## 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
 
-# usage: 
-# [theta, obj_value, conv, iters] = mle_estimate(theta, data, model, modelargs, control, nslaves) 
+# usage:
+# [theta, obj_value, conv, iters] = mle_estimate(theta, data, model, modelargs, control, nslaves)
 #
 # inputs:
 # theta: column vector of model parameters
 # data: data matrix
 # model: name of function that computes log-likelihood
 # modelargs: (cell) additional inputs needed by model. May be empty ("")
-# control: (optional) BFGS or SA controls (see bfgsmin and samin). May be empty (""). 
+# control: (optional) BFGS or SA controls (see bfgsmin and samin). May be empty ("").
 # nslaves: (optional) number of slaves if executed in parallel (requires MPITB)
 #
 # outputs:
@@ -53,22 +53,22 @@
 
 	# bfgs or sa?
 	if (size(control,1)*size(control,2) == 0) # use default bfgs if no control
-		control = {Inf,0,1,1};	
-	  method = "bfgs";
+		control = {Inf,0,1,1};
+		method = "bfgs";
 	elseif (size(control,1)*size(control,2) < 11)
 		method = "bfgs";
-	else method = "sa";	
+	else method = "sa";
 	endif
-	
 
+	# do estimation using either bfgsmin or samin
 	if strcmp(method, "bfgs")
 	  [theta, obj_value, convergence, iters] = bfgsmin("mle_obj", {theta, data, model, modelargs, nslaves}, control);
-	elseif strcmp(method, "sa") 	
+	elseif strcmp(method, "sa")
 	  [theta, obj_value, convergence] = samin("mle_obj", {theta, data, model, modelargs, nslaves}, control);
-	endif	
-		
+	endif
+
 	if nslaves > 0
 		LAM_Finalize;
-	endif # cleanup			
+	endif # cleanup
 	obj_value = - obj_value; # recover from minimization rather than maximization
-endfunction	
+endfunction
--- a/main/econometrics/inst/nls_obj.m	Tue Jan 23 22:05:01 2007 +0000
+++ b/main/econometrics/inst/nls_obj.m	Wed Jan 24 10:51:22 2007 +0000
@@ -1,15 +1,15 @@
 # Copyright (C) 2005  Michael Creel <michael.creel@uab.es>
-# 
+#
 # 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
@@ -22,15 +22,15 @@
 
 function [obj_value, score] = nls_obj(theta, data, model, modelargs, nslaves)
 
-	n = rows(data);   
+	n = rows(data);
 
 	if nslaves > 0
 		global NEWORLD NSLAVES TAG
 		nn = floor(n/(NSLAVES + 1)); # number of obsns per slave
-    
+
 		# The command that the slave nodes will execute
-    		cmd=['contrib = nls_obj_nodes(theta, data, model, modelargs, nn); ',...	
-        	 'MPI_Send(contrib,0,TAG,NEWORLD);'];	
+    		cmd=['contrib = nls_obj_nodes(theta, data, model, modelargs, nn); ',...
+        	 'MPI_Send(contrib,0,TAG,NEWORLD);'];
 
 		# send items to slaves
 		NumCmds_Send({"theta", "nn", "cmd"}, {theta, nn, cmd});