# How to overcome Coefficients: (4 not defined because of singularities) [duplicate]

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) ## marked as duplicate by gung - Reinstate Monica♦ r StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); May 9 at 16:26

• 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. – gung - Reinstate Monica May 9 at 16:25
formula = verdict ~ stnsci + stnnon + aftbef