Hello, I was wondering if there was an easy way to calculate the rate of change in a variable for an unbalanced panel data set. Below is a detailed description in R of what I am asking. Thank you. Geoff #Suppose I have the following unbalanced panel data; Person <- c(rep('Frank',5), rep('Tony',4), rep('Edward',4)); Year <- c(2005,2006,2007,2008,2009,2005,2006,2008,2009,2006,2007,2008,2009); Score <- c(55,58,63,23,34,38,56,87,44,32,98,45,56); Data <- data.frame(Person=Person, Year=Year, Score=Score); Data; #Is there a simple way to calculate the Year-to-Year percentage change in Score that accounts for the missing data?; #Notice that Tony is missing data for the Year 2007 and Edward is missing the Year 2005; #Note as well that we will need to end up losing the Year 2005 in the calculation; -- Geoffrey Smith Visiting Assistant Professor Department of Finance W. P. Carey School of Business Arizona State University [[alternative HTML version deleted]]
Geoffrey Smith-3 wrote:> > Hello, I was wondering if there was an easy way to calculate the rate of > change in a variable for an unbalanced panel data set. Below is a > detailed > description in R of what I am asking. Thank you. Geoff > >A classic for mixed models, which simply does not know what "missing data" are (= handles those cases graciously). Dieter library(nlme) Person <- c(rep('Frank',5), rep('Tony',4), rep('Edward',4)); Year <- c(2005,2006,2007,2008,2009,2005,2006,2008,2009,2006,2007,2008,2009); Score <- c(55,58,63,23,34,38,56,87,44,32,98,45,56); Data <- data.frame(Person=Person, Year=Year, Score=Score); Data; summary(lme(Score~Year, random=~1|Person,data=Data)) -- View this message in context: http://r.789695.n4.nabble.com/lags-for-unbalanced-panel-data-tp3341764p3341882.html Sent from the R help mailing list archive at Nabble.com.