plm

How to run regressions on multidimensional panel data in R

与世无争的帅哥 提交于 2019-12-03 14:04:27
问题 I need to run a regression on a panel data . It has 3 dimensions (Year * Company * Country). For example: ============================================ year | comp | count | value.x | value.y ------+------+-------+----------+----------- 2000 | A | USA | 1029.0 | 239481 ------+------+-------+----------+----------- 2000 | A | CAN | 2341.4 | 129333 ------+------+-------+----------+----------- 2000 | B | USA | 2847.7 | 187319 ------+------+-------+----------+----------- 2000 | B | CAN | 4820.5 |

How to deal with NA in a panel data regression?

我的未来我决定 提交于 2019-12-03 09:47:55
问题 I am trying to predict fitted values over data containing NA s, and based on a model generated by plm . Here's some sample code: require(plm) test.data <- data.frame(id=c(1,1,2,2,3), time=c(1,2,1,2,1), y=c(1,3,5,10,8), x=c(1, NA, 3,4,5)) model <- plm(y ~ x, data=test.data, index=c("id", "time"), model="pooling", na.action=na.exclude) yhat <- predict(model, test.data, na.action=na.pass) test.data$yhat <- yhat When I run the last line I get an error stating that the replacement has 4 rows while

Is there a predict function for PLM in R?

匿名 (未验证) 提交于 2019-12-03 08:51:18
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a small N large T panel which I am estimating via plm (panel linear regression model), with fixed effects. Is there any way to get predicted values for a new dataset? (I want to estimate parameters on a subset of my sample, and then use these to calculate model-implied values for the whole sample). Thanks! 回答1: There are (at least) two methods in the package to produce estimates from plm objects: -- fixef.plm: Extract the Fixed Effects -- pmodel.response: A function to extract the model.response It appears to me that the author(s) are

How to run regressions on multidimensional panel data in R

只谈情不闲聊 提交于 2019-12-03 04:00:42
I need to run a regression on a panel data . It has 3 dimensions (Year * Company * Country). For example: ============================================ year | comp | count | value.x | value.y ------+------+-------+----------+----------- 2000 | A | USA | 1029.0 | 239481 ------+------+-------+----------+----------- 2000 | A | CAN | 2341.4 | 129333 ------+------+-------+----------+----------- 2000 | B | USA | 2847.7 | 187319 ------+------+-------+----------+----------- 2000 | B | CAN | 4820.5 | 392039 ------+------+-------+----------+----------- 2001 | A | USA | 7289.9 | 429481 ------+------+-----

Clustered standard errors different in plm vs lfe

纵饮孤独 提交于 2019-12-03 03:09:06
When I run a cluster standard error panel specification with plm and lfe I get results that differ at the second significant figure. Does anyone know why they differ in their calculation of the SE's? set.seed(572015) library(lfe) library(plm) library(lmtest) # clustering example x <- c(sapply(sample(1:20), rep, times = 1000)) + rnorm(20*1000, sd = 1) y <- 5 + 10*x + rnorm(20*1000, sd = 10) + c(sapply(rnorm(20, sd = 10), rep, times = 1000)) facX <- factor(sapply(1:20, rep, times = 1000)) mydata <- data.frame(y=y,x=x,facX=facX, state=rep(1:1000, 20)) model <- plm(y ~ x, data = mydata, index = c(

Waldtest in R to get adjust F statistic with plm and result shown with stargazer?

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working with an unbalanced short panel. Raw data: bankFull.xlsx What I actually want is only get the regression results with two side fixed effects and robust S.E reported, which is very easy in Stata. I followed online tutorial but ran into some problem always with # Adjust F statistic wald_results <- waldtest(FE1, vcov = cov1) Error in model.matrix.pFormula(formula, data, rhs = 1, model = model, : NA in the individual index variable no matter how I adjusted the data! It almost drives me crazy. here is my code: bankFull <- openxlsx:

plm model “within” - Warning messages in R

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have a problem running this plm model: my data are (example): country=c(1,1,1,2,2,2,3,3,3) year=c(1,2,3,1,2,3,1,2,3) a=c(1,4,6,3,5,8,4,5,7) b=c(8,5,7,2,7,4,9,7,1) matrix=cbind(country, year, a, b) matrix=plm.data(matrix) I run following regression: reg=plm(a~year+b, data=matrix, index=NULL, model="within") summary(reg) and get following warning message:[1] Warning messages: 1: In if (is.na(le)) { : the condition has length > 1 and only the first element will be used 2: In if (is.na(le)) " __no length(.)__ " else if (give.length) { : the

How to include a year fixed effect (in a year-quarter panel data) in R using plm function?

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Thank you all in advance for your help. My question is essentially a "bump" of the following question: R: plm -- year fixed effects -- year and quarter data . Basically, I was wondering if there is anyway using the plm function in R to include a fixed effect that is not at the same level as the data. For example, suppose you have the following data library(plm) id <- c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2) year <- c(1999,1999,1999,1999,2000,2000,2000,2000,1999,1999,1999,1999,2000,2000,2000,2000) qtr <- c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4) y <-

plm error variable lengths differ

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm completely new to R, and I'm trying to run an unbalanced fixed effects model using plm. I'm not sure if this question has been answered as most of the answers on this web site are beyond my technological grasp. My data is set up in five columns, Year, Country, Var1, Var2, and Var3. The Var3 column is missing data sporadically. My goal is to regress Var1 for a country-year observation on the Var2, Var3, and an interaction; with country fixed effects. The missing Var 3 data is blank, no n/a's. Here's my code: >model<-plm(Var1~Var2+Var3

How to deal with NA in a panel data regression?

[亡魂溺海] 提交于 2019-12-03 00:21:44
I am trying to predict fitted values over data containing NA s, and based on a model generated by plm . Here's some sample code: require(plm) test.data <- data.frame(id=c(1,1,2,2,3), time=c(1,2,1,2,1), y=c(1,3,5,10,8), x=c(1, NA, 3,4,5)) model <- plm(y ~ x, data=test.data, index=c("id", "time"), model="pooling", na.action=na.exclude) yhat <- predict(model, test.data, na.action=na.pass) test.data$yhat <- yhat When I run the last line I get an error stating that the replacement has 4 rows while data has 5 rows. I have no idea how to get predict return a vector of length 5... If instead of