[Tutor] PatsyError: categorical data cannot be >1-dimensional

Tariq Khasiri tariqkhasiri at gmail.com
Fri Jun 25 08:43:50 EDT 2021


This following command is saying that my cannot be >1-dimensional.


My categorical variables here are : law_lag (effective year of a law in a
few states of the USA ) , year and statefip ( which is 20 years from
1990-2010 across 50 states [statefip ] of the United States ).


Can anyone tell me if there are any basic issues I'm missing here to
address ? At a beginner level , there's a high chance I'll miss the basic
stuff.


These are the info for my variables btw from my Dataframe after putting the
info command:

year         93585     non-null object

statefip     93585     non-null category

law_lag     92924     non-null float32


## My regression command which is returning me the main error mentioned in
the header

PH = PH[~pd.isnull(PH.ln_incwage)]

PH_male = PH[PH.male==1]

formula = ( "ln_incwage ~ C(law_lag)*C(year) + C(statefip)" " + hispanic +
asian + ismarried + lths + hsdegree + somecollege + age2" )

reg = (

    smf

    .wls(formula, data=PH_male, weights=PH.black.values)

    .fit(

        cov_type='cluster',

        cov_kwds={'groups': PH_male.fip.values},

        method='pinv')

)


reg.summary()


More information about the Tutor mailing list