gwr_probitd.m

来自「计量工具箱」· M 代码 · 共 37 行

M
37
字号
% PURPOSE: An example of using gwr_probit()
%          Geographically weighted probit regression model
%          (on a small data set)                  
%---------------------------------------------------
% USAGE: gwr_d 
%---------------------------------------------------

clear all;
% load the Anselin data set
load anselin.dat;
y = anselin(:,1);
nobs = length(y);
x = [ones(nobs,1) anselin(:,2:3)];
[nobs nvar] = size(x);
north = anselin(:,4);
east = anselin(:,5);

% convert y's to 0,1 values
ymean = mean(y);
yzip = zeros(nobs,1);
ind = find(y > ymean);
yzip(ind,1) = 1;

vnames = strvcat('crime','constant','income','hvalue');

% y =  dependent variable
% x = a matrix of indepdendent variables
% east holds  x-coordinates
% north holds y-coordinates
% nobs = # of observations
% nvar = # of explanatory variables
info.dtype = 'gaussian'; % Gaussian distance weighting
tic; result1 = gwr_probit(yzip,x,east,north,info); toc;
prt(result1,vnames);

tt=1:nobs;
plot(tt,yzip,'+',tt,result1.yhat,'o');

⌨️ 快捷键说明

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