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
F test xtreg, fe indicates pooled OLS is better. What are the consequences for fe?Hello, I am running a fixed effects model on an unbalanced dataset. I cannot reject the null hypoth…
Correcting autocorrelation by adding year dummy variables?Hello everybody! For my master dissertation, I'm dealing with panel data. In addition, I detected h…
Replace missings in an unbalanced panel CONDITIONAL on year and firm IDHello everyone, I am new to Statalist and have an issue with filling up missings in a panel data set…
Small N and large T panel analysisHi! I am using panel data with N=6 and monthly data from 2000 to 2017 i.e., T=216. The specific indu…
Panel data regression GLS error*Dear Members! Please could you help me to understand the reason for this: xtrc AVRG_GNI ROA ROE OS…
Subscribe to:
Post Comments (Atom)
0 Response to Nearstat Error Message
Post a Comment