Sorry I bothered the list with this. The "no missing data" criterion
is documented in the FAQs and, in my haste, I simply didn't look far
enough.
I fixed the file and MatchIt worked like a charm. I would suggest
moving the information about missing data up to discussion of the
routines, however.
Tracy Lightcap
Professor and Chair
Department of Political Science
LaGrange College
601 Broad St.
LaGrange GA 30240-2999
(O) tlightcap(a)lagrange.edu (H) altlamp(a)mindspring.com
706.880.8226
www.lagrange.edu/academics/political-science/faculty/tlightcap.aspx
-
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/
I'm trying to use matchit to preprocess some data. File DUI90 is 470
cases by 8 variables. Some of those variables have missing data. I
tried to use MatchIt on a subset of the variables and got the following:
> drug.out <- matchit (newgroup ~ Age + Sex + Race + Priors, data =
DUI90)
Error in matchit(newgroup ~ Age + Sex + Race + Priors, data = DUI90) :
Missing values exist in the data
But, in fact, they don't, at least for the variables in the model
itself. Does MatchIt have an aversion for missing data in any part of
a data set? It looks that way, but this isn't mentioned in the
documentation. I can see why there might be a no NA restriction for
the model variables, but it seems like the other fields could be
carried along for the ride when they have missing values. It's easy to
fill in the blanks, but tiresome.
I'm using R 2.8.0 on MacOSX 10.5.6 on a Macbook Pro. MatchIt is v.
2.4-10. I see that this was built on R 2.8.1, but I doubt that is the
source of such an elementary problem. Any help is appreciated.
Tracy
Tracy Lightcap
Professor and Chair
Department of Political Science
LaGrange College
601 Broad St.
LaGrange GA 30240-2999
(O) tlightcap(a)lagrange.edu (H) altlamp(a)mindspring.com
706.880.8226
www.lagrange.edu/academics/political-science/faculty/tlightcap.aspx
-
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 Hillard,
Note that both plots display the same information, but that the axes
have been transformed.
In general, for plot.ci, you want to enter the primary term first,
because that will be the reference point for the axis. Using a squared
term (whether centered or not) on the x-axis does not make sense
because the axis cannot be interpreted directly without some mental
math. (And the whole point of a graph is to facilitate
interpretation!)
If you are interested in plot.ci, I recommend that you read the zelig
help for plot.ci (at
http://gking.harvard.edu/zelig/docs/commandsRd/plot.ci.pdf) and the
source code, available when you type plot.ci (without parentheses) at
the command prompt. The plot.ci function passes additional plotting
parameters to the lower-level functions via ..., so any option
available described in help(par) is also available.
Best,
Olivia
On Mon, Apr 27, 2009 at 12:51 AM, Hillard Pouncy
<hillard.pouncy(a)gmail.com> wrote:
> Dear Olivia
> Here's what I did. I just changed the order in which I entered the
> variables from the model I described earlier:
> z.outblksq <- zelig(PTURN100 ~ meblkvar * PDEM100 + I(meblkvar^2) +PIND100 +
> ENTRPY10 + MINC1000, model = "ls", data = turnc)
> In the first attached file labeled blksq.pdf, I entered the variable
> I(medblkvar^2) first. In the second attached file I entered the non-squared
> variable (medblkvar) first. Same terms, just entered in a different order.
> The two graphs tell the same story, but they are strikingly different. For
> the first one, blksq.pdf, the main effect on the x axis is a race variable
> and zero on the X-axis equals districts where the black population is 50
> percent (high diversity). As values on the x axis increase districts
> become less diverse. Because the variable was first centered before being
> squared districts with the same value could be composed of mostly blacks or
> mostly non-blacks. The moderating variable Percent Democratic does a good
> job of pulling the districts apart so that those that are primarily black
> (and primarily Democratic) separate from those that are primarily non-black
> districts (and less Democratic).
> The second one graph, blksqs.pdf is more straight forward and here the main
> effect is a race variable on the x-axis. It is centered so that negative
> values capture less black districts and positive values capture mostly black
> districts. Again Percent Democratic is the moderating variable and again it
> separates the districts nicely.
> I am happy that the Zelig plot package changes its presentation depending
> upon how the variables are entered, but is there a write up somewhere that
> spells out the rules Zelig is using so that I might have even more control
> over my presentation strategy?
> Thanks,
> Hillard Pouncy
>
> On Sun, Apr 26, 2009 at 5:33 PM, Olivia Lau <olivia.lau(a)post.harvard.edu>
> wrote:
>>
>> Dear Hillard,
>>
>> From your code, I can't tell what the alternative model is. In the
>> code you sent, you get the primary effect of meblkvar because you have
>> PDEM100*meblkvar in your formula, which is expanded to PDEM100 +
>> mebklvar + I(PDEM100 * mebklvar). Since the expanded formula has both
>> meblkvar + I(meblkar^2), you should expect the quadratic effect.
>>
>> The plot.ci function simply takes the first of the two terms (in the
>> order you entered them) as the axis label; since you entered
>> I(meblkvar^2) first, that's the axis label. Thus, if you use
>> z.outblksq <- zelig(PTURN100 ~ meblkvar * PDEM100 + I(meblkvar^2) +
>> PIND100 + ENTRPY10 + MINC1000, model = "ls", data = turnc)
>> you should get meblkvar as the axis label. You can, of course,
>> specify the x axis label by using
>> plot.ci(...., xlab = "Whatever meblkvar stands for")
>>
>> Best,
>> Olivia
>>
>> On Sun, Apr 26, 2009 at 5:24 PM, Hillard Pouncy
>> <hillard.pouncy(a)gmail.com> wrote:
>> > Does the variable order in an equation affect the plot outcome?
>> > I calculated this equation z.outblksq <-zelig(PTURN100 ~ I(meblkvar^2) +
>> > PIND100 +PDEM100 * meblkvar + ENTRPY10 + MINC1000, model = "ls", data =
>> > turnc) with a quadratic terms first. I ran a simulation on the
>> > interaction
>> > terms
>> > x.xlow <-setx(z.outblksq, meblkvar = -45:50, PDEM100 = 35)
>> >> x.xhigh <-setx(z.outblksq, meblkvar = -45:50, PDEM100=95)
>> >> s.outblksq <-sim(z.outblksq, x = x.xlow, x= x.xhigh)
>> > The plot.ci command produced a plot I did not expect that used the
>> > quadratic
>> > term for the x axis.
>> > I like the plot, but I don't understand what happened.
>> > I changed the variable in an alternative model and the term on the x
>> > axis
>> > was the non-quadratic variable I expected (meblkvar).
>> > Can anybody explain this one?
>> > best
>> > Hillard Pouncy
>
>
-
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/
Does the variable order in an equation affect the plot outcome?
I calculated this equation z.outblksq <-zelig(PTURN100 ~ I(meblkvar^2) +
PIND100 +PDEM100 * meblkvar + ENTRPY10 + MINC1000, model = "ls", data =
turnc) with a quadratic terms first. I ran a simulation on the interaction
terms
x.xlow <-setx(z.outblksq, meblkvar = -45:50, PDEM100 = 35)
> x.xhigh <-setx(z.outblksq, meblkvar = -45:50, PDEM100=95)
> s.outblksq <-sim(z.outblksq, x = x.xlow, x= x.xhigh)
The plot.ci command produced a plot I did not expect that used the quadratic
term for the x axis.
I like the plot, but I don't understand what happened.
I changed the variable in an alternative model and the term on the x axis
was the non-quadratic variable I expected (meblkvar).
Can anybody explain this one?
best
Hillard Pouncy
Hello,
I tried to analyse a dataset using zelig with 'ls.mixed" where the dataset has been multiple imputed.
zelig itself does not give errors.
So mydata is of class mi.
z.out<-zelig(formula=vas~tampa+tag(1|pp),model="ls.mixed",data=mydata)
But if I want to pool the outcomes and ask for summary(z.out)
it does give errors and no pooled results.
Is that a known problem?
Thanks in advance,
Karin Oudshoorn
I apologize if this was double-posted, I didn't see the original email
make it onto the list
Hello,
In short, I would like some advice on how to interpret and hopefully
plot the results from an ordinal mixed-effects model.
I am working on an analysis to predict the comfort of repeated
hand-washing with soap formulations. Ratings of Like, Indifferent or
Dislike (1, 2 or 3) were recorded after 10 consecutive hand-washings.
Dozens of people participated in the study. (This appears to be a good
candidate for logit.gee also, but this function appears to only accept
binomial responses, not multinomial. I got this response with logit.gee
>>> "ERROR: Cgee" >>> when trying the code: z.out <- zelig(formula=
Score ~ Product + Application, id = "Subject"+ data=soap.data,
model="logit.gee")).
Subject Product Question Application Score Response
1 1 869 2 1 3 Like
2 1 869 2 2 3 Like
3 1 869 2 3 3 Like
4 1 869 2 4 3 Like
5 1 869 2 5 3 Like
6 1 869 2 6 3 Like
> str(soap.data)
'data.frame': 560 obs. of 6 variables:
$ Subject : Factor w/ 56 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1
1 1 ...
$ Product : Factor w/ 2 levels "143","869": 2 2 2 2 2 2 2 2 2 2 ...
$ Question : int 2 2 2 2 2 2 2 2 2 2 ...
$ Application: int 1 2 3 4 5 6 7 8 9 10 ...
$ Score : Factor w/ 3 levels "1","2","3": 3 3 3 3 3 3 3 3 3 3 ...
$ Response : Factor w/ 3 levels "Dislike","Indifferent",..: 3 3 3 3 3
3 3 3 3 3 ...
Logit.mixed
GENERICALLY: z.out <- zelig(formula= Response ~ x1 + x2 + tag(z1 + z2 |
g),
data=mydata, model="logit.mixed")
My interest is in knowing how the score changes as Applications
increase, comparing the 2 Products.
Using the random-intercepts model
z.out <- zelig(formula= Score ~ Product + Application + tag(1 |
Subject),
data=soap.data, model="logit.mixed")
I got the following output
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 9.0872 3.0488 2.981 0.0029 **
Product[T.869] -1.4118 3.5758 -0.395 0.6930
Application -0.0314 0.1147 -0.274 0.7839
Correlation of Fixed Effects:
(Intr) P[T.86
Prdc[T.869] -0.814
Application -0.216 0.004
The logit.mixed analysis worked fine, and I got what I wanted up to a
point. I now have 2 questions ---
1. Does anyone have any suggestions for using Zelig output to plot
the model predictions? I'd like to get something such as the confidence
interval plots that the Effects package produces for multinomial models.
But Effects doesn't recognize the "mer", "lme4" or "gee" object classes.
Specifically, plots of confidence bands around the "Application" slope,
per each Product, are what would be helpful to the scientist I'm
assisting.
2. Could someone help interpret the simulation output? For the
last line of the output, it states Predicted Value Y|X. I assume this
is conditional on the average input values, ( not very interesting in
this case), but to me it seems to be predicting output values of 0 or 1.
The response scale was 1,2, or 3; zero was not possible. Clearly I
don't understand what Predicted Value Y|X output means.
> x.out <- setx(z.out)
> s.out <- sim(z.out, x = x.out)
> summary(s.out)
Model: logit.mixed
Number of simulations: 1000
Values of X
(Intercept) Product[T.869] Application
1 1 0 5.481
Expected Values: E(Y|X)
mean sd 2.5% 97.5%
1 0.9962 0.01909 0.9694 1
Predicted Values: Y|X
0 1
1 0.066 0.934
CONFIDENTIALITY NOTICE:
This e-mail communication and any attachments may contain proprietary and privileged information for the use of the designated recipients named above.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
-
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.
The short answer is: Use vglm directly. Thomas may have implemented
this parameterization.
The long answer is:
You can only change the default parameterization in a Zelig model in
certain classes of models. For example a glm model uses family() to
provide an inverse link function for calculating the expected value
from the linear predictor. The multinomial logit model is implemented
via VGAM, which also has a faimly function. If the VGAM link for the
mlogit model supports an alternative parameterization, you can pass it
to the fitting function using ... -- that is, by adding additional
arguments to zelig(...).
Keep in mind, however, that the MLE is invariant to
reparameterization, and direct interpretation of coefficients is
dangerous. Better to simulate the quantities of interest.
Best,
Olivia
---------- Forwarded message ----------
From: Kirill Olegovich Kalinin <kkalinin(a)umich.edu>
Date: Mon, Apr 13, 2009 at 6:03 PM
Subject: alternative parameterization question
To: olau(a)fas.harvard.edu
Cc: olivia.lau(a)post.harvard.edu
Dear Olivia,
I wonder how can I do alternative parameterization with sum of
parameters equal 0 in Zelig?s mlogit model?
Thank you in advance!
Kirill Kalinin
PhD student,
Department of Political Science,
University of Michigan
-
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/
It looks like it't not the problem: see
https://stat.ethz.ch/pipermail/r-help/2008-August/170205.html
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Thu, 9 Apr 2009, Casey Klofstad wrote:
> Hey Kosuke-
>
> Per this old message you sent me, I'm using logit.survey in Zelig for
> a different project, and I got the error message cited in the URL
> below ("In eval(expr, envir, enclos) : non-integer #successes in a
> binomial glm!"). Does this mean the run failed? It produces results
> (and the result produced differ from a un-weighted model).
>
> Thanks,
>
> -c
>
> On Wed, Mar 4, 2009 at 11:19 PM, Kosuke Imai <kimai(a)princeton.edu> wrote:
>> okay. I think I fixed the errors. I will ask them to upload the new version.
>> One thing about the use of weights in nonlinear models (it works fine for
>> linear models) is that you need to use something like survey package (you
>> will get warning messsages; see
>> https://stat.ethz.ch/pipermail/r-help/2006-April/103862.html) Unfortunately,
>> we have not incorporated this package fully yet (we do have for example
>> survey.logit but we don't have survey.ologit).
>>
>> Kosuke
>>
>> --
>> Department of Politics
>> Princeton University
>> http://imai.princeton.edu
>>
>> On Wed, 4 Mar 2009, Casey Klofstad wrote:
>>
>>> Hey Kosuke-
>>>
>>> "polact" is created with:
>>>
>>> ds1$polact <- (ds1$q12_a + ds1$q12_b + ds1$q12_c + ds1$q12_d)
>>> ds2$polact <- (ds2$q12_a + ds2$q12_b + ds2$q12_c + ds2$q12_d)
>>> ds3$polact <- (ds3$q12_a + ds3$q12_b + ds3$q12_c + ds3$q12_d)
>>> ds4$polact <- (ds4$q12_a + ds4$q12_b + ds4$q12_c + ds4$q12_d)
>>> ds5$polact <- (ds5$q12_a + ds5$q12_b + ds5$q12_c + ds5$q12_d)
>>>
>>> What other error are you getting?
>>>
>>> Best,
>>>
>>> -c
>>>
>>> On Wed, Mar 4, 2009 at 9:44 PM, Kosuke Imai <kimai(a)princeton.edu> wrote:
>>>>
>>>> now i'm getting an error because there is no "polact" variable. also, the
>>>> code you gave me yields an error too...
>>>>
>>>> Kosuke
>>>>
>>>> --
>>>> Department of Politics
>>>> Princeton University
>>>> http://imai.princeton.edu
>>>>
>>>> On Tue, 3 Mar 2009, Casey Klofstad wrote:
>>>>
>>>>> Sorry, here's the code for that:
>>>>>
>>>>> ds1$econview <- (ds1$q18+ds1$q19+ds1$q20)/3
>>>>> ds2$econview <- (ds2$q18+ds2$q19+ds2$q20)/3
>>>>> ds3$econview <- (ds3$q18+ds3$q19+ds3$q20)/3
>>>>> ds4$econview <- (ds4$q18+ds4$q19+ds4$q20)/3
>>>>> ds5$econview <- (ds5$q18+ds5$q19+ds5$q20)/3
>>>>>
>>>>> Also, I've attached the entire code file I've been using in case I
>>>>> forgot to add any other variables to the truncated version I sent you.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> -c
>>>>>
>>>>> On Mon, Mar 2, 2009 at 10:37 PM, Kosuke Imai <kimai(a)princeton.edu>
>>>>> wrote:
>>>>>>
>>>>>> I started looking at this but I get an error because there is no
>>>>>> "econview"
>>>>>> in ds5.
>>>>>>
>>>>>> Kosuke
>>>>>>
>>>>>> --
>>>>>> Department of Politics
>>>>>> Princeton University
>>>>>> http://imai.princeton.edu
>>>>>>
>>>>>> On Wed, 25 Feb 2009, Casey Klofstad wrote:
>>>>>>
>>>>>>> Here you go. The zip file contains 5 imputed data sets and a code
>>>>>>> file. The code file takes you though matching to the analysis
>>>>>>> problems. I'm sure I've just missed soemthing obvious, but who knows.
>>>>>>>
>>>>>>> Thanks VERY much!
>>>>>>>
>>>>>>> Best,
>>>>>>>
>>>>>>> -c
>>>>>>>
>>>>>>> On Wed, Feb 25, 2009 at 5:08 PM, Kosuke Imai <kimai(a)princeton.edu>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> hmmm... can you send me the data set if you don't mind? also a few
>>>>>>>> lines
>>>>>>>> of
>>>>>>>> your code so that I can replicate your error?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Kosuke
>>>>>>>>
>>>>>>>> --
>>>>>>>> Department of Politics
>>>>>>>> Princeton University
>>>>>>>> http://imai.princeton.edu
>>>>>>>>
>>>>>>>> On Wed, 25 Feb 2009, Casey Klofstad wrote:
>>>>>>>>
>>>>>>>>> I just tried this and I get the same error:
>>>>>>>>>
>>>>>>>>> Error in model.frame.default(formula = polact ~ treat, data = list(X
>>>>>>>>> =
>>>>>>>>> 1:2399, :
>>>>>>>>> variable lengths differ (found for '(weights)')
>>>>>>>>>
>>>>>>>>> Best,
>>>>>>>>>
>>>>>>>>> -c
>>>>>>>>>
>>>>>>>>> On Tue, Feb 24, 2009 at 5:13 PM, Kosuke Imai <kimai(a)princeton.edu>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Can you try paste this and then run the negbin model you had a
>>>>>>>>>> trouble
>>>>>>>>>> with?
>>>>>>>>>>
>>>>>>>>>> zelig2negbin <- function(formula, model, data, M, ...) {
>>>>>>>>>> mf <- match.call(expand.dots = TRUE)
>>>>>>>>>> mf$model <- mf$M <- mf$robust <- NULL
>>>>>>>>>> mf[[1]] <- MASS::glm.nb
>>>>>>>>>> if (is.character(mf$weights))
>>>>>>>>>> mf$weights <- as.name(mf$weights)
>>>>>>>>>> as.call(mf)
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Kosuke
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Department of Politics
>>>>>>>>>> Princeton University
>>>>>>>>>> http://imai.princeton.edu
>>>>>>>>>>
>>>>>>>>>> On Tue, 24 Feb 2009, Casey Klofstad wrote:
>>>>>>>>>>
>>>>>>>>>>> Hey Kosuke-
>>>>>>>>>>>
>>>>>>>>>>> Thanks for the response.
>>>>>>>>>>>
>>>>>>>>>>> I tried this and I still get the same error with just one ds.
>>>>>>>>>>> Also,
>>>>>>>>>>> I
>>>>>>>>>>> note that I have the same problem with negbin, but not poisson.
>>>>>>>>>>>
>>>>>>>>>>> ??!?!?
>>>>>>>>>>>
>>>>>>>>>>> Best,
>>>>>>>>>>>
>>>>>>>>>>> -c
>>>>>>>>>>>
>>>>>>>>>>> On Tue, Feb 24, 2009 at 3:56 PM, Kosuke Imai <kimai(a)princeton.edu>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Does the same command work on one of the imputed data sets
>>>>>>>>>>>> without
>>>>>>>>>>>> mi()?
>>>>>>>>>>>>
>>>>>>>>>>>> Kosuke
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Department of Politics
>>>>>>>>>>>> Princeton University
>>>>>>>>>>>> http://imai.princeton.edu
>>>>>>>>>>>>
>>>>>>>>>>>> On Tue, 24 Feb 2009, Casey Klofstad wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hey all-
>>>>>>>>>>>>>
>>>>>>>>>>>>> I posted the below onthe Zelig discussion board, but I think
>>>>>>>>>>>>> this
>>>>>>>>>>>>> might also be related to MatchIt:
>>>>>>>>>>>>>
>>>>>>>>>>>>> I just weighted some data, and am trying to examine the results
>>>>>>>>>>>>> with
>>>>>>>>>>>>> ordered logit. The code is:
>>>>>>>>>>>>>
>>>>>>>>>>>>> z.out <- zelig(as.factor(polact) ~ treat, weights="weights",
>>>>>>>>>>>>> data
>>>>>>>>>>>>> =
>>>>>>>>>>>>> mi(ds1, ds2, ds3, ds4, ds5), model = "ologit")
>>>>>>>>>>>>>
>>>>>>>>>>>>> This produces the error:
>>>>>>>>>>>>>
>>>>>>>>>>>>> Error in model.frame.default(formula = as.factor(polact) ~
>>>>>>>>>>>>> treat,
>>>>>>>>>>>>> data
>>>>>>>>>>>>> =
>>>>>>>>>>>>> list( :
>>>>>>>>>>>>> variable lengths differ (found for '(weights)')
>>>>>>>>>>>>>
>>>>>>>>>>>>> The same weighted model above runs fine in OLS, and I am running
>>>>>>>>>>>>> MatchIt Version 2.4-10 (downloaded from Gary King's website).
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thoughts?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks much,
>>>>>>>>>>>>>
>>>>>>>>>>>>> -c
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>
>
>
>
>
Is there an easy way to loop through a series of simulations with
different DVs?
e.g., suppose I have a list of DV names and I want to simulate
quantities of interest for the same model run against each DV. Can I
do something like this:
dvnames <- c("risk.scale", "instr.scale", "affect.scale")
for (dvname in dvnames) {
z.out <- zelig([dvname] ~ male + age,
model = "ls",
data = mi(miin1, miin2, miin3, miin4, miin5))
x.out <- setx(z.out, male = 1)
x.alt <- setx(z.out, male = 0)
men.mean <-mean(sim(z.out, x = x.out)$qi$ev)
women.mean <-mean(sim(z.out, x = x.alt)$qi$ev)
print(dvname, men.mean, women.mean)
x.out <- setx(z.out, age = 25)
x.alt <- setx(z.out, age = 65)
younger.mean <-mean(sim(z.out, x = x.out)$qi$ev)
older.mean <-mean(sim(z.out, x = x.alt)$qi$ev)
print(dvname, younger.mean, older.mean)
}
I've tried, but haven't yet succeeded. Any advice appreciated!
Don
Donald Braman
Associate Professor of Law
The George Washington University Law School
2000 H Street, NW | Washington, DC 20052
tel (202) 994-0572 | fax (202) 994-3377
http://www.law.gwu.edu/Faculty/profile.aspx?id=10123http://research.yale.edu/culturalcognitionhttp://ssrn.com/author=286206
-
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 Levi (and everyone else),
Crossed factors or nested factors aren't a problem. The model syntax doesn't
treat them differently, so it is best to explicitly define your nests,
rather than implicitly. e.g., if you have L3 nested in L2 in yourdata, you
might create a nested factor Lnest as follows:
yourdata <- transform(yourdata, Lnest= (L2:L3)[drop=TRUE])
then you'd include the effect for L2 and for the nest, tag(1 | L2) + tag(1 |
Lnest).
if L2 and L3 are crossed, you'd just include them as tag(1 | L2) + tag(1 |
L3).
The vignettes for lme4 have some nice examples.
HTH,
Delia
>
>
> On Mon, Apr 6, 2009 at 6:20 AM, Gary King <king(a)harvard.edu> wrote:
>
>> I'm not sure of the direct answer to your question (Delia Bailey, who
>> wrote the Zelig bridge functions, probably knows; what do you think,
>> Delia?), but one thing you can do is to define a single level of nesting
>> from the multiple levels so each precinct in the U.S. can be seen as within
>> a county, and each county within a state, but it can also just be given a
>> unique number and treated as from a single collection of precincts
>> nationally. Not exactly what you wanted, but it works.
>>
>> Gary
>> ---
>> http://gking.harvard.edu
>>
>>
>> On 04/05/2009 07:03 AM, Littvay, Levi wrote:
>>
>> Dear Everyone
>>
>> Is it possible to run a three level or a cross-classified model with Zelig
>> logit.mixed (or any of the other mixed) commands?
>>
>> If so, please let me know how to set it up. The manual is clear about a
>> single source of nesting (g) but not three levels (where g is nested within
>> h) or cross-classified (for example middle school and high school where
>> someone who went to one middle school possibly went to any other high school
>> in the dataset and vice versa) random effects.
>>
>> Also, (assuming 3 level models are possible) please let me know how I need
>> to set up the id variables that define the nesting. Should I use:
>>
>> 1 1
>> 1 1
>> 1 2
>> 1 2
>> 2 1
>> 2 1
>> 2 2
>>
>> For L3 and L2 ID or is this better?
>>
>> 1 11
>> 1 11
>> 1 12
>> 1 12
>> 2 21
>> 2 21
>> 2 22
>>
>> Thanks.
>>
>> L
>>
>> -
>> 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/
>>
>>
>
>
> --
> NOTE:
> Please add delia.bailey(a)gmail.com to your address book.
> I am no longer using my dbailey(a)wustl.edu account.
>
>
--
NOTE:
Please add delia.bailey(a)gmail.com to your address book.
I am no longer using my dbailey(a)wustl.edu account.