How to perform Mixed Design ANOVA on MICE imputed data in R?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







3















I have a question about performing a Mixed Design ANOVA in R after multiple imputation using MICE. My data is as follows:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,88,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,65,64,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,83,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)


So: we have 6 repeated measurements of diastolic blood pressure (measure 1 till 6). The grouping factor is gender, which is called group. This variable is coded 1 if male and 0 if female. Before multiple imputation, we have used the following code in R:



library(reshape)
library(reshape2)
datLong <- melt(dat, id = c("id", "group"), measured = c("measure_1", "measure_2", "measure_3", "measure_4", "measure_5", "measure_6"))
datLong

colnames(datLong) <- c("ID", "Gender", "Time", "Score")
datLong
table(datLong$Time)
datLong$ID <- as.factor(datLong$ID)

library(ez)
model_mixed <- ezANOVA(data = datLong,
dv = Value,
wid = ID,
within = Time,
between = Gender,
detailed = TRUE,
type = 3,
return_aov = TRUE)
model_mixed


This worked perfectly. However, our data is not complete. We have missing values, that we impute using MICE:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,NA,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,NA,NA,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,NA,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)

imp_anova <- mice(dat, maxit = 0)
meth <- imp_anova$method
pred <- imp_anova$predictorMatrix
imp_anova <- mice(dat, method = meth, predictorMatrix = pred, seed = 2018, maxit = 10, m = 5)


(The imputation gives logged events, because of the made-up data and the simple imputation code e.g id used as a predictor. For my real data, the imputation was correct and valid)



Now I have the imputed dataset of class ‘mids’. I have searched the internet, but I cannot find how I can perform the mixed design ANOVA on this imputed set, as I did before with the complete set using ezANOVA. Is there anyone who can and wants to help me?










share|improve this question























  • I think cross validated would be a better forum for your question.

    – Mankind_008
    Jan 3 at 16:11




















3















I have a question about performing a Mixed Design ANOVA in R after multiple imputation using MICE. My data is as follows:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,88,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,65,64,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,83,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)


So: we have 6 repeated measurements of diastolic blood pressure (measure 1 till 6). The grouping factor is gender, which is called group. This variable is coded 1 if male and 0 if female. Before multiple imputation, we have used the following code in R:



library(reshape)
library(reshape2)
datLong <- melt(dat, id = c("id", "group"), measured = c("measure_1", "measure_2", "measure_3", "measure_4", "measure_5", "measure_6"))
datLong

colnames(datLong) <- c("ID", "Gender", "Time", "Score")
datLong
table(datLong$Time)
datLong$ID <- as.factor(datLong$ID)

library(ez)
model_mixed <- ezANOVA(data = datLong,
dv = Value,
wid = ID,
within = Time,
between = Gender,
detailed = TRUE,
type = 3,
return_aov = TRUE)
model_mixed


This worked perfectly. However, our data is not complete. We have missing values, that we impute using MICE:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,NA,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,NA,NA,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,NA,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)

imp_anova <- mice(dat, maxit = 0)
meth <- imp_anova$method
pred <- imp_anova$predictorMatrix
imp_anova <- mice(dat, method = meth, predictorMatrix = pred, seed = 2018, maxit = 10, m = 5)


(The imputation gives logged events, because of the made-up data and the simple imputation code e.g id used as a predictor. For my real data, the imputation was correct and valid)



Now I have the imputed dataset of class ‘mids’. I have searched the internet, but I cannot find how I can perform the mixed design ANOVA on this imputed set, as I did before with the complete set using ezANOVA. Is there anyone who can and wants to help me?










share|improve this question























  • I think cross validated would be a better forum for your question.

    – Mankind_008
    Jan 3 at 16:11
















3












3








3


2






I have a question about performing a Mixed Design ANOVA in R after multiple imputation using MICE. My data is as follows:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,88,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,65,64,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,83,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)


So: we have 6 repeated measurements of diastolic blood pressure (measure 1 till 6). The grouping factor is gender, which is called group. This variable is coded 1 if male and 0 if female. Before multiple imputation, we have used the following code in R:



library(reshape)
library(reshape2)
datLong <- melt(dat, id = c("id", "group"), measured = c("measure_1", "measure_2", "measure_3", "measure_4", "measure_5", "measure_6"))
datLong

