Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

intEff function R returns weird errors

$
0
0

I have the following probit model with an interaction effect between i and a:

probit5 <- glm(y ~ a + b + c + d + e + f + g + h + i + j + k + l + i*a,
           family = binomial(link = "probit"), 
           data = data)

But when I use the intEff function:

intEff(probit5, c("i", "a"), data = data)

I get the following error:

Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent
In addition: Warning message:
In cbind(deriv1, deriv2, deriv3, nn, deriv0) :
  number of rows of result is not a multiple of vector length (arg 4)

the data frame "data" looks like this, and class says it's a data.frame

enter image description here

Reproducable example:

a <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
b <- c(18, 18, 18, 18, 18, 18, 18, 18, 18, 18)
c <- c(3.667, 3.667, 3.667, 3.667, 3.667, 3.667, 3.667, 3.667, 3.667, 3.667)
d <- c(4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8)
e <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
f <- c(4.54, 4.54, 4.54, 4.54, 4.54, 4.54, 4.54, 4.54, 4.54, 4.54)
g <- c(3.6364, 3.6364, 3.6364, 3.6364, 3.6364, 3.6364, 3.6364, 3.6364, 3.6364, 3.6364)
h <- c(2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8)
i <- c(1, 0, 1, 0, 1, 0, 1, 0, 1, 0)
j <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
k <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
l <- c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
y <- c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0)

data <- data.frame(y, a, b, c, d, e, f, g, h, i, j, k, l)

probit <- glm(y ~ a + b + c + d + e + f + g  + h + i + j + k + l + i*a,
               family = binomial(link = "probit"), 
               data = data)

intEff(probit, c("i", "a"), data = data)
´´´

But this shows a different error:

Error in apply(X[, vars], 2, table) : dim(X) must have a positive length ´´´

Maybe it is important to note that data.csv was imported with read.csv2


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>