predict.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/REC-html40/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Description of predict</title>
  6. <meta name="keywords" content="predict">
  7. <meta name="description" content="Interpolate a fit produced by locfit().">
  8. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  9. <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  10. <meta name="robots" content="index, follow">
  11. <link type="text/css" rel="stylesheet" href="../../../m2html.css">
  12. <script type="text/javascript">
  13. if (top.frames.length == 0) { top.location = "../../../index.html"; };
  14. </script>
  15. </head>
  16. <body>
  17. <a name="_top"></a>
  18. <!-- ../../menu.html chronux_2_10 --><!-- # locfit --><!-- menu.html m -->
  19. <h1>predict
  20. </h1>
  21. <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  22. <div class="box"><strong>Interpolate a fit produced by locfit().</strong></div>
  23. <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  24. <div class="box"><strong>function [y, se] = predict(varargin) </strong></div>
  25. <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  26. <div class="fragment"><pre class="comment"> Interpolate a fit produced by locfit().
  27. predict(fit) produces the fitted values at locfit's selected points.
  28. predict(fit,x) interpolates the fits to points specified by x.
  29. Input arguments:
  30. fit The locfit() fit.
  31. x Points to interpolate at. May be a matrix with d columns,
  32. or cell with d components (each a vector). In the former
  33. case, a fitted value is computed for each row of x.
  34. In the latter, the components of x are interpreted as
  35. grid margins.
  36. Can also specify 'data' (evaluate at data points);
  37. or 'fitp' (extract the fitted points).
  38. 'band',value
  39. Type of standard errors to compute. Default is 'band','n', for none.
  40. Other choices are 'band','g' (use a global s to estimate the resiudal
  41. standard deviation, so standard errors are s*||l(x)||);
  42. 'band','l' (use a local s(x), so std. errors are s(x)*||l(x)||);
  43. 'band','p' (prediction errors, so s*sqrt(1+||l(x)||^2).
  44. 'direct'
  45. Compute the local fit directly (rather than using local
  46. regression, at each point specified by the x argument.
  47. 'kappa',vector
  48. Vector of constants for simultaneous confidence bands,
  49. computed by the kappa0() function.
  50. 'level',value
  51. Coverage probability for confidence intervals and bands.
  52. Default is 0.95.
  53. Output is a vector of fitted values (if 'band','n'), or a cell
  54. with fitted value, standard error vectors, and matrix of lower
  55. and upper confidence limits.
  56. Note that for local likelihood fits, back-transformation is
  57. not performed, so that (e.g.) for Poisson regression with the
  58. log-link, the output estimates the log-mean, and its standard errors.
  59. Likewise, for density estimation, the output is log(density).
  60. Author: Catherine Loader.</pre></div>
  61. <!-- crossreference -->
  62. <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  63. This function calls:
  64. <ul style="list-style-image:url(../../../matlabicon.gif)">
  65. </ul>
  66. This function is called by:
  67. <ul style="list-style-image:url(../../../matlabicon.gif)">
  68. <li><a href="../../../chronux_2_10/locfit/Book/fig11_1.html" class="code" title="">fig11_1</a> Local Regression and Likelihood, Figure 11.1</li><li><a href="../../../chronux_2_10/locfit/Book/fig13_1.html" class="code" title="">fig13_1</a> Local Regression and Likelihood, Figure 13.1</li><li><a href="../../../chronux_2_10/locfit/Book/fig5_6.html" class="code" title="">fig5_6</a> Local Regression and Likelihood, Figure 5.6.</li><li><a href="../../../chronux_2_10/locfit/Book/fig6_1.html" class="code" title="">fig6_1</a> Local Regression and Likelihood, Figure 6.1.</li><li><a href="../../../chronux_2_10/locfit/Book/fig6_6.html" class="code" title="">fig6_6</a> Local Regression and Likelihood, Figure 6.6.</li><li><a href="../../../chronux_2_10/locfit/Book/fig7_5.html" class="code" title="">fig7_5</a> Local Regression and Likelihood, Figure 7.5.</li><li><a href="../../../chronux_2_10/locfit/Book/fig7_6.html" class="code" title="">fig7_6</a> Local Regression and Likelihood, Figure 7.6.</li><li><a href="../../../chronux_2_10/locfit/Book/fig8_1.html" class="code" title="">fig8_1</a> Local Regression and Likelihood, Figure 8.1.</li><li><a href="../../../chronux_2_10/locfit/Book/fig8_2.html" class="code" title="">fig8_2</a> Local Regression and Likelihood, Figure 8.2.</li><li><a href="../../../chronux_2_10/locfit/Book/fig9_2.html" class="code" title="">fig9_2</a> Local Regression and Likelihood, Figure 9.2.</li><li><a href="fitted.html" class="code" title="function y = fitted(fit)">fitted</a> Fitted values from a locfit object.</li><li><a href="lfband.html" class="code" title="function lfband(fit,varargin)">lfband</a> adds confidence bands around the plot of a locfit() fit.</li><li><a href="lfplot.html" class="code" title="function lfplot(varargin)">lfplot</a> Plot (for one or two dimensions) a locfit() fit.</li><li><a href="locfit_all.html" class="code" title="function out=locfit_all(varargin)">locfit_all</a> Smoothing noisy data using Local Regression and Likelihood.</li><li><a href="residuals.html" class="code" title="function y = residuals(fit,type)">residuals</a> Residuals (or a few other things) from a locfit() fit.</li><li><a href="scb.html" class="code" title="function z=scb(x,y,varargin)">scb</a> Simultaneous Confidence Bands</li><li><a href="../../../chronux_2_10/spectral_analysis/helper/den_jack.html" class="code" title="function [m,ll,ul,llj,ulj]=den_jack(X,family,varargin)">den_jack</a> Function to compute smooth estimates of the mean of x using locfit,</li></ul>
  69. <!-- crossreference -->
  70. <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  71. <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [y, se] = predict(varargin)</a>
  72. 0002
  73. 0003 <span class="comment">% Interpolate a fit produced by locfit().</span>
  74. 0004 <span class="comment">%</span>
  75. 0005 <span class="comment">% predict(fit) produces the fitted values at locfit's selected points.</span>
  76. 0006 <span class="comment">% predict(fit,x) interpolates the fits to points specified by x.</span>
  77. 0007 <span class="comment">%</span>
  78. 0008 <span class="comment">% Input arguments:</span>
  79. 0009 <span class="comment">% fit The locfit() fit.</span>
  80. 0010 <span class="comment">% x Points to interpolate at. May be a matrix with d columns,</span>
  81. 0011 <span class="comment">% or cell with d components (each a vector). In the former</span>
  82. 0012 <span class="comment">% case, a fitted value is computed for each row of x.</span>
  83. 0013 <span class="comment">% In the latter, the components of x are interpreted as</span>
  84. 0014 <span class="comment">% grid margins.</span>
  85. 0015 <span class="comment">% Can also specify 'data' (evaluate at data points);</span>
  86. 0016 <span class="comment">% or 'fitp' (extract the fitted points).</span>
  87. 0017 <span class="comment">% 'band',value</span>
  88. 0018 <span class="comment">% Type of standard errors to compute. Default is 'band','n', for none.</span>
  89. 0019 <span class="comment">% Other choices are 'band','g' (use a global s to estimate the resiudal</span>
  90. 0020 <span class="comment">% standard deviation, so standard errors are s*||l(x)||);</span>
  91. 0021 <span class="comment">% 'band','l' (use a local s(x), so std. errors are s(x)*||l(x)||);</span>
  92. 0022 <span class="comment">% 'band','p' (prediction errors, so s*sqrt(1+||l(x)||^2).</span>
  93. 0023 <span class="comment">% 'direct'</span>
  94. 0024 <span class="comment">% Compute the local fit directly (rather than using local</span>
  95. 0025 <span class="comment">% regression, at each point specified by the x argument.</span>
  96. 0026 <span class="comment">% 'kappa',vector</span>
  97. 0027 <span class="comment">% Vector of constants for simultaneous confidence bands,</span>
  98. 0028 <span class="comment">% computed by the kappa0() function.</span>
  99. 0029 <span class="comment">% 'level',value</span>
  100. 0030 <span class="comment">% Coverage probability for confidence intervals and bands.</span>
  101. 0031 <span class="comment">% Default is 0.95.</span>
  102. 0032 <span class="comment">%</span>
  103. 0033 <span class="comment">% Output is a vector of fitted values (if 'band','n'), or a cell</span>
  104. 0034 <span class="comment">% with fitted value, standard error vectors, and matrix of lower</span>
  105. 0035 <span class="comment">% and upper confidence limits.</span>
  106. 0036 <span class="comment">%</span>
  107. 0037 <span class="comment">% Note that for local likelihood fits, back-transformation is</span>
  108. 0038 <span class="comment">% not performed, so that (e.g.) for Poisson regression with the</span>
  109. 0039 <span class="comment">% log-link, the output estimates the log-mean, and its standard errors.</span>
  110. 0040 <span class="comment">% Likewise, for density estimation, the output is log(density).</span>
  111. 0041 <span class="comment">%</span>
  112. 0042 <span class="comment">% Author: Catherine Loader.</span>
  113. 0043
  114. 0044 <span class="keyword">if</span> (nargin&lt;1)
  115. 0045 error(<span class="string">'predict requires fit argument'</span>);
  116. 0046 <span class="keyword">end</span>;
  117. 0047
  118. 0048 fit = varargin{1};
  119. 0049
  120. 0050 <span class="keyword">if</span> (nargin==1) x = <span class="string">'fitp'</span>; <span class="keyword">else</span> x = varargin{2}; <span class="keyword">end</span>;
  121. 0051
  122. 0052 band = <span class="string">'n'</span>;
  123. 0053 what = <span class="string">'coef'</span>;
  124. 0054 rest = <span class="string">'none'</span>;
  125. 0055 dir = 0;
  126. 0056 level = 0.95;
  127. 0057 d = size(fit.data.x,2);
  128. 0058 kap = [zeros(1,d) 1];
  129. 0059
  130. 0060 na = 3;
  131. 0061 <span class="keyword">while</span> na &lt;= nargin
  132. 0062 inc = 0;
  133. 0063 <span class="keyword">if</span> strcmp(varargin{na},<span class="string">'band'</span>)
  134. 0064 band = varargin{na+1};
  135. 0065 inc = 2;
  136. 0066 <span class="keyword">end</span>;
  137. 0067 <span class="keyword">if</span> strcmp(varargin{na},<span class="string">'what'</span>)
  138. 0068 what = varargin{na+1};
  139. 0069 inc = 2;
  140. 0070 <span class="keyword">end</span>;
  141. 0071 <span class="keyword">if</span> strcmp(varargin{na},<span class="string">'restyp'</span>)
  142. 0072 rest = varargin{na+1};
  143. 0073 inc = 2;
  144. 0074 <span class="keyword">end</span>;
  145. 0075 <span class="keyword">if</span> strcmp(varargin{na},<span class="string">'direct'</span>)
  146. 0076 dir = 1;
  147. 0077 inc = 1;
  148. 0078 <span class="keyword">end</span>;
  149. 0079 <span class="keyword">if</span> strcmp(varargin{na},<span class="string">'kappa'</span>)
  150. 0080 kap = varargin{na+1};
  151. 0081 inc = 2;
  152. 0082 <span class="keyword">end</span>;
  153. 0083 <span class="keyword">if</span> strcmp(varargin{na},<span class="string">'level'</span>)
  154. 0084 level = varargin{na+1};
  155. 0085 inc = 2;
  156. 0086 <span class="keyword">end</span>;
  157. 0087 <span class="keyword">if</span> (inc == 0)
  158. 0088 disp(varargin{na});
  159. 0089 error(<span class="string">'Unknown argument'</span>);
  160. 0090 <span class="keyword">end</span>;
  161. 0091 na = na+inc;
  162. 0092 <span class="keyword">end</span>;
  163. 0093
  164. 0094 [y se cb] = mexpp(x,fit,band,what,rest,dir,kap,level);
  165. 0095 <span class="keyword">if</span> (band==<span class="string">'n'</span>)
  166. 0096 y = y;
  167. 0097 <span class="keyword">else</span>
  168. 0098 y = {y se cb};
  169. 0099 <span class="keyword">end</span>;
  170. 0100
  171. 0101 <span class="keyword">return</span>;</pre></div>
  172. <hr><address>Generated on Fri 12-Aug-2011 11:36:15 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
  173. </body>
  174. </html>