-1
$\begingroup$

This is cross-posted on StackExchange, but as it has to do with statistics, I thought I'd try here.

I'm trying to analyze experimental data with one between-subjects factor (rank) and two within-subjects factors (cost,msg) using the ez package. Participants were randomly assigned to both cost and msg at two points in time, so theoretically they could have the same combination of cost and msg at both points in time. ezDesign indicates that my data is balanced with no missing values.

Suppose my dataset ez_data looks like this:

     id choice_num choice        msg           cost   product            rank id_r
1.1   1    1      1 Provincial      Same cost   Cleaner Least important  1.1
2.1   2    1      1    No norm More expensive   Cleaner  Most important  2.1
3.1   3    1      1    No norm      Same cost      Soap Least important  3.1
4.1   4    1      1       Norm      Same cost    Coffee  Most important  4.1
5.1   5    1      1 Provincial      Same cost      Soap  Most important  5.1
6.1   6    1      1    No norm      Same cost Chocolate  Most important  6.1
7.1   7    1      1 Provincial      Same cost   Cleaner  Most important  7.1
8.1   8    1      0 Provincial      Same cost    Coffee Least important  8.1
9.1   9    1      1 Provincial      Same cost   Cleaner Least important  9.1
10.1 10    1      1       Norm More expensive Chocolate  Most important 10.1
11.1 11    1      1       Norm      Same cost      Soap  Most important 11.1
12.1 12    1      0 Provincial      Same cost    Coffee  Most important 12.1
13.1 13    1      1       Norm      Same cost      Soap  Most important 13.1
14.1 14    1      1 Provincial      Same cost      Soap Least important 14.1
15.1 15    1      0       Norm More expensive    Coffee  Most important 15.1
16.1 16    1      1 Provincial      Same cost   Cleaner Least important 16.1
17.1 17    1      1    No norm More expensive Chocolate Least important 17.1
18.1 18    1      0 Provincial More expensive      Soap Least important 18.1
19.1 19    1      1       Norm More expensive Chocolate  Most important 19.1
20.1 20    1      1 Provincial      Same cost   Cleaner Least important 20.1

Based on the comments here, I've created a new ID variable that concatenates the choice_num with the id variable so that there are no repeated values for the labels for "id" across the different levels of the factors.

Then, I simply run the command:

ezANOVA(data=ez_data, dv=.(choice), wid=.(id_r), within=.(cost,msg), between=.(rank), type=3)

But this still yields the error:

Error in ezANOVA_main(data = data, dv = dv, wid = wid, within = within,  : 
  One or more cells is missing data. Try using ezDesign() to check your data.

Thoughts?

$\endgroup$

2 Answers 2

6
$\begingroup$

Your data definitely has missing values. See output of with(ez_data,table(id,cost,msg)), or (following the suggestion in the error message) ezDesign(data=ez_data,y=id,x=cost,col=msg)

Ah, I see now that you likely posted merely a subset of your data. Still, as you note "Participants were randomly assigned to both cost and msg at two points in time, so theoretically they could have the same combination of cost and msg at both points in time.", this means that you could have missing data in the sense that some participants may not have data for all possible combinations of msg and cost, which is necessary if you want to treat those variables as manipulated within-Ss.

$\endgroup$
1
  • $\begingroup$ Thanks! I'd just stumbled to the conclusion that it may be more appropriate to use a mixed model (where subjects are treated as a random factor) for this very reason. For example, using lmer I'm playing with models such that: m1 = lmer(choice ~ cost + msg + rank + (cost|id) + (msg|id), data=data) if using lmer. Does this seem like a better approach? $\endgroup$
    – roody
    Apr 30, 2013 at 21:29
2
$\begingroup$

I solve my problem based on this solution.

You can identify the missing data by

#Dataframe with your ANOVA wid (Subjects)
temp = as.data.frame(table(data$YourWid))

#Use the number of levels from you within variables
#Returns only the subjects that have less than number of levels (Missing data)
temp[temp$Freq<2,]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.