I'm not exactly sure what's going on with your code, but I think you could
run the same analysis without splitting the data set and running 9
separate analyses just be setting exact = "stock" in a single matchit()
call. Then match.data() could be run on the single output object. cobalt's
bal.tab() can help examine balance on the separate groups.
Noah
On Mon, Feb 26, 2018 at 12:20 PM Samadi, Mehrdad <Mehrdad.Samadi(a)finra.org>
wrote:
Hi All,
I’ve been working with your MatchIT function in R and have a question:
I’m able to successfully run MatchIT on a list of dataframes using the
lapply function, which outputs a large list with a number of elements
corresponding to the number of separate MatchIT procedures that I ran, and
within each of these elements, 9 sub elements which correspond to the
standard output of MatchIt.
While I can successfully extract summary information from this MatchIt
large list using the summary function and lapply or sapply, I’m having
difficulty extracting the matrices of matched observations from each
separate MatchIt procedure. I get the error message, “invalid subscript
type ‘closure’.
Some more context is provide below, any insight that you have would be
helpful. Thanks for your time and consideration.
The raw dataframe “sample” has the following structure:
*stock*
*firm*
*var*
*treated*
APPL
A
0.5
1
APPL
B
0.54
0
APPL
C
0.33
0
APPL
D
0.38
0
APPL
E
0.88
0
BAC
A
0.5
0
BAC
B
0.54
1
BAC
C
0.33
0
BAC
D
0.38
0
BAC
E
0.88
0
JPM
A
0.5
0
JPM
B
0.54
1
JPM
C
0.33
0
JPM
D
0.38
0
JPM
E
0.88
0
I want to use matchit for each stock separately, so I’m using a
combination of the split function and lapply:
X <- split(sample,sample$stock)
output <- lapply(names(X), function(n) {
matchit(treated ~
var,data=X[[n]],method="nearest",distance="mahalanobis",replace=FALSE,ratio=1)})
This would output a large list with 3 elements and within each of these 3
elements, another 9 elements corresponding to MatchIt output.
I would like to extract the matrices corresponding to the matched
observations for each stock using match.data by again using lapply or
sapply, but get the following error:
sapply(output,match.data)
Error in X[[n]] : invalid subscript type 'closure'
Best,
Mehrdad
Confidentiality Notice:: This email, including attachments, may include
non-public, proprietary, confidential or legally privileged information. If
you are not an intended recipient or an authorized agent of an intended
recipient, you are hereby notified that any dissemination, distribution or
copying of the information contained in or transmitted with this e-mail is
unauthorized and strictly prohibited. If you have received this email in
error, please notify the sender by replying to this message and permanently
delete this e-mail, its attachments, and any copies of it immediately. You
should not retain, copy or use this e-mail or any attachment for any
purpose, nor disclose all or any part of the contents to any other person.
Thank you.
-
---
MatchIt mailing list served by HUIT
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe:
http://lists.gking.harvard.edu/mailman/listinfo/ei
MatchIt Software and Documentation:
http://gking.harvard.edu/matchit/
Browse/Search <http://gking.harvard.edu/matchit/Browse/Search> List
Archive:
http://lists.gking.harvard.edu/mailman/private/matchit/
Matchit mailing list
Matchit(a)lists.gking.harvard.edu
To unsubscribe from this list or get other information:
https://lists.gking.harvard.edu/mailman/listinfo/matchit