Skip to content

Change fo3 cleaning #21

@korenmiklos

Description

@korenmiklos

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions