In some cases, the cut() variable can be useful. Here, though, I would do
something like that following:
new.indicator <-1*(abs(var1-var)>=.1)
The statement without the 1* provides a logical vector, and the 1*
converts it to a 0-1 numeric vector.
Best,
Dan
----
Ph.D. Student
Department of Government
Harvard University
Tutor, Currier House
dhopkins(a)fas.harvard.edu
Basic question -
I want to make a dummy variable from a continuous variable such that it is
attached to my dataframe and can be used in further analysis... but I've
only done this before with categorical variables where I could input
something like: dummy<-(var1==1)|(var1==2)|(var1==3)
dummy[(var1==1)]<-1
dummy[(var1==2)|(var1==3)]<-0
But for a continuous var1, I don't know how to do it.
What I want to do is to create a dummy variable that codes 1 when the
difference of 2 continuous variables in my data set is greater than or
equal to .1. (I thought this would require 2 steps - first making a
variable that is the differnce of the two columns, and then making a dummy
from that...)
difference<- abs(var1-var2)
dummy<-as.numeric(div>=.1)
But this doesn't create a variable that I can use in regression, etc with
my other variables... I get errors that variable lengths differ - even
when I try cleaning the data first, etc - so I assume it is because it
needs to be attached to the dataset.
Any help?
On Fri, 21 Apr 2006, Dan Hopkins wrote:
In MatchIt, the "ratio" argument
indicates the number of control units to
be matched to each treated unit.
More generally, the "MatchIt" manual is quite thorough, and provides a
good review of how to implement a wide variety of matching estimators.
We should have mentioned it in section, and perhaps even assigned it--it
will be helpful for the problem set. It is available here:
http://gking.harvard.edu/matchit/docs/matchit.pdf
Best,
Dan
----
Ph.D. Student
Department of Government
Harvard University
Tutor, Currier House
dhopkins(a)fas.harvard.edu
http://www.danhopkins.org
On Fri, 21 Apr 2006, Rebecca Marie Nelson wrote:
Yesterday in section we talked about some different options we might
select when matching, particularly with vs without replacement and 1 to 1
vs 1 to M matching. How do we control these options in R? I looked at
the Zelig guide online and help(matchit), and see that replace=TRUE is an
argument - does this control replacement? Any ideas on what argument
controls 1 to 1 vs 1 to M matching? I did not see an obvious candidate.
Thanks for your help,
Becky
_______________________________________________
gov2001-l mailing list
gov2001-l(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l