Hillard, thank you that worked.
> require(utils)
> attach(CatchCR.df)
The following object(s) are masked from CatchCR.df ( position 3
) :
A..V. Allur. Allur.Prop AllurCatch Attract Food Light Orient
Run Tot.Caught Tot.Caught.Prop Victor. VictorCatch
I've looked at the documentation for 'attach', and didn't see any clues
about zelig's need for this function( isn't zelig somehow calling glm?),
but didn't need attach if using the glm function directly (no doubt
this description is mangling the real workings of glm vs. zelig). If
you have time, could you explain why attach is needed for zelig's glm,
but not for glm directly? I'd like to understand when to use 'attach'
in the future.
Thanks again, Paul
________________________________
From: Hillard Pouncy [mailto:hillard.pouncy@gmail.com]
Sent: Tuesday, February 24, 2009 3:34 PM
To: Prew, Paul
Subject: Re: [zelig] Help with having zelig recognize my data?
try an >attach(CatchCR.df) command
Hillard Pouncy
On Tue, Feb 24, 2009 at 4:10 PM, Prew, Paul
<Paul.Prew(a)ecolab.com> wrote:
Hello, I am still very inexperienced with Zelig. I
hope you can help me with a question that I have not been able to
resolve from reading the documentation.
I'm attempting a basic binomial logit model, using data
that has already been analyzed via the 'glm' package. I would like to
see how the zelig simulation output can augment the results.
I'm just doing a cut&paste with my objects in the place
of the example objects from the documentation:
++++++ Documentation Example for logit +++++++
# Unconditional prediction:
data(turnout)
z.out <- zelig(vote ~ race + educate, model =
"logit", data = turnout)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out)
++++++ My Attempt +++++++
> data(CatchCR.df)
Warning message:
In data(CatchCR.df) : data set 'CatchCR.df' not found
> ls()
[1] "Allur.glm" "Allur.Int" "Allur.mod"
"CatchCR.df"
> str(CatchCR.df)
'data.frame': 20 obs. of 13 variables:
$ Run : num 1 2 3 4 5 6 7 8 9 10 ...
$ Food : Factor w/ 2 levels "Fed","Starved":
2 1 2 1 2 1 2 1 1 1 ...
$ Attract : Factor w/ 2 levels "No","Yes": 2 2 2
2 2 1 1 1 1 2 ...
$ Orient : Factor w/ 2 levels
"Challenged","Open": 2 2 1 1 1 2 2 1 2 1 ...
$ Light : Factor w/ 2 levels "Off","On": 1 1 1
1 1 1 1 1 1 1 ...
$ Allur. : num 45 50 15 20 20 45 25 25 30 15
...
$ Victor. : num 40 40 85 65 70 35 55 55 60 55
...
$ A..V. : num 1.125 1.25 0.176 0.308 0.286
...
$ AllurCatch : num 9 10 3 4 4 9 5 5 6 3 ...
$ VictorCatch : num 8 8 17 13 14 7 11 11 12 11 ...
$ Allur.Prop : num 0.45 0.5 0.15 0.2 0.2 0.45 0.25
0.25 0.3 0.15 ...
$ Tot.Caught : num 17 18 20 17 18 16 16 16 18 14
...
$ Tot.Caught.Prop: num 0.85 0.9 1 0.85 0.9 0.8 0.8 0.8
0.9 0.7 ...
++++++ Ran glm immediately after without a problem
+++++++
Allur.Int<-glm(CatchCR.df$Allur.Prop~(Food+Attract+Orient+Light)^2,
family=binomial, data = CatchCR.df)
Any help is greatly appreciated, thanks, Paul
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.
The summary of a sim() helpfully returns confidence intervals of 2.5% &
97.5% -- I wonder if there is an easy way to estimate other CIs without
plotting them? Normally, I would just calculate it using a standard
formula from the SD, mean & sample size, but that gives me a very small CI
interval relative to what Zelig provides at 2.5%/97.5%, so I think that
can't be right (I'm guessing that's because it doesn't accounting for
the multiple imputations?).
Don
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
>
>
-
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/
Hey all-
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)')
Also, the same weighted model above runs fine in OLS.
Thoughts?
Thanks much,
-c
--
Casey A. Klofstad
University of Miami
Department of Political Science
Coral Gables, FL
klofstad(a)gmail.com
http://www.as.miami.edu/personal/cklofstad/
-
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/
Hello,
I am attempting to "automate" a Bayesian normal linear regression
using Zelig. Basically, I have a list containing several zelig()
objects, each having a different formula, same data set, and same
model (normal.bayes).
My problem lies in the setx() method, where I am setting a numeric
parameter to a value other than the mean. This is straightforward if I
input the parameters name into setx(). i.e.,
setx.out<-setx(zelig.model, parameter1=20)
where parameter1 is the name of the given parameter.
To automate this process, via a for loop, I need to reference the
parameter from the zelig.model object, by using a index. i.e,.
for (i in 1:10){
setx.out<-setx(zelig.model, zelig.model$coefficients[4] <- value*i }
So far, I have not had any luck of the sort.
I have looked over the setx.default.R source code, but it is still Greek to me.
There is always the convoluted option of manually setting the setx.out
values, i.e.,
setx.out[4]<- value
But this runs into the problem of having to also update 2nd order and
higher terms in the linear regression. My hope is to have the code
support general formula models; hence, the code would not know which
values in the setx.out object to update.
Corey
-
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,
I am running into a problem using lapply() on the method zelig().
Here is the list of models I am looking at,
>model<- list()
>model[[1]]<-as.formula("yield ~(pyrrolidone + teaHF + holdTime + holdTemp)^2 + I(pyrrolidone^2) + I(teaHF^2) + I(holdTime^2) + I(holdTemp^2)")
>model[[2]]<- as.formula("impurity ~ (pyrrolidone + teaHF + holdTime + holdTemp)^2 + I(pyrrolidone^2) + I(teaHF^2) + I(holdTime^2) + I(holdTemp^2)")
>model[[3]]<- as.formula("startMat ~ (pyrrolidone + teaHF + holdTime + holdTemp)^2 + I(pyrrolidone^2) + I(teaHF^2) + I(holdTime^2) + I(holdTemp^2)")
Now, if I want to run a simple lm(), I use the following syntax with no errors,
>y<-lapply(model, function(z) lm(z, data=data1))
Or, I can explicitly reference MCMCregress without errors,
>y<-lapply(model, function(z) MCMCregress(z, data=data1, model="normal.bayes"))
But, I get the following when using zelig,
>lapply(model, function(z) zelig(z, data=data1, model="normal.bayes"))
Error in parse(text = x) : unexpected end of input in "+"
Any ideas on how to circumvent this issue?
Corey
-
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/
you need to do something along the following:
data1 <- read.csv(blah, blah,...
data2 <- read.csv(blah, blah,...
data3 <- read.csv(blah, blah,...
data4 <- read.csv(blah, blah,...
data5 <- read.csv(blah, blah,...
then,
> z.out <- zelig(as.factor(ipip) ~ wage1992 + prtyid + ideol, model =
"ologit",
+ data = mi(data1, data2, data3, data4, data5), by =
"gender")
If this is still not clear, I suggest you go through the basics of R
either using our manual or some other materials. There is a start-up cost
but after that things will get better.
Good luck!
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Thu, 19 Feb 2009, Mike Haynes wrote:
> This has been my problem...I have poured over the manual for hours and
> just don't understand past the point of loading the data....again, I am
> simply looking for that one last computer function in Zelig (collapsing
> my 5 imputed data sets) in order to move on...
>
>>>> Kosuke Imai <kimai(a)Princeton.EDU> 02/19/09 7:52 PM >>>
> Sounds good. Then, you just need to follow the example that's given in
> the
> manual to fit the model using all imputed data sets.
>
> Kosuke
>
>
-
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/
Sounds good. Then, you just need to follow the example that's given in the
manual to fit the model using all imputed data sets.
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Thu, 19 Feb 2009, Mike Haynes wrote:
> just to be sure I am loading my data sets correctly:
>
> 1) I used the command for data sets with headers:
>
> read.csv("outdata1.csv", header = TRUE)
>
> This resulted in my entire data set with headers being listed
>
> 2) I performed the same "read" function for each of the subsequent 4
> data sets....after trial and error, I determined that they must be
> loaded individually... but after each read, each data set was displayed.
>
> 3) Finally, after all 5 "read" functions were performed, I was able to
> go back and perform diagnostics on any/all..ie..sim(), summary(),
> etc.....
>
> This is what makes me believe I loaded them properly.
>
> Thanks again.
> Mike
>
>
> ** Confidentiality Notice: This e-mail and any files transmitted with it are confidential to the extent permitted by law and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message and destroy all copies. **
>
-
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/
The "data()" command is to load the demo data sets that come with Zelig
and so you should not use it to load your own data sets. No need to read
the entire zelig manual! You can read the Chapter on "User's Guide" which
covers the basics of R and Zelig.
Good luck,
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Thu, 19 Feb 2009, Mike Haynes wrote:
> Yes, I was able to successfully run the demo(mi) function, and it
> provided me the same information as in the 584 page pdf manual that I
> unsuccessfully attempted to understand for 6 hours on Monday. When I
> get to the "data" string, I enter:
>
> data(outdata1, outdata2, outdata3, outdata4, outdata5) and 5 times, it
> says dataset not found...yet I know I successfully loaded each of the 5
> data sets.
>
> As I mentioned, I am not well versed at computer syntax, so what may be
> obvious or intuitive to others, needs to be explicit to me.....could it
> be possible that I need to perform some function that makes the program
> recognize the names "outdata1", etc.... before attempting to perform the
> first "data(xxxx, etc...) function??
> All I am trying to do is collapse 5 imputed data sets already obtained
> through Amelia...my committee member suggested using Zelig because he
> heard it will automatically perform such function (his words). This is
> the last step in completing my data set before moving on the actual
> statistical analysis to be performed in SPSS....any help you can provide
> to perform this last data set completion function is greatly
> appreciated.
> If easier, please provide a phone I can call at your convenience.
> Best,
> Mike
>
> PS., the versions of R and Zelig were loaded Monday morning from each
> respective site...I believe R is 2.8.1 and Zelig was downloaded directly
> from the website.
> thanks again.
> MH
>
>>>> Kosuke Imai <kimai(a)Princeton.EDU> 02/19/09 4:08 PM >>>
> I'm not sure what's going on here, but I would first try
>
> demo(mi)
>
> if that doesn't work, then it means you have an old version of Zelig
> installed (or R itself could be old too). If that works, then you must
> have incorrectly loaded the data sets.
>
> Kosuke
>
>
-
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/
Hello...I am a new Zelig user and do not consider myself very computer
savvy when it comes to syntax/programming. I am attempting to collapse
5 imputed csv data sets generated by Amelia into one final data set for
my dissertation.
I can load my files using the read.csv header function and see the
diagnostics associated with dim() and summary(), however, when I attempt
to create the data set, the program does not recognize my files.
I attempted the following command per the Zelig manual...and these are
the exact names of my datasets:
data = mi(outdata1.csv, outdata2.csv, outdata3.csv, outdata4.csv,
outdata5.csv)
The return said files not read because they do not exist.
Any help with how to exactly perform the function of collapsing imputed
data sets into a final set is greatly appreciated, and I look forward to
learning more about this program!
Best,
Michael Haynes
** Confidentiality Notice: This e-mail and any files transmitted with it are confidential to the extent permitted by law and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message and destroy all copies. **
-
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/