Skip to content

Commit

Permalink
remove assumptions and add sort for GEKS
Browse files Browse the repository at this point in the history
  • Loading branch information
MjStansfi committed Mar 23, 2022
1 parent 8284ab1 commit 8c5a688
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/multilateral_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ GEKS <- function(input_data,
#Rebase period
input_data[,"period_index":=fmatch(period_index, unique(period_index))]

#Must sort as bilateral assumes p0 and p1 vectors correlate to same product
sortcol <-c("period_index","id")
setorderv(input_data, sortcol)

tempGEK <- GEKS_w(input_data,
index_method,
matched = matched,
Expand Down Expand Up @@ -66,7 +70,6 @@ GEKS_w <- function(input_data,
# for every period in the window...
for(j in 1:n){


# for every period in the window...
for(k in 1:n){
# if j=k then the index is 1
Expand Down Expand Up @@ -112,7 +115,6 @@ GEKS_w <- function(input_data,

}
# calculate the price index for 'base' period j and 'next' period k
# browser()
switch(index_method,
'GEKS-F' = {pindices[j,k] <- fisher_t(p0,p1,q0,q1)},
'GEKS-T' = {pindices[j,k] <- tornqvist_t(p0,p1,q0,q1)},
Expand Down

0 comments on commit 8c5a688

Please sign in to comment.