I have a formal model from which I'm deriving some parameters that I would like to estimate. I haven't done this kind of thing before, and I'd like to have some help to solve this issue in R. I observe $z_i$ (money) and four characteristics of population. I want to regress these characteristics on $z_i$. My regression model should be $$z_i = \frac{\beta N}{\gamma} \ \textbf{1}_{\{\text{type 1}\}} + (\tilde{\alpha} + \tilde{\beta}) \frac{\beta N}{\gamma} \ \textbf{1}_{\{\text{type 2}\}} + (1 - \tilde{\beta}) \frac{\beta N}{\gamma} \ \textbf{1}_{\{\text{type 3}\}} + (\tilde{\alpha}) \frac{\beta N}{\gamma} \ \textbf{1}_{\{\text{type 4}\}} + \epsilon_i$$ where $\epsilon \sim N(\mu, \sigma^2)$

I want the weighting parameters $\tilde{\alpha}$ and $\tilde{\beta}$ to be obtained from a OLS regression, and I want all my coefficients to sum to 1.

Parameters in the equation above are not identified, so I propose to solve this by re-parametrization:$$D_1 = \frac{\beta N}{\gamma} \quad D_2 = (\tilde{\alpha} + \tilde{\beta}) \frac{\beta N}{\gamma} \quad D_3 = (1 - \tilde{\beta}) \frac{\beta N}{\gamma} \quad D_4 = (\tilde{\alpha}) \frac{\beta N}{\gamma}$$

From this I can find $$\frac{D_2}{D_1} = \tilde{\alpha} + \tilde{\beta} \qquad \frac{D_3}{D_1} = 1 - \tilde{\beta} \qquad \frac{D_4}{D_1} = \tilde{\alpha}$$

I want to estimate the equation above in R to get $\tilde{\alpha}$ and $\tilde{\beta}$. How can I do that?



1 Answer 1


Penalized Constrained Least Squares Fitting should be able to help. Otherwise, google "constrained least squares" for some examples that others have posted.

Also, what is $\gamma$, $\beta$ and $N$ in this case? Are they known at all?

  • $\begingroup$ Thanks. I will check that. $\gamma$, $\beta$ and N are just constants. $\endgroup$ Commented Mar 18, 2013 at 17:33
  • $\begingroup$ In that case, see if this helps: $$D_1 + D_2 + D_3 + D_4 = 1$$ $$\frac{\beta N}{\gamma} + \frac{\beta N}{\gamma}(\tilde{\alpha} + \tilde{\beta}) + \frac{\beta N}{\gamma}(1 - \tilde{\beta}) + \frac{\beta N}{\gamma}(\tilde{\alpha}) = 1$$ $$\frac{\beta N}{\gamma}(1 + (\tilde{\alpha} + \tilde{\beta}) + (1 - \tilde{\beta}) + (\tilde{\alpha})) = 1$$ $$2 + 2\tilde{\alpha} = \frac{\gamma}{\beta N}$$ $$\tilde{\alpha} = \frac{\gamma}{2\beta N} - 1$$ $\endgroup$
    – RS18
    Commented Mar 19, 2013 at 2:20
  • $\begingroup$ It does help, but I don't know how to program that in R. $\endgroup$ Commented Mar 19, 2013 at 3:43
  • $\begingroup$ The knowledge that $\gamma$, $\beta$ and $N$ are constant, matched with the constraint of the coefficients summing to 1, means that $\tilde{\alpha}$ must be equal to that, and $\tilde{\beta}$ can be any value, as it doesn't affect the constraint at all. $\endgroup$
    – RS18
    Commented Mar 19, 2013 at 21:30
  • $\begingroup$ This answer (and the knowledge that PCLS exists in mgcv) might be really useful to me, but the R help page is a bit cryptic. Can you recommend a good online tutorial? Maybe a paper or a set of lecture notes? I want to know what it does AND how to program it. $\endgroup$ Commented Apr 17, 2013 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.