Announcement

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

  • categorical variables in gvselect

    Dear all, thanks in advance.

    I’m trying to run the best subset command "gvselect" and I wonder how to introduce the categorical variables.
    If I try to introduce i.categoricalvariable in the varlist I get the error "factor-variable and time-series operators not allowed".

    At this regard in the help- I don't see any explanation.

    Thanks again.
    Gianfranco


  • #2
    I am not familiar with this command, but probably it predates factor variables. As stated in the FAQ Advice #12, you need to state the provenance of community-contributed commands that you reference. Before factor variables, you would use the -xi- prefix or generate the indicators yourself.

    Code:
    sysuse auto, clear
    xi: regress mpg i.rep78
    tabulate rep78, gen(repair)
    regress mpg repair2-repair5

    Comment


    • #3
      Hello Statalisters,

      I am using gvselect from SSC in Stata 13.1. I tried introducing categorical variables in gvselect using the xi prefix after running a logistic regression and got the response and error below. The variables without the i. prefix are continuous. I don't know the reason for this error. Thanks in advance for your help.

      logit hosp pce i.usctyp i.chr_id i.sex i.wealth_cat1 i.caste i.marst i.edu2 i.emp2 i.tobac i.relig i.comorb i.insur ageyr_c diag_mo q402_0_ , vce(cluster village)

      xi: gvselect <term> pce ageyr_c diag_mo q402_0_ i.usctyp i.chr_id i.sex i.wealth_cat1 i.caste i.marst i.edu2 i.emp2 i.tobac i.relig i.comorb i.insur , nmodels(2) : logit hosp <term>

      i.usctyp _Iusctyp_1-2 (naturally coded; _Iusctyp_1 omitted)
      i.chr_id _Ichr_id_1-5 (naturally coded; _Ichr_id_1 omitted)
      i.sex _Isex_1-2 (naturally coded; _Isex_1 omitted)
      i.wealth_cat1 _Iwealth_ca_1-5 (naturally coded; _Iwealth_ca_1 omitted)
      i.caste _Icaste_1-3 (naturally coded; _Icaste_1 omitted)
      i.marst _Imarst_2-3 (naturally coded; _Imarst_2 omitted)
      i.edu2 _Iedu2_1-2 (naturally coded; _Iedu2_1 omitted)
      i.emp2 _Iemp2_1-2 (naturally coded; _Iemp2_1 omitted)
      i.tobac _Itobac_1-2 (naturally coded; _Itobac_1 omitted)
      i.relig _Irelig_1-2 (naturally coded; _Irelig_1 omitted)
      i.comorb _Icomorb_0-1 (naturally coded; _Icomorb_0 omitted)
      i.insur _Iinsur_0-1 (naturally coded; _Iinsur_0 omitted)

      138 observations containing missing predictor values

      varlist not allowed
      r(101);

      Comment

      Working...
      X