Dear Jason,
Here are some quick responses to your questions.
First, the units that were (or were not) discarded due to common support
restrictions can be identified using the $discarded output from matchit. For
example:
temp <- matchit(treat~re74+re75+age+educ, data=lalonde, discard="both")
temp$discarded
In that case, temp$discarded is a vector of length 614 that is TRUE if units
were discarded because of common support restrictions and FALSE if they were
not.
To output a data set to a .txt or .csv file you can use commands like:
m.data <- match.data(temp)
write.table(m.data, file="matches.txt", sep="\t", quote=FALSE)
That will create a tab-delimited file. Other delimiters can be used by
specifying a different "sep" (see help(write.table) for more information).
I hope this is helpful.
Liz
-----Original Message-----
From: owner-matchit(a)mail-1.hmdc.harvard.edu
[mailto:owner-matchit@mail-1.hmdc.harvard.edu]On Behalf Of Jason Barabas
Sent: Monday, February 27, 2006 9:24 AM
To: matchit(a)mail-1.hmdc.harvard.edu
Subject: [matchit] Common Support and Export Function
Hi,
I have two questions concerning data management in MatchIt. First, how
can I identify the treatment and control units that share common
support, not just those units that are ultimately matched? Second, how
can I export a matched or common support dataset created via match.data
into another program? Section 3.3. of the MatchIt manual mentions
commands like "write.csv" or "write.dta," but an example would be
greatly appreciated.
Thanks.
Jason
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)latte.harvard.edu
Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)latte.harvard.edu
Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Hi,
I have two questions concerning data management in MatchIt. First, how
can I identify the treatment and control units that share common
support, not just those units that are ultimately matched? Second, how
can I export a matched or common support dataset created via match.data
into another program? Section 3.3. of the MatchIt manual mentions
commands like "write.csv" or "write.dta," but an example would be
greatly appreciated.
Thanks.
Jason
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)latte.harvard.edu
Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
You still need to provide the formula since it tells you which variable is
the treatment variable. You should be able to do something like:
m.out <- matchit(treat ~ 1, data=lalonde, method="nearest",
distance=lalonde$ps)
Kosuke
On Tue, 21 Feb 2006, Setoguchi, Soko,M.D. wrote:
> Hi Kosuke,
>
> Thanks for your answer.
> Sorry, I still don't get it.
> Do you mean
> m.out<- Mathcit(distance = lalonde$ps)?
> No need for formula in the function??
>
> Or,
> m.out <- matchit(treat ~ ps , data = lalonde, method = "nearest",
> distance=lalonde$ps)??
>
> Soko
>
>
>
>
> > -----Original Message-----
> > From: Kosuke Imai [mailto:kimai@Princeton.Edu]
> > Sent: Tuesday, February 21, 2006 1:28 PM
> > To: Setoguchi, Soko,M.D.
> > Cc: matchit(a)mail-1.hmdc.harvard.edu
> > Subject: RE: [matchit] Re: question abt MatchIt
> >
> > Dear Soko,
> >
> > distance = lalonde$ps should do it.
> >
> > Cheers,
> > Kosuke
> >
> > -----------------------------------------------------
> > Kosuke Imai Office: Corwin Hall 041
> > Assistant Professor Phone: 609-258-6601
> > Department of Politics eFax: 973-556-1929
> > Princeton University Email: kimai(a)Princeton.Edu
> > Princeton, NJ 08544-1012 http://imai.princeton.edu
> > -----------------------------------------------------
> >
> > On Tue, 21 Feb 2006, Setoguchi, Soko,M.D. wrote:
> >
> > > Hi Kosuke,
> > >
> > > I noticed that you updated MatchIt so that we can use our own distance
> > measure.
> > > So the argument I have to put in is
> > > > distance = pscore
> > >
> > > Would you give me more detailed example?
> > >
> > > For example, if I am using Lalonde data and I have created my propensity
> > score
> > > using a function that is not available within MatchIt. I predicted the
> > > propensity score values by the function and named it as 'lalonde$ps'.
> > >
> > > If I want to used this propensity score to match treated to control
> > using
> > > nearest method, what would the commands be exactly?
> > > I guess I was not sure what to put in as a formula in the function of
> > matchit.
> > >
> > > I would guess you have to do something like
> > > m.out <- matchit(treat ~ ????, data = lalonde, method = "nearest",
> > distance=ps)
> > >
> > > Please let me know.
> > >
> > > Soko
> > >
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: owner-matchit(a)mail-1.hmdc.harvard.edu [mailto:owner-
> > matchit@mail-
> > > > 1.hmdc.harvard.edu] On Behalf Of Kosuke Imai
> > > > Sent: Monday, December 19, 2005 4:11 PM
> > > > To: Gary King
> > > > Cc: Jeanie (Jie) Na; MatchIt Software Listserv
> > > > Subject: Re: [matchit] Re: question abt MatchIt
> > > >
> > > > You can also use your own distance measure by
> > > >
> > > > distance = pscore
> > > >
> > > > where pscore is a vector of your own distance measure.
> > > >
> > > > Kosuke
> > > >
> > > > ---------------------------------------------------------
> > > > Kosuke Imai Office: Corwin Hall 041
> > > > Assistant Professor Phone: 609-258-6601
> > > > Department of Politics Fax: 973-556-1929
> > > > Princeton University Email: kimai(a)Princeton.Edu
> > > > Princeton, NJ 08544-1012 http://imai.princeton.edu
> > > > ---------------------------------------------------------
> > > >
> > > >
> > > > On Dec 19, 2005, at 2:00 PM, Gary King wrote:
> > > >
> > > > > On Fri, 16 Dec 2005, Jeanie (Jie) Na wrote:
> > > > >
> > > > >> Hi Dr. King,
> > > > >>
> > > > >> I am learning to use MatchIt package in R for a project I am
> > > > >> working on.
> > > > >> I have a couple of questions when I read about the manual.
> > > > >>
> > > > >> 1) I have a few categorical variables with multiple levels and a
> > few
> > > > >> continuous variables as covariates. The examples given in the
> > > > >> manual of
> > > > >> MatchIt seem to have all the covariates as dichotomous or
> > > > >> continuous. Do
> > > > >> I need to recode my data and give them values 1 to n (# of levels)?
> > > > >> It doesnt seem to be ok as of now when I have character values for
> > > > >> those
> > > > >> categorical variables.
> > > > >
> > > > > you can exact match on fully category variables. otherwise, i
> > > > > think you'd want to make them into 'continuous' variables as you
> > > > > would right side variables in a regression (such as a set of J-1
> > > > > dummies coding J categories for a nominal variable)
> > > > >
> > > > >>
> > > > >> 2) can you give me an example of the command if I want to use my
> > own
> > > > >> distance measure? What would be the input for distance? Will it be
> > a
> > > > >> distance matrix with rows for the treated,columns for the
> > controlled,
> > > > >> and values are the abs(logit(propensity score of control
> > > > >> i)-logit(propensity score of treated j)). Or would it be a matrix
> > > > >> with
> > > > >> propensity scores as one column?
> > > > >
> > > > > the program allows you to estimate the distance based on
> > > > > Mahalanobis distance or the propensity score computed in a variety
> > > > > of ways. if you need different metrics you might need to explain
> > > > > some more about what you're looking for.
> > > > >
> > > > > Best of luck,
> > > > > Gary King
> > > > >
> > > > >>
> > > > >> I hope I explained myself well. Thank you very much for your advice.
> > > > >> --
> > > > >> Jeanie (Jie) Na
> > > > >>
> > > > >> Programmer Analyst II _ _ ___
> > > > >> _ _ ____
> > > > >> Department of Quantitative Health Sciences [_]-[_] / - \ | |
> > > > >> _| | (_(_
> > > > >> Cleveland Clinic Foundation | | ( |_| ) )
> > > > >> _ ( _| )
> > > > >> Tel: (216)4451369 [_]-[_] \_\_\ |
> > > > >> _| |_| (___/
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >> -------------------------------------------------------------------
> > --
> > > > >> ---------
> > > > >> Confidentiality Note: This message is intended for use only by
> > > > >> the individual or entity to which it is addressed and may contain
> > > > >> information that is privileged, confidential, and exempt from
> > > > >> disclosure under applicable law. If the reader of this message is
> > > > >> not the intended recipient or the employee or agent responsible
> > > > >> for delivering the message to the intended recipient, you are
> > > > >> hereby notified that any dissemination, distribution or copying of
> > > > >> this communication is strictly prohibited. If you have received
> > > > >> this communication in error, please contact the sender
> > > > >> immediately and destroy the material in its entirety, whether
> > > > >> electronic or hard copy. Thank you.
> > > > >> ------------
> > > > >> Visit us online at our award-winning http://
> > > > >> www.clevelandclinic.org for a complete listing of Cleveland Clinic
> > > > >> services, staff and locations from one of the country's leading
> > > > >> hospitals.
> > > > >>
> > =====================================================================
> > > > >> =========
> > > > >>
> > > > >>
> > > > >
> > > > > -
> > > > > MatchIt mailing list served by Harvard-MIT Data Center
> > > > > List Address: matchit(a)latte.harvard.edu
> > > > > Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
> > > > > MatchIt Software and Documentation:
> > http://gking.harvard.edu/matchit/
> > > >
> > > >
> > > > -
> > > > MatchIt mailing list served by Harvard-MIT Data Center
> > > > List Address: matchit(a)latte.harvard.edu
> > > > Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
> > > > MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
> > >
> >
>
>
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)latte.harvard.edu
Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Dear Soko,
distance = lalonde$ps should do it.
Cheers,
Kosuke
-----------------------------------------------------
Kosuke Imai Office: Corwin Hall 041
Assistant Professor Phone: 609-258-6601
Department of Politics eFax: 973-556-1929
Princeton University Email: kimai(a)Princeton.Edu
Princeton, NJ 08544-1012 http://imai.princeton.edu
-----------------------------------------------------
On Tue, 21 Feb 2006, Setoguchi, Soko,M.D. wrote:
> Hi Kosuke,
>
> I noticed that you updated MatchIt so that we can use our own distance measure.
> So the argument I have to put in is
> > distance = pscore
>
> Would you give me more detailed example?
>
> For example, if I am using Lalonde data and I have created my propensity score
> using a function that is not available within MatchIt. I predicted the
> propensity score values by the function and named it as 'lalonde$ps'.
>
> If I want to used this propensity score to match treated to control using
> nearest method, what would the commands be exactly?
> I guess I was not sure what to put in as a formula in the function of matchit.
>
> I would guess you have to do something like
> m.out <- matchit(treat ~ ????, data = lalonde, method = "nearest", distance=ps)
>
> Please let me know.
>
> Soko
>
>
>
>
> > -----Original Message-----
> > From: owner-matchit(a)mail-1.hmdc.harvard.edu [mailto:owner-matchit@mail-
> > 1.hmdc.harvard.edu] On Behalf Of Kosuke Imai
> > Sent: Monday, December 19, 2005 4:11 PM
> > To: Gary King
> > Cc: Jeanie (Jie) Na; MatchIt Software Listserv
> > Subject: Re: [matchit] Re: question abt MatchIt
> >
> > You can also use your own distance measure by
> >
> > distance = pscore
> >
> > where pscore is a vector of your own distance measure.
> >
> > Kosuke
> >
> > ---------------------------------------------------------
> > Kosuke Imai Office: Corwin Hall 041
> > Assistant Professor Phone: 609-258-6601
> > Department of Politics Fax: 973-556-1929
> > Princeton University Email: kimai(a)Princeton.Edu
> > Princeton, NJ 08544-1012 http://imai.princeton.edu
> > ---------------------------------------------------------
> >
> >
> > On Dec 19, 2005, at 2:00 PM, Gary King wrote:
> >
> > > On Fri, 16 Dec 2005, Jeanie (Jie) Na wrote:
> > >
> > >> Hi Dr. King,
> > >>
> > >> I am learning to use MatchIt package in R for a project I am
> > >> working on.
> > >> I have a couple of questions when I read about the manual.
> > >>
> > >> 1) I have a few categorical variables with multiple levels and a few
> > >> continuous variables as covariates. The examples given in the
> > >> manual of
> > >> MatchIt seem to have all the covariates as dichotomous or
> > >> continuous. Do
> > >> I need to recode my data and give them values 1 to n (# of levels)?
> > >> It doesnt seem to be ok as of now when I have character values for
> > >> those
> > >> categorical variables.
> > >
> > > you can exact match on fully category variables. otherwise, i
> > > think you'd want to make them into 'continuous' variables as you
> > > would right side variables in a regression (such as a set of J-1
> > > dummies coding J categories for a nominal variable)
> > >
> > >>
> > >> 2) can you give me an example of the command if I want to use my own
> > >> distance measure? What would be the input for distance? Will it be a
> > >> distance matrix with rows for the treated,columns for the controlled,
> > >> and values are the abs(logit(propensity score of control
> > >> i)-logit(propensity score of treated j)). Or would it be a matrix
> > >> with
> > >> propensity scores as one column?
> > >
> > > the program allows you to estimate the distance based on
> > > Mahalanobis distance or the propensity score computed in a variety
> > > of ways. if you need different metrics you might need to explain
> > > some more about what you're looking for.
> > >
> > > Best of luck,
> > > Gary King
> > >
> > >>
> > >> I hope I explained myself well. Thank you very much for your advice.
> > >> --
> > >> Jeanie (Jie) Na
> > >>
> > >> Programmer Analyst II _ _ ___
> > >> _ _ ____
> > >> Department of Quantitative Health Sciences [_]-[_] / - \ | |
> > >> _| | (_(_
> > >> Cleveland Clinic Foundation | | ( |_| ) )
> > >> _ ( _| )
> > >> Tel: (216)4451369 [_]-[_] \_\_\ |
> > >> _| |_| (___/
> > >>
> > >>
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> ---------
> > >> Confidentiality Note: This message is intended for use only by
> > >> the individual or entity to which it is addressed and may contain
> > >> information that is privileged, confidential, and exempt from
> > >> disclosure under applicable law. If the reader of this message is
> > >> not the intended recipient or the employee or agent responsible
> > >> for delivering the message to the intended recipient, you are
> > >> hereby notified that any dissemination, distribution or copying of
> > >> this communication is strictly prohibited. If you have received
> > >> this communication in error, please contact the sender
> > >> immediately and destroy the material in its entirety, whether
> > >> electronic or hard copy. Thank you.
> > >> ------------
> > >> Visit us online at our award-winning http://
> > >> www.clevelandclinic.org for a complete listing of Cleveland Clinic
> > >> services, staff and locations from one of the country's leading
> > >> hospitals.
> > >> =====================================================================
> > >> =========
> > >>
> > >>
> > >
> > > -
> > > MatchIt mailing list served by Harvard-MIT Data Center
> > > List Address: matchit(a)latte.harvard.edu
> > > Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
> > > MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
> >
> >
> > -
> > MatchIt mailing list served by Harvard-MIT Data Center
> > List Address: matchit(a)latte.harvard.edu
> > Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
> > MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
>
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)latte.harvard.edu
Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Hi,
The MatchIt manual recommends multiple imputation in section 5.2.5 on
page 32. Is it possible to use multiple datasets generated by Amelia in
MatchIt?
Naming each dataset individually does not work (see Example 1 below).
Similarly, the "data=list(...)" method of using multiple datasets in
zelig does not work (see Example 2 below). Finally, I tried to create a
new data frame called "allimputeddata.data" with the variables from each
imputed dataset, but I receive an error message stating: Error in
eval(expr, envir, enclos) : object "outcome" not found. I suspect I
receive this message because the new data frame automatically renames
the variables so that the outcome variables are now
impute1.data.outcome, impute2.data.outcome, etc.
Example 1: m.out <- matchit(outcome ~ var1 + var2 + var3,
data=impute1.data, impute2.data, impute3.data, impute4.data,
impute5.data, method = "nearest")
Example 2: m.out <- matchit(outcome ~ var1 + var2 + var3,
data=list(impute1.data, impute2.data, impute3.data, impute4.data,
impute5.data), method = "nearest")
Example 3: m.out <- matchit(outcome ~ var1 + var2 + var3,
data=allimputeddata.data), method = "nearest")
Thanks for your help.
Jason Barabas
<mailto:matchit@mail-1.hmdc.harvard.edu>
Dear Meng,
Thanks for your message. It sounds like the sample size limitation
may be driven by memory allocation, which can be changed with
memory.limit(), or the amount of RAM on the computer itself. Note
that there can be some limitations to manipulating very large datasets
within R.
I'm not entirely sure about the second error message. If you have
missing data, I'd try subsetting the dataframe to fully-observed
units, as it may be driven by the way that match.data() handles
missing covariates.
Dan
On 2/7/06, Xu, Meng <XuM(a)ccf.org> wrote:
>
>
>
> Dear Dr. Ho,
>
> I am a biostatistician in the "Department of Quantitative Health Sciences"
> of Cleveland Clinic Foundation. I am trying to use MatchIt to do the optimal
> matching and encountering two questions:
>
>
>
> Can you tell me the limit of the sample size for using MatchIt? My control
> is 18000, and I always got the error message of "Error: cannot allocate
> vector of size 7492 Kb"
> When I cut the sample size, it worked and I could get m.out. But when I try
> to use match.data(m.out) to retrieve the data, I got the error message of
> "Error in data.frame(..., check.names = FALSE) : arguments imply differing
> number of rows: 3302, 3125".
>
>
>
> Thank you very much for helping me with this.
>
>
>
> Meng
>
>
>
>
>
> ------------------------------------------------------------------------------
> Confidentiality Note: This message is intended for use only by the
> individual or entity to which it is addressed and may contain information
> that is privileged, confidential, and exempt from disclosure under
> applicable law. If the reader of this message is not the intended recipient
> or the employee or agent responsible for delivering the message to the
> intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please contact the sender
> immediately and destroy the material in its entirety, whether electronic or
> hard copy. Thank you.
> ------------
> Visit us online at our award-winning http://www.clevelandclinic.org for a
> complete listing of Cleveland Clinic services, staff and locations from one
> of the country's leading hospitals.
> ==============================================================================
>
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)latte.harvard.edu
Subscribe/Unsubscribe: http://lists.hmdc.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/