r - Error when using `delthamethod`{msm} for a fitted linear model: covariances should be a n x n matrix -


i using delthamethod package msm derive standard error of transformed variable.

example code:

require(msm)  x1 <- 1:10 x2 <- c(0,0,0,0,0,0,0,0,0,0) y <- c(1,3,3,4,5,7,7,8,9,10)  m1 <- lm(y~x1+x2) summary(m1)  deltamethod(~ (1-x1), coef(m1), vcov(m1)) 

the error "covariances should 3x3 matrix". reason 1 variable not have variation (x2 zero) , has "na" in regression output.

is there easy fix this? know leave variable out, running more 1.000 regressions each around 15 parameters estimate, , na variables (without variation) every time different variables.

how about:

deltamethod(~(1-x1), na.omit(coef(m1)), vcov(m1)) # [1] 0.2949063 

Comments