0
$\begingroup$

Stats is not my strong point but trying to run a regression. I'm aware that it happens because some of these variables are perfectly collinear. However, I do not know how to fix this? Any help would be much appreciated. This is my current script:

### Deviant coding of 'Sex' variable
dat_full$deviant_sex <- scale(ifelse(dat_full$sex == "Female",0,1), scale = F)

## Mean centre predictors

### Complexity
dat_full$stnsci <- scale(ifelse(dat_full$complexity == "scientific", 1, 0), center = T, scale = F)
dat_full$stnnon <- scale(ifelse(dat_full$complexity == "none", 1, 0), center = T, scale = F)

### Timing
dat_full$aftbef <- scale(ifelse(dat_full$timing == "before", 1, 0), center = T, scale = F)
dat_full$aftnon <- scale(ifelse(dat_full$timing == "none", 1, 0), center = T, scale = F)

#regression
fulldata <- lm(verdict ~ stnsci + stnnon + 
               aftbef + aftnon + stnsci:aftbef +
               stnsci:aftnon + stnnon:aftbef + 
               stnnon:aftnon , data=dat_full)
summary (fulldata)

enter image description here

$\endgroup$

marked as duplicate by gung - Reinstate Monica r May 9 at 16:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ How many possible values are there for complexity, or for timing? You appear to be trying to have new variables for every level of a categorical variable. $\endgroup$ – gung - Reinstate Monica May 9 at 16:25
  • 1
    $\begingroup$ I think you will find the information you need in the linked thread. Please read it. If it isn't what you want / you still have a question afterwards, come back here & edit your question to state what you learned & what you still need to know. Then we can provide the information you need without just duplicating material elsewhere that already didn't help you. $\endgroup$ – gung - Reinstate Monica May 9 at 16:27
1
$\begingroup$

I think the easiest thing you could do is to start "small", say with

formula = verdict ~ stnsci + stnnon + aftbef

and then keep adding variables and interactions step by step, so you can see exactly at which point collinearity sets in. At that point you might opt for discarding the most recently introduced variable or, if you want to keep it, some of the previously introduced variables, until collinearity disappears.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.