Have anyone tied it yet? What should be set as "data" parameter?
I keep getting an error message and have no idea how to fix it.
> load("shuttle.RData")
> dta<-data
>
> z.out<-zelig(as.numeric(incident)~as.numeric(temperature)+as.numeric(pressure),model="logit", data= dta)
Error in model.frame.default(formula = as.numeric(incident) ~ as.numeric(temperature) + :
'data' must be a data.frame, not a matrix or an array
Sincerely,
Olena Ageyeva
_________________________________________________________________
Windows Live?: Life without walls.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009
Have folks found a command in Zelig that lets one check standard errors on coefficient terms so we know whether coefficients are significant?
Thanks.
Tom
Thomas Sander
Executive Director
Saguaro Seminar: Civic Engagement in America
Harvard Kennedy School, Harvard University
79 JFK Street, Taubman 364, Cambridge, MA 02138
T - 617.496.2764 F - 617.495.1589
tom_sander at harvard.eduwww.hks.harvard.edu/saguaro
social capital blog: http://socialcapital.wordpress.com
-----Original Message-----
From: gov2001-l-bounces at lists.fas.harvard.edu [mailto:gov2001-l-bounces at lists.fas.harvard.edu] On Behalf Of gov2001-l-request at lists.fas.harvard.edu
Sent: Tuesday, March 10, 2009 1:56 PM
To: gov2001-l at lists.fas.harvard.edu
Subject: gov2001-l Digest, Vol 46, Issue 19
Send gov2001-l mailing list submissions to
gov2001-l at lists.fas.harvard.edu
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
or, via email, send a message with subject or body 'help' to
gov2001-l-request at lists.fas.harvard.edu
You can reach the person managing the list at
gov2001-l-owner at lists.fas.harvard.edu
When replying, please edit your Subject line so it is more specific
than "Re: Contents of gov2001-l digest..."
Today's Topics:
1. Re: zelig() (Olena Ageyeva)
2. Re: zelig() (Olena Ageyeva)
3. permanently loading a package (Allen, Abigail)
----------------------------------------------------------------------
Message: 1
Date: Tue, 10 Mar 2009 12:56:36 -0400
From: Olena Ageyeva <eageeva at hotmail.com>
Subject: Re: [gov2001-l] zelig()
To: <gov2001-l at lists.fas.harvard.edu>
Message-ID: <COL104-W226BD4DF536DA07148B326BBA10 at phx.gbl>
Content-Type: text/plain; charset="windows-1252"
Thanks, Brandon.
I have tried to make changes in my code as you suggested, but I still can't make it work.
Here is my code:
load("shuttle.RData")
temperature<-as.numeric(data[,3])#separating variables
pressure<-as.numeric(data[,4])
incident<-as.numeric(data[,2])
data<-as.data.frame(cbind(incident,temperature, pressure))#making a data frame
z.out<-zelig(incident~temperature+pressure,model="logit", data= data)
Running this code I get just the following message and no results:
How to cite this model in Zelig:
Kosuke Imai, Gary King, and Oliva Lau. 2008. "logit: Logistic Regression for Dichotomous Dependent Variables" in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software," http://gking.harvard.edu/zelig
I did read the documentation about using zelig(), but it's still not clear to me how to use it.
Sincerely,
Olena Ageyeva
Date: Tue, 10 Mar 2009 07:39:15 -0500
From: bstewart at fas.harvard.edu
To: gov2001-l at lists.fas.harvard.edu
Subject: Re: [gov2001-l] zelig()
Olena,
data.frame is an object class in R (all objects have classes in R) that is similar to a matrix but more flexible. Your class is "numeric" after you have done as.numeric. To get a dataframe, you need to combine all the different elements into one dataset. See the following code as an example:
shuttle <- load("shuttle.RData")datatbc <- as.numeric(data) ##Data to be convertedIncident <- datatbc[24:46] ##Make VariablesTemperature <- datatbc[47:69]
Pressure <- datatbc[70:92]data <- as.data.frame(cbind(Incident, Temperature, Pressure)) ##Combine to make data framecheck <- zelig(Incident ~ Temperature + Pressure, model="logit", data=data)
I converted the data, into a numeric vector (the object datatbc) and then sliced that object into variables (the next three lines). Then by combining the three variables with cbind() we create a matrix, that gets converted with "as.data.frame"
Finally, on the last line, I've added the relevant zelig code. I could have labeled that variables data$Incident, data$Temperature etc. Specifying the "data" field in Zelig (or most any other model in R) simply allows you to refer to objects with their variable name inside the data frame rather than the dataframe, a dollar sign, the variable name.
Brandon
On Tue, Mar 10, 2009 at 5:40 AM, Olena Ageyeva <eageeva at hotmail.com> wrote:
Have anyone tied it yet? What should be set as "data" parameter?
I keep getting an error message and have no idea how to fix it.
> load("shuttle.RData")
> dta<-data
>
> z.out<-zelig(as.numeric(incident)~as.numeric(temperature)+as.numeric(pressure),model="logit", data= dta)
Error in model.frame.default(formula = as.numeric(incident) ~ as.numeric(temperature) + :
'data' must be a data.frame, not a matrix or an array
Sincerely,
Olena Ageyeva
Windows Live?: Keep your life in sync. Check it out.
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.eduhttp://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_________________________________________________________________
Access your email online and on the go with Windows Live Hotmail.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Access_022009
Hi All,
The following are the relevant dates for the various stages of the
replication project. These are group due dates. We do not need to hear
from each student individually. Gary and Patrick, please add anything else
that I may have missed.
Today, March 9, 2009: Proposed paper to replicate is due.
March 30, 2009 by 2pm: A draft of your replication project is due. We want
6 things from your group. (1) A pdf of the article you are replicating.
(2) A *PDF *of the draft of your paper. This draft must include the names
(and email addresses) of your coauthors, your replication of the main
tables/figures in the paper you are replicating and a brief discussion of
how you intend to improve the existing analysis. (3) A file containing the
data you used to perform the replication. (4) A code book (or key) for the
data used in your replication. (5) A txt or r file containing all of the
code used in your replication (the code should be well commented so others
can easily follow along). (6) Anything else that may be required for
another group to successfully replicate your replication of the paper you
have selected. These 6 things should be emailed to me and Patrick by 2pm.
If the dataset is too large to email, please email all of the other
materials and bring a copy of the dataset on a CD to class.
March 31, 2009: By this date, your group will be assigned to replicate the
work of another student group. Patrick or I will send your group an email
with all of the necessary materials.
April 6, 2009 by 2pm: Your replication of another student groups'
replication is due. You should email me and Patrick as well as all of the
members of the student group whose work you replicated a *pdf* memo pointing
out ways to make their paper and analysis better. You will be evaluated
based on how helpful, not how destructive, you are.
May 4, 2009 by 5pm: The final version of your paper is due.
Good luck on your projects!
Best,
Miya
--
Miya Woolfalk
Ph.D. Student
Harvard University
Government and Social Policy
Hi all,
Just a reminder that the deadline for sending us your proposed paper to
replicate and a few sentences is tomorrow March 9.
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science,
Harvard University
http://www.people.fas.harvard.edu/~plam
I have a question about the score function. Do we use the same log-likelihood function as we derive for gamma|y? If so, do we need to show "long hand work" for both gamma and theta?
Sincerely,
Olena Ageyeva
_________________________________________________________________
Windows Live? Contacts: Organize your contact list.
http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-…
Dear Miya
I have a question on lectures notes: in the following piece of R code i
don't get the part in bold:
# Predicted Values
set.seed(12345)
M <- 1000
par.draws <- mvrnorm(M, mu=opt.new.par , Sigma=opt.new.vcv)
*beta.draws <- par.draws[,-5]
sigma2.draws <- exp(par.draws[,5])*
X.c <- apply(X.data, 2, mean)
mu.c <- c()
for(i in 1:nrow(beta.draws)){
mu.c[i] <- X.c %*% beta.draws[i,]
}
m <- 1
Y.c.predict <- c()
for(i in 1:length(mu.c)){
Y.c.predict[i] <- rnorm(m, mean=mu.c[i], sd= sqrt(sigma2.draws[i]))
}
mean(Y.c.predict); sd(Y.c.predict)
#84.92893
#2.005887
why is the 5th column of an output of a multivariate normal sampling that of
the variances????
Thanks!
Charlotte
Hi everyone,
I'm trying to understand the how to give standard errors/confidence
intervals as required in parts 2.3 and 2.4 of this week's problem set.
Is this simply a case of looking at the m-vector of estimates for the
expected difference/expected probabilities over m simulations and
using the sd() or quantile() functions on this vector to generate
standard errors or confidence intervals? Or am I missing something
more fundamental?
Many thanks,
Matt
Hi all,
PS 4 has been graded and will be returned on Monday if you turned in a hard
copy. Those who only submitted online already have their grades in their
dropbox. Just a few comments:
Problem 1:
- One assumption that many people left out is that we only observe the sum
of the Bernoulli trials for a binomial.
- When shifting up and down, remember that you should be adding/subtracting
a constant since it's a log-likelihood. If we were plotting the likelihood,
then we would be multiplying a constant.
- When reparameterizing pi, many of you said that we need to do this
because we cannot do log() of a negative number. While this is true, the
main reason we are reparameterizing is because we need pi to be in [0,1]
because it's a probability. Hence, while we can do log(2), 2 is not an
appropriate value for pi.
Problem 2:
- While most of you were able to understand the indicator variables, many of
you programmed it so that the indicator variable was generated inside the LL
function. The idea should be that the indicator variable is just another
variable in your data, and should not be generated inside the function.
This is so that we can be as flexible as possible. For example, if you
programmed it inside your function, it would not work if I told you that all
odd numbered observations came from one distribution and all even numbered
ones came from another.
- Some of you programmed the LL function using ifelse statements or some
version of them. While you may arrive at the correct answer, the ifelse
statements are completely unnecessary. You can just program the actual
log-likelihood in one line using the indicator variable.
I encourage you all to look at the answer key.
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science,
Harvard University
http://www.people.fas.harvard.edu/~plam
I will be out of the office starting 03/06/2009 and will not return until
03/16/2009.
I will respond to your message when I return. In the meantime please
contact Benson Kazembe (bkazembe at unicef.org)
we only need one email from each group.
On Sat, Mar 7, 2009 at 9:23 AM, Yuan Lu <merrycrystal at gmail.com> wrote:
> Hi all,
> The deadline for choosing a paper to replicate and having it approved is
> Mar 9 . Do each of us need to send the proposed paper and quick note to
> Prof. King and the TAs individually? Or can we do it as a group ?
>
> Thank you!
> Yuan
>
> --
> Yuan Lu
> Graduate student
> Department of Global Health and Population
> School of Public Health
> Harvard University
> Mobile: 857-207-2460
>
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science,
Harvard University
http://www.people.fas.harvard.edu/~plam