plm

R: How to calculate year-wise mean and other operations on daily data for elements in a column

我只是一个虾纸丫 提交于 2019-12-13 07:27:21
问题 Please help me out. I have been stuck for a long time. I am an R beginner, and I want to know how to perform operations on data frame elements using multiple indices e.g. firms and time as in the below case elegantly? I want to perform some typical operations e.g year-wise mean on some other variables for each firm, and here is an example: I am want to calculate year-wise mean from daily data of variables A and F for all firms in the dataset. This is my dataset. I have used dplyr and hydroTSM

Automate regression with specific dependent and independent variables

。_饼干妹妹 提交于 2019-12-13 07:06:05
问题 MVE: Let this be the data set: data <- data.frame(year = rep(seq(1966,2015,1), 8), county = c(rep('prva', 50), rep('druga', 50), rep('treća', 50), rep('četvrta', 50), rep('peta', 50), rep('šesta', 50), rep('sedma', 50), rep('osma', 50)), crime1 = runif(400), crime2 = runif(400), crime3 = runif(400), uvar1 = runif(400), uvar2 = runif(400), uvar3 = runif(400), var1 = runif(400), var2 = runif(400), var3 = runif(400), var4 = runif(400), var5 = runif(400)) Let's say crime1,2 and 3 are specific

How to cluster standard errors of plm at different level rather than id or time?

拥有回忆 提交于 2019-12-13 05:08:18
问题 I run a panel regression by plm . plm only can cluster standard errors at "group" or "time" levels. But I want to cluster at the country level rather than group or time. (For my data, group is the firm level.) I use the following code to cluster: summary(r, vcov = function(x) vcovHC(x, cluster = "group", method = "arellano")) But the options for cluster are only group and time. I want to cluster at country level. 来源: https://stackoverflow.com/questions/52320079/how-to-cluster-standard-errors

R: plm — year fixed effects — year and quarter data

眉间皱痕 提交于 2019-12-12 08:35:28
问题 I am having a problem setting up a panel data model. Here is some sample 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 <- rnorm(16, mean=0, sd=1) x <- rnorm(16, mean=0, sd=1) data <- data.frame(id=id,year=year,qtr=qtr,y_q=paste(year,qtr,sep="_"),y=y,x=x) I run the following regression using 'id' as the individual index and 'year' as the time

plm model “within” - Warning messages in R

半腔热情 提交于 2019-12-12 01:45:35
问题 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)) " _

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

旧城冷巷雨未停 提交于 2019-12-12 00:42:43
问题 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)

pgmm from plm package summary error

烂漫一生 提交于 2019-12-11 23:23:53
问题 I am trying to use the pgmm function from the plm package for R . The regression runs and I can call up the results, however, asking for the summary gives the following error: Error in t(y) %*% x : non-conformable arguments I've imported the data from the World Bank using the WDI package: library(WDI) # Load package COUNTRIES <- c("AGO","BEN","BWA","BFA","BDI") # Specify countries INDICATORS <- c("NY.GDP.PCAP.KN", "SP.DYN.TFRT.IN", "SP.DYN.CBRT.IN", "SP.POP.TOTL") # Specify indicators LONG <-

plm error variable lengths differ

空扰寡人 提交于 2019-12-11 19:49:46
问题 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

Unable to install sandwich package: installation of package ‘sandwich’ had non-zero exit status

筅森魡賤 提交于 2019-12-11 15:15:59
问题 I need to install the "plm" package. After installing it, the "sandwich" package was missing. > library(plm) Error: package or namespace load failed for ‘plm’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘sandwich Tried to install the "sandwich" package, returned with this: Installing package into ‘library_path’ (as ‘lib’ is unspecified) also installing the dependency ‘zoo’ There is a binary version available but the source

Random effects estimation error with plm package due to negative variance

筅森魡賤 提交于 2019-12-11 08:55:32
问题 I'm trying to estimate a panel data model with random effects Swamy and Ahora transformation on market share data of tourism destinations. Please, find attached the dataset in https://github.com/Joseperles/Statistical-questions The model is estimated according the following code: random<-plm(ld_Share~ld_Gdp+ld_Gdppc+ld_Gkf+ld_Cpi+ld_Fdi+ld_Exrate, data=Panel, index=c("Country", "obs"), model="random") However I get this error message: Error in swar(object, data, effect) : the estimated