// input y, mk, ccc, st
// data should have individuals as columns, and time as rows
// program subtracts out ymin

version 16

import delimited "C:\Users\lberg\Box\logtrev\replication_package\regression_data_main.csv"

mata
y = st_data(.,.)
mk=6
ccc=0
st=13

/******* don't change below this point *******/


/* Can go in and add code to take hpfilter and subtract ymin */
T=rows(y)
n=cols(y)
y=y-J(T,n,min(y))

idx1=J(1,1,1::n)'
x2=(idx1\y)
fc=fixedcore(x2,mk)


for(tt=st;tt<=T; tt++){
    xx=y[1::tt,]
	autosort_(xx,mk,ccc,fc)
	ccc=0
}
end