1 # Created by Octave 3.6.1, Wed Mar 28 20:33:11 2012 UTC <root@brouzouf>
13 # name: <cell-element>
17 for internal use by gmm_estimate
21 # name: <cell-element>
25 for internal use by gmm_estimate
30 # name: <cell-element>
37 # name: <cell-element>
41 Computes Delta method mean and covariance of a nonlinear
42 transformation defined by "func"
46 # name: <cell-element>
50 Computes Delta method mean and covariance of a nonlinear
55 # name: <cell-element>
62 # name: <cell-element>
66 usage: [theta, obj_value, convergence, iters] =
67 gmm_estimate(theta, data, weight, moments, momentargs, control, nslaves)
70 theta: column vector initial parameters
72 weight: the GMM weight matrix
73 moments: name of function computes the moments
74 (should return nXg matrix of contributions)
75 momentargs: (cell) additional inputs needed to compute moments.
77 control: (optional) BFGS or SA controls (see bfgsmin and samin).
79 nslaves: (optional) number of slaves if executed in parallel
83 theta: GMM estimate of parameters
84 obj_value: the value of the gmm obj. function
85 convergence: return code from bfgsmin
86 (1 means success, see bfgsmin for details)
87 iters: number of BFGS iteration used
89 please type "gmm_example" while in octave to see an example
93 # name: <cell-element>
97 usage: [theta, obj_value, convergence, iters] =
102 # name: <cell-element>
109 # name: <cell-element>
113 GMM example file, shows initial consistent estimator,
114 estimation of efficient weight, and second round
119 # name: <cell-element>
123 GMM example file, shows initial consistent estimator,
124 estimation of efficient
128 # name: <cell-element>
135 # name: <cell-element>
139 The GMM objective function, for internal use by gmm_estimate
140 This is scaled so that it converges to a finite number.
141 To get the chi-square specification
142 test you need to multiply by n (the sample size)
146 # name: <cell-element>
150 The GMM objective function, for internal use by gmm_estimate
155 # name: <cell-element>
162 # name: <cell-element>
166 usage: [theta, V, obj_value] =
167 gmm_results(theta, data, weight, moments, momentargs, names, title, unscale, control, nslaves)
170 theta: column vector initial parameters
172 weight: the GMM weight matrix
173 moments: name of function computes the moments
174 (should return nXg matrix of contributions)
175 momentargs: (cell) additional inputs needed to compute moments.
177 names: vector of parameter names
178 e.g., names = char("param1", "param2");
179 title: string, describes model estimated
180 unscale: (optional) cell that holds means and std. dev. of data
182 control: (optional) BFGS or SA controls (see bfgsmin and samin). May be empty ("").
183 nslaves: (optional) number of slaves if executed in parallel
187 theta: GMM estimated parameters
188 V: estimate of covariance of parameters. Assumes the weight matrix
189 is optimal (inverse of covariance of moments)
190 obj_value: the value of the GMM objective function
192 please type "gmm_example" while in octave to see an example
196 # name: <cell-element>
200 usage: [theta, V, obj_value] =
201 gmm_results(theta, data, weight, moments, mome
205 # name: <cell-element>
212 # name: <cell-element>
216 GMM variance, which assumes weights are optimal
220 # name: <cell-element>
224 GMM variance, which assumes weights are optimal
229 # name: <cell-element>
233 gmm_variance_inefficient
236 # name: <cell-element>
240 GMM variance, which assumes weights are not optimal
244 # name: <cell-element>
248 GMM variance, which assumes weights are not optimal
253 # name: <cell-element>
260 # name: <cell-element>
264 kernel_density: multivariate kernel density estimator
267 dens = kernel_density(eval_points, data, bandwidth)
270 eval_points: PxK matrix of points at which to calculate the density
271 data: NxK matrix of data points
272 bandwidth: positive scalar, the smoothing parameter. The fit
273 is more smooth as the bandwidth increases.
274 kernel (optional): string. Name of the kernel function. Default is
276 prewhiten bool (optional): default false. If true, rotate data
277 using Choleski decomposition of inverse of covariance,
278 to approximate independence after the transformation, which
279 makes a product kernel a reasonable choice.
280 do_cv: bool (optional). default false. If true, calculate leave-1-out
281 density for cross validation
282 computenodes: int (optional, default 0).
283 Number of compute nodes for parallel evaluation
284 debug: bool (optional, default false). show results on compute nodes if doing
287 dens: Px1 vector: the fitted density value at each of the P evaluation points.
290 Wand, M.P. and Jones, M.C. (1995), 'Kernel smoothing'.
291 http://www.xplore-stat.de/ebooks/scripts/spm/html/spmhtmlframe73.html
295 # name: <cell-element>
299 kernel_density: multivariate kernel density estimator
304 # name: <cell-element>
308 kernel_density_cvscore
311 # name: <cell-element>
315 some kernels can assign zero density
319 # name: <cell-element>
323 some kernels can assign zero density
328 # name: <cell-element>
335 # name: <cell-element>
339 kernel_density_nodes: for internal use by kernel_density - does calculations on nodes
343 # name: <cell-element>
347 kernel_density_nodes: for internal use by kernel_density - does calculations on
351 # name: <cell-element>
358 # name: <cell-element>
362 kernel_example: examples of how to use kernel density and regression functions
363 requires the optim and plot packages from Octave Forge
365 usage: kernel_example;
369 # name: <cell-element>
373 kernel_example: examples of how to use kernel density and regression functions
378 # name: <cell-element>
382 kernel_optimal_bandwidth
385 # name: <cell-element>
389 kernel_optimal_bandwidth: find optimal bandwith doing leave-one-out cross validation
392 * depvar: column vector or empty ("").
393 If empty, do kernel density, orherwise, kernel regression
394 * kernel (optional, string) the kernel function to use
396 * h: the optimal bandwidth
400 # name: <cell-element>
404 kernel_optimal_bandwidth: find optimal bandwith doing leave-one-out cross valid
408 # name: <cell-element>
415 # name: <cell-element>
419 kernel_regression: kernel regression estimator
422 fit = kernel_regression(eval_points, depvar, condvars, bandwidth)
425 eval_points: PxK matrix of points at which to calculate the density
426 depvar: Nx1 vector of observations of the dependent variable
427 condvars: NxK matrix of data points
428 bandwidth (optional): positive scalar, the smoothing parameter.
429 Default is N ^ (-1/(4+K))
430 kernel (optional): string. Name of the kernel function. Default is
432 prewhiten bool (optional): default true. If true, rotate data
433 using Choleski decomposition of inverse of covariance,
434 to approximate independence after the transformation, which
435 makes a product kernel a reasonable choice.
436 do_cv: bool (optional). default false. If true, calculate leave-1-out
437 fit to calculate the cross validation score
438 computenodes: int (optional, default 0).
439 Number of compute nodes for parallel evaluation
440 debug: bool (optional, default false). show results on compute nodes if doing
443 fit: Px1 vector: the fitted value at each of the P evaluation points.
448 # name: <cell-element>
452 kernel_regression: kernel regression estimator
457 # name: <cell-element>
461 kernel_regression_nodes
464 # name: <cell-element>
468 kernel_regression_nodes: for internal use by kernel_regression - does calculations on nodes
472 # name: <cell-element>
476 kernel_regression_nodes: for internal use by kernel_regression - does calculati
480 # name: <cell-element>
487 # name: <cell-element>
492 [theta, obj_value, conv, iters] = mle_estimate(theta, data, model, modelargs, control, nslaves)
495 theta: column vector of model parameters
497 model: name of function that computes log-likelihood
498 modelargs: (cell) additional inputs needed by model. May be empty ("")
499 control: (optional) BFGS or SA controls (see bfgsmin and samin). May be empty ("").
500 nslaves: (optional) number of slaves if executed in parallel (requires MPITB)
503 theta: ML estimated value of parameters
504 obj_value: the value of the log likelihood function at ML estimate
505 conv: return code from bfgsmin (1 means success, see bfgsmin for details)
506 iters: number of BFGS iteration used
508 please see mle_example.m for examples of how to use this
512 # name: <cell-element>
517 [theta, obj_value, conv, iters] = mle_estimate(theta, data, model, mode
521 # name: <cell-element>
528 # name: <cell-element>
532 Example to show how to use MLE functions
536 # name: <cell-element>
540 Example to show how to use MLE functions
545 # name: <cell-element>
552 # name: <cell-element>
556 usage: [obj_value, score] = mle_obj(theta, data, model, modelargs, nslaves)
558 Returns the average log-likelihood for a specified model
559 This is for internal use by mle_estimate
563 # name: <cell-element>
567 usage: [obj_value, score] = mle_obj(theta, data, model, modelargs, nslaves)
572 # name: <cell-element>
579 # name: <cell-element>
587 # name: <cell-element>
596 # name: <cell-element>
603 # name: <cell-element>
607 usage: [theta, V, obj_value, infocrit] =
608 mle_results(theta, data, model, modelargs, names, title, unscale, control)
611 theta: column vector of model parameters
613 model: name of function that computes log-likelihood
614 modelargs: (cell) additional inputs needed by model. May be empty ("")
615 names: vector of parameter names, e.g., use names = char("param1", "param2");
616 title: string, describes model estimated
617 unscale: (optional) cell that holds means and std. dev. of data (see scale_data)
618 control: (optional) BFGS or SA controls (see bfgsmin and samin). May be empty ("").
619 nslaves: (optional) number of slaves if executed in parallel (requires MPITB)
622 theta: ML estimated value of parameters
623 obj_value: the value of the log likelihood function at ML estimate
624 conv: return code from bfgsmin (1 means success, see bfgsmin for details)
625 iters: number of BFGS iteration used
629 # name: <cell-element>
633 usage: [theta, V, obj_value, infocrit] =
634 mle_results(theta, data, model, mo
638 # name: <cell-element>
645 # name: <cell-element>
649 usage: [V,scorecontribs,J_inv] =
650 mle_variance(theta, data, model, modelargs)
652 This is for internal use by mle_results
656 # name: <cell-element>
660 usage: [V,scorecontribs,J_inv] =
661 mle_variance(theta, data, model, modelargs)
666 # name: <cell-element>
673 # name: <cell-element>
678 [theta, obj_value, conv, iters] = nls_estimate(theta, data, model, modelargs, control, nslaves)
681 theta: column vector of model parameters
683 model: name of function that computes the vector of sums of squared errors
684 modelargs: (cell) additional inputs needed by model. May be empty ("")
685 control: (optional) BFGS or SA controls (see bfgsmin and samin). May be empty ("").
686 nslaves: (optional) number of slaves if executed in parallel (requires MPITB)
689 theta: NLS estimated value of parameters
690 obj_value: the value of the sum of squared errors at NLS estimate
691 conv: return code from bfgsmin (1 means success, see bfgsmin for details)
692 iters: number of BFGS iteration used
694 please see nls_example.m for examples of how to use this
698 # name: <cell-element>
703 [theta, obj_value, conv, iters] = nls_estimate(theta, data, model, mode
707 # name: <cell-element>
714 # name: <cell-element>
719 define arguments for nls_estimate #
725 # name: <cell-element>
730 define arguments for nls_estimate #
735 # name: <cell-element>
742 # name: <cell-element>
746 usage: [obj_value, score] = nls_obj(theta, data, model, modelargs, nslaves)
748 Returns the average sum of squared errors for a specified model
749 This is for internal use by nls_estimate
753 # name: <cell-element>
757 usage: [obj_value, score] = nls_obj(theta, data, model, modelargs, nslaves)
762 # name: <cell-element>
769 # name: <cell-element>
773 This is for internal use by nls_estimate
777 # name: <cell-element>
781 This is for internal use by nls_estimate
786 # name: <cell-element>
793 # name: <cell-element>
797 usage: theta = parameterize(theta, otherargs)
799 This is an empty function, provided so that
800 delta_method will work as is. Replace it with
801 the parameter transformations your models use.
802 Note: you can let "otherargs" contain the model
803 name so that this function can do parameterizations
804 for a variety of models
808 # name: <cell-element>
812 usage: theta = parameterize(theta, otherargs)
814 This is an empty function, pro
818 # name: <cell-element>
825 # name: <cell-element>
829 Example likelihood function (Poisson for count data) with score
833 # name: <cell-element>
837 Example likelihood function (Poisson for count data) with score
842 # name: <cell-element>
849 # name: <cell-element>
853 the form a user-written moment function should take
857 # name: <cell-element>
861 the form a user-written moment function should take
866 # name: <cell-element>
873 # name: <cell-element>
877 this prints matrices with row and column labels
881 # name: <cell-element>
885 this prints matrices with row and column labels
890 # name: <cell-element>
897 # name: <cell-element>
901 this prints matrices with column labels but no row labels
905 # name: <cell-element>
909 this prints matrices with column labels but no row labels
914 # name: <cell-element>
921 # name: <cell-element>
925 Standardizes and normalizes data matrix,
926 primarily for use by BFGS
930 # name: <cell-element>
934 Standardizes and normalizes data matrix,
935 primarily for use by BFGS
940 # name: <cell-element>
947 # name: <cell-element>
951 for internal use by gmm_estimate
955 # name: <cell-element>
959 for internal use by gmm_estimate
964 # name: <cell-element>
971 # name: <cell-element>
975 Unscales parameters that were estimated using scaled data
976 primarily for use by BFGS
980 # name: <cell-element>
984 Unscales parameters that were estimated using scaled data