Tobias Christoph
2017-May-11 13:37 UTC
[R] Error: invalid type (closure) for the variable 'time' - object specific trend
Hey, I just have trouble adding a object specific time trend with the plm-package. I recieve the following error: * **"Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data, : invalid type for the variable 'time' "* I used the formula: / FE_trend<- plm(log(revenue) ~ log(supply)+ city*time, data=R_Test_log_Neu, model="within", effect = "twoways") // / Do you have an idea how to fix it? Toby [[alternative HTML version deleted]]
Duncan Murdoch
2017-May-11 15:23 UTC
[R] Error: invalid type (closure) for the variable 'time' - object specific trend
On 11/05/2017 9:37 AM, Tobias Christoph wrote:> Hey, > > I just have trouble adding a object specific time trend with the > plm-package. I recieve the following error: > * > **"Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, > data = data, : invalid type for the variable 'time' "* > > I used the formula: > > / FE_trend<- plm(log(revenue) ~ log(supply)+ city*time, > data=R_Test_log_Neu, model="within", effect = "twoways") // > / > Do you have an idea how to fix it?I don't know that package and you didn't supply a reproducible example, so there are at least these two possibilities: 1. Your dataframe R_Test_log_Neu contains no column named "time". (Remember that "Time" and "time" are different.) Fix: use the correct column name. 2. The plm package isn't doing lookup of symbols from the formula first in your dataframe. This would need to be fixed in the package. A workaround might be to name the columns with unique names that won't be found anywhere else, e.g. name your column "NeuTime" instead of "time". Duncan Murdoch
Tobias Christoph
2017-May-11 20:20 UTC
[R] Error: invalid type (closure) for the variable 'time' - object specific trend
Hey Duncan, thank you very much for your quick reply. _My data used:_ 1st column(town):1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,...........,11 2nd column(year):1,2,3,4,5,6,7,8,9,10,11,12,1,2,3.......,12 3rd column (revenue): 4th colum (supply): I have now renamed my colums and did the regression again. Now there is a problem with R-squared, as it is the sum of 1 now with no given std. error and t-value. This is probably due to the fact, that I try to estimate more parameters than data. To add a linear trend I found the following formular:*lm(y ~ x1 + factor(ccode)*time, data=df)* I try to I decode it for and use it for my regression: *plm(log(revenue) ~ log(supply) + factor(town)*time, data=R_Test_log_Neu)* When I do this regression I will get the original error: "invalid type (closure) for the variable 'time' - object specific trend" With the notation"time" not my colum is meant, but probably the command "time" in R. Can you follow my thoughts? Tobi Am 11.05.2017 um 17:23 schrieb Duncan Murdoch:> Duncan Murdoch