A
download cmpmod.m
Language: Matlab
LOC: 21
Project Info
MatLinks/Chorus(matlinks)
Server: SourceForge
Type: cvs
...chest\copyleft\gpl\stixbox\
   bincoef.m
   cat2tbl.m
   ciboot.m
   ciquant.m
   cmpmod.m
   Contents.m
   contincy.m
   corr.m
   covboot.m
   covjack.m
   cvar.m
   datas1.m
   datas10.m
   datas11.m
   datas2.m
   datas3.m
   datas4.m
   datas5.m
   datas6.m
   datas7.m
   datas8.m
   datas9.m
   dbeta.m
   dbinom.m
   dchisq.m
   df.m
   dgamma.m
   dgumbel.m
   dhypg.m
   dlognorm.m
   dnorm.m
   dt.m
   dweib.m
   egumbel.m
   getdata.m
   histo.m
   identif5.m
   identify.m
   kaplamai.m
   ldiscrim.m
   linreg.m
   lodds.m
   loddsinv.m
   logitfit.m
   lsfit.m
   lsselect.m
   normmix.m
   octvinit.m
   pairs.m
   pbeta.m
   pbinom.m
   pchisq.m
   pf.m
   pgamma.m
   pgumbel.m
   phypg.m
   plognorm.m
   plotdens.m
   plotempd.m
   plotsym.m
   pnorm.m
   pt.m
   pweib.m
   qbeta.m
   qbinom.m
   qchisq.m
   qf.m
   qgamma.m
   qgumbel.m
   qhypg.m
   qlognorm.m
   qnorm.m
   qqgamma.m
   qqgumbel.m
   qqnorm.m
   qqplot.m
   qqweib.m
   qt.m
   quantile.m
   qweib.m
   ranktrf.m
   rbeta.m
   rbinom.m
   rboot.m
   rchisq.m
   Readme.m
   rf.m
   rgamma.m
   rgumbel.m
   rhypg.m
   rlognorm.m
   rnorm.m
   rt.m
   rweib.m
   spearman.m
   stdboot.m
   stdize.m
   stdjack.m
   stixdemo.m
   test1b.m
   test1n.m
   test1r.m
   test2n.m
   test2r.m

function [p, es, el] = cmpmod(Y, As, Al);
%CMPMOD   Compare small linear model versus large one
%
%         [p, es, el] = cmpmod(Y, Xsmall, Xlarge)
%
%	  The standard hypothesis test of a larger linear regression 
%	  model against a smaller one. The standard F-test is used.
%	  The output is the p-value, the residuals from the smaller 
%	  model, and the residuals from the larger model.
%
%	  See also LSFIT 

%       Anders Holtsberg, 27-07-95
%       Copyright (c) Anders Holtsberg

n = length(Y);
ns = size(As,2);
nl = size(Al,2);
one = ones(n,1);
if any((one-As*(As\one))>10*eps)
   disp('Warning: perhaps you should include an intercept column of ones.')
end
if any(any((As-Al*(Al\As))>500*eps))
   disp('Warning: small model not included in large model, result is rubbish!')
end

ths = As\Y;
Ys = As*ths;
es = Y-Ys;

thl = Al\Y;
Yl = Al*thl;
el = Y-Yl;

Rs = sum(es.^2);
Rl = sum(el.^2);

z = ((Rs-Rl)/(nl-ns)) ./ (Rl/(n-nl));

p = 1-pf(z, nl-ns, (n-nl));

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us