Hi, is it possible that I can force my independent variables in regress to be positive and add up to 1?
I want to illustrate the synthetic control method as simply being a from of constrained OLS, but I've never manually done this in Stata. Easily done in Python, but I was unsure if we could do it here. Precisely, I need for there to be 1: no constant, 2, all the betas should be greater than or = 0, and the sum of the coefficients must add up to 1. I know cnserg exists, but I've never used it and I was wondering if someone else has
Code:
clear * cls u "http://fmwww.bc.edu/repec/bocode/s/synth_smoking.dta", clear keep state year cigsale frame put state year cigsale, into(scmframe) cwf scmframe reshape wide cigsale, i(year) j(state) // California's ID is 3, so it goes first by convention order cigsale3, a(year) tsset year reg cigsale3 cigsale1-cigsale39 if year < 1989, nocons predict cf_Cali line cigsale3 cf_Cali year, xli(1989) br
Comment