Hi all,
We are attempting to replicate some Stata code in R and need some advice.
areg , cluster(district) - which allows the use of a fixed effect for
school districts without calculating coefficients on all of the dummies by
demeaning the other predictor variables.
Any ideas on how we can incorporate a fixed effect with the glm command in R
without having to manually demean all of our independent variables or
include dummies for each of our hundreds of districts?
thanks,
Matt
On Sat, Mar 13, 2010 at 5:12 PM, Maya Sen <msen at fas.harvard.edu> wrote:
> Hi all,
>
> I've posted all of the replication papers that groups are working with
> on the course website (under a link called "Replication Papers"). If
> you don't see your group on the page, it means that (a) I lost track
> of your email(s) in my inbox, or (b) your group was still deciding on
> a paper last I heard. In either case, please send me an update with a
> PDF of your paper and I'll post it this weekend.
>
> Everyone is welcome to have a look and see what other folks are
> working on -- we've got some really interesting projects in the works!
>
> Maya
>
> Ps. Feel free to email questions to the list about replication papers
> -- we're checking email, and chances are many of your classmates are
> too!
> _______________________________________________
> gov2001-l mailing list
> gov2001-l at lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>
--
Matthew Kraft
Doctoral Candidate
Quantitative Policy Analysis
Harvard Graduate School of Education
General question: for the replication assignment, do we have to write all
the functions by hand? Or are we allowed to use R packages to help us along
the way?
Specifically: for our group's replication assignment, we need to calculate
robust, one-way clustered standard errors. In order to do this, can we just
use zelig's "vcovHAC" and "cluster" options? Or do we have to manually
estimate these quantities by writing functions implementing the scores and
'sandwich' estimator, etc?
Thank you!
Try to not use null!
=======================================
CONFIDENTIALITY NOTICE: This e-mail, including any attachments, is for the sole use of the intended recipient and may contain information that is confidential and privileged under state and Federal privacy laws. If you received this e-mail in error, be aware that any unauthorized use; disclosure, copying, or distribution is strictly prohibited. Please contact the sender immediately and destroy all copies of this message.
=======================================
----- Original Message -----
From: gov2001-l-request at lists.fas.harvard.edu
To: gov2001-l at lists.fas.harvard.edu
Sent: Friday, March 12, 2010 12:00:08 PM GMT -05:00 US/Canada Eastern
Subject: gov2001-l Digest, Vol 56, Issue 24
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. Problem 3: ReLogit output downward biased? (Abdul Ahad Tariq)
2. Re: Problem 3: ReLogit output downward biased? (Iain Osgood)
3. P3 Relogit (Matthew Kraft)
4. Re: P3 Relogit (Abdul Ahad Tariq)
----------------------------------------------------------------------
Message: 1
Date: Thu, 11 Mar 2010 16:12:19 -0500
From: Abdul Ahad Tariq <abdulahad.t at gmail.com>
Subject: [gov2001] Problem 3: ReLogit output downward biased?
To: "Class List for Gov 2001/E-2001" <gov2001-l at lists.fas.harvard.edu>
Message-ID:
<f330d63b1003111312m196ff9b9t79843918bf8d1220 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
>From the problem statement, it seems that simple Logit is an underestimation
of the true probability whereas ReLogit should correct for this. However, I
observed the opposite.
When probability of onset is computed using Logit coefficient estimates, I
get a value ~ 0.019
When probability of onset is computed using ReLogit coefficient estimates, I
get a value ~ 0.003
I looked at the King and Zeng paper, but didn't find what the functional
form would be for the ReLogit model, so I'm just plugging the X*Betas from
ReLogit into the usual Logit functional form (using the function inv.logit)
to get probabilities. I suspect this is why the predicted probability for
ReLogit isn't quite right. Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fas.harvard.edu/mailman/private/gov2001-l/attachments/20100311…
------------------------------
Message: 2
Date: Thu, 11 Mar 2010 16:21:56 -0500
From: Iain Osgood <osgood2 at fas.harvard.edu>
Subject: Re: [gov2001] Problem 3: ReLogit output downward biased?
To: "Class List for Gov 2001/E-2001" <gov2001-l at lists.fas.harvard.edu>
Message-ID:
<e7322f8f1003111321vec4c514y9d18f1cee7b5cf60 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi Abdul,
You should be able to use the same procedure for calculating the fitted
values that you used before, and in particular you can plug your draws from
the posterior of beta into the exact same logit link. I would suggest
double-checking the implementation of the relogit model, for example, check
to see that you are using the right data.
Iain
On Thu, Mar 11, 2010 at 4:12 PM, Abdul Ahad Tariq <abdulahad.t at gmail.com>wrote:
> >From the problem statement, it seems that simple Logit is an
> underestimation of the true probability whereas ReLogit should correct for
> this. However, I observed the opposite.
>
> When probability of onset is computed using Logit coefficient estimates, I
> get a value ~ 0.019
> When probability of onset is computed using ReLogit coefficient estimates,
> I get a value ~ 0.003
>
> I looked at the King and Zeng paper, but didn't find what the functional
> form would be for the ReLogit model, so I'm just plugging the X*Betas from
> ReLogit into the usual Logit functional form (using the function inv.logit)
> to get probabilities. I suspect this is why the predicted probability for
> ReLogit isn't quite right. Any thoughts?
>
>
> _______________________________________________
> gov2001-l mailing list
> gov2001-l at lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fas.harvard.edu/mailman/private/gov2001-l/attachments/20100311…
------------------------------
Message: 3
Date: Thu, 11 Mar 2010 17:18:38 -0500
From: Matthew Kraft <mak251 at mail.harvard.edu>
Subject: [gov2001] P3 Relogit
To: "Class List for Gov 2001/E-2001" <gov2001-l at lists.fas.harvard.edu>
Message-ID:
<f4c47bd01003111418n561359b8gb4b42bb7e11a02bd at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hey all,
When I run the rare events logit code I keep getting the error below.
source("http://gking.harvard.edu/zelig/install.R")
library(Zelig)
rare <- zelig(onset ~ warl + gdpenl + lpopl1 + lmtnest + ncontig + Oil +
nwstate + instab + polity2l + ethfrac + relfrac, data=subset.2, model =
"relogit")
"Error in family$linkfun(mustart) : Value 0 out of range (0, 1)"
Any ideas of what I am doing wrong?
thanks,
m
> _______________________________________________
> gov2001-l mailing list
> gov2001-l at lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>
>
--
Matthew Kraft
Doctoral Candidate
Quantitative Policy Analysis
Harvard Graduate School of Education
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fas.harvard.edu/mailman/private/gov2001-l/attachments/20100311…
------------------------------
Message: 4
Date: Thu, 11 Mar 2010 17:25:18 -0500
From: Abdul Ahad Tariq <abdulahad.t at gmail.com>
Subject: Re: [gov2001] P3 Relogit
To: "Class List for Gov 2001/E-2001" <gov2001-l at lists.fas.harvard.edu>
Message-ID:
<f330d63b1003111425m61d7b31du1273da2047a477b2 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
A few other people noted a similar problem. I think that the consensus
seemed to be that if you didn't recode onset to be 0/1 earlier, one would
run into this problem.
On Thu, Mar 11, 2010 at 5:18 PM, Matthew Kraft <mak251 at mail.harvard.edu>wrote:
> Hey all,
>
> When I run the rare events logit code I keep getting the error below.
>
> source("http://gking.harvard.edu/zelig/install.R")
> library(Zelig)
> rare <- zelig(onset ~ warl + gdpenl + lpopl1 + lmtnest + ncontig + Oil +
> nwstate + instab + polity2l + ethfrac + relfrac, data=subset.2, model =
> "relogit")
>
> "Error in family$linkfun(mustart) : Value 0 out of range (0, 1)"
>
> Any ideas of what I am doing wrong?
>
> thanks,
>
> m
>
>
>> _______________________________________________
>> gov2001-l mailing list
>> gov2001-l at lists.fas.harvard.edu
>> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>>
>>
>
>
> --
> Matthew Kraft
> Doctoral Candidate
> Quantitative Policy Analysis
> Harvard Graduate School of Education
>
> _______________________________________________
> gov2001-l mailing list
> gov2001-l at lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fas.harvard.edu/mailman/private/gov2001-l/attachments/20100311…
------------------------------
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.eduhttp://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
End of gov2001-l Digest, Vol 56, Issue 24
*****************************************
Hi all,
I've posted all of the replication papers that groups are working with
on the course website (under a link called "Replication Papers"). If
you don't see your group on the page, it means that (a) I lost track
of your email(s) in my inbox, or (b) your group was still deciding on
a paper last I heard. In either case, please send me an update with a
PDF of your paper and I'll post it this weekend.
Everyone is welcome to have a look and see what other folks are
working on -- we've got some really interesting projects in the works!
Maya
Ps. Feel free to email questions to the list about replication papers
-- we're checking email, and chances are many of your classmates are
too!
Hey all,
When I run the rare events logit code I keep getting the error below.
source("http://gking.harvard.edu/zelig/install.R")
library(Zelig)
rare <- zelig(onset ~ warl + gdpenl + lpopl1 + lmtnest + ncontig + Oil +
nwstate + instab + polity2l + ethfrac + relfrac, data=subset.2, model =
"relogit")
"Error in family$linkfun(mustart) : Value 0 out of range (0, 1)"
Any ideas of what I am doing wrong?
thanks,
m
> _______________________________________________
> gov2001-l mailing list
> gov2001-l at lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>
>
--
Matthew Kraft
Doctoral Candidate
Quantitative Policy Analysis
Harvard Graduate School of Education
>From the problem statement, it seems that simple Logit is an underestimation
of the true probability whereas ReLogit should correct for this. However, I
observed the opposite.
When probability of onset is computed using Logit coefficient estimates, I
get a value ~ 0.019
When probability of onset is computed using ReLogit coefficient estimates, I
get a value ~ 0.003
I looked at the King and Zeng paper, but didn't find what the functional
form would be for the ReLogit model, so I'm just plugging the X*Betas from
ReLogit into the usual Logit functional form (using the function inv.logit)
to get probabilities. I suspect this is why the predicted probability for
ReLogit isn't quite right. Any thoughts?
Hi Iain and Class,
For Q 2.3, I have curves for War Onset vs. lagged GDP, for both recently
independent states and non-recently independent states. My question is how
can I get both lines to show up on the same plot? Or is it okay if we just
include two separate plots (one of recently independent and one for
non-recently independent states)?
Thanks to everyone,
Abdul
Hey Iain and Maya,
I was wondering if there was a typo on problem 2.3? It says we need to do
the function over GDP's from $250 to $8000, but that seems to really be
messing with my computer (i.e. Taking forever). Also it seems like there
isn't that much difference between $800 and $8000 (unless I'm doing
something terribly wrong) so I was wondering if we were really supposed to
go that far out.
-Ashley Anderson
Ok, I've been trying to run the function for 1.2 for quite some time, but
I'm stuck and get this message "Error in X %*% beta : requires
numeric/complex matrix/vector arguments." This seems like X and beta are
nonconformable, but I thought I was careful enough to make sure this wasn't
the case.
I'm including my code (and variants) below. What am I modeling wrong?
Thanks,
Alonso
myll <- function(par, y, X) {
beta <- par[1:ncol(X)]
ll.log <- -1*sum(log(1 + exp(1-2*y) %*% (X %*% beta)))
return(ll.log)
}
# alternative 1
myll.2 <- function(par, y, X) {
beta <- par[1:ncol(X)]
pie <- (1/(1+exp(-X %*% beta)))
sum(-y * log(1 + (1/pie)) + (1-y)*log (1-pie) )
}
# alternative 2
myll.3 <- function(par, y, X) {
beta <- par[1:ncol(X)]
-1*sum(log(1 + exp(1-2*y) %*% (X %*% beta)))
}
myll(par = c(rep(0, 13)), y = subset.2[,"onset"], X =
cbind(1,subset.2[,2:12]))
Hi all,
Just a reminder that we're having section tonight as usual, even
though there's no pset over Spring Break. We'll be going over the
ordered categorical models and the binomial models, and also going
over code that could be helpful for your replications.
best, Maya