Abbi Christina
Abbi Christina

Reputation: 1

How to add in a nested factor within a model that is using aligned rank transformation

I am trying to add in a nested factor of individual ID into my model using aligned rank transformation (from the R ARTool package) so I can run ANOVAs. So far I have not had much luck in getting ID added in and getting a p-value for it to see if there's any significance.

an example of my data set would look similar to this:

ID <- A1, A1, A2, A2, A3, A3, A4, A4, A5, A5...

ATR<- 0, 12, 135, 20, 12, 0, 35, 45, 240, 5...

Treatment<-stress, nonstress, nonstress, stress, stress, nonstress, nonstress, stress, nonstress, stress...

Status<- Resident, Resident, intruder, intruder, intruder, intruder, resident, resident, resident, resident...

I need to determine if ID is significant because my individuals were tested twice in the experiment.

This is the code I have been using, and while it works, it does not give me a p-value for ID. It only gives me for treatment, status, and the interaction between treatment and status:

Salamander$ID <- as.factor(Salamander$ID)
Salamander$Treatment <- as.factor(Salamander$Treatment)
Salamander$Status <- as.factor(Salamander$Status)

ID.model <- art(ATR ~ Treatment * Status + (1|ID), 
            data = Salamander)
anova(ID.model)

This is the output I get from ID.model, which is great and what I need, but I also need a fourth line with ID and its p-value.

Analysis of Variance of Aligned Rank Transformed Data

Table Type: Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
Model: Mixed Effects (lmer)
Response: art(ATR)

                         F Df Df.res    Pr(>F)    

### 1 Treatment    14.2967  1     60 0.0003620 ***
2 Status            6.4403  1     60 0.0137717 *
3 Treatment:Status 11.0069  1     60 0.0015458 **

Signif. codes:   0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I also tried making the (1|ID) into (1|Treatment:Status:ID) but I got an error saying that was too complex for the dataset. Finally I tried these lines of code by not turning ID into a factor hoping that would help:

sallys$Status <- as.factor(sallys$Status)
sallys$Treatment <- as.factor(sallys$Treatment)

Id.model.3 <- art(ATR ~ Treatment * Status + (1| Identification),
              data = sallys)
summary(Id.model.3)

But when I try this version I get an error every time:

Error in eval(predvars, data, env) : object 'Identification' not found

I do know it is possible to add in ID as a nested factor with ARTool because it's been done in past research (https://www.jstor.org/stable/pdf/26754460.pdf?casa_token=-eIEHXXWBJ4AAAAA:V2BxlGbKXbzVeW9M8VrbdQxhtkFE-C6qDYww5ojRNY88tWndbXh41CwhYuOiVWfhd4Wk8E6M844hp0MvYWQPqa4bnhqJWaat34ZlYoVNqdctnig992dGwg) but I think I am missing the actual coding for it. I also have to use aligned rank transformation because I work with behavior and this is the only data transformation that works on my dataset.

Also because of me trying the nested models, I haven't been able to run emmeans to get post-hoc results.

Upvotes: 0

Views: 23

Answers (0)

Related Questions