Can I add 3 continuous independent variables and one binary categorical variable (without making dummy variables, as a dummy variable is created for more than 3 categories?) For example: one dependent variable and 3 independent variables, with the effect between 2 age groups in SPSS analyzed. Do I have to create an interaction term with all the independent variables?
I'm not sure where you got information about a dummy code only being used for 3 categories...that isn't true. You can dummy code any number of categorical predictors. The core point behind it is to provide one category as the reference group and the other codes as contrasts to the reference group. So all you need is two codes: one for the first reference group and a code for the comparison group. You also don't have to use an interaction term. It depends on what you are trying to investigate with your analysis.
As an example, I have simulated data below that shows three IVs and one DV. One of the predictors is a binary categorical predictor of gender, with the coding $0 = male$ and $1 = female$). I am using R here, but the idea should be essentially the same for SPSS and I show it like this to show you how dummy coding from scratch will get the result you are looking for anyway. First I create three random, normally distributed variables called
#### Simulate Data #### set.seed(123) y <- rnorm(n=1000) x1 <- rnorm(n=1000) x2 <- rnorm(n=1000)
Then I create our main variable. It is a factor that can only have values from 0 to 1, and then I label them with "Male" and "Female".
gender <- factor( rbinom(n=1000, size = 1, prob = .5), labels = c("Male","Female") )
Thereafter I just smoosh all this data into a data frame and fit a regression.
#### Create Data Frame #### df <- data.frame(x1,x2,gender,y) #### Fit Model #### fit <- lm(y ~ x1 + x2 + gender, data = df) summary(fit)
If you run
summary(fit) it will give you a long output, so I have only included the relevant section below:
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.08013 0.04360 1.838 0.06640 . x1 0.08283 0.03095 2.676 0.00758 ** x2 -0.02543 0.03196 -0.796 0.42638 genderFemale -0.13999 0.06256 -2.238 0.02546 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Here you can see the
gender variable is now named
genderFemale. This is because it is being contrasted against the other level
genderMale, which is the
(Intercept) of the regression output (this is how it is done in SPSS as well). We can see that compared to the male group, the female group, after controlling for all other factors, has a conditional mean that is -.14 less than the males.
I don't have SPSS installed nor do I have the space to install it again, but this video below shows a direct example of dummy coding with a binary: