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

Error with clm objects #38

Open
ryanvosbigian opened this issue Jun 21, 2024 · 0 comments
Open

Error with clm objects #38

ryanvosbigian opened this issue Jun 21, 2024 · 0 comments

Comments

@ryanvosbigian
Copy link

There is an error when using resids (and other functions) with clm objects.

Error in X[, -1L, drop = FALSE] %*% object$beta :
non-conformable arguments

The error originates from the getMeanResponse.clm function.

I think I fixed it with:

getMeanResponse.clm <- function(object) {
  # Have to do this the long way, for now! :(
  mf <- model.frame(object)
  if (!is.null(cl <- attr(object$terms, "dataClasses"))) {
    .checkMFClasses(cl, mf)
  }
  X <- model.matrix(object$terms, data = mf, contrasts = object$contrasts)
  if(sum(object$aliased$beta) > 0) {
    X <- X[, !c(object$aliased$beta), drop = FALSE]
    # X <- X[, !c(FALSE, object$aliased$beta), drop = FALSE] # ERROR WAS HERE
  }

  
  drop(X[, -1L, drop = FALSE] %*% object$beta[!object$aliased$beta] - object$alpha[1L])
  ### drop(X[, -1L, drop = FALSE] %*% object$beta - object$alpha[1L]) # ERROR ALSO HERE
  
}
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