Announcement

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

  • .5178703044404551b invalid name

    I am trying to run this code, with which I have had issues before.


    gen ln_PERCAPITA= ln(PERCAPITA)

    * Regresión

    regress ln_PERCAPITA ethnici1 edumo2 edumo3 edufa2 edufa3 female birthreg2 birthreg3 desplazado1 [iw=FEX_C] if FG==1



    **Construccion inicadormatrix
    matrix b= e(b)'
    mat list b

    mat rowname b = b1 b2 b3 b4 b5 b6 b7 b8 b9 b10
    mat list b
    predict mu

    ** Smoothed distribution
    gen mu_tilde= exp(mu) if FG==1
    label var mu_tilde "Smoothed distribution"
    gen ln_mutilde = ln(mu_tilde)

    **drop mu_tilde
    ** Residuales
    gen e= ln_PERCAPITA-mu if FG==1

    *las comillas en el r(mean) indican que estoy utilizando una variable macro
    sum ethnici1 [iw=FEX_C] if FG==1
    local ethnici1= `r(mean)'
    sum edumo2 [iw=FEX_C] if FG==1
    local edumo2= `r(mean)'
    sum edumo3 [iw=FEX_C] if FG==1
    local edumo3= `r(mean)'
    sum edufa2 [iw=FEX_C] if FG==1
    local edufa2= `r(mean)'
    sum edufa3 [iw=FEX_C] if FG==1
    local edufa3= `r(mean)'
    sum female [iw=FEX_C] if FG==1
    local female= `r(mean)'
    sum birthreg2 [iw=FEX_C] if FG==1
    local birthreg2 = `r(mean)'
    sum birthreg3 [iw=FEX_C] if FG==1
    local birthreg3= `r(mean)'
    sum desplazado1 [iw=FEX_C] if FG==1
    local desplazado1= `r(mean)'



    mat C = (`ethnici1', `edumo2', `edumo3', `edufa2', `edufa3', `female', `birthreg2', `birthreg3' , `desplazado1', 1)

    mat list C
    mat v= C*b
    mat list v

    gen v= `ethnici1'*b[1,1] +`edumo2'*b[2,1] +`edumo3'*b[3,1] + `edufa2'*b[4,1] + `edufa3'*b[5,1] + `female'*b[6,1] + `birthreg2'*b[7,1] + `birthreg3'b[8,1] + `desplazado1'*b[9,1] + b[10, 1]

    sum v
    gen vtilde= exp(v + e) if FG==1
    gen ln_vtilde =ln(vtilde)


    sum(PERCAPITA) [iw=FEX_C] if FG==1
    local sum_percapita= r(sum)
    local mean_percapita= r(mean)
    **Generar ln del mean anterior
    local ln_meanpercapita= ln(`mean_percapita')


    **Logaritmo de los ingresos percapita de cada uno de los indviduos
    sum (ln_PERCAPITA) [iw=FEX_C] if FG==1
    local sum_lnpercapita= r(sum)
    local sum_wlnpercapita= r(sum_w)

    local mld= `ln_meanpercapita' - (`sum_lnpercapita'/`sum_wlnpercapita')
    gen mld= `ln_meanpercapita' - (`sum_lnpercapita'/`sum_wlnpercapita')
    dis `mld'

    ** ineqdeco PERCAPITA [iw=FEX_C] if FG==1

    **Smoothed distribution
    sum(mu_tilde) [iw=FEX_C] if FG==1
    local sum_mutilde= r(sum)
    local mean_mutilde= r(mean)
    **Generar ln del mean anterior
    local ln_meanmutilde= ln(`mean_mutilde')

    sum (ln_mutilde) [iw=FEX_C] if FG==1
    local sum_lnmutilde= r(sum)
    local sum_wlnmutilde= r(sum_w)

    local mldsmooth= `ln_meanmutilde' - (`sum_lnmutilde'/`sum_wlnmutilde')
    gen mldsmooth= `ln_meanmutilde' - (`sum_lnmutilde'/`sum_wlnmutilde')
    dis `mldsmooth'

    *Standardized distribution
    sum(vtilde) [iw=FEX_C] if FG==1
    local sum_vtilde= r(sum)
    local mean_vtilde= r(mean)
    **Generar ln del mean anterior
    local ln_meanvtilde= ln(`mean_vtilde')


    sum (ln_vtilde) [iw=FEX_C] if FG==1
    local sum_lnvtilde= r(sum)
    local sum_wlnvtilde= r(sum_w)

    local mldstandar= `ln_meanvtilde' - (`sum_lnvtilde'/`sum_wlnvtilde')
    gen mldstandar= `ln_meanvtilde' - (`sum_lnvtilde'/`sum_wlnvtilde')
    dis `mldstandar'

    ** IOL (θa) ecuación (10) y (10')
    gen iol= mldsmooth
    gen iol_std= mld - mldstandar

    **IOR (θa) ecuación (11) y (11')
    gen ior= mldsmooth/mld
    gen ior_std= 1 - mldstandar/ mld


    The error is:

    gen v= `ethnici1'*b[1,1] +`edumo2'*b[2,1] +`edumo3'*b[3,1] + `edufa2'*b[4,1] + `edufa3'*b[5,1] + `female'*b[6,1] + `birthreg2'*b
    > [7,1] + `birthreg3'b[8,1] + `desplazado1'*b[9,1] + b[10, 1]
    .5178703044404551b invalid name


    Can anyone help me figuring out the mistake?

  • #2
    gen v= `ethnici1'*b[1,1] +`edumo2'*b[2,1] +`edumo3'*b[3,1] + `edufa2'*b[4,1] + `edufa3'*b[5,1] + `female'*b[6,1] + `birthreg2'*b[7,1] + `birthreg3'b[8,1] + `desplazado1'*b[9,1] + b[10, 1]

    There is a typo, missing an asterisk.

    Comment


    • #3
      Thank you Kenn!!!!

      Comment


      • #4
        After running this code once again, i get an error of invalid syntax,


        gen v= `ethnici1'*b[1,1] + `edumo2'*b[2,1] + `edumo3'*b[3,1] + `edufa2'*b[4,1] + `edufa3'*b[5,1] + `female'*b[6,1] + `birthreg2'*b[7,1] + `birthreg3'*b[8,1] +
        `desplazado1'*b[9,1] + b[10, 1]

        I've checed the type of variables, and all them are numeric

        Can anyone help me?

        Comment


        • #5
          There are no variable names on the right-hand side of your command in #4, just local macro names and matrix elements.

          There could be a typo in #4 I can't spot -- a vacuous comment -- but otherwise check that the local macros are all visible by typing

          Code:
          macro list
          just before your command. I wonder about a bug of the kind explained at

          https://journals.sagepub.com/doi/pdf...36867X20931028

          whereby the local macros have been defined but in some space not visible to your command. This could happen for example if you defined the local macros in a do-file but are using the Command window for the command that will not execute.
          Last edited by Nick Cox; 04 Oct 2023, 02:18.

          Comment

          Working...
          X