www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@linearmodel/ParameterStatistics.m

    function values = ParameterStatistics(obj, types)
%PARAMETERSTATISTICS Calculates parameter statistics for the linear model.
%
%   STATS = PARAMETERSTATISTICS( LINEARMODEL )
%   STATS = PARAMETERSTATISTICS( LINEARMODEL, STATTYPES )
%
% See also mbcmodel.linearmodel.AliasMatrix,
% mbcmodel.linearmodel.Covariance,
% mbcmodel.linearmodel.Correlation,
% mbcmodel.linearmodel.SingleVIF, 
% mbcmodel.linearmodel.MultipleVIF,
% mbcmodel.linearmodel.PartialVIF

%   Copyright 2004-2007 The MathWorks, Inc.

persistent validTypes
if isempty(validTypes)
    validTypes  = {...
            'Alias'...
            'Covariance'...
            'Correlation'...
            'VIFsingle'...
            'VIFmultiple'...
            'VIFpartial'...
            'Stepwise'...
        };
end

m = obj.Object;

error( obj.pAssertNotBeingEdited( 'Cannot get parameter statistics while the model is being edited.' ) );
error( obj.pAssertIsFitted() );

% Have we got any properties?
ALLPROPS = nargin < 2;
if ALLPROPS
	types = validTypes;
end

ISCHAR = ischar(types);
if ISCHAR
	types = {types};
end

values = cell(1, length(types));
% reorder statistics 
Store= get(m,'Store');
ms= m;
m= InitStore2(m,Store.D,Store.y);

% Iterate over each input type
for i = 1:numel(types)
    % Get this one
    thisType = types{i};
    % Try and find it in the valid types
    index = find(strcmpi(thisType, validTypes));
    % Did we find it?
    if isempty(index)
        error('mbc:mbcmodel:model:InvalidArgument', ...
            'Parameter Statistic type not found');
    end
    switch index;
        case 1 % Alias
            v = alias(m);
        case 2 % Covariance
            v = cov(m);
        case 3 % Correlation
            v = cov(m);
            [s,v]=xregcov2corr(v);
       case 4 % VIFsingle
            v = vifsingle(m);
        case 5 % VIFmultiple
            v = vifmultiple(m);
        case 6 % VIFpartial
            v = vifpartial(m);
        case 7 % Stepwise
            % requires normal order
            tord= termorder(ms);
            [dummy1, dummy2, dummy3, B] = stepwise(ms);
            % calculate t statistics
            nonzero= B(:,2)~=0;
            B(nonzero,3)= B(nonzero,1)./B(nonzero,2);
            B(~nonzero,3)= NaN; 
            % reorder
            v = B(tord,:);
    end
    
    values{i} = v;
end

if ISCHAR
	values = values{1};
end

if ALLPROPS
	values = cell2struct(values, validTypes,2);
end