colnames(datLong) <- c("ID", "Gender", "Time", "Score")
datLong
table(datLong$Time)
datLong$ID <- as.factor(datLong$ID)

library(ez)
model_mixed <- ezANOVA(data = datLong,
dv = Value,
wid = ID,
within = Time,
between = Gender,
detailed = TRUE,
type = 3,
return_aov = TRUE)
model_mixed


This worked perfectly. However, our data is not complete. We have missing values, that we impute using MICE:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,NA,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,NA,NA,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,NA,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)

imp_anova <- mice(dat, maxit = 0)
meth <- imp_anova$method
pred <- imp_anova$predictorMatrix
imp_anova <- mice(dat, method = meth, predictorMatrix = pred, seed = 2018, maxit = 10, m = 5)


(The imputation gives logged events, because of the made-up data and the simple imputation code e.g id used as a predictor. For my real data, the imputation was correct and valid)



Now I have the imputed dataset of class ‘mids’. I have searched the internet, but I cannot find how I can perform the mixed design ANOVA on this imputed set, as I did before with the complete set using ezANOVA. Is there anyone who can and wants to help me?










share|improve this question














I have a question about performing a Mixed Design ANOVA in R after multiple imputation using MICE. My data is as follows:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,88,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,65,64,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,83,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)


So: we have 6 repeated measurements of diastolic blood pressure (measure 1 till 6). The grouping factor is gender, which is called group. This variable is coded 1 if male and 0 if female. Before multiple imputation, we have used the following code in R:



library(reshape)
library(reshape2)
datLong <- melt(dat, id = c("id", "group"), measured = c("measure_1", "measure_2", "measure_3", "measure_4", "measure_5", "measure_6"))
datLong

colnames(datLong) <- c("ID", "Gender", "Time", "Score")
datLong
table(datLong$Time)
datLong$ID <- as.factor(datLong$ID)

library(ez)
model_mixed <- ezANOVA(data = datLong,
dv = Value,
wid = ID,
within = Time,
between = Gender,
detailed = TRUE,
type = 3,
return_aov = TRUE)
model_mixed


This worked perfectly. However, our data is not complete. We have missing values, that we impute using MICE:



id <- c(1,2,3,4,5,6,7,8,9,10)
group <- c(0,1,1,0,0,1,0,0,0,1)
measure_1 <- c(60,80,90,54,60,61,77,67,88,90)
measure_2 <- c(55,NA,88,55,70,62,78,66,65,92)
measure_3 <- c(58,88,85,56,68,62,89,62,70,99)
measure_4 <- c(64,80,78,92,NA,NA,87,65,67,96)
measure_5 <- c(64,85,80,65,74,69,90,65,70,99)
measure_6 <- c(70,NA,80,55,73,64,91,65,91,89)
dat <- data.frame(id, group, measure_1, measure_2, measure_3, measure_4, measure_5, measure_6)
dat$group <- as.factor(dat$group)

imp_anova <- mice(dat, maxit = 0)
meth <- imp_anova$method
pred <- imp_anova$predictorMatrix
imp_anova <- mice(dat, method = meth, predictorMatrix = pred, seed = 2018, maxit = 10, m = 5)


(The imputation gives logged events, because of the made-up data and the simple imputation code e.g id used as a predictor. For my real data, the imputation was correct and valid)



Now I have the imputed dataset of class ‘mids’. I have searched the internet, but I cannot find how I can perform the mixed design ANOVA on this imputed set, as I did before with the complete set using ezANOVA. Is there anyone who can and wants to help me?







r anova mixed-models






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 15:53









Anna_70Anna_70

263




263













  • I think cross validated would be a better forum for your question.

    – Mankind_008
    Jan 3 at 16:11





















  • I think cross validated would be a better forum for your question.

    – Mankind_008
    Jan 3 at 16:11



















I think cross validated would be a better forum for your question.

– Mankind_008
Jan 3 at 16:11







I think cross validated would be a better forum for your question.

– Mankind_008
Jan 3 at 16:11














0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54025671%2fhow-to-perform-mixed-design-anova-on-mice-imputed-data-in-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54025671%2fhow-to-perform-mixed-design-anova-on-mice-imputed-data-in-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith