Mercurial > octave-antonio
view scripts/statistics/tests/f_test_regression.m @ 16826:a4969508008e
doc: Periodic spellcheck of the documentation.
* doc/interpreter/doccheck/aspell-octave.en.pws: Update Octave-specific
Aspell dictionary.
* doc/interpreter/contrib.txi, doc/interpreter/errors.txi,
doc/interpreter/expr.txi, doc/interpreter/io.txi, doc/interpreter/preface.txi,
doc/interpreter/sparse.txi, doc/interpreter/stmt.txi,
doc/interpreter/strings.txi, libinterp/corefcn/qz.cc,
libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/fftw.cc,
libinterp/interpfcn/graphics.cc, scripts/general/structfun.m,
scripts/image/ind2rgb.m, scripts/image/rgb2ind.m, scripts/io/importdata.m,
scripts/linear-algebra/duplication_matrix.m, scripts/linear-algebra/housh.m,
scripts/miscellaneous/mkoctfile.m, scripts/plot/comet3.m, scripts/plot/gco.m,
scripts/plot/legend.m, scripts/plot/print.m, scripts/signal/fftshift.m,
scripts/signal/periodogram.m, scripts/sparse/pcg.m,
scripts/statistics/tests/f_test_regression.m,
scripts/statistics/tests/t_test_regression.m, scripts/strings/strjoin.m,
scripts/strings/strsplit.m: Correct spellings or add @nospell macro.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 23 Jun 2013 12:49:53 -0700 |
parents | 72c96de7a403 |
children | 1c89599167a6 |
line wrap: on
line source
## Copyright (C) 1995-2012 Kurt Hornik ## ## This file is part of Octave. ## ## Octave 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 3 of the License, or (at ## your option) any later version. ## ## Octave 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 Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{pval}, @var{f}, @var{df_num}, @var{df_den}] =} f_test_regression (@var{y}, @var{x}, @var{rr}, @var{r}) ## Perform an F test for the null hypothesis @nospell{rr * b = r} in a ## classical normal regression model y = X * b + e. ## ## Under the null, the test statistic @var{f} follows an F distribution ## with @var{df_num} and @var{df_den} degrees of freedom. ## ## The p-value (1 minus the CDF of this distribution at @var{f}) is ## returned in @var{pval}. ## ## If not given explicitly, @var{r} = 0. ## ## If no output argument is given, the p-value is displayed. ## @end deftypefn ## Author: KH <Kurt.Hornik@wu-wien.ac.at> ## Description: Test linear hypotheses in linear regression model function [pval, f, df_num, df_den] = f_test_regression (y, x, rr, r) if (nargin < 3 || nargin > 4) print_usage (); endif [T, k] = size (x); if (! (isvector (y) && (length (y) == T))) error ("f_test_regression: Y must be a vector of length rows (X)"); endif y = reshape (y, T, 1); [q, c_R ] = size (rr); if (c_R != k) error ("f_test_regression: RR must have as many columns as X"); endif if (nargin == 4) s_r = size (r); if ((min (s_r) != 1) || (max (s_r) != q)) error ("f_test_regression: R must be a vector of length rows (RR)"); endif r = reshape (r, q, 1); else r = zeros (q, 1); endif df_num = q; df_den = T - k; [b, v] = ols (y, x); diff = rr * b - r; f = diff' * inv (rr * inv (x' * x) * rr') * diff / (q * v); pval = 1 - fcdf (f, df_num, df_den); if (nargout == 0) printf (" pval: %g\n", pval); endif endfunction