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.