Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Syntax to multiply the vector of the regressors by the estimated coefficient (omitted because of collinearity)

    I have the following syntax to multiply each vector (independent variable) by the coefficient of the estimation:

    forvalues i = 1(1)103 {
    qui replace F_1isoXyea_`i'_1962 = F_1isoXyea_`i'_1962*exp(_b[F_1isoXyea_`i'_1962])
    }

    However, since there is collinearity some regressors are omitted from the regression, and therefore the syntax reports error.

    [F_1isoXyea_2_1962] not found
    r(111);

    How can I adapt the syntax to do the multiplication by ignoring the cases in which the regressors were omitted from the regression?

    I've attached the do-file to demonstrate the complete syntax.

    Thanks in advance for your attention!
    Attached Files

  • #2
    You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stat output, and sample data using dataex (or illustrate the problem using a Stata supplied data set). Folks don't want to open files. Simplify what you post to the minimum needed to demonstrate your problem.

    When a variable is dropped, you don't lose cases, you lose the variable. You shouldn't have a parameter for the omitted variables at all. You can use the capture prefix to have Stata continue to run even when one of the replaces does not work.
    capture: replace y=x*exp(x)
    or whatever.
    As a matter of style, it is often better to create new variables rather than replace all of a variable - it creates the potential for confusion when you have the same variable with two meanings in a program.

    Comment

    Working...
    X