Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.A41.4.44.0304202027260.74150-100000@homer06.u.washington.edu>
Date: 2003-04-21T03:31:32Z
From: Thomas Lumley
Subject: To create a Panel and run a Pooled OLS
In-Reply-To: <000b01c307b2$66dbcd80$b029f78c@emp.hhs.se>

On Mon, 21 Apr 2003, Sophie Langenskiold wrote:

> I appreciate your help a lot. Unfortunately, none of your
> recommendations work. I have written a small program to illustrate my
> problems. I hope there is a solution...
>
> Cross1 <- data.frame(i=c(1,2,3),Y=c(3,2,2),X1=c(2,3,4))
> Cross2 <- data.frame(i=c(1,2,3),Y=c(2,3,1),X1=c(5,6,7))
> Panel <- merge(Cross1,Cross2,by="i")
> OLS <- lm(Panel$Y~Panel$X1)
>

I think your problem is with the merge() statement. The Panel dataframe
looks like
> Panel
  i Y.x X1.x Y.y X1.y
1 1   3    2   2    5
2 2   2    3   3    6
3 3   2    4   1    7

so it doesn't have X1 or Y variables.

The solution depends on what you want, but my guess is that you need
  Panel<-rbind(Cross1,Cross2)
  lm(Y~X1,data=Panel)

Or perhaps
   Panel<-rbind(cbind(Cross1,time=1),cbind(Cross2,time=2))
   lm(Y~X1,data=Panel)


	-thomas