-
Notifications
You must be signed in to change notification settings - Fork 7
Description
From Kelsey Sewell:
Update:
I tried converting Demographic.E4 allele to a factor with 2 levels (as opposed to a character variable) and I still was getting the same error. Please note, there are no NA’s in this variable:
summary(ImputesAmyloid$Demographic.E4 allele)
No Yes
173 51
I then tried to recreate the error using the states dataset from R and I couldn’t. I used this code and it ran fine:
states = as.data.frame(state.x77)
states$murdercat = states$Murder
states$murdercat= as.factor(ifelse(states$Murder <= 5, "Low",
ifelse(states$Murder > 5, "High", NA)))
test = moderation1(y = "Income",
x = "Illiteracy",
m = "murdercat",
cvs = "Frost",
df = states,
with_out = T)
I so I created a new ‘categorical’ variable in my dataset (even though Demographic.E4 allele was already categorical):
ImputesAmyloid$allelecat = ImputesAmyloid$Demographic.E4 allele
ImputesAmyloid$allelecat = as.factor(ifelse(ImputesAmyloid$Demographic.E4 allele == "No", "No",
ifelse(ImputesAmyloid$Demographic.E4 allele == "Yes", "Yes", NA)))
Then ran the model using the new variable and it ran fine.
doublemodtest <- moderation1(y = "Image.PET.Centiloid",
x = "totalMETs",
m = "allelecat",
cvs = c("Age", "Demographic.Sex", "mood.y", "premorbidIQ.y", "`PSQI.Q7-Medicine-Induced Sleep`", "Collection"),
with_out = F,
df = ImputesAmyloid)
I really have no idea why this worked as Demographic.E4 allele and allelecat appear to be exactly the same?
str(ImputesAmyloid$
Demographic.E4 allele)
Factor w/ 2 levels "No","Yes": 1 1 1 1 1 2 1 1 1 1 ...
str(ImputesAmyloid$allelecat)
Factor w/ 2 levels "No","Yes": 1 1 1 1 1 2 1 1 1 1 ...
The only difference I can think of is that Demographic.E4 allele was read in from excel using the readxl package, whereas allelecat wasn’t.