Hi all I want to use plm function on splitted dataset but facing problems while doing it. I did the same for lm function it worked fine but now my problem forces me to use lags into it while in a single set I have multiple type of data, which I believe can only be done with panel data. The code I am using is A = split(mydata, mydata$Unique.ID.Number) Z = lapply(A, function(df){plm(Total.Sales ~ Purchase.Score, data = df)}) It is showing this error Error in eval(expr, envir, enclos) : object 'Total.Sales' not found This works when we try Z = lapply(A, function(df){lm(Total.Sales ~ Purchase.Score, data = df)}) Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Plm-on-splitted-data-tp4637610.html Sent from the R help mailing list archive at Nabble.com.
Hello, For testing the codes, it will be good to have a slice of "mydata".? You can use dput(head(mydata,15)) and paste the output (for first 15 lines of data) in the email.? In that way, you will get much faster response. A.K.? ----- Original Message ----- From: goyalprtk <prateeka.goyal at eclerx.com> To: r-help at r-project.org Cc: Sent: Tuesday, July 24, 2012 11:37 AM Subject: [R] Plm on splitted data Hi all I want to use plm function on splitted dataset but facing problems while doing it. I did the same for lm function it worked fine but now my problem forces me to use lags into it while in a single set I have multiple type of data, which I believe can only be done with panel data. The code I am using is A = split(mydata, mydata$Unique.ID.Number) Z = lapply(A, function(df){plm(Total.Sales ~ Purchase.Score, data = df)}) It is showing this error Error in eval(expr, envir, enclos) : object 'Total.Sales' not found This works when we try Z = lapply(A, function(df){lm(Total.Sales ~ Purchase.Score, data = df)}) Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Plm-on-splitted-data-tp4637610.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On Tue, Jul 24, 2012 at 10:37 AM, goyalprtk <prateeka.goyal at eclerx.com> wrote:> > Hi all > > I want to use plm function on splitted dataset but facing problems while > doing it. > > I did the same for lm function it worked fine but now my problem forces me > to use lags into it while in a single set I have multiple type of data, > which I believe can only be done with panel data. > > The code I am using is > > A = split(mydata, mydata$Unique.ID.Number) > Z = lapply(A, function(df){plm(Total.Sales ~ Purchase.Score, data = df)}) > > It is showing this error > > Error in eval(expr, envir, enclos) : object 'Total.Sales' not found > > This works when we try > > Z = lapply(A, function(df){lm(Total.Sales ~ Purchase.Score, data = df)})Hmmm, Strange -- would it be possible for you to whip up a small reproducible example? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Best, Michael> > > Thanks in advance > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plm-on-splitted-data-tp4637610.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Thanks all for your help... Problem was in my dataset only.. 1 of the splitted part of dataset had all the dependent variables as zero. In other words if dependent variable in all the proposed panels of a dataset is zero than plm will not work -- View this message in context: http://r.789695.n4.nabble.com/Plm-on-splitted-data-tp4637610p4637740.html Sent from the R help mailing list archive at Nabble.com.