[R] Plm function, error in uniqval[as.character(effect), , drop = F]
Hi, there, I am trying to run a panel regression with a huge dataset, which has lots of missing values. Here is some description of all variables. > str(com3) Classes ‘plm.dim’ and 'data.frame': 172153 obs. of 30 variables: $ tic : Factor w/ 3435 levels "A","AA","AAC",..: 1 1 1 1 1 1 1 1 1 1 ... $ idate : Factor w/ 81309 levels "2001/12/31 0:27",..: 34 2371 2450 4789 5977 7297 7650 9988 11288 12749 ... $ IS_EFFECTIVE: int 1 1 1 1 1 1 1 1 1 1 ... $ MATERIAL_WEAKNESS : int 0 0 0 0 0 0 0 0 0 0 ... $ SIG_DEFICIENCY : int 0 0 0 0 0 0 0 0 0 0 ... $ NOTEFF_ACC_RULE : int 0 0 0 0 0 0 0 0 0 0 ... $ NOTEFF_FIN_FRAUD: int 0 0 0 0 0 0 0 0 0 0 ... $ NOTEFF_OTHER: int 0 0 0 0 0 0 0 0 0 0 ... $ IC_OP_TYPE_a1m0 : int NA NA NA NA NA NA NA NA NA NA ... $ AUDITOR_FKEY: int NA NA NA NA NA NA NA NA NA NA ... $ AUDITOR_AGREES : int NA NA NA NA NA NA NA NA NA NA ... $ COMBINED_IC_OP : int NA NA NA NA NA NA NA NA NA NA ... $ IC_IS_EFFECTIVE_Y1N0: Factor w/ 4 levels "","0","1","ND": NA NA NA NA NA NA NA NA NA NA ... $ AUDIT_FEES : int NA NA NA NA NA NA NA NA NA NA ... $ NON_AUDIT_FEES : int NA NA NA NA NA NA NA NA NA NA ... $ BENEFITS_FEES : int NA NA NA NA NA NA NA NA NA NA ... $ IT_FEES : int NA NA NA NA NA NA NA NA NA NA ... $ TAX_FEES: int NA NA NA NA NA NA NA NA NA NA ... $ AUDIT_RELATED_FEES : int NA NA NA NA NA NA NA NA NA NA ... $ OTHER_FEES : int NA NA NA NA NA NA NA NA NA NA ... $ CARD: int NA NA NA NA NA NA NA NA NA NA ... $ DISC: int NA NA NA NA NA NA NA NA NA NA ... $ HACK: int NA NA NA NA NA NA NA NA NA NA ... $ INSD: int NA NA NA NA NA NA NA NA NA NA ... $ PHYS: int NA NA NA NA NA NA NA NA NA NA ... $ PORT: int NA NA NA NA NA NA NA NA NA NA ... $ STAT: int NA NA NA NA NA NA NA NA NA NA ... $ UNKN: int NA NA NA NA NA NA NA NA NA NA ... $ BRCH: int NA NA NA NA NA NA NA NA NA NA ... $ ddate : Factor w/ 81306 levels "2001/12/31 0:27",..: 34 2371 2450 4789 5977 7297 7650 9988 11288 12749 ... And I ran a panel regression as follow: rm(list=ls()) library(plm) como3 <- read.csv(file.path('como3.csv'),header = T, stringsAsFactors = F) com3=plm.data(como3, indexes = NULL) summary(com3) Y <- cbind(com3$BRCH) X <- cbind(com3$IS_EFFECTIVE,com3$MATERIAL_WEAKNESS,com3$SIG_DEFICIENCY,com3$IC_IS_EFFECTIVE_Y1N0,com3$AUDITOR_AGREES,com3$COMBINED_IC_OP,com3$AUDIT_FEES) fixed <- plm(Y ~ X,com3, index = c("tic","idate"),effect="individual",model = "within") summary(fixed) Unfortunately, I got this error: series IT_FEES, BRCH are constants and have been removedError in uniqval[as.character(effect), , drop = F] : incorrect number of dimensions BRCH is my dependent variable, which is a dichotomous variable (happened =1, unhappen=0). I don't know why it is considered as the "constant"? Does it cause this error? I have been looking for a solution in the internet for several days, but have not found an answer to fix the problem. Does anybody have an idea what I am doing wrong and what must be done to fix the problem? Thanks in advance. Lynn Huang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] plm function & plm r.squared error
Dear Constanze, the error message gives you a hint, where the problem might be. The first error massage says that you have NAs in your index variables "Unit" and "Week". You can check that with the is.na() function. The second error message (r.squared) tells you to specify the model, that is on which transformation of the data the R-squared has to be computed. There is no default. Moreover, you insert a dataframe ("pCN04") instead on a plm object in r.squared(). Kind regards Nina Schönfelder - FernUniversität in Hagen Fakultät für Wirtschaftswissenschaft Lehrstuhl für Volkswirtschaftslehre, insbes. Makroökonomik 58084 Hagen On 16/02/15 22:25, fay constanze wrote: DearGiovanni,Congratulationsfor the?truly helpful?plm package! Being new to R, I have a problem with the plm function for financial markets timeseries data: After having defined a large, unbalanced panel pdata.frame (https://www.dropbox.com/s/2r9t1cu9v65gobk/Database_CN_2004.csv?dl=0)and running a simple OLS model of two variables regressing company returns(Perf) on index returns (PerfIn)synch <-plm (Perf ~ PerfIn , data=pCN04, na.action = na.omit, index=c("Unit", "Week"), model="pooling") I keepreceiving the following error:Error in model.matrix.pFormula(formula, data, rhs =1, model = model,? : ? NA in theindividual index variableIn addition:Warning message:In `[.data.frame`(index, as.numeric(rownames(mf)),) :? NAsintroduced by coercion There aremuch more NAs in y (Perf) than in x (PerfIn) and I have tried to get rid ofthem with na.omit. Another error I have is with the same model for the r.squaredfunction r.squared(pCN04,model=NULL, Perf ~ PerfIn, type= "ess")Error in tss.default(object, model = model) : ??unused argument (model = model)In addition: Warning message:In mean.default(haty) : argument is not numeric or logical: returning NAMany thanks in advance,your help is very precious to me!Constanze __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] plm function & plm r.squared error
DearGiovanni,Congratulationsfor the truly helpful plm package! Being new to R, I have a problem with the plm function for financial markets timeseries data: After having defined a large, unbalanced panel pdata.frame (https://www.dropbox.com/s/2r9t1cu9v65gobk/Database_CN_2004.csv?dl=0)and running a simple OLS model of two variables regressing company returns(Perf) on index returns (PerfIn)synch <-plm (Perf ~ PerfIn , data=pCN04, na.action = na.omit, index=c("Unit", "Week"), model="pooling") I keepreceiving the following error:Error in model.matrix.pFormula(formula, data, rhs =1, model = model, : NA in theindividual index variableIn addition:Warning message:In `[.data.frame`(index, as.numeric(rownames(mf)),) : NAsintroduced by coercion There aremuch more NAs in y (Perf) than in x (PerfIn) and I have tried to get rid ofthem with na.omit. Another error I have is with the same model for the r.squaredfunction r.squared(pCN04,model=NULL, Perf ~ PerfIn, type= "ess")Error in tss.default(object, model = model) : unused argument (model = model)In addition: Warning message:In mean.default(haty) : argument is not numeric or logical: returning NAMany thanks in advance,your help is very precious to me!Constanze [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] plm function
Dear Ieva, plm(.., model="within") (which is the default for plm()) estimates a within model on time-demeaned data, which is "equivalent" to using the LSDV estimator. Therefore any time-constant dummy variable you add "by hand" will be discarded because of perfect collinearity. What kind of dummies are you trying to include? If they are time-constant they will be incompatible with the within (FE) estimator, but not with other uses of plm() like random effects ('model="random"') or pooling ('model="pooling"'). A reproducible example, as requested by the posting guide, would have clarified things. Best wishes, Giovanni Giovanni Millo, PhD Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 - original message - Message: 15 Date: Wed, 14 Mar 2012 13:46:03 +0200 From: Ieva Sriubait? To: r-help@R-project.org Subject: [R] plm function Message-ID: Content-Type: text/plain Dear Sir/ Madam, I am writing about the panel data for my bachelor degree. I would really appreciate if You could help dealing with R functions. I am trying to estimate the panel data lm model with plm function. When i include 3dummy variables into the regression it dont appear in the sumarry of the model, but when i estimate a simple lm model it appears. Why is it so? What should i do to estimate the statistics for those dummy variables? Thank You. Ieva - end original message - Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}} __ R-help@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.
[R] plm function
Dear Sir/ Madam, I am writing about the panel data for my bachelor degree. I would really appreciate if You could help dealing with R functions. I am trying to estimate the panel data lm model with plm function. When i include 3dummy variables into the regression it dont appear in the sumarry of the model, but when i estimate a simple lm model it appears. Why is it so? What should i do to estimate the statistics for those dummy variables? Thank You. Ieva [[alternative HTML version deleted]] __ R-help@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.