Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordinal regression determinant #44

Open
ecmerkle opened this issue Sep 26, 2021 · 0 comments
Open

Ordinal regression determinant #44

ecmerkle opened this issue Sep 26, 2021 · 0 comments

Comments

@ecmerkle
Copy link

I like your ordinal regression case study, and the approach to setting priors on the cutpoints is relevant to some models I am working on. I think that the determinant of that Jacobian matrix does have an analytic determinant, though. I have not written up a full proof, but I am convinced that the determinant is the product of the diagonal times the matrix dimension. In R, it would be something like

prod(diag(J)) * nrow(J)

Here is some code for testing this expression on matrices of the specified structure, with random entries:

nrep <- 100
## dimension of matrix:
nr <- sample(3:20, 100, replace=TRUE)

res <- matrix(NA, nrep, 2)

for(i in 1:nrep){
  ## matrix entries:
  ents <- rnorm((nr[i] - 1), sd=2)

  tmpmat <- matrix(0, nr[i], nr[i])
  tmpmat[,1] <- 1

  for(j in 1:(nr[i] - 1)){
    tmpmat[j:(j+1), (j+1)] <- c(ents[j], -ents[j])
  }

  res[i,1] <- det(tmpmat)
  res[i,2] <- prod(diag(tmpmat)) * nr[i]
}

all.equal(res[,1], res[,2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant