[Rd] Should there be a confint.mlm ?

steven pav @h@bbychef @ending from gm@il@com
Fri Jul 20 06:51:07 CEST 2018


It seems that confint.default returns an empty data.frame for objects of
class mlm. For example:

```
nobs <- 20
set.seed(1234)
# some fake data
datf <-
data.frame(x1=rnorm(nobs),x2=runif(nobs),y1=rnorm(nobs),y2=rnorm(nobs))
fitm <- lm(cbind(y1,y2) ~ x1 + x2,data=datf)
confint(fitm)
# returns:
     2.5 % 97.5 %
```

I have seen proposed workarounds on stackoverflow and elsewhere, but
suspect this should be fixed in the stats package. A proposed
implementation would be:

```
# I need this to run the code, but stats does not:
format.perc <- stats:::format.perc

# compute confidence intervals for mlm object.
confint.mlm <- function (object, level = 0.95, ...) {
  cf <- coef(object)
  ncfs <- as.numeric(cf)
  a <- (1 - level)/2
  a <- c(a, 1 - a)
  fac <- qt(a, object$df.residual)
  pct <- format.perc(a, 3)
  ses <- sqrt(diag(vcov(object)))
  ci <- ncfs + ses %o% fac
  setNames(data.frame(ci),pct)
}

# returning to the example above,
confint(fitm)
# returns:
                 2.5 % 97.5 %
y1:(Intercept) -1.2261 0.7037
y1:x1          -0.5100 0.2868
y1:x2          -2.7554 0.8736
y2:(Intercept) -0.6980 2.2182
y2:x1          -0.6162 0.5879
y2:x2          -3.9724 1.5114
```




-- 

--sep

	[[alternative HTML version deleted]]



More information about the R-devel mailing list