Announcement

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

  • Invalid Syntax: Correcting for Heteroskedasticity & Autocorrelation using Fixed effects

    Dear Statalisterss

    May you kindly assist me with this question. Through this forum i have learnt how to correct for heteroskedasticity and autocorrelation. The problem is i am getting an error message (Invalid syntax, in some cases it says option vce not allowed) ) and i am failing to fix the error. Before i add the command vce (cluster PanelID) the code runs smoothly without errors, but after adding it gives me an error. I have tried to use vce (Cluster PanelID) or vce(robust) but i get the same error message. I am using Stata/SE 15.0
    here is the code i am using (i am pasting the first parts of my code)
    Code:
    // Section 1
     local no=1
     local varlist_depe  OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC
     local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs
     foreach vars in `varlist_depe'{
     qui xtreg `vars' `s1_varlist'  Ind1-Ind13 Yr* if s1!=.,fe vce(cluster CompCode)
     local p=Ftail(e(df_m),e(df_r),e(F))
     qui estat ic
     matrix S=r(S)
    local aic=S[1,5]
    outreg2 using s1_main.doc, append  ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist')  label
    local no=`no'+1
    }
    // Section 3
    local s3Varlist  Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3
    local varlist3    LnNEDelta LnNEDOwn NEDOpsDummy
    
    foreach ret_vari in `varlist3'{
    qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(cluster CompCode)
    local p=Ftail(e(df_m),e(df_r),e(F))
     qui estat ic
    matrix S=r(S)
    local aic=S[1,5]
    outreg2 using s3a_main.doc, append   ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Varlist') label
    local no=`no'+1
    
    qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(cluster CompCode)
    local p=Ftail(e(df_m),e(df_r),e(F))
     qui estat ic
    matrix S=r(S)
    local aic=S[1,5]
    outreg2 using s3b_main.doc, append   ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Varlist') label
    local no=`no'+1
    }
    Thats the code i am using and below i am pasting the output i am getting

    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce cluster (CompCode)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    option vce not allowed
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe cluster (CompCode)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout

    . // Section 3
    . local s3Varlist Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3

    . local varlist3 LnNEDelta LnNEDOwn NEDOpsDummy

    .
    . foreach ret_vari in `varlist3'{
    2. qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe cluster (CompCo
    > de)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s3a_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    8. local no=`no'+1
    9.
    . qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe cluster (CompCode)
    10. local p=Ftail(e(df_m),e(df_r),e(F))
    11. qui estat ic
    12. matrix S=r(S)
    13. local aic=S[1,5]
    14. outreg2 using s3b_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    15. local no=`no'+1
    16. }
    invalid syntax
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=,fe cluster (CompCode)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    invalid syntax
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce(robust)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout

    . // Section 3
    . local s3Varlist Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3

    . local varlist3 LnNEDelta LnNEDOwn NEDOpsDummy

    .
    . foreach ret_vari in `varlist3'{
    2. qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(robust)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s3a_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    8. local no=`no'+1
    9.
    . qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(robust)
    10. local p=Ftail(e(df_m),e(df_r),e(F))
    11. qui estat ic
    12. matrix S=r(S)
    13. local aic=S[1,5]
    14. outreg2 using s3b_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    15. local no=`no'+1
    16. }
    invalid syntax
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe cluster(CompCode)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout

    . // Section 3
    . local s3Varlist Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3

    . local varlist3 LnNEDelta LnNEDOwn NEDOpsDummy

    .
    . foreach ret_vari in `varlist3'{
    2. qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe cluster(CompCode
    > )
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s3a_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    8. local no=`no'+1
    9.
    . qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe cluster(CompCode)
    10. local p=Ftail(e(df_m),e(df_r),e(F))
    11. qui estat ic
    12. matrix S=r(S)
    13. local aic=S[1,5]
    14. outreg2 using s3b_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    15. local no=`no'+1
    16. }
    invalid syntax
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce(robust)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout

    . // Section 3
    . local s3Varlist Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3

    . local varlist3 LnNEDelta LnNEDOwn NEDOpsDummy

    .
    . foreach ret_vari in `varlist3'{
    2. qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(robust)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s3a_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    8. local no=`no'+1
    9.
    . qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(robust)
    10. local p=Ftail(e(df_m),e(df_r),e(F))
    11. qui estat ic
    12. matrix S=r(S)
    13. local aic=S[1,5]
    14. outreg2 using s3b_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    15. local no=`no'+1
    16. }
    invalid syntax
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce(cluster CompCode)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout

    . // Section 3
    . local s3Varlist Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3

    . local varlist3 LnNEDelta LnNEDOwn NEDOpsDummy

    .
    . foreach ret_vari in `varlist3'{
    2. qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(cluster Comp
    > Code)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s3a_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    8. local no=`no'+1
    9.
    . qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(cluster CompCod
    > e)
    10. local p=Ftail(e(df_m),e(df_r),e(F))
    11. qui estat ic
    12. matrix S=r(S)
    13. local aic=S[1,5]
    14. outreg2 using s3b_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    15. local no=`no'+1
    16. }
    invalid syntax
    r(198);

    end of do-file

    r(198);

    . do "C:\Users\01424576\AppData\Local\Temp\STD2158_ 0000 00.tmp"

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Data"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Dat
    > a

    . use database.dta, clear

    . cd "C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Au
    > to\Stata output\2. Fixed effects_Robust"
    C:\Users\01424576\Desktop\Results\With Hausman Test\Original Model but -InstOwnBlockCont - Hetero+Auto\Sta
    > ta output\2. Fixed effects_Robust

    . // drop if Year==2010|Year==2011|Year==2012
    . tsset CompId Year, yearly
    panel variable: CompId (unbalanced)
    time variable: Year, 2002 to 2016, but with gaps
    delta: 1 year

    . set more off

    .
    . // Section 1
    . local no=1

    . local varlist_depe OpsTC LnOpsIss LnNEDelta LnNEDOwn LnTC

    . local s1_varlist K3 CoAct Time InstOwn CEOwn Gops Bsize LnFsize Lvg NEDs

    . foreach vars in `varlist_depe'{
    2. qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce(cluster CompCode)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s1_main.doc, append ctitle("`vars'") addstat( R_sq_within,e(r2), R_sq_between,e(r2_b),
    > R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`s1_varlist') label
    8. local no=`no'+1
    9. }
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout
    s1_main.doc
    dir : seeout

    . // Section 3
    . local s3Varlist Bsize NEDs LnFsize Frsk CAge Lvg CEOwn Gops Block CFOSls InstOwn Indp CoAct ROA K3

    . local varlist3 LnNEDelta LnNEDOwn NEDOpsDummy

    .
    . foreach ret_vari in `varlist3'{
    2. qui xtreg res_2a `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(cluster Comp
    > Code)
    3. local p=Ftail(e(df_m),e(df_r),e(F))
    4. qui estat ic
    5. matrix S=r(S)
    6. local aic=S[1,5]
    7. outreg2 using s3a_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    8. local no=`no'+1
    9.
    . qui xtreg res_2b `ret_vari' c.`ret_vari'#c.K3 `s3Varlist' Ind1-Ind13 Yr* if s3!=.,fe vce(cluster CompCod
    > e)
    10. local p=Ftail(e(df_m),e(df_r),e(F))
    11. qui estat ic
    12. matrix S=r(S)
    13. local aic=S[1,5]
    14. outreg2 using s3b_main.doc, append ctitle("`ret_vari'") addstat( R_sq_within,e(r2), R_sq_between,e(
    > r2_b), R_sq_overall,e(r2_o),F_test, e(F), Prob>F,`p',AIC,`aic') keep(`ret_vari' c.`ret_vari'#c.K3 `s3Var
    > list') label
    15. local no=`no'+1
    16. }
    invalid syntax
    r(198);

    end of do-file

    r(198);
    Last edited by Akios Majoni; 07 Apr 2019, 11:10.

  • #2
    The "option vce not allowed" error message is coming from
    Code:
    qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce cluster (CompCode)
    which should be written as
    Code:
    qui xtreg `vars' `s1_varlist' Ind1-Ind13 Yr* if s1!=.,fe vce (cluster CompCode)
    There is a lot of code to read through here, and much of it is difficult to follow as it refers to things outside itself. Also, because you did not surround it by code delimiters it is badly aligned and there are spurious line breaks, etc. (Please read Forum FAQ #12 for instructions on the use of code delimiters.) The "invalid syntax" messages are arising inside a loop, so it is not immediately apparent which command is even causing the error. I suggest you re-run the code with
    Code:
    set tracedepth 1
    set trace on
    just before the loop. The output will be considerably expanded. In particular, it will show the way that macros are expanded, and you will be able to see from which command the syntax error arose.

    Comment


    • #3
      Thank you Clyde for you help. The "option vce not allowed" error message is now solved. I run the code with set tracedepth 1 and set trace on and i am still going through it. Will give feedback when i am done. Thank you very much



      Comment

      Working...
      X