Dear Statalist-Community,
I am trying to calculate the distance between two datsets using their latitude & longitude locations and the 'nearstat' command.
Following, the used commands are listed:
************************************************** ****************************
use "$data\Prep_Buffer_DHS.dta", clear
append using "$data\All_Location_Insa_nodup.dta", keep(id latitude longitude)
* Sort so that nearstat will run, putting all projects first
gsort -id
* First count how many projects are within 200 km to know how many loops->to run nearstat
foreach dist in 15 25 50 75 100 200 {
nearstat LATNUM LONGNUM, ///
near(latitude longitude) distvar(_1LSLAdist`dist') ///
ncount(numberwithin`dist') dband(0 `dist') favor(speed)
}
drop _1LSLAdist15 _1LSLAdist25 _1LSLAdist50 _1LSLAdist75 _1LSLAdist100 _1LSLAdist200
************************************************** **********************************
When I run the 'nearstat' command, I get the following error message:
'The order for the nearest neighbor cannot be greater than the number of near features.'
Does anyone know how to interpret the error message? I could'nt find a solution yet.
Thank you very much for your support in advance and warm greetings !
Related Posts with Nearstat Error Message
Bootstrapping for logistic regression on imbalanced dataHi there, I've googled quite a bit but haven't quite figured out how to implement this in STATA. I …
ARDL with daily frequency and with a business calendarI have a doubt, in the ARDL models with stata can they be run with a daily frequency, specifically w…
Counting number of days between dates among different observations excluding overlap by groupHello, I am working on Windows 10, Stata 14.2 for a project that asks to count the number of days a…
error message when using XtgraphHello, I am currently having some issues using xtgraph that I haven't experienced before. When I us…
Counterfactual decomposition issueHi all, I want to use counterfactual decomposition method with a binary dependent variable. I used …
Subscribe to:
Post Comments (Atom)
0 Response to Nearstat Error Message
Post a Comment