aov_ez error

Home forums ANOVA aov_ez error

This topic contains 2 replies, has 2 voices, and was last updated by  henrik 7 months, 1 week ago.

  • Author
    Posts
  • #240

    sbmlang
    Participant

    When I run the aov_ez function on my entire data frame (alldata), I do not get an error.

    This is a snapshot of the data I have in alldata:

    head(alldata):
    erp chindex chlabel bin ERPset Anteriority Laterality Subject Group
    1 0.958 33 Anterior Left 1 LHD009_ERPs_newb_newch_lp30Hznch Anterior Left LHD009 LHD
    2 2.908 34 Anterior Central 1 LHD009_ERPs_newb_newch_lp30Hznch Anterior Central LHD009 LHD
    3 3.065 35 Anterior Right 1 LHD009_ERPs_newb_newch_lp30Hznch Anterior Right LHD009 LHD
    4 -2.965 36 Posterior Left 1 LHD009_ERPs_newb_newch_lp30Hznch Posterior Left LHD009 LHD
    5 3.343 37 Posterior Central 1 LHD009_ERPs_newb_newch_lp30Hznch Posterior Central LHD009 LHD
    6 2.876 38 Posterior Right 1 LHD009_ERPs_newb_newch_lp30Hznch Posterior Right LHD009 LHD

    str(alldata)

    ‘data.frame’: 2262 obs. of 9 variables:
    $ erp : num 0.958 2.908 3.065 -2.965 3.343 …
    $ chindex : int 33 34 35 36 37 38 33 34 35 36 …
    $ chlabel : Factor w/ 6 levels “Anterior Central”,..: 2 1 3 5 4 6 2 1 3 5 …
    $ bin : Factor w/ 13 levels “1”,”2″,”3″,”4″,..: 1 1 1 1 1 1 2 2 2 2 …
    $ ERPset : Factor w/ 29 levels “AMC126_ERPs_newb_newch_lp30Hznch”,..: 21 21 21 21 21 21 21 21 21 21 …
    $ Anteriority: Factor w/ 2 levels “Anterior”,”Posterior”: 1 1 1 2 2 2 1 1 1 2 …
    $ Laterality : Factor w/ 3 levels “Central”,”Left”,..: 2 1 3 2 1 3 2 1 3 2 …
    $ Subject : Factor w/ 29 levels “AMC126″,”AMC131”,..: 21 21 21 21 21 21 21 21 21 21 …
    $ Group : Factor w/ 2 levels “AMC”,”LHD”: 2 2 2 2 2 2 2 2 2 2 …

    I don’t have any issues using aov_ez here:
    aov_alldata <- aov_ez(“Subject”, “erp”, alldata, within = c(“bin” , “Anteriority” , “Laterality”))

    However, when I make a subset of the data (subdata) and run aov_ez with the exact same code (except substituting subdata for alldata), I get an error that says:

    aov_subdata <- aov_ez(“Subject”, “erp”, subdata, within = c(“bin” , “Anteriority” , “Laterality”))

    Error in rownames<-(*tmp*, value = colnames(B)) :
    length of ‘dimnames’ [1] not equal to array extent
    In addition: Warning message:
    In aov(formula(paste(dv.escaped, “~”, paste(c(between.escaped, within.escaped), :
    Error() model is singular

    I initially subset my data like this:

    subdata = alldata [alldata$bin == c(“3”, “7”) & alldata$Group ==”LHD”,]

    str(subdata)
    ‘data.frame’: 174 obs. of 9 variables:
    $ erp : num -5.27 -1.37 -2.42 -1.73 -2.87 …
    $ chindex : int 33 35 37 34 36 38 33 35 37 34 …
    $ chlabel : Factor w/ 6 levels “Anterior Central”,..: 2 3 4 1 5 6 2 3 4 1 …
    $ bin : Factor w/ 13 levels “1”,”2″,”3″,”4″,..: 3 3 3 7 7 7 3 3 3 7 …
    $ ERPset : Factor w/ 29 levels “AMC126_ERPs_newb_newch_lp30Hznch”,..: 21 21 21 21 21 21 22 22 22 22 …
    $ Anteriority: Factor w/ 2 levels “Anterior”,”Posterior”: 1 1 2 1 2 2 1 1 2 1 …
    $ Laterality : Factor w/ 3 levels “Central”,”Left”,..: 2 3 1 1 2 3 2 3 1 1 …
    $ Subject : Factor w/ 29 levels “AMC126″,”AMC131”,..: 21 21 21 21 21 21 22 22 22 22 …
    $ Group : Factor w/ 2 levels “AMC”,”LHD”: 2 2 2 2 2 2 2 2 2 2 …

    But, I had difficulties, and since I did not have any difficulties with alldata, I thought it might be helpful to restart the process with my subset data. So I then tried creating a new .csv (via write.csv) and created subdata2:

    Str(subdata2)
    ‘data.frame’: 174 obs. of 8 variables:
    $ erp : num -5.27 -1.37 -2.42 -1.73 -2.87 …
    $ chindex : int 33 35 37 34 36 38 33 35 37 34 …
    $ bin : Factor w/ 2 levels “3”,”7″: 1 1 1 2 2 2 1 1 1 2 …
    $ ERPset : Factor w/ 29 levels “AMC126_ERPs_newb_newch_lp30Hznch”,..: 21 21 21 21 21 21 22 22 22 22 …
    $ Anteriority: Factor w/ 2 levels “Anterior”,”Posterior”: 1 1 2 1 2 2 1 1 2 1 …
    $ Laterality : Factor w/ 3 levels “Central”,”Left”,..: 2 3 1 1 2 3 2 3 1 1 …
    $ Subject : Factor w/ 29 levels “AMC126″,”AMC131”,..: 21 21 21 21 21 21 22 22 22 22 …
    $ Group : Factor w/ 2 levels “AMC”,”LHD”: 2 2 2 2 2 2 2 2 2 2 …

    head(subdata2)
    erp chindex bin ERPset Anteriority Laterality Subject Group
    1 -5.271 33 3 LHD009_ERPs_newb_newch_lp30Hznch Anterior Left LHD009 LHD
    2 -1.373 35 3 LHD009_ERPs_newb_newch_lp30Hznch Anterior Right LHD009 LHD
    3 -2.417 37 3 LHD009_ERPs_newb_newch_lp30Hznch Posterior Central LHD009 LHD
    4 -1.734 34 7 LHD009_ERPs_newb_newch_lp30Hznch Anterior Central LHD009 LHD
    5 -2.870 36 7 LHD009_ERPs_newb_newch_lp30Hznch Posterior Left LHD009 LHD
    6 -4.718 38 7 LHD009_ERPs_newb_newch_lp30Hznch Posterior Right LHD009 LHD

    Yet, when I run:

    subdata2_aov <- aov_ez(“Subject”, “erp”, subdata2 , within = c(“bin” , “Anteriority” , “Laterality”))

    I get the exact same error:

    Error in rownames<-(*tmp*, value = colnames(B)) :
    length of ‘dimnames’ [1] not equal to array extent
    In addition: Warning message:
    In aov(formula(paste(dv.escaped, “~”, paste(c(between.escaped, within.escaped), :
    Error() model is singular

    Do you have any idea what I’m doing wrong?

  • #242

    sbmlang
    Participant

    I figured out the issue; there was an error with the way the data was subset.

  • #243

    henrik
    Keymaster

    Wonderful that this issue has solved itself. Thanks for the update.

You must be logged in to reply to this topic.

 

Author: sbmlang