Hi,
I'm trying to run matchit followed by zelig to calculate the ATT:
After running z.out <- zelig(@@@), I get the following error message:
Error in `[.data.frame`(d, , all.vars(as.expression(formula))) :
undefined columns selected
I'm not sure why I'm getting this error message--afterwards, I want to run:
x.out1 <- setx(z.out1, data = match.data(m.outf, "treat"), cond = TRUE)
s.out1 <- sim(z.out1, x = x.out1)
Any help at all would be most appreciated!
best,
Prashant
P.S. Specifically, I had run the following code:
ps <- glm(Tr ~ female + urban + father_edu + mother_edu + siblings +
hs_type_best + kuaiban + wangjie + sx_non_mil12 + I(age^2) + I(urban*age) +
I(urban*mother_edu) + I(urban*sx_non_mil12) + I(female*sx_non_mil12) +
I(urban*wangjie) + I(female*wangjie), family=binomial, data=my.data)
X = cbind(age, female, urban, father_edu, mother_edu, siblings,
hs_type_best, kuaiban, wangjie, sx_non_mil12, I(age^2), I(urban*age),
I(urban*mother_edu), I(urban*sx_non_mil12), I(female*sx_non_mil12),
I(urban*wangjie), I(female*wangjie), ps$fitted)
m.outf <- matchit(Tr ~ X, data = rdmatchAC.lk12.range10, method = "genetic",
ratio = 2, replace = TRUE, pop.size=1000, discard = "control")
z.out1 <- zelig(Y1 ~ Tr + X + gk_score, model = "ls", data =
match.data(m.outf, "control"))
x.out1 <- setx(z.out1, data = match.data(m.outf, "treat"), cond = TRUE)
s.out1 <- sim(z.out1, x = x.out1)
I think you need to remove NAs in your data set. When there is "NA" among
the estimated coefficients, sims() cannot handle the simulation.
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Mon, 27 Jul 2009, Murtaza Haider, Professor wrote:
> Dear Kosuke,
>
>
>
> I appreciate your help very much. I'll in future send emails to the Zelig mailing list.
>
>
>
> I have attached with this message a data set that is part of many textbooks, including Bill Greene's Econometric Analysis and David Hensher's Applied Choice Analysis. The data are in public domain and are not restricted by copyright.
>
>
>
> The data set comprise of 210 individuals who were administered a stated preference for intercity travel choices in Australia. The four alternatives were: air, bus, rail, and car. The explanatory variables included the following:
>
>
>
> Id individual's unique ID
>
> Alt alternatives available to the individual
>
> Hinc household income in '000s
>
> Psize size of the traveling party, i.e. number of commuters traveling together
>
> Aasc alternative specific constant for air
>
> Tasc alternative specific constant for train
>
> Basc alternative specific constant for bus
>
> Casc alternative specific constant for car
>
> Psizea size of traveling party interacted with the mode air
>
> Mode chosen alternative
>
> Twait terminal wait time in minutes
>
> Invc cost of travel
>
> Invt in vehicle travel time in minutes
>
> Gc generalized cost, a composite variable consisting of in vehicle travel time and out- of-pocket costs
>
> mc mode choice, 1 if the mode is chosen, 0 otherwise,
>
> hinca household income interacted with mode air
>
> hincb household income interacted with mode bus
>
> hinct household income interacted with mode train
>
> psizeb size of traveling party interacted with mode bus
>
> psizet size of traveling party interacted with mode train
>
> t a variable needed for running the model
>
> choice it is the dependent variable
>
>
>
> In Stata, one can use either clogit or asclogit to estimate McFadden's logit model. In R, we have two alternatives: mlogit, a package written for McFadden's logit, or coxph model, which can be tricked into maximizing the same likelihood function as the other routines do. I used Zelig to estimate coxph.
>
>
>
> The trick with coxph is to create a new variable (t in this case) that assumes the value 2 if the alternative is not chosen by the individual and 1 otherwise. mc is the traditional dependant variable that assumes the value 1 if the alternative is chosen and 0 otherwise.
>
>
>
> I ran the following Zelig command to estimate the coxph model:
>
>
>
> z1 <- zelig(Surv(t,mc) ~ invt+twait+gc+hinc*alt+ strata(id), model = "coxph",data = h09,na.action=na.exclude)
>
>
>
> I get the following error:
>
> ERROR: Invalid status value
>
>
>
> However, when I replace mc with choice in the above script, the model is estimated without any problem:
>
>
>
> It generates the following output:
>
> coef se(coef) exp(coef) z p
>
> invt -0.00449 0.00121 0.9955 -3.723 2.0e-04
>
> twait -0.09709 0.01053 0.9075 -9.218 0.0e+00
>
> gc 0.00747 0.00683 1.0075 1.095 2.7e-01
>
> hinc NA 0.00000 NA NA NA
>
> alt[T.bus] 0.43194 0.90091 1.5402 0.479 6.3e-01
>
> alt[T.car] -3.58484 0.98922 0.0277 -3.624 2.9e-04
>
> alt[T.train] 1.82237 0.82629 6.1865 2.205 2.7e-02
>
> hinc:alt[T.bus] -0.02389 0.01639 0.9764 -1.457 1.4e-01
>
> hinc:alt[T.car] 0.00153 0.01226 1.0015 0.125 9.0e-01
>
> hinc:alt[T.train] -0.06274 0.01567 0.9392 -4.005 6.2e-05
>
>
>
>
>
> The only difference between choice and mc is that mc is a factor variable with value labels, whereas choice does not have any labels.
>
>
>
> Lastly, I cannot simulate using the following code:
>
>
>
> x.out <- setx(z.out, strata = "id")
>
> s.out <- sim(z.out, x = x.out)
>
>
>
> In this particular application of coxph, the simulated values for each individual (strata) should sum to 1.
>
>
>
> Many thanks for your consideration.
>
>
>
> Sincerely, Murtaza
>
>
>
>
>
> -----Original Message-----
> From: Kosuke Imai [mailto:kimai@Princeton.EDU]
> Sent: Monday, July 27, 2009 10:58 AM
> To: Murtaza Haider, Professor
> Cc: Gary King; zelig(a)lists.gking.harvard.edu
> Subject: RE: Thank you for Zelig
>
>
>
> Hi,
>
>
>
> Can you send us a code that replicates this error using the data set we
>
> provide with coxph? That way, we can determine whether this error is
>
> general or something specific to your data set. Also, it would be great
>
> if you could send your queries to the zelig mailing list (cc'd) so that
>
> other users can give you suggestions and/or benefit from the discussion.
>
>
>
> Thanks,
>
> Kosuke
>
>
>
> --
>
> Department of Politics
>
> Princeton University
>
> http://imai.princeton.edu
>
>
>
> On Fri, 24 Jul 2009, Murtaza Haider, Professor wrote:
>
>
>
>> Greetings:
>
>>
>
>> I apologize for the delay in this response. I've been away on vacation. Thank you for suggesting multinomial probit. I have tested it and it works fine.
>
>>
>
>> There is another way of using Zelig to estimate McFadden's Logit models. Because of the similarities in the likelihood functions, one can trick Cox proportional hazards model, which is available in your package, to estimate McFadden's Logit model.
>
>>
>
>> When I used the coxph working in your package, I confronted two issues. First, the choice variable in my data set was a factor variable with names. The algorithm did not work until I stripped the value labels "yes/no" from the binary (1/0) variable.
>
>>
>
>> Secondly, I've not been able to simulate using the s.out command. I get to the s.out stage that returns the message: "subscript out of bounds." Here is the command I ran:
>
>>
>
>> z.out <- zelig(Surv(t,choice) ~ invt+twait+gc+aasc+tasc+ basc+hinca+ strata(id),
>
>> model = "coxph", data = h09,na.action=na.exclude)
>
>>
>
>> x.out <- setx(z.out, strata = "id")
>
>> s.out <- sim(z.out, x = x.out)
>
>>
>
>> Sincerely, Murtaza
>
>>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi,
Can you send us a code that replicates this error using the data set we
provide with coxph? That way, we can determine whether this error is
general or something specific to your data set. Also, it would be great
if you could send your queries to the zelig mailing list (cc'd) so that
other users can give you suggestions and/or benefit from the discussion.
Thanks,
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Fri, 24 Jul 2009, Murtaza Haider, Professor wrote:
> Greetings:
>
> I apologize for the delay in this response. I've been away on vacation. Thank you for suggesting multinomial probit. I have tested it and it works fine.
>
> There is another way of using Zelig to estimate McFadden's Logit models. Because of the similarities in the likelihood functions, one can trick Cox proportional hazards model, which is available in your package, to estimate McFadden's Logit model.
>
> When I used the coxph working in your package, I confronted two issues. First, the choice variable in my data set was a factor variable with names. The algorithm did not work until I stripped the value labels "yes/no" from the binary (1/0) variable.
>
> Secondly, I've not been able to simulate using the s.out command. I get to the s.out stage that returns the message: "subscript out of bounds." Here is the command I ran:
>
> z.out <- zelig(Surv(t,choice) ~ invt+twait+gc+aasc+tasc+ basc+hinca+ strata(id),
> model = "coxph", data = h09,na.action=na.exclude)
>
> x.out <- setx(z.out, strata = "id")
> s.out <- sim(z.out, x = x.out)
>
> Sincerely, Murtaza
>
>
>
>
>
> -----Original Message-----
> From: Kosuke Imai [mailto:kimai@Princeton.EDU]
> Sent: Friday, July 03, 2009 11:29 AM
> To: Gary King
> Cc: Murtaza Haider, Professor
> Subject: Re: Thank you for Zelig
>
> Hi,
>
> Yes, reorganization is a bit of pain and so we may have to add that
> model. For the mean time, you can incorporate choice specific covariates
> in a relatively straightforward manner into a multinomial probit model;
> http://imai.princeton.edu/software/MNP.html The model is quite a bit more
> demanding than multinomial logit, but you may be able to fit it to your
> data.
>
> Good luck,
> Kosuke
>
> ---------------------------------------------------------
> Kosuke Imai Office: Corwin Hall 041
> Assistant Professor Phone: 609-258-6601
> Department of Politics Fax: 609-258-1101
> Princeton University Email: kimai(a)Princeton.Edu
> Princeton, NJ 08544-1012 http://imai.princeton.edu/
> ---------------------------------------------------------
>
> On Fri, 3 Jul 2009, Gary King wrote:
>
>> Thanks for your note. I think its possible to use our mlogit command to run
>> this model by reorganizing the data, but it wouldn't be pleasant to do that
>> reorganization. And so it probably does make sense to add a new model (or
>> easy function to do the reorg) for this.
??>
>> Gary
>> ---
>> http://gking.harvard.edu
>>
>>
>> On 07/02/2009 06:05 PM, Murtaza Haider, Professor wrote:
>>
>> Hi:
>>
>>
??>
>> Thank you indeed for your response. The Logit model I am
>> referring to is also known as McFadden?s Logit (2000 Noble in
>> Economics). The likelihood function of McFadden?s Logit is
>> similar to the Cox Proportional Hazard Model. Stata uses clogit
>> or asclogit
>> (http://www.ats.ucla.edu/stat/stata/seminars/stata10/choice_models.htm)
>> to estimate this model.
>>
>>
??>
>> In McFadden?s Logit model, the data are conditioned differently,
>> where each decision-maker is repeated multiple times in the data
>> set. Using the Mexico data set as an example, each respondent
>> will in fact be entered in three rows because there are three
>> choices in the dependant variable vote88.
>>
>>
??>
>> Let?s assume that we have a variable that controls for the
>> number of face to face meetings between the respondent and
>> representatives of the three political parties. This variable
>> value will then be different for each party for each respondent.
>> This will then become a choice-specific attribute. To deal with
>> such data where the attributes of choice differ for each
>> respondent, one cannot use the conventional multinomial Logit
>> model. I have looked at the options available in the mlogit
>> model under Zelig and believe that this model cannot be fitted
>> using Zelig.
>>
>>
??>
>> Sincerely, Murtaza
>>
>>
??>
>>
??>
>>
??>
>> From: Gary King [mailto:king@harvard.edu]
>> Sent: Thursday, July 02, 2009 5:16 PM
>> To: Murtaza Haider, Ph.D.
>> Subject: Re: Thank you for Zelig
>>
>>
??>
>>
>> doesn't the 'mlogit' model at
>> http://gking.harvard.edu/zelig/docs/index.html do what you want?
>>
>> thanks for the kind words.
>>
>> Gary
>> ---
>> http://gking.harvard.edu
>>
>>
>> On 07/02/2009 11:27 AM, Murtaza Haider, Ph.D. wrote:
>>
>> Dear Gary:
>>
>>
??>
>> I m writing this message to express my deep gratitude for Zelig. It is
>> proving to be a great help in teaching econometrics to my students who
>> are usually uninitiated in statistics and probability.
>>
>>
??>
>> I would like to suggest mlogit (with choice-specific attributes as
>> regressors) to be considered for Zelig. I believe it is not part of
>> Zelig yet. The package is available at the following URL:
>>
>> http://cran.r-project.org/web/packages/mlogit/index.html
>>
>>
??>
>>
??>
>> Sincerely,
>>
>>
??>
>> Murtaza
>>
>>
??>
>> --
>> Murtaza Haider, Ph.D.
>> Associate Professor
>> Ted Rogers School of Retail Management, Ryerson University
>> Director, Institute of Housing & Mobility
>>
>> 350 Victoria Street (Street entrance: 55 Dundas Street West)
>>
>> Toronto, Ontario Canada M5B 2K3
>> Tel: 416.979.5000 x 2480, Fax: 416.979.5324
>>
>>
??>
>>
>>
>
I am hoping that someone on the Zelig mailing list might be able to help
me with the following question. I had previously posted it on the R-help
list but didn't get any replies.
I need to estimate a model that predicts the proportional split of
travel among the vehicles of a household based on vehicle
characteristics such as age, fuel economy, and travel cost per mile. The
model estimation dataset has a record for each household vehicle with
information about the vehicle, the household, and the proportion of the
total household vehicle travel using that vehicle. I have not been able
to figure out how use multinomial logit estimation functions in R to
predict proportions rather than categorical probabilities. I have found
from searching the web that there is a Stata function, FMLOGIT, that
will do what I want. Does anyone know how this can be done in R? All of
my model estimation scripts for the large model I'm building are in R
and I would like to keep it that way to create a nice replicable set of
scripts and data to document the model. Thanks much.
Here's some additional information. I am currently using linear
regression to estimate the model. Then in application I scale the
proportions coming from the model for the vehicles in each household by
dividing by their sum. Perhaps that is good enough.
Brian Gregor
Senior Transportation Analyst
Oregon Department of Transportation
Transportation Planning Analysis Unit
555 13th Street NE
Salem, OR 97301
503-986-4120
Hi,
I'm very sorry to post again. I forgot to mention that there is another
error which may be part of the same problem?
After I run matchit, I run summary(m.outf) and it gives me an error message
as well:
m.outf <- matchit(Tr ~ X, data = lk12_rdmatchAC_range20, method = "genetic",
ratio = 2, replace = TRUE, pop.size=1000, discard = "control")
summary(m.outf)
Error in `row.names<-.data.frame`(`*tmp*`, value = c("distance", "Xage", :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘X.1’
When I next run
plot(m.outf)
there is no problem--I get qq plots that look reasonable.
And of course when I run zelig I get the same problem as before:
z.out1 <- zelig(Y1 ~ Tr + X + gk_score, model = "ls", data =
match.data(m.outf, "control"))
Error in `[.data.frame`(d, , all.vars(as.expression(formula))) :
undefined columns selected
Any advice would be most appreciated!
Thanks!
Hi,
Thanks for pointing this out. We are fixing it, and will let you know
once it's been fixed. For the meantime, you can download separate
chapters by clicking each link. The manual is more than 500 pages and so
you may not want to print out the whole thing!
Thanks,
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Wed, 8 Jul 2009, Roger Leenders wrote:
>
> Hi,
>
> I would like to download the file zelig.pdf from
> http://gking.harvard.edu/zelig/docs/
>
> Unfortunately, every time I try I receive the message that the file can not
> be opened as it is damaged. I have tried it from different computers at
> different times, but it seems to be a persistent problem.
> Could you provide me with the correct file? I would like to give the software
> a go.
>
> sincerely,
> Roger Leenders
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi, Kirill.
I think we need to get something clear here.
- Is pr a categorical variable? Can each observation take one of
four values (J, K, L, or U), but not more than one value at a time?
OR:
- Is pr_J, etc a set of indicator variables? Can an observation
have J = 1 AND K = 1 at the same time (for example)?
If pr_J, etc are indicator variables, you need to check to see if the
set of four indicator variables are collinear. If your indicators are
collinear, then zelig will drop one of them -- in your case J. You
need to fix before you run Zelig (or any R modeling function).
I think that your pr indicators are probably categorical in practice
(if not also in theory). See my previous email about computing first
differences with a categorical variable.
Yours,
Olivia
On Tue, Jul 7, 2009 at 10:05 AM, Kirill Olegovich
Kalinin<kkalinin(a)umich.edu> wrote:
> Dear Olivia,
>
> Thank you. I need to compute first differences for four indicators,
> indicating presence/absence of partisanship, linked to specific parties,
> such as J, K, L and U.
> As a result, I need to compute first differences, such as:
> Pr(Party = 1 | Partisanship J=0) - Pr(Party = 1 | Partisanship J= 1)
> Pr(Party = 1 | Partisanship K=0) - Pr(Party = 1 | Partisanship K=1)
> Pr(Party = 1 | Partisanship L=0) - Pr(Party = 1 | Partisanship L=1)
> Pr(Party = 1 | Partisanship U=0) - Pr(Party = 1 | Partisanship U=1)
>
> The problem with this that one variable (J) needs to be dropped from the
> equation. Although I can compute Pr(Party = 1 | Partisanship J= 1), using
> the command line Partisanship.low<- setx(z.out, pr_K=0, pr_L=0,pr_U=0), it
> is not really obvious for me how to make reference variable Partisanship
> J=0.
>
> Could you help?
>
> Best,
> Kirill
>
>
> Quoting Olivia Lau <olivia.lau(a)post.harvard.edu>:
>
>> Dear Kirill,
>>
>> If pr is a categorical variable, it must take one of the enumerated
>> values (in your case: U, K, L or J). If you want to calculate first
>> differences for pr = J, then there are three first differences that
>> you could calculate:
>>
>> Pr(Party = 1 | pr = J) - Pr(Party = 1 | pr = U) # Since pr = U, pr cannot
>> be J
>> Pr(Party = 1 | pr = J) - Pr(Party = 1 | pr = K)
>> Pr(Party = 1 | pr = J) - Pr(Party = 1 | pr = L)
>>
>> Does this make sense? Because there are four levels in pr, there are
>> 4 - 1 first differences that can be calculated.
>>
>> Yours,
>> Olivia
>>
>> On Sat, Jul 4, 2009 at 2:29 AM, Kirill Olegovich
>> Kalinin<kkalinin(a)umich.edu> wrote:
>>>
>>> Hello Olivia,
>>>
>>> Thank you for your help! Let?s say I need to find Pr(Party = 1 | pr_J =
>>> 0)
>>> - Pr(Party = 1 | pr_J = 1). Is it ok, to write in Zelig
>>> Partisanship.low<- setx(z.out, pr_U=0, pr_K=0, pr_L=0)
>>> Partisanship.high<- setx(z.out, pr_U=1, pr_K=0, pr_L=0) # or pr_K=1 or
>>> pr_L=1 to get pr_J=0
>>> s.out<-sim(z.out, x=Partisanship.high, x1=Partisanship.low)
>>> summary(s.out)
>>>
>>> Is this the right logic?
>>>
>>> Best,
>>> Kirill.
>>>
>>>
>>> Quoting Olivia Lau <olivia.lau(a)post.harvard.edu>:
>>>
>>>> Hi, Kirill.
>>>>
>>>> To obtain a first difference, you need to compare the expected value
>>>> of Pr(Party = 1 | pr_J = 1) to some other Pr(Party = 1 | ... ). Since
>>>> I don't know what you're using for the ..., let's focus on how to
>>>> calculate Pr(Party = 1 | pr_J = 1). There are two approaches:
>>>>
>>>> 1) The way you have it set up now, category J is the reference
>>>> category, such that if pr_U = 0, pr_K = 0, and pr_L = 0, then you can
>>>> calculate Pr(Party = 1 | pr_J = 1). In code:
>>>> z.out <- zelig(Party ~ Presidentialism + pr_U + pr_K + pr_L,
>>>> model = "logit", data=dat).
>>>> x.out <- setx(z.out, pr_U = 0, pr_K = 0, pr_L = 0)
>>>> s.out <- sim(z.out, x = x.out)
>>>>
>>>> 2) When you have a categorical variable in Zelig (or in R, for that
>>>> matter), you don't need to separate the variable into indicator
>>>> variables as you have done. Let's suppose that a categorical variable
>>>> pr has values U, K, L, and J. Then you can do:
>>>> z.out <- zelig(Party ~ Presidentialism + as.factor(pr), model =
>>>> "logit", data=dat)
>>>> x.out <- setx(z.out, as.factor(pr) = "J")
>>>> s.out <- sim(z.out, x = x.out)
>>>>
>>>> Best,
>>>> Olivia
>>>>
>>>>
>>>>
>>>> On Thu, Jul 2, 2009 at 5:27 AM, Kirill Olegovich
>>>> Kalinin<kkalinin(a)umich.edu> wrote:
>>>>>
>>>>> Dear Olivia,
>>>>>
>>>>> I wonder how, can I compute first differences for the reference
>>>>> category,
>>>>> using Zelig. Let?s say, I have four dummy variables pr_U, pr_K, pr_L,
>>>>> pr_J
>>>>> obtained from a single category variable. So after dropping pr_J, I
>>>>> run
>>>>> the model z.out <- zelig(Party ~ Presidentialism + pr_U + pr_K +
>>>>> pr_L,
>>>>> model = "logit", data=dat). How do I calculate first difference for
>>>>> dropped pr_J?
>>>>>
>>>>> Thank you for your help!
>>>>>
>>>>> Best,
>>>>> Kirill.
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Dear Kirill,
If pr is a categorical variable, it must take one of the enumerated
values (in your case: U, K, L or J). If you want to calculate first
differences for pr = J, then there are three first differences that
you could calculate:
Pr(Party = 1 | pr = J) - Pr(Party = 1 | pr = U) # Since pr = U, pr cannot be J
Pr(Party = 1 | pr = J) - Pr(Party = 1 | pr = K)
Pr(Party = 1 | pr = J) - Pr(Party = 1 | pr = L)
Does this make sense? Because there are four levels in pr, there are
4 - 1 first differences that can be calculated.
Yours,
Olivia
On Sat, Jul 4, 2009 at 2:29 AM, Kirill Olegovich
Kalinin<kkalinin(a)umich.edu> wrote:
> Hello Olivia,
>
> Thank you for your help! Let?s say I need to find Pr(Party = 1 | pr_J = 0)
> - Pr(Party = 1 | pr_J = 1). Is it ok, to write in Zelig
> Partisanship.low<- setx(z.out, pr_U=0, pr_K=0, pr_L=0)
> Partisanship.high<- setx(z.out, pr_U=1, pr_K=0, pr_L=0) # or pr_K=1 or
> pr_L=1 to get pr_J=0
> s.out<-sim(z.out, x=Partisanship.high, x1=Partisanship.low)
> summary(s.out)
>
> Is this the right logic?
>
> Best,
> Kirill.
>
>
> Quoting Olivia Lau <olivia.lau(a)post.harvard.edu>:
>
>> Hi, Kirill.
>>
>> To obtain a first difference, you need to compare the expected value
>> of Pr(Party = 1 | pr_J = 1) to some other Pr(Party = 1 | ... ). Since
>> I don't know what you're using for the ..., let's focus on how to
>> calculate Pr(Party = 1 | pr_J = 1). There are two approaches:
>>
>> 1) The way you have it set up now, category J is the reference
>> category, such that if pr_U = 0, pr_K = 0, and pr_L = 0, then you can
>> calculate Pr(Party = 1 | pr_J = 1). In code:
>> z.out <- zelig(Party ~ Presidentialism + pr_U + pr_K + pr_L,
>> model = "logit", data=dat).
>> x.out <- setx(z.out, pr_U = 0, pr_K = 0, pr_L = 0)
>> s.out <- sim(z.out, x = x.out)
>>
>> 2) When you have a categorical variable in Zelig (or in R, for that
>> matter), you don't need to separate the variable into indicator
>> variables as you have done. Let's suppose that a categorical variable
>> pr has values U, K, L, and J. Then you can do:
>> z.out <- zelig(Party ~ Presidentialism + as.factor(pr), model =
>> "logit", data=dat)
>> x.out <- setx(z.out, as.factor(pr) = "J")
>> s.out <- sim(z.out, x = x.out)
>>
>> Best,
>> Olivia
>>
>>
>>
>> On Thu, Jul 2, 2009 at 5:27 AM, Kirill Olegovich
>> Kalinin<kkalinin(a)umich.edu> wrote:
>>>
>>> Dear Olivia,
>>>
>>> I wonder how, can I compute first differences for the reference category,
>>> using Zelig. Let?s say, I have four dummy variables pr_U, pr_K, pr_L,
>>> pr_J
>>> obtained from a single category variable. So after dropping pr_J, I
>>> run
>>> the model z.out <- zelig(Party ~ Presidentialism + pr_U + pr_K +
>>> pr_L,
>>> model = "logit", data=dat). How do I calculate first difference for
>>> dropped pr_J?
>>>
>>> Thank you for your help!
>>>
>>> Best,
>>> Kirill.
>>>
>>
>>
>>
>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi, Kirill.
To obtain a first difference, you need to compare the expected value
of Pr(Party = 1 | pr_J = 1) to some other Pr(Party = 1 | ... ). Since
I don't know what you're using for the ..., let's focus on how to
calculate Pr(Party = 1 | pr_J = 1). There are two approaches:
1) The way you have it set up now, category J is the reference
category, such that if pr_U = 0, pr_K = 0, and pr_L = 0, then you can
calculate Pr(Party = 1 | pr_J = 1). In code:
z.out <- zelig(Party ~ Presidentialism + pr_U + pr_K + pr_L,
model = "logit", data=dat).
x.out <- setx(z.out, pr_U = 0, pr_K = 0, pr_L = 0)
s.out <- sim(z.out, x = x.out)
2) When you have a categorical variable in Zelig (or in R, for that
matter), you don't need to separate the variable into indicator
variables as you have done. Let's suppose that a categorical variable
pr has values U, K, L, and J. Then you can do:
z.out <- zelig(Party ~ Presidentialism + as.factor(pr), model =
"logit", data=dat)
x.out <- setx(z.out, as.factor(pr) = "J")
s.out <- sim(z.out, x = x.out)
Best,
Olivia
On Thu, Jul 2, 2009 at 5:27 AM, Kirill Olegovich
Kalinin<kkalinin(a)umich.edu> wrote:
> Dear Olivia,
>
> I wonder how, can I compute first differences for the reference category,
> using Zelig. Let?s say, I have four dummy variables pr_U, pr_K, pr_L, pr_J
> obtained from a single category variable. So after dropping pr_J, I run
> the model z.out <- zelig(Party ~ Presidentialism + pr_U + pr_K + pr_L,
> model = "logit", data=dat). How do I calculate first difference for
> dropped pr_J?
>
> Thank you for your help!
>
> Best,
> Kirill.
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/