Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tibbles and column spaces #4

Open
doomlab opened this issue Nov 17, 2020 · 0 comments
Open

tibbles and column spaces #4

doomlab opened this issue Nov 17, 2020 · 0 comments

Comments

@doomlab
Copy link
Owner

doomlab commented Nov 17, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant