You don't have to redo this, but for question c you may want to construct
bins based on the quantiles of the predicted probabilities. This way, you
won't have some empty bins (then, you don't need to indicate how many
observations are).
Kosuke
it pays to check out old emails sometimes ;)
-----Original Message-----
From: gov1000-list-admin(a)fas.harvard.edu
[mailto:gov1000-list-admin@fas.harvard.edu] On Behalf Of Dave Kane
Sent: Sunday, December 08, 2002 1:08 PM
To: Phillip Y. Lipscy
Cc: gov1000-list(a)fas.harvard.edu
Subject: [gov1000-list] sorting dataframes/matrices
help(sort) points you to "order". Check out the help. Here is an
example:
> x
a b
1 1 o
2 2 c
3 3 x
4 4 h
5 5 f
> x[order(x$b),]
a b
2 2 c
5 5 f
4 4 h
1 1 o
3 3 x
> x[order(x$a),]
a b
1 1 o
2 2 c
3 3 x
4 4 h
5 5 f
>
Dave
Phillip Y. Lipscy writes:
> Dear all,
>
> sort() works nicely for vectors but not for dataframes and matrices
(for
> matrices it doesn't sort by columns properly). Since even ms excel
can sort
> dataframes by columns, I'm assuming R can do that too, but so far I
haven't
> found anything that seems to let me do that. Any ideas?
>
> Thanks,
> Phillip.
>
> -------------------------------------------------
> Phillip Y. Lipscy
> Perkins Hall Room #129
> 35 Oxford Street
> Cambridge, MA 02138
> (617)493-4893
> lipscy(a)fas.harvard.edu
>
> Ph.D. Candidate
> Harvard University, FAS, Department of Government
> -------------------------------------------------
>
>
>
>
>
> _______________________________________________
> gov1000-list mailing list
> gov1000-list(a)fas.harvard.edu
> http://www.fas.harvard.edu/mailman/listinfo/gov1000-list
--
David Kane
Lecturer in Government
617-563-0122
dkane(a)latte.harvard.edu
_______________________________________________
gov1000-list mailing list
gov1000-list(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/gov1000-list
Dear All,
Quick question: if I have a 544x2 matrix, and wish to sort that matrix so that
the first column is in ascending order, and so that the correspondence between
the first column value and the second column value for each row is preserved,
how do I do that in R? Commands including "sort", "order," and "rank" seem
unhelpful, though perhaps I am using them incorrectly?
Many thanks.
Best,
Dan
Two questions
1. What goes on the x-axis for the graphs in part a? I'm thinking
ADAACA, and there will be two curves- one for high and the other for
low growth. And I'll repeat the same graph, this time for
non-incumbent. Am I right?
2. How do I graph CI for part b?
Thanks,
Chester
> 1. In part b: Is it OK if I calculate the mean probability and the 95%
> confidence interval and provide a density plot?
You want figures that look like the one in the lecture notes (Replication
of Garrett)
> 2. Regarding part c: We have to simulate predicted values. I am not sure
> whether the simaultion in the solution of question 2 in HW5 was of predicted
> values or rather expected values. So which is it?
You need the predicted probabilities.
Kosuke
> What exactly are we supposed to do for question b?
> My understanding is that I need to come up with a graph that is
> similar to what Gary had in the slides (the graph that 250 people asked
> for). Am I right? How is "First differences" then? How do I draw lines
> that represent the confidence intervals? HELP!!!!!
Yes, that's what you are supporsed to do. You are also right that it's not
really "first differences."
Kosuke
Hi,
This is an R question I've had from the beginning of the semester. I would
like to be able to grab the indices of an array conditioned on some
criteria. For example, if I have
> foo <- c(1,2,1,2)
> foo
[1] 1 2 1 2
and I want the indices of foo where foo[i]=1; is there a simple command in R
to do that? I know I can write a function that will do it:
> index <- seq(1:length(foo))
> bar <- index[index*((foo==1)*1) != 0]
so that
> bar
[1] 1 3
and
> foo[bar]
[1] 1 1
But, am I overlooking an obvious solution built into R?
Thanks,
John.