{"action":"closed","issue":{"url":"https://api.github.com/repos/markmfredrickson/RItools/issues/40","labels_url":"https://api.github.com/repos/markmfredrickson/RItools/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/markmfredrickson/RItools/issues/40/comments","events_url":"https://api.github.com/repos/markmfredrickson/RItools/issues/40/events","html_url":"https://github.com/markmfredrickson/RItools/issues/40","id":122814622,"number":40,"title":"SparseMMFromFactor has internally inconsistent results with manually manipulated match","user":{"login":"josherrickson","id":1674171,"avatar_url":"https://avatars.githubusercontent.com/u/1674171?v=3","gravatar_id":"","url":"https://api.github.com/users/josherrickson","html_url":"https://github.com/josherrickson","followers_url":"https://api.github.com/users/josherrickson/followers","following_url":"https://api.github.com/users/josherrickson/following{/other_user}","gists_url":"https://api.github.com/users/josherrickson/gists{/gist_id}","starred_url":"https://api.github.com/users/josherrickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josherrickson/subscriptions","organizations_url":"https://api.github.com/users/josherrickson/orgs","repos_url":"https://api.github.com/users/josherrickson/repos","events_url":"https://api.github.com/users/josherrickson/events{/privacy}","received_events_url":"https://api.github.com/users/josherrickson/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-17T20:15:14Z","updated_at":"2015-12-18T11:03:05Z","closed_at":"2015-12-18T11:03:05Z","body":"See code below.\r\n\r\n    library(optmatch)\r\n    library(SparseM)\r\n    data(nuclearplants)\r\n\r\n    m <- pairmatch(pr ~ t1 + t2 + cap, data = nuclearplants)\r\n    m[\"I\"] <- NA\r\n\r\n    z <- attr(m, \"contrast.group\")\r\n\r\n    sparsem <- SparseMMFromFactor(m)\r\n\r\n    t <- t(as.matrix.csr(z))%*%sparsem\r\n    c <- t(as.matrix.csr(!z))%*%sparsem\r\n\r\n    > attr(t, \"dimension\")\r\n    [1]  1 10\r\n    > attr(c, \"dimension\")\r\n    [1]  1 10\r\n    > sapply(attributes(t), length)\r\n           ra        ja        ia dimension     class \r\n           10        10         2         2         1 \r\n    > sapply(attributes(c), length)\r\n           ra        ja        ia dimension     class \r\n            9         9         2         2         1 \r\n\r\n`c` should have 10 objects in `ra` and `ja`; or it should have dimension 1x9 (the former is preferred for my use case).\r\n\r\nI'm uncertain if the issue is in `SparseMMFromFactor` or something with `matrix.csr`'s Ops. I suspect the former, but I'd have to dive a lot deeper into the code than I am able to right now to be certain."}}