⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dummycode.m

📁 The BNL toolbox is a set of Matlab functions for defining and estimating the parameters of a Bayesi
💻 M
字号:
function y=dummycode(x,baselinecategory)
%y=dummycode(x,baselinecategory) recodes categorical variable (0,1,...k) into k-1 dummies
% x is a vector, y is a lenght(x)*(k-1) matrix
if nargin==1 baselinecategory=0;,end;

if ~isvector(x)
     error('dummycode takes only vectors as inputs'),return, end;
m=min(x);
r=range(x);
a= find(m==0);
if isempty(a) error('no observations in category 0'),return,end;
y=zeros(length(x), r-1);
for i=1:r+1
    a=find(x==(i-1));
    if isempty(a) error('at least one empty category'),return,end;
    y(a,i)=1;
end
y(:,baselinecategory+1)=[];

    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -