Dear forum members,
my data is a panel structured as follows: id change nid1 nid2 nid3 nid4 nid5
For each id, i would like to create a variable that determines how many changes happened in the nids in the previous year. I tried:
egen nn_changes = count(change[_n-1]) if change[_n-1]==1, by( nid1 nid2 nid3 nid4 nid5) but it doesnt seem to work. Is a loop required here?
Your help is appreciated.
Kind regards
Related Posts with Counting observations of nearest neighbours
Using weights in regressionHi everyone, I want to run a regression using weights in stata. I already know which command to use …
Probit margins "Factor not found in list of covariates"Dear Stata users, I am running a probit model with three binary indep. vars. and some other continu…
Multiply imputed dataset still contains missing valuesHi, I've attempted MI with the mi chained command on my dataset of around 6000 with mainly ordinal …
Doubts about ipdmetanHi all, I am performing an analysis using meta-analysis techniques, with raw data at patient level.…
IV regression with FE and first differencesHey everyone! I am investigating the effect that refugees have on rental prices in England. I have …
Subscribe to:
Post Comments (Atom)
0 Response to Counting observations of nearest neighbours
Post a Comment