From: <mc...@us...> - 2008-11-12 11:28:48
|
Revision: 5428 http://octave.svn.sourceforge.net/octave/?rev=5428&view=rev Author: mcreel Date: 2008-11-12 11:28:21 +0000 (Wed, 12 Nov 2008) Log Message: ----------- minor revisions to call chi2pdf instead of chisquare_pdf, and similar Modified Paths: -------------- trunk/octave-forge/main/econometrics/inst/kernel_density.m trunk/octave-forge/main/econometrics/inst/kernel_example.m trunk/octave-forge/main/econometrics/inst/kernel_regression.m Modified: trunk/octave-forge/main/econometrics/inst/kernel_density.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/kernel_density.m 2008-11-12 09:52:41 UTC (rev 5427) +++ trunk/octave-forge/main/econometrics/inst/kernel_density.m 2008-11-12 11:28:21 UTC (rev 5428) @@ -31,7 +31,8 @@ # makes a product kernel a reasonable choice. # do_cv: bool (optional). default false. If true, calculate leave-1-out # density for cross validation -# computenodes: int (optional, default 0). Number of compute nodes for parallel evaluation +# computenodes: int (optional, default 0). +# Number of compute nodes for parallel evaluation # debug: bool (optional, default false). show results on compute nodes if doing # a parallel run # outputs: @@ -43,9 +44,14 @@ function z = kernel_density(eval_points, data, bandwidth, kernel, prewhiten, do_cv, computenodes, debug) - if nargin < 3; error("kernel_density: at least 3 arguments are required"); endif + if nargin < 2; error("kernel_density: at least 2 arguments are required"); endif + n = rows(data); + k = columns(data); + + # set defaults for optional args + if (nargin < 3) bandwidth = (n ^ (-1/(4+k))); endif # bandwidth - see Li and Racine pg. 26 if (nargin < 4) kernel = "__kernel_normal"; endif # what kernel? if (nargin < 5) prewhiten = false; endif # automatic prewhitening? if (nargin < 6) do_cv = false; endif # ordinary or leave-1-out Modified: trunk/octave-forge/main/econometrics/inst/kernel_example.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/kernel_example.m 2008-11-12 09:52:41 UTC (rev 5427) +++ trunk/octave-forge/main/econometrics/inst/kernel_example.m 2008-11-12 11:28:21 UTC (rev 5428) @@ -68,7 +68,7 @@ printf("time for univariate kernel density example using %d data points and %d compute nodes: %f\n", n, nodes, t1); printf("A rough integration under the fitted univariate density is %f\n", sum(dens)*stepsize); figure(); -plot(grid_x, dens, ";fitted density;", grid_x, chisquare_pdf(grid_x,3), ";true density;"); +plot(grid_x, dens, ";fitted density;", grid_x, chi2pdf(grid_x,3), ";true density;"); title("Example 2: Kernel density fit: Univariate Chi^2(3) data"); ############################################################ Modified: trunk/octave-forge/main/econometrics/inst/kernel_regression.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/kernel_regression.m 2008-11-12 09:52:41 UTC (rev 5427) +++ trunk/octave-forge/main/econometrics/inst/kernel_regression.m 2008-11-12 11:28:21 UTC (rev 5428) @@ -20,19 +20,20 @@ # # inputs: # eval_points: PxK matrix of points at which to calculate the density -# dev_var: Nx1 vector of observations of the dependent variable -# data: NxK matrix of data points -# bandwidth: positive scalar, the smoothing parameter. The fit -# is more smooth as the bandwidth increases. +# depvar: Nx1 vector of observations of the dependent variable +# condvars: NxK matrix of data points +# bandwidth (optional): positive scalar, the smoothing parameter. +# Default is N ^ (-1/(4+K)) # kernel (optional): string. Name of the kernel function. Default is # Gaussian kernel. -# prewhiten bool (optional): default false. If true, rotate data +# prewhiten bool (optional): default true. If true, rotate data # using Choleski decomposition of inverse of covariance, # to approximate independence after the transformation, which # makes a product kernel a reasonable choice. # do_cv: bool (optional). default false. If true, calculate leave-1-out -# density for cross validation -# computenodes: int (optional, default 0). Number of compute nodes for parallel evaluation +# fit to calculate the cross validation score +# computenodes: int (optional, default 0). +# Number of compute nodes for parallel evaluation # debug: bool (optional, default false). show results on compute nodes if doing # a parallel run # outputs: @@ -49,7 +50,7 @@ # set defaults for optional args if (nargin < 4) bandwidth = (n ^ (-1/(4+k))); endif # bandwidth - see Li and Racine pg. 66 if (nargin < 5) kernel = "__kernel_normal"; endif # what kernel? - if (nargin < 6) prewhiten = false; endif # automatic prewhitening? + if (nargin < 6) prewhiten = true; endif # automatic prewhitening? if (nargin < 7) do_cv = false; endif # ordinary or leave-1-out if (nargin < 8) computenodes = 0; endif # parallel? if (nargin < 9) debug = false; endif; # debug? @@ -59,7 +60,7 @@ n = rows(depvar); if prewhiten - H = bandwidth*chol(cov(convars)); + H = bandwidth*chol(cov(condvars)); else H = bandwidth; endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-03-20 19:50:39
|
Revision: 7081 http://octave.svn.sourceforge.net/octave/?rev=7081&view=rev Author: hauberg Date: 2010-03-20 19:50:32 +0000 (Sat, 20 Mar 2010) Log Message: ----------- Use 'diag (A)*B' instead of 'dmult (A, B)' Modified Paths: -------------- trunk/octave-forge/main/econometrics/inst/poisson.m trunk/octave-forge/main/econometrics/inst/poisson_moments.m trunk/octave-forge/main/econometrics/inst/scale_data.m Modified: trunk/octave-forge/main/econometrics/inst/poisson.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/poisson.m 2010-03-20 19:44:02 UTC (rev 7080) +++ trunk/octave-forge/main/econometrics/inst/poisson.m 2010-03-20 19:50:32 UTC (rev 7081) @@ -20,6 +20,6 @@ x = data(:,2:columns(data)); lambda = exp(x*theta); log_density = -lambda + y .* (x*theta) - lgamma(y+1); - score = dmult(y - lambda,x); + score = diag (y - lambda) * x; if (otherargs{1} == 1) score = "na"; endif # provide analytic score or not? endfunction Modified: trunk/octave-forge/main/econometrics/inst/poisson_moments.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/poisson_moments.m 2010-03-20 19:44:02 UTC (rev 7080) +++ trunk/octave-forge/main/econometrics/inst/poisson_moments.m 2010-03-20 19:50:32 UTC (rev 7081) @@ -22,5 +22,5 @@ w = data(:, k+2:columns(data)); lambda = exp(x*theta); e = y ./ lambda - 1; - m = dmult(e, w); + m = diag(e) * w; endfunction Modified: trunk/octave-forge/main/econometrics/inst/scale_data.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/scale_data.m 2010-03-20 19:44:02 UTC (rev 7080) +++ trunk/octave-forge/main/econometrics/inst/scale_data.m 2010-03-20 19:50:32 UTC (rev 7081) @@ -38,7 +38,7 @@ # don't take out mean if the column is a constant, to preserve identification b = b .* test; b = A*b; - bb = dmult(b, ones(k,n))'; + bb = (diag(b) * ones(k,n))'; endif zz = z*A + bb; scalecoefs = {A,b}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2012-03-24 18:58:59
|
Revision: 10039 http://octave.svn.sourceforge.net/octave/?rev=10039&view=rev Author: thomas-weber Date: 2012-03-24 18:58:52 +0000 (Sat, 24 Mar 2012) Log Message: ----------- Replace deprecated function calls Modified Paths: -------------- trunk/octave-forge/main/econometrics/inst/gmm_example.m trunk/octave-forge/main/econometrics/inst/gmm_results.m Modified: trunk/octave-forge/main/econometrics/inst/gmm_example.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/gmm_example.m 2012-03-24 18:38:45 UTC (rev 10038) +++ trunk/octave-forge/main/econometrics/inst/gmm_example.m 2012-03-24 18:58:52 UTC (rev 10039) @@ -25,7 +25,7 @@ w = [x, rand(n,1)]; theta_true = ones(k,1); lambda = exp(x*theta_true); -y = poisson_rnd(lambda); +y = poissrnd(lambda); [xs, scalecoef] = scale_data(x); # The arguments for gmm_estimate Modified: trunk/octave-forge/main/econometrics/inst/gmm_results.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/gmm_results.m 2012-03-24 18:38:45 UTC (rev 10038) +++ trunk/octave-forge/main/econometrics/inst/gmm_results.m 2012-03-24 18:58:52 UTC (rev 10039) @@ -88,7 +88,7 @@ df = n - k; if df > 0 clabels = char("Value","df","p-value"); - a = [n*obj_value, df, 1 - chisquare_cdf(n*obj_value, df)]; + a = [n*obj_value, df, 1 - chi2cdf(n*obj_value, df)]; printf("\n"); prettyprint(a, junk, clabels); else @@ -96,7 +96,7 @@ end; # results for parameters - a =[theta, se, theta./se, 2 - 2*normal_cdf(abs(theta ./ se))]; + a =[theta, se, theta./se, 2 - 2*normcdf(abs(theta ./ se))]; clabels = char("estimate", "st. err", "t-stat", "p-value"); printf("\n"); prettyprint(a, names, clabels); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2010-03-20 19:53:31
|
Revision: 7082 http://octave.svn.sourceforge.net/octave/?rev=7082&view=rev Author: hauberg Date: 2010-03-20 19:53:25 +0000 (Sat, 20 Mar 2010) Log Message: ----------- Use 'char' instead of 'str2mat' Modified Paths: -------------- trunk/octave-forge/main/econometrics/inst/gmm_example.m trunk/octave-forge/main/econometrics/inst/gmm_results.m Modified: trunk/octave-forge/main/econometrics/inst/gmm_example.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/gmm_example.m 2010-03-20 19:50:32 UTC (rev 7081) +++ trunk/octave-forge/main/econometrics/inst/gmm_example.m 2010-03-20 19:53:25 UTC (rev 7082) @@ -36,7 +36,7 @@ momentargs = {k}; # needed to know where x ends and w starts # additional args for gmm_results -names = str2mat("theta1", "theta2", "theta3", "theta4", "theta5"); +names = char("theta1", "theta2", "theta3", "theta4", "theta5"); gmmtitle = "Poisson GMM trial"; control = {100,0,1,1}; Modified: trunk/octave-forge/main/econometrics/inst/gmm_results.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/gmm_results.m 2010-03-20 19:50:32 UTC (rev 7081) +++ trunk/octave-forge/main/econometrics/inst/gmm_results.m 2010-03-20 19:53:25 UTC (rev 7082) @@ -25,7 +25,7 @@ # momentargs: (cell) additional inputs needed to compute moments. # May be empty ("") # names: vector of parameter names -# e.g., names = str2mat("param1", "param2"); +# e.g., names = char("param1", "param2"); # title: string, describes model estimated # unscale: (optional) cell that holds means and std. dev. of data # (see scale_data) @@ -87,7 +87,7 @@ junk = "X^2 test"; df = n - k; if df > 0 - clabels = str2mat("Value","df","p-value"); + clabels = char("Value","df","p-value"); a = [n*obj_value, df, 1 - chisquare_cdf(n*obj_value, df)]; printf("\n"); prettyprint(a, junk, clabels); @@ -97,7 +97,7 @@ # results for parameters a =[theta, se, theta./se, 2 - 2*normal_cdf(abs(theta ./ se))]; - clabels = str2mat("estimate", "st. err", "t-stat", "p-value"); + clabels = char("estimate", "st. err", "t-stat", "p-value"); printf("\n"); prettyprint(a, names, clabels); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |