-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Take 5 consecutive years of data. The following changes should be made. Other patterns remain the same.
| Data | Corrected |
|---|---|
11011 |
11111 |
01011 |
01111 |
11010 |
11110 |
00100 |
00000 |
10100 |
10000 |
00101 |
00001 |
Basically, change the middle to the 2 neighbors, if in the 4 neighbors they are a majority. Pseudocode, check before running.
forvalues i = 0/1 {
bysort frame_id_numeric (year): generate neighbor`i' = `X'[_n-1] == `i' & `X'[_n+1] == `i'
bysort frame_id_numeric (year): generate sum`i' = (`X'[_n-1] == `i') + (`X'[_n+1] == `i') + (`X'[_n-2] == `i') + (`X'[_n+2] == `i')
replace `X' = `i' if `X' == 1-`i' & neighbor`i' & sum`i' >= 3
} The current code seems to only do this for sumi' == 4`, which is too strict.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels