1

Hoping to get some guidance for this analysis. I am currently following this guide for running a 2 way RMANOVA. This guide focuses on the car and afex package. I'm having issues with errors on both packages, but my focus is on afex, as that seems to be the simplest assuming I can trouble shoot.

I have one between subjects and one within factors. The basic set up of the experiment is I have 5 fish tanks, each individual tank equipped with a treatment and readings were taken at 0,24,48 hrs for each trial.

Here's an example of the data frame I am using for the afex package:

  date                trial tank  hours treatment  volt
   <dttm>              <chr> <chr> <chr> <chr>     <dbl>
 1 2022-07-26 00:00:00 PT1   1     0     PWT        18.2
 2 2022-07-26 00:00:00 PT1   2     0     PPCO       15.9
 3 2022-07-26 00:00:00 PT1   3     0     PPCOPWT    11.2
 4 2022-07-26 00:00:00 PT1   4     0     UV         13.0
 5 2022-07-26 00:00:00 PT1   5     0     Control    14.7
 6 2022-07-27 00:00:00 PT1   1     24    PWT        26.5
 7 2022-07-27 00:00:00 PT1   2     24    PPCO       42.1
 8 2022-07-27 00:00:00 PT1   3     24    PPCOPWT    27.2
 9 2022-07-27 00:00:00 PT1   4     24    UV         14.2
10 2022-07-27 00:00:00 PT1   5     24    Control    28.3
# ℹ 65 more rows
# ℹ Use `print(n = ...)` to see more rows

(note: I have performed Shapiro-wilk's normality, looked at distribution and outliers and have confirmed normality)

Here is the code I am running with afex:

afmod1 <- afex::aov_car(volt ~treatment*hours + Error(tank/hours),data=rasdata)

Volt is my response, treatment is the treatment on the tank, hours is 0,24,48 (when measurement was taken) and tank is a an identifier for each tank (1-5). I will mention that treatment corresponds with tank, as each tank has a single treatment for each trial (eg. tank 1 will always get PWT treatment).

Here is the error that code returns

Converting to factor: treatment
Contrasts set to contr.sum for the following variables: treatment
Warning message:
More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
To turn off this warning, pass `fun_aggregate = mean` explicitly. 

(ignore the converting factor - forgot to do it for this run) Contrasts set to contr.sum.... is an expected error. The warning message is the issue I'm having. This package takes long form data and from what I can tell from experimenting it takes the long form and converts to wide to run the car function. I'm guessing the error is stemming from some way that my data is organized but I haven't figure out what that is.

One final note - did switch to trying the car function by itself, manually converting my data to wide form without afex, but this requires some additional commands that are also giving me errors (which I also am having trouble with figuring out)

Any assistance would be greatly appreciated. I'm very new to programing and R and it's been difficult to find resource for troubleshooting.

0 Answers0