Dear Statalist members,

english is not my native language, if something should be incomprehensible, then please ask for it and I will try to formulate it in a better way.
I need to regress a constrained regression for my translog cost function. But I need to do it in a way with # as I want to use margins afterwards.
My variables are continuous and represent input prices wk and outputs - loan and deposits.

I have tried these commands but the regression outputs differ from the regression outputs where I generate variables for the interactions in advance...so I suggest that the syntax is wrong here or that I need to include these restrictions differently.

Code:
*\\ MULTIPLY LN SQUARED TERMS BY 0.5
foreach var in deposits loan w1 w2 w3 {
gen double ln_`var'2 =  0.5*(ln_`var')^2
}

Code:
constraint define 1 ln_w1 + ln_w2 + ln_w3= 1

constraint define 2 c.ln_loan#c.ln_w1 + c.ln_loan#c.ln_w2 + c.ln_loan#c.ln_w3 = 0

constraint define 3 c.ln_deposits#c.ln_w1 + c.ln_deposits#c.ln_w2 + c.ln_deposits#c.ln_w3 = 0

constraint define 4 ln_w12 + c.ln_w1#c.ln_w2 + c.ln_w1#c.ln_w3 + ln_w22 + c.ln_w2#c.ln_w3 + ln_w32 = 0
I have read some articles, but they do not have the topic of constraining interaction coefficients...
https://www.stata.com/manuals13/rconstraint.pdf
https://www.statalist.org/forums/for...685-constraint
https://www.statalist.org/forums/for...ht-with-cnsreg

Any advice for me? It do not have to include my variables, I just need the correct way to measure it...

Thank you.