Hi Everyone,
A slightly modified version of problem set 4 is now up on the course
website. The only change is a clarification of problem 2.
Best,
Kevin
------------------------------------------------------
Kevin Quinn
Assistant Professor
Department of Government and
Center for Basic Research in the Social Sciences
34 Kirkland Street
Harvard University
Cambridge, MA 02138
Hi guys-
Problem set 4 is now posted. Also, we have a link to next week's chapter
on matrix algebra on the "WWW links" page. (It's a pdf document.) For
those of you who didn't take the math prefresher, I would recommend
reading Simon and Blume chapter 7 as well.
See you soon-
Alison
Hi Everyone,
New lecture notes are now up on the course website. The material for
today has been substantially expanded from the last version of the
notes.
Best,
Kevin
------------------------------------------------------
Kevin Quinn
Assistant Professor
Department of Government and
Center for Basic Research in the Social Sciences
34 Kirkland Street
Harvard University
Cambridge, MA 02138
The problem is with the line
xyplot <-(Fertility~Education|Catholic)
xyplot is a preexisting function in the lattice package. What you are
doing in this line is overwriting this xyplot function with the
formula on the right hand side of the <-. If you just type:
xyplot <-(Fertility~Education|Catholic)
xyplot
at the R command prompt you'll see that xyplot is now just this
formula. Because the correct version of xyplot no longer exists in
memory you will need to quite out of R and restart. I you load the
lattice package and type xyplot:
library(lattice)
xyplot
you'll see that xyplot is the function it is supposed to be.
Please take a look at the examples from lecture and section to see how
xyplot is called. Also note that the panel=function(x,y,...){ lines
should be inside the call to xyplot(). Again, take a look at the
examples on the course website to see how this works.
Hope this helps.
Best,
Kevin
> Well, I'm not getting syntax errors now :) but nothing happens with my code:
>
> > library(foreign)
> > par(mfrow=c(2,4))
> > Fish <- read.spss("Fish_data.sav", to.data.frame=TRUE)
> > data(swiss)
> > xyplot <-(Fertility~Education|Catholic)
> > panel=function(x, y, ...) {
> + panel.xyplot(x, y, ...)
> + panel.loess(x, y, span=.95, degree=1, ...)
> + }
> >
>
> Yet, this looks right. (?)
>
See below for tips...
> Hi Ryan,
>
> I'm having some trouble inserting R-generated pdfs into my LaTeX
> document. Here's the code:
>
> \begin{figure}[h!!]
> \centering
> \scalebox{.5}{\includegraphics{firstscatterplot.pdf}}
> \caption{Scatterplot of Sahlins data}
> \label{f1}
> \end{figure}\\
>
> When I compile/typeset the file, I get the following error:
>
> ! LaTeX Error: File `totalgraph' not found.
>
> See the LaTeX manual or LaTeX Companion for explanation.
> Type H <return> for immediate help.
> ...
>
> l.127 ...alebox{1.2}{\includegraphics{totalgraph}}
This is letting you know that the error occurs in line 127. You can use
the Goto Line function in XEmacs to hop right to that line, and I think
you'll see that the error is not in the code at the top of your email, but
in a latter line. Others have suggestions?
Best,
Ryan
Hi Everyone,
Someone asked the following:
> Quick question. With normal R graphics, I had the option of copy/pasting
> graphs directly into MS word, do I have that option with lattice
> graphics? I can't seem to copy graphs? Am I forced to confront LaTex in
> order to do this problem set?
If there are any MS Word users out there I'm sure there is a probably
a better way to get lattice graphics into a Word document than my
response below. Please send any suggestions to the listserv.
My answer:
The short answer is that you should be able to use MS Word for all the
problem sets.
You should be able to use the pdf() function to write a plot out to a
pdf file that you should be able to include in a Word file. For
instance:
library(lattice)
library(car)
data(Robey)
pdf(file="test.pdf", height=6, width=6)
xyplot(tfr~contraceptors, data=Robey)
dev.off()
will plot tfr on contraceptors from the Robey dataset and send the
output to pdf a file named test.pdf. The resulting figure will be 6
inches by 6 inches.
Nothing is printed to the screen with this syntax so the best way to
use this for a real problem is to fiddle around plotting things on
your screen until you get things right and to then add the call to
pdf() before your graphics commands and dev.off() after the graphics
commands. Once you have the pdf file you should be able to include
this in a Word document.
There is also a jpeg command that writes figures out as jpg files.
You can get more info with
help(pdf)
and
help(jpeg)
at the R command prompt.
Unfortunately, the computer I have in front of me at the
moment isn't a windows machine and it doesn't have MS Word, so I can't
guarantee that what I suggested actually works in Word.
Please let me know if this doesn't work. I'm happy to help you figure
out a way to make it work.
Best,
Kevin
Hi! In Problem 5, I got the R code, but I am having trouble with the
explanation part...does the question about the conditional mean refer to
the expected value?
Thanks,
:)yelena
Hi! I am a bit confused by the Problem 3 question. I see only three
combinations [1. levels of dem vs. econ development, 2. levels of dem vs.
Islamic religious tradition, 3. levels of dem vs. OPEC membership], but the
question asks us about "four combinations of Muslim/non-Muslim and
OPEC/non-OPEC nations." Am I missing a combination?
Thanks,
:)yelena