Dear Daniel,
We have just uploaded a new version (2.2-11) of MatchIt to CRAN which should
automatically convert variables to factors in the summary() and plot()
commands and thus fix this problem. It should be available on CRAN within
about 24 hours. Please let us know if you continue to have problems with
this.
To answer your other question, the call.=FALSE argument simply tells stop()
not to print out the actual command that led to the error. See help(stop)
for more information.
I hope this is helpful.
Sincerely,
Liz Stuart
-----Original Message-----
From: owner-matchit_at_lists_gking_harvard_edu(a)mail.hmdc.harvard.edu
[mailto:owner-matchit_at_lists_gking_harvard_edu@mail.hmdc.harvard.edu]O
n Behalf Of Daniel Gerlanc
Sent: Monday, July 10, 2006 3:48 PM
To: matchit(a)lists.gking.harvard.edu
Subject: Re: [matchit] Problem w/ Summary in MatchIt; Calls to "stop" in
matchit.R
Thanks! Converting the columns to factors causes the function to
evaluate without errors.
In this case, the MatchIt code should convert character vectors to
factors and possibly tell the user this (or "stop" and tell the user
to coerce the character vector to factor) - Avoid run-time errors!
Another question.
In the "matchit" function located in "matchit.R", calls to "stop"
include a "call" argument:
stop("Dataframe must be specified",call.=FALSE)
What is the purpose of the "call.=FALSE" argument?
Best,
Daniel Gerlanc
Williams College
On 7/8/06, Kosuke Imai <kimai(a)princeton.edu> wrote:
> Hi,
> Perhaps, you can convert a character variable into a factor variable
> using as.factor().
> Hope this helps,
> 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 Wed, 5 Jul 2006, Daniel Gerlanc wrote:
>
> > I am running R 2.3.1 on Linux and using MatchIt version 2.2-10. I'm
> > having a problem similar to the one documented by David Kane on April
> > 18th (See
http://lists.hmdc.harvard.edu/lists/matchit/2006_04/msg00004.html).
> >
> > It seems that when I include a column of class "character" in the data
> > frame that I pass as an argument to "data", the "summary" method
> > returns the following error:
> >
> > Error in x * w : non-numeric argument to binary operator
> > In addition: Warning messages:
> > 1: argument is not numeric or logical: returning NA in:
> > mean.default(x1, na.rm = T)
> > 2: argument is not numeric or logical: returning NA in:
> > mean.default(x0, na.rm = T)
> >
> > I replicated the error using the toy example that Dave Kane provided:
> >
> > > set.seed(1)
> > > x <- data.frame(treated = ifelse(rnorm(100) < -1, 1, 0), b =
rnorm(100), c = ifelse(rnorm(100) < 0, "green", "blue"))
> > > summary(x)
> > treated b c
> > Min. :0.00 Min. :-1.9144 blue :50
> > 1st Qu.:0.00 1st Qu.:-0.6510 green:50
> > Median :0.00 Median :-0.1772
> > Mean :0.11 Mean :-0.0378
> > 3rd Qu.:0.00 3rd Qu.: 0.5009
> > Max. :1.00 Max. : 2.3080
> > > mt <- matchit(treated ~ b, data = x, exact = "c")
> > > summary(mt)
> > Error in x * w : non-numeric argument to binary operator
> > In addition: Warning messages:
> > 1: argument is not numeric or logical: returning NA in:
> > mean.default(x1, na.rm = T)
> > 2: argument is not numeric or logical: returning NA in:
> > mean.default(x0, na.rm = T)
> >
> > Subsequently, I set the "c" column of "x" to all 0s, called "matchit"
> > again, then called called summary. There were no errors under this
> > configuration. As I mentioned earlier, the problem most likely has to
> > do with the multiplication of character data. I would lke to use
> > "character" values as pre-treatment variables so a solution to this
> > problem would be greatly appreciated!
> >
> > Thank you!
> >
> > Daniel Gerlanc
> >
> > -
> > MatchIt mailing list served by Harvard-MIT Data Center
> > List Address: matchit(a)lists.gking.harvard.edu
> > Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
> > MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
> >
>
>
--
Daniel Gerlanc
(201) 213-0927
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.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)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Thanks! Converting the columns to factors causes the function to
evaluate without errors.
In this case, the MatchIt code should convert character vectors to
factors and possibly tell the user this (or "stop" and tell the user
to coerce the character vector to factor) - Avoid run-time errors!
Another question.
In the "matchit" function located in "matchit.R", calls to "stop"
include a "call" argument:
stop("Dataframe must be specified",call.=FALSE)
What is the purpose of the "call.=FALSE" argument?
Best,
Daniel Gerlanc
Williams College
On 7/8/06, Kosuke Imai <kimai(a)princeton.edu> wrote:
> Hi,
> Perhaps, you can convert a character variable into a factor variable
> using as.factor().
> Hope this helps,
> 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 Wed, 5 Jul 2006, Daniel Gerlanc wrote:
>
> > I am running R 2.3.1 on Linux and using MatchIt version 2.2-10. I'm
> > having a problem similar to the one documented by David Kane on April
> > 18th (See http://lists.hmdc.harvard.edu/lists/matchit/2006_04/msg00004.html).
> >
> > It seems that when I include a column of class "character" in the data
> > frame that I pass as an argument to "data", the "summary" method
> > returns the following error:
> >
> > Error in x * w : non-numeric argument to binary operator
> > In addition: Warning messages:
> > 1: argument is not numeric or logical: returning NA in:
> > mean.default(x1, na.rm = T)
> > 2: argument is not numeric or logical: returning NA in:
> > mean.default(x0, na.rm = T)
> >
> > I replicated the error using the toy example that Dave Kane provided:
> >
> > > set.seed(1)
> > > x <- data.frame(treated = ifelse(rnorm(100) < -1, 1, 0), b = rnorm(100), c = ifelse(rnorm(100) < 0, "green", "blue"))
> > > summary(x)
> > treated b c
> > Min. :0.00 Min. :-1.9144 blue :50
> > 1st Qu.:0.00 1st Qu.:-0.6510 green:50
> > Median :0.00 Median :-0.1772
> > Mean :0.11 Mean :-0.0378
> > 3rd Qu.:0.00 3rd Qu.: 0.5009
> > Max. :1.00 Max. : 2.3080
> > > mt <- matchit(treated ~ b, data = x, exact = "c")
> > > summary(mt)
> > Error in x * w : non-numeric argument to binary operator
> > In addition: Warning messages:
> > 1: argument is not numeric or logical: returning NA in:
> > mean.default(x1, na.rm = T)
> > 2: argument is not numeric or logical: returning NA in:
> > mean.default(x0, na.rm = T)
> >
> > Subsequently, I set the "c" column of "x" to all 0s, called "matchit"
> > again, then called called summary. There were no errors under this
> > configuration. As I mentioned earlier, the problem most likely has to
> > do with the multiplication of character data. I would lke to use
> > "character" values as pre-treatment variables so a solution to this
> > problem would be greatly appreciated!
> >
> > Thank you!
> >
> > Daniel Gerlanc
> >
> > -
> > MatchIt mailing list served by Harvard-MIT Data Center
> > List Address: matchit(a)lists.gking.harvard.edu
> > Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
> > MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
> >
>
>
--
Daniel Gerlanc
(201) 213-0927
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
I am running R 2.3.1 on Linux and using MatchIt version 2.2-10. I'm
having a problem similar to the one documented by David Kane on April
18th (See http://lists.hmdc.harvard.edu/lists/matchit/2006_04/msg00004.html).
It seems that when I include a column of class "character" in the data
frame that I pass as an argument to "data", the "summary" method
returns the following error:
Error in x * w : non-numeric argument to binary operator
In addition: Warning messages:
1: argument is not numeric or logical: returning NA in:
mean.default(x1, na.rm = T)
2: argument is not numeric or logical: returning NA in:
mean.default(x0, na.rm = T)
I replicated the error using the toy example that Dave Kane provided:
> set.seed(1)
> x <- data.frame(treated = ifelse(rnorm(100) < -1, 1, 0), b = rnorm(100), c = ifelse(rnorm(100) < 0, "green", "blue"))
> summary(x)
treated b c
Min. :0.00 Min. :-1.9144 blue :50
1st Qu.:0.00 1st Qu.:-0.6510 green:50
Median :0.00 Median :-0.1772
Mean :0.11 Mean :-0.0378
3rd Qu.:0.00 3rd Qu.: 0.5009
Max. :1.00 Max. : 2.3080
> mt <- matchit(treated ~ b, data = x, exact = "c")
> summary(mt)
Error in x * w : non-numeric argument to binary operator
In addition: Warning messages:
1: argument is not numeric or logical: returning NA in:
mean.default(x1, na.rm = T)
2: argument is not numeric or logical: returning NA in:
mean.default(x0, na.rm = T)
Subsequently, I set the "c" column of "x" to all 0s, called "matchit"
again, then called called summary. There were no errors under this
configuration. As I mentioned earlier, the problem most likely has to
do with the multiplication of character data. I would lke to use
"character" values as pre-treatment variables so a solution to this
problem would be greatly appreciated!
Thank you!
Daniel Gerlanc
-
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/