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

📄 find_neighborsd2.m

📁 计量工具箱
💻 M
字号:
% PURPOSE: An example of using find_neighbors()%          finds an index to the nearest neighbors %          demo for a large data set                   %---------------------------------------------------% USAGE: find_neighborsd2%---------------------------------------------------clear all;% A data set for 1980 Presidential election results covering 3,107 % US counties. From Pace, R. Kelley and Ronald Barry. 1997. ``Quick% Computation of Spatial Autoregressive Estimators'',% in  Geographical Analysis.% %  Variables are:%  columns 1-4 are census identifiers %  column 5  = lattitude%  column 6  = longitude%  column 7  = population casting votes%  column 8  = population over age 19 eligible to vote%  column 9  = population with college degrees%  column 10 = homeownership%  column 11 = incomeload elect.dat;                    % load data on voteslatt = elect(:,5);long = elect(:,6);y = elect(:,7);    % # of votersy = y./elect(:,8); % percentage of elgible voters voting% To find indexes to m neighbors% (where m is the # of nearest neighbors,)m = 3;index = find_neighbors(latt,long,m);% pull out nearest neighbor values from yy1 = y(index(:,1),1); % pulls out nearest neighbor partcipation rates% plot participation rates in each county vs that in the nearest neighborplot(y,y1,'.g');xlabel('voter participation rates');ylabel('nearest voter participation rates');fprintf(1,'in pause mode, hit any key to continue \n');pause;y2 = y(index(:,1),1)+y(index(:,2),1); % crime rates in nearest 2 neighborsy2 = y2/2; % an average of these% plot participation rates in each county vs the average in the nearest 2 neighborsplot(y,y2,'.r');xlabel('voter participation rates');ylabel('average of 2 neighboring county participation rates');

⌨️ 快捷键说明

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