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

📄 tobit_gd.m

📁 用于做统计分析的matlab 程序包,各种基本统计分析的函数都有
💻 M
字号:
% PURPOSE: An example using tobit_g()
%          Gibbs sampling tobit censored regression
%                         
%---------------------------------------------------
% USAGE: tobit_gd
%---------------------------------------------------

clear all;
% generate uncensored data
n=100; k = 2; sige = 5;
evec = randn(n,1)*sqrt(sige);
tt=1:n;
x = randn(n,k);
x(1:n,1) = ones(n,1);

b = ones(k,1);
b(2,1) = 2.0;
b(1,1) = 0.5;

y = x*b + evec;
% add a few outliers
y(50,1) = 15;
y(75,1) = 15;

yc = zeros(n,1);

% now censor the data
ind = find(y >= 0);
yc(ind,1) = y(ind,1);
if length(ind) == n
	error('no censored observations -- try again');
end;

Vnames = strvcat('y','constant','x1');
          
res1 = ols(yc,x);
res2 = tobit(yc,x);

prior.rval = 40;        % heteroscedastic prior
ndraw = 1100;
nomit = 100;
result = tobit_g(yc,x,ndraw,nomit,prior);

plot(tt,result.vmean);
title('vi-estimates');

prt(res1,Vnames);
prt(res2,Vnames);
prt(result,Vnames);


⌨️ 快捷键说明

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