I am a total novice to R, I have an assignment using Linear regression, where we have to produce 2 different models, to see which one is a better predictor of pain. The first model is just to contain age and gender. The second model is to include extra variables; The State Trait Anxiety Inventory scores, The Pain Catastrophizing Scale, The Mindful Attention Awareness Scale, and measures of cortisol levels in both salivia and serum (blood).
The research question states that we need to conduct a hierarchical regression, by building a model containing age and sex as predictors of pain (model 1), then building a new model with the predictors: age, sex, STAI, pain catastrophizing, mindfulness, and cortisol measures (model 2). Hence, the predictors used in model 1 are a subset of the predictors used in model 2. After completion of both models, need comparison to assess whether substantial new information was gained about pain in model 2 compared to model 1.
I am having a lot of problems with "sex" as a variable, someone had coded a "3" instead of male and female and although I have excluded the score, "3" is still coming up as a level in the data set, is there a way to remove this?
Furthermore how can I convert "sex" into a "factor" type vector instead of "character" vector? Can categorical variables be predictors in a model? I have attempted to do this using the following command, but it continues to return in errors.
sex_vector <- c("female", "male") etc.
factor.sex.vector <- factor(sex.vector)
Below is an excerpt of the data set:
data.frame': 156 obs. of 10 variables:
$ sex : Factor w/ 3 levels "3","female","male": 2 2 3 3 3 3 3 2 2 2 ...