My data consists of 4 variables:COUNTRY, CATEGORY, EXPORTS and SUM. The variable of interest is EXPORTS. My constraints are working for the sums of CATEGORY and for COUNTRY. The problem is that the value of EXPORTS must not exceed the value of SUM
What I have so far:
data_tab <- xtabs(EXPORTE ~ CATEGORY + COUNTRY, data=data)
cat_tab <- xtabs(EXPORTE ~ CATEGORY, data=IO_data)
country_tab <- xtabs(EXPORTE ~ COUNTRY, data=RGR_data)
target.list <- list(1,2)
target.data <- list(cat_tab,country_tab)
out <- Ipfp(data_tab, target.list, target.data, print = TRUE, tol = 1e-12)
EXP_RAS <- left_join(data,as.data.frame(out$p.hat))
EXP_RAS <- EXP_RAS %>% mutate(EXPORTE_RAS = Freq*sum(cat_tab)) %>% select(-Freq)
How can I add a constraint, that EXPORTS not exceed SUM? Thank you in advance for your help.