i am trying to create code that recognizes pattern. Specifically if a person makes certain buying behavior every year at the same month (ex : Christmas shopping done on black Friday), and I want to eliminate those shoppers from my analysis.
the variables I have(sample) are :
Dates: Person_id : shopping_item: 20150301 1 10 20140301 1 10
And I am not sure how to code it in Matlab. So far I am thinking the following way: 1) Unique dates and id’s dates = unique(Z.date); ndates = length(dates); insider_id = unique(PersonID); insider_id(isnan(insider_id)) = []; ninsids = length(insider_id);
2) index flt_1 = dates > 0 & insider_id>0;
3) loop (That’s where I need MOST help with THE LOGIC)
for j=1:length(Z.flt_1)
if Z.flt_0(j)>0
diff(Z.date (j), Z.insider_id(j)) = diff(date(j), Z.insider_id(j)) - diff(date(j)-1, Z.insider_id(j))
z= diff=>335 & diff<=395;
pattern=diff.*z;
end
end
Aucun commentaire:
Enregistrer un commentaire