# Exact logistic regression, R, and elrm: data formatting and output

I use SPSS, but am forced to use R for exact logistic regression. So I'm brand new to R (and hating it so far) and also new to logistic regression. I've read the original elrm paper and looked at examples of its use. However, I can't find information on the questions below (after the data description).

The fit of two models of cognitive processing was compared for each subject in each of 3 conditions. My binary dependent variable is whether the difference in model fits was significant or not (my "Success" variable below). I have three experimental Conditions: 0, 1, and 2. 0 is my reference group. My question is: is there an overall effect of Condition? If so, which conditions differ? The specific alternative hypothesis is that the proportion/probability of "success" should be greater in conditions 0 and 1 than in condition 2. My data look like

...and so on. SPSS actually creates the dummy variables for you on the fly but they are easy enough to create explicitly.

Question 1: I have read that to use elrm you have to enter the data such that the response variable represents success/number of trials. And as far as I can tell elrm doesn't create dummy variables automatically. I've seen examples of tables representing this data structure, but can't find any step-by-step examples of getting raw data into that format, espescially given a one-variable 3-levels situation. Is there an example out there that I'm missing? If not, is this what the data should look like?

I'm not sure how I'd enter the dummy variables into the formula...just as separate variables?

Question 2: I can see how I can get the tests of the coefficients of the dummy variables. But I can't figure out how to get a test of the overall effect of the independent variable. I need to evaluate the overall effect of Condition before looking at individual conditions. Is there a way to get that out of elrm? (I found an example of this done for the aod package which runs regular logistic regression but not exact logistic regression.)

Question 3: I can't find a description of what the p-value for individual coeffeicients represents in elrm. Is this is for the Wald test?

• Which paper are you referring to? What package are you using in R - the CRAN package that's actually called elrm or something else? If you're finding R difficult (and coming from SPSS it might be hard), have you seen this? The author also has a more recent book by the same title. – Glen_b Jul 9 '14 at 0:40
• @Glen_b I found the paper at CRAN link and at the Journal of Statistics Software (although their site seems to be down). But it's geared toward experienced users. The R for SPSS users looks helpful though, thanks. – Michelle Jul 9 '14 at 2:52
• The thing you linked to there is the manual. The manual may seem confusing, but it's a goldmine of precise information. If you want a basic 'how to use this' type document, the vignettes that many packages have are usually a good way to start. But don't ignore the manual completely, since it often tells you how to do things the vignette or vignettes don't cover. Pay particular attention to the examples section at the end of the manual entries to get a sense of how functions are used. – Glen_b Jul 9 '14 at 5:37
• The titanic example at the bottom of page 6 of the manual you linked to suggests it does create dummies automatically - that formula has a factor in it. R handles factors automatically, you don't even see the dummies. [Even if elrm somehow didn't handle factors by itself, it's easy to generate a set of dummies in R - e.g. if you have a factor called x, then model.matrix(~x)[,-1] will generate dummies for every factor level after the first. Try (x=as.factor(sample(LETTERS[1:3],10,replace=TRUE))); model.matrix(~x)[,-1] and see] – Glen_b Jul 9 '14 at 5:47
• @Glen_b Ahh, ok. That makes way more sense than not having the ability to automatically create dummies. I didn't quite realize what as.factor was doing (still working on getting the data structure down). I'll have to look into the examples in more detail. Thanks! – Michelle Jul 10 '14 at 0:21