Dear Matchit authors:
Hope this email finds you well.
I have some questions about categorical variable in matchit(). When I load
the data using read.csv(), I keep the stringsAsFactors = TRUE (default) and
the categorical variables are stored as factor with n levels. For example,
gender will be factor w/2 levels "Female", "male": 1 1 1 2; Treatment will
be factor w/ 2 levels "Treatment",..: 2 2 2 2 2 2 2 2 2 2 ..." ; RELIGION
will be "factor w/ 3 levels "Catholic","None",..: 1 2 3 3 3 3 3 1 1 1 ..."
.
I wonder:
1. whether matchit() works with factors now?
2. if not, could I just convert the categorical variables to numeric, i.e.
gender to 1 and 2; religion to 1, 2, 3; treatment to 1, 2?
3. Or I need to not only convert the categorical variables to numeric but
also need to manually code them as dummies i.e, convert gender to 0 and 1,
convert religion to n-1 dummy variables (Catholic vs. Other; Catholic vs.
None), convert treatment to 0 and 1?
Thank you in advance for your help.
Yanyi
Dear Dr. Rosenbaum:
Thank you so much for your confirmation!
Yanyi
On Wed, Jun 5, 2019 at 12:05 PM Janet Rosenbaum <
Janet.Rosenbaum(a)downstate.edu> wrote:
> Convert to dummies.
>
> > On Jun 5, 2019, at 12:00 PM, matchit-request(a)lists.gking.harvard.edu
> wrote:
> >
> > Send Matchit mailing list submissions to
> > matchit(a)lists.gking.harvard.edu
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > https://lists.gking.harvard.edu/mailman/listinfo/matchit
> > or, via email, send a message with subject or body 'help' to
> > matchit-request(a)lists.gking.harvard.edu
> >
> > You can reach the person managing the list at
> > matchit-owner(a)lists.gking.harvard.edu
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Matchit digest..."
> >
> >
> > Today's Topics:
> >
> > 1. Questions about categorical variable in matchit() (YY J)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Wed, 5 Jun 2019 11:16:14 -0400
> > From: YY J <jiangyanyi01(a)gmail.com>
> > To: matchit(a)lists.gking.harvard.edu
> > Subject: [matchit] Questions about categorical variable in matchit()
> > Message-ID:
> > <CAFqjsgvjJ+8T4Mv7HctsNpzjP5ocMGEaM8fQQy3sj7qneh6uOg(a)mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Dear Matchit authors:
> >
> > Hope this email finds you well.
> >
> > I have some questions about categorical variable in matchit(). When I
> load
> > the data using read.csv(), I keep the stringsAsFactors = TRUE (default)
> and
> > the categorical variables are stored as factor with n levels. For
> example,
> > gender will be factor w/2 levels "Female", "male": 1 1 1 2; Treatment
> will
> > be factor w/ 2 levels "Treatment",..: 2 2 2 2 2 2 2 2 2 2 ..." ; RELIGION
> > will be "factor w/ 3 levels "Catholic","None",..: 1 2 3 3 3 3 3 1 1 1
> ..."
> > .
> >
> > I wonder:
> >
> > 1. whether matchit() works with factors now?
> > 2. if not, could I just convert the categorical variables to numeric,
> i.e.
> > gender to 1 and 2; religion to 1, 2, 3; treatment to 1, 2?
> > 3. Or I need to not only convert the categorical variables to numeric but
> > also need to manually code them as dummies i.e, convert gender to 0 and
> 1,
> > convert religion to n-1 dummy variables (Catholic vs. Other; Catholic vs.
> > None), convert treatment to 0 and 1?
> >
> > Thank you in advance for your help.
> >
> > Yanyi
> >