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
-----------------------------------------------------
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/