Forum: open-discussion
Monitor Forum | Start New ThreadRE: Using tidy() with censReg() [ Reply ] By: Arne Henningsen on 2016-09-21 06:51 | [forum:43515] |
censReg() inherits from maxLik() so that should work. I am not 100% sure about the dependencies when implementing tidy.maxLik() in the "maxLik" package. If tidy.maxLik() is implemented in the "broom" package, the "broom" package does *not* need to depend on the "maxLik" package. The DESCRIPTION file of the "broom" package should just mention that this package 'enhances' the "maxLik" package. |
RE: Using tidy() with censReg() [ Reply ] By: Ott Toomet on 2016-09-21 06:38 | [forum:43514] |
Does censReg object inherit from maxLik? In that case tidy for maxLik might suffice. I haven't really looked at such dependencies but does a package always need to import the namespace where the generic is defined? That sounds like a dependency hell for me... Is the same true if implementing it in broom? Cheers, Ott |
RE: Using tidy() with censReg() [ Reply ] By: Arne Henningsen on 2016-09-21 06:29 | [forum:43513] |
Dear Elena and Ott We could implement a tidy() method for objects returned by censReg() in the "censReg" package or for objects of class "maxLik" in the "maxLik" package. However, AFAIK, this would require that the "censReg" or "maxLik" package depends on the "broom" package. As I would like to keep the number of dependencies of our packages as small as possible, I suggest to ask the maintainers of the "broom" package to implement a tidy() method for objects of class "maxLik" in their package. (I guess that a tidy() method for "maxLik" objects should also work for "censReg" objects.) The "broom" package already has tidy() methods for the following classes: coeftest, default, density, dist, ftable, manova, map, NULL, numeric, pairwise.htest, power.htest ,spec, table, ts, TukeyHSD. Hence, it shouldn't be a big deal to implement an additional method for "maxLik" objects in the "broom" package. What do you think? Best regards, Arne |
RE: Using tidy() with censReg() [ Reply ] By: Ott Toomet on 2016-09-20 04:14 | [forum:43511] |
Well, the reason is simple--tidy for censReg objects is not implemented. I cannot install censReg right now (some sort of network problems) but have you tried coef(summary(Tobit)) instead? If 'Tobit' inherits from 'maxLik', it should work. Arne, should we implement 'tidy' method for maxLik? I am not quite sure how to do methods for generics that may not be available but that should not be a big issue. |
Using tidy() with censReg() [ Reply ] By: Elena Derby on 2016-09-20 02:02 | [forum:43510] |
Hi all, I am having trouble using the tidy() code to turn the results from a Tobit regression into a matrix so that I can manipulate the coefficients. Here is a copy of the code I am using to get a Tobit estimate from randomly generated censored data: x1 <- rnorm(500, mean = 0, sd = 1) x2 <- rnorm(500, mean = 0, sd = 1) u <- rnorm(500, mean = 0, sd = 2) y_latent <- 2*x1 + 8*x2 + u #betas chosen arbitrarily y_2 <- ifelse(y_latent>0,y_latent,0) Tobit <- censReg( y_2 ~ x1 + x2) Tobit_m <- tidy(Tobit) when I run the last line I get the following error message: Error in tidy.list(Tobit) : No tidying method recognized for this list In addition: Warning message: In sort(names(x)) == c("d", "u", "v") : longer object length is not a multiple of shorter object length can anyone explain why? And how to get these coefficient results into a matrix short of copy and paste? Here is what I have when I just run Tobit: Call: censReg(formula = y_2 ~ x1 + x2) Coefficients: (Intercept) x1 x2 logSigma 0.1405 1.6704 7.9608 0.5978 |