Greetings,
New problem. I realized that my original calculations had very small
n values. I thought that this didn't make sense given the size of the
data set, and so I went back and redid the filtering process on the data
set, as Lucy described, which yielded many more cases to work with.
However, the same matrix algebra that worked before refuses to work now.
When I try to calculate the beta's, I get this error.
Error in "rownames<-"('*tmp*', value=colnames(a)) :
length of dimnames[1] not equal to array extent
Any suggestions
Regards,
Sheldon Bond
Hi everyone,
hope the problem set is going well- can anyone tell me why it is we always
use na.omit, when in Fox02 (page59) says that na.exclude is better as it
preserves some of the information in the observation with the missing
data. Is it better? When would it be a good idea to use exclude rather
than omit?
Lucy
Greetings,
I am having trouble translating the codebook and the barro data. the
names of the variables are completely generic and I can not find where in
the code book it tells you how to connect the generic variable names to
the actual variable names. For example, when I put the data into r, the
variable names came out as (V001, V002, V003, etc.) I used
read.table("barro.dat", row.names=1) to read the data. Any suggestions?
Regards,
Sheldon Bond
Hi all,
I can't vouch for this program at all (since its for PCs and I use a
Mac) but TeXDesign (http://www-unix.oit.umass.edu/~gintis/) is supposed
to make table-making in LaTeX a breeze. If you try it, let me know how
it works out.
Also, if any Mac user/unix expert out there wants to teach me how to
build/compile a tcl/tk program called arraymaker
(http://www.ctan.org/tex-archive/support/arraymaker/arraymaker) that
makes pretty latex tables, I will buy you a pitcher of beer or take you
to lunch, your choice.
Thanks
andy
Hi, everyone. Problem Set 7, and the related data and mini-codebook, have
all been posted to the course webpage. That set is due Monday, 29
November, just after the Thanksgiving break. Have a nice (warm) weekend!
Ryan
------------------------------------------
Ryan T. Moore ~ Government & Social Policy
Ph.D. Candidate ~ Harvard University
Homepage: http://www.people.fas.harvard.edu/~rtmoore/
Gov1000: http://www.courses.fas.harvard.edu/~gov1000/
So, I've written this code:
y<-as.vector(barro$grsh56)
x1<-as.vector(barro$invsh55)
x2<-as.vector(barro$bmp5)
x3<-as.vector(barro$prights5)
xmat<-cbind(x1,x2,x3)
betamat<-matrix(c("x_1","x_2","x_3",NA,NA,NA),3,2)
for(j in 1:3){
betamat[j,2]<- solve(t(xmat[j])%*%xmat[j])%*%t(xmat[j])%*%y
}
to calculate my slope coefficients. Unfortunately, whenever I run it, I
get this error:
Error in "[<-"(`*tmp*`, j, 2, value = c(-0.0703937971842481, NA, NA,
NA, :
number of items to replace is not a multiple of replacement length
But, as you can see, the replacement length in betamat is 3 (rows 1-3,
in col. 2) and the loop generates 3 coefficients.
So, to trouble shoot this, I tried doing it one at a time:
> beta1<-solve(t(x1)%*%x1)%*%t(x1)%*%y
but i got this error:
Error in solve.default(t(x1) %*% x1) : system is computationally
singular: reciprocal condition number = 0
Hmmm...any clue why this is happening? Is it the fact that there are
missing values in the matrix? How can we deal with those?
andy
if it wasn't clear from my response to the list, the problem i was
encountering with as.vector etc. was that it was making vectors and
matrices that were NOT the vectors and matrices that i actually wanted
(they were carrying over labels from the data frame).
to check that you're getting the information you need, i would type x1,
for example, and see what it actually pops out. same goes for xmat and
the other matrices.
for the matrix functions like %*% to work, you need
to make sure that you have matrices and vectors that consist _only_ of the
data that - there cannot be row names, column names, etc cropping up.
good luck,
michael
On Fri, 19 Nov 2004, Andy Harris wrote:
> So, I've written this code:
>
> y<-as.vector(barro$grsh56)
> x1<-as.vector(barro$invsh55)
> x2<-as.vector(barro$bmp5)
> x3<-as.vector(barro$prights5)
> xmat<-cbind(x1,x2,x3)
> betamat<-matrix(c("x_1","x_2","x_3",NA,NA,NA),3,2)
> for(j in 1:3){
> betamat[j,2]<- solve(t(xmat[j])%*%xmat[j])%*%t(xmat[j])%*%y
> }
>
> to calculate my slope coefficients. Unfortunately, whenever I run it, I
> get this error:
>
> Error in "[<-"(`*tmp*`, j, 2, value = c(-0.0703937971842481, NA, NA,
> NA, :
> number of items to replace is not a multiple of replacement length
>
> But, as you can see, the replacement length in betamat is 3 (rows 1-3,
> in col. 2) and the loop generates 3 coefficients.
>
> So, to trouble shoot this, I tried doing it one at a time:
> > beta1<-solve(t(x1)%*%x1)%*%t(x1)%*%y
> but i got this error:
> Error in solve.default(t(x1) %*% x1) : system is computationally
> singular: reciprocal condition number = 0
>
> Hmmm...any clue why this is happening? Is it the fact that there are
> missing values in the matrix? How can we deal with those?
>
> andy
>
> _______________________________________________
> gov1000-list mailing list
> gov1000-list(a)lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov1000-list
>
Hi Everyone,
Some folks have been asking about Sections 9.1.1 and Sections 9.1.2.
While these sections might provide some additional intuition to some
people they aren't strictly necessary for what we're doing right now.
We'll come back to the issue of dummy variables later in class from a
non-ANOVA perspective that I think will probably make more sense to
most of you.
Hope this helps.
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
5.15 #3. How does one regress residuals on residuals in R. I've looked
through help, Fox02, and section notes, but I don't see where to begin.
I have 1 and 2 so far and have tried:
library(car)
data(Anscombe)
attach(Anscombe)
names(Anscombe)
anscombe.mod1<-lm(education~young+urban)
anscombe.mod2<-lm(income~young+urban)
anscombe.mod3<-lm(anscombe.mod1~anscombe.mod2)--->though I receive errors
Tips welcome :)
question 6b asks, "how is your interpreation different from part a)
above?" what exactly is this asking us to do - to compare the values of
our coefficients, R-squared, and the standard error of regression in the
simple regressions with those values from the multiple regression?