Related
I am trying to run lme4 package in R. I have 10 Lines in total with four plants for each line in each of the two replications. But some of the plants died and there are some missing values. Weight is the response variable. Here are some lines from the data:
Line Rep Weight PLANT
Line 1 1 NA 1
Line 1 1 NA 2
Line 1 1 NA 3
Line 1 1 NA 4
Line 2 1 26 1
Line 2 1 26 2
Line 2 1 26 3
Line 2 1 27 4
Line 1 2 26 1
Line 1 2 28 2
Line 1 2 26 3
Line 1 2 25 4
Line 2 2 24 1
Line 2 2 26 2
Line 2 2 25 3
Line 2 2 NA 4
I want to run linear mixed model using lme4 package so I tried running:
lme4 <- lmer(Weight ~ 1 + (1|Rep:Plant), data=Data)
But I got an error:
boundary (singular) fit: see ?isSingular
> dput(Data)
structure(list(Line = c("Line 1", "Line 1", "Line 1", "Line 1",
"Line 2", "Line 2", "Line 2", "Line 2", "Line 1", "Line 1", "Line 1",
"Line 1", "Line 2", "Line 2", "Line 2", "Line 2"), Rep = c(1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2), Weight = c(NA,
NA, NA, NA, 26, 26, 26, 27, 26, 28, 26, 25, 24, 26, 25, NA),
PLANT = c(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)), row.names = c(NA,
-16L), class = c("tbl_df", "tbl", "data.frame"))
I am using it for the first time and I am not sure about the error. I will appreciate any help!
Your model did fit, but it generated that warning because your random effects are very small. You can read more about this in this post or the help page
Let us look at your data:
ggplot(Data,aes(x=PLANT,y=Weight,col=Rep)) + geom_jitter() + geom_boxplot(alpha=0.2) + facet_wrap(~Rep)
The effects of PLANT and in combination with Rep is extremely small. Let's look at the fitted model:
fit = lmer(Weight ~ 1 + (1|PLANT:Rep),data=Data)
boundary (singular) fit: see ?isSingular
ranef(fit)
$`PLANT:Rep`
(Intercept)
1:1 0
1:2 0
2:1 0
2:2 0
3:1 0
3:2 0
4:1 0
4:2 0
This is exactly what happened. So we can try to account for some other effects and we still see very small coefficients:
fit = lmer(Weight ~ Line + (1|Rep:PLANT),data=Data)
ranef(fit)
$`Rep:PLANT`
(Intercept)
1:1 1.397563e-19
1:2 2.811371e-19
1:3 8.112169e-20
1:4 1.813251e-19
2:1 -1.725964e-19
2:2 -2.463986e-20
2:3 -2.027357e-19
2:4 -2.833681e-19
The takehome message is, there's no really systematic effect coming from PLANT, so you don't need to specify a highly complicated model, do something like:
fit = lmer(Weight ~ Line + (1|Rep),data=Data)
The data in case anyone is interested:
Data = structure(list(Line = structure(c(1L, 1L, 1L, 1L, 12L, 12L, 12L,
12L, 23L, 23L, 23L, 23L, 34L, 34L, 34L, 34L, 45L, 45L, 45L, 45L,
56L, 56L, 56L, 56L, 65L, 65L, 65L, 65L, 66L, 66L, 66L, 66L, 67L,
67L, 67L, 67L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 13L,
13L, 13L, 13L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L,
16L, 16L, 8L, 8L, 8L, 8L, 66L, 66L, 66L, 66L, 17L, 17L, 17L,
17L, 18L, 18L, 18L, 18L, 9L, 9L, 9L, 9L, 19L, 19L, 19L, 19L,
20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 24L,
24L, 24L, 24L, 25L, 25L, 25L, 25L, 2L, 2L, 2L, 2L, 26L, 26L,
26L, 26L, 27L, 27L, 27L, 27L, 10L, 10L, 10L, 10L, 28L, 28L, 28L,
28L, 29L, 29L, 29L, 29L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L,
67L, 67L, 67L, 67L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 33L,
33L, 33L, 33L, 35L, 35L, 35L, 35L, 36L, 36L, 36L, 36L, 37L, 37L,
37L, 37L, 38L, 38L, 38L, 38L, 39L, 39L, 39L, 39L, 40L, 40L, 40L,
40L, 25L, 25L, 25L, 25L, 19L, 19L, 19L, 19L, 24L, 24L, 24L, 24L,
41L, 41L, 41L, 41L, 42L, 42L, 42L, 42L, 30L, 30L, 30L, 30L, 43L,
43L, 43L, 43L, 44L, 44L, 44L, 44L, 22L, 22L, 22L, 22L, 46L, 46L,
46L, 46L, 47L, 47L, 47L, 47L, 17L, 17L, 17L, 17L, 48L, 48L, 48L,
48L, 49L, 49L, 49L, 49L, 27L, 27L, 27L, 27L, 23L, 23L, 23L, 23L,
50L, 50L, 50L, 50L, 51L, 51L, 51L, 51L, 52L, 52L, 52L, 52L, 41L,
41L, 41L, 41L, 7L, 7L, 7L, 7L, 46L, 46L, 46L, 46L, 11L, 11L,
11L, 11L, 33L, 33L, 33L, 33L, 53L, 53L, 53L, 53L, 54L, 54L, 54L,
54L, 13L, 13L, 13L, 13L, 38L, 38L, 38L, 38L, 4L, 4L, 4L, 4L,
37L, 37L, 37L, 37L, 55L, 55L, 55L, 55L, 57L, 57L, 57L, 57L, 44L,
44L, 44L, 44L, 58L, 58L, 58L, 58L, 59L, 59L, 59L, 59L, 12L, 12L,
12L, 12L, 47L, 47L, 47L, 47L, 48L, 48L, 48L, 48L, 60L, 60L, 60L,
60L, 21L, 21L, 21L, 21L, 18L, 18L, 18L, 18L, 28L, 28L, 28L, 28L,
26L, 26L, 26L, 26L, 61L, 61L, 61L, 61L, 31L, 31L, 31L, 31L, 59L,
59L, 59L, 59L, 52L, 52L, 52L, 52L, 29L, 29L, 29L, 29L, 62L, 62L,
62L, 62L, 63L, 63L, 63L, 63L, 54L, 54L, 54L, 54L, 55L, 55L, 55L,
55L, 53L, 53L, 53L, 53L, 51L, 51L, 51L, 51L, 50L, 50L, 50L, 50L,
64L, 64L, 64L, 64L, 20L, 20L, 20L, 20L, 58L, 58L, 58L, 58L, 16L,
16L, 16L, 16L, 57L, 57L, 57L, 57L, 14L, 14L, 14L, 14L, 63L, 63L,
63L, 63L, 64L, 64L, 64L, 64L, 61L, 61L, 61L, 61L, 36L, 36L, 36L,
36L, 40L, 40L, 40L, 40L, 6L, 6L, 6L, 6L, 39L, 39L, 39L, 39L,
45L, 45L, 45L, 45L, 15L, 15L, 15L, 15L, 1L, 1L, 1L, 1L, 42L,
42L, 42L, 42L, 43L, 43L, 43L, 43L, 65L, 65L, 65L, 65L, 49L, 49L,
49L, 49L, 56L, 56L, 56L, 56L, 3L, 3L, 3L, 3L, 62L, 62L, 62L,
62L, 35L, 35L, 35L, 35L, 5L, 5L, 5L, 5L, 60L, 60L, 60L, 60L,
34L, 34L, 34L, 34L), .Label = c("Line1", "Line10", "Line11",
"Line12", "Line13", "Line14", "Line15", "Line16", "Line17", "Line18",
"Line19", "Line2", "Line20", "Line21", "Line22", "Line23", "Line24",
"Line25", "Line26", "Line27", "Line28", "Line29", "Line3", "Line30",
"Line31", "Line32", "Line33", "Line34", "Line35", "Line36", "Line37",
"Line38", "Line39", "Line4", "Line40", "Line41", "Line42", "Line43",
"Line44", "Line45", "Line46", "Line47", "Line48", "Line49", "Line5",
"Line50", "Line51", "Line52", "Line53", "Line54", "Line55", "Line56",
"Line57", "Line58", "Line59", "Line6", "Line60", "Line61", "Line62",
"Line63", "Line64", "Line65", "Line66", "Line67", "Line7", "Line8",
"Line9"), class = "factor"), Rep = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 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A, 33L, NA, NA,
NA, 21L, 23L, 18L, 23L, 32L, 29L, 30L, 30L, 18L, 19L, 21L, 21L,
25L, 25L, 25L, 26L, 26L, 27L, NA, NA, 29L, 29L, 27L, 29L, 26L,
NA, NA, NA, 26L, 20L, 23L, 27L, NA, NA, NA, NA, 32L, 32L, 30L,
30L, 20L, 20L, 20L, 19L, 22L, 21L, 22L, 22L, 24L, 23L, 23L, 25L,
20L, 25L, NA, NA, 27L, 26L, NA, NA, NA, NA, NA, NA, 30L, 28L,
NA, NA, 25L, 26L, 27L, 26L, NA, NA, NA, NA, 20L, 19L, NA, NA,
19L, 27L, 26L, 29L, 26L, 29L, 31L, 29L, 25L, 25L, 24L, 25L, 26L,
25L, 26L, 26L, 25L, 24L, 24L, 28L, 22L, 26L, 24L, 28L, 29L, 30L,
26L, NA, NA, NA, NA, NA, 26L, 24L, 24L, 24L, NA, NA, NA, NA,
NA, NA, NA, NA, 30L, 30L, 30L, 31L, 24L, 25L, 28L, 22L, 28L,
31L, 30L, NA, 31L, 30L, 29L, 25L, 25L, 22L, 24L, 20L, 30L, 30L,
30L, 29L, 26L, 32L, 28L, 29L, 20L, 15L, 15L, 11L, 25L, 24L, 24L,
24L, 26L, 29L, 31L, 30L, 24L, 28L, 20L, 22L, 29L, 26L, 26L, 28L,
27L, 27L, 27L, 26L, 21L, 22L, 21L, NA, 28L, 29L, 24L, 24L, 28L,
29L, 28L, 27L, 28L, 29L, 27L, 29L, NA, NA, NA, NA, 22L, 26L,
21L, 21L, 26L, 30L, 28L, 30L, 27L, 26L, 28L, 26L, 25L, 25L, 26L,
26L, 27L, 26L, 23L, 29L, NA, NA, NA, NA, 27L, 23L, 29L, 23L,
28L, 29L, 28L, 26L, 20L, NA, NA, NA, 28L, 23L, 26L, 21L, 28L,
26L, 26L, 29L, 20L, 27L, 20L, 26L, 29L, 26L, 28L, 28L, 30L, 27L,
NA, NA, 26L, 21L, 26L, 25L, 27L, 26L, 27L, 24L, 25L, 20L, 21L,
20L, 25L, 25L, 31L, 24L, 29L, 28L, 31L, 27L, 25L, 28L, 26L, 26L,
NA, NA, NA, NA, 24L, 25L, 23L, 27L, 20L, 26L, 25L, 25L, 29L,
28L, 29L, 29L, 26L, 27L, 25L, 28L, NA, NA, NA, NA, 26L, 28L,
NA, NA, 21L, 20L, 31L, 25L, 31L, 28L, 30L, 29L, 23L, 25L, 24L,
28L, 25L, 22L, 25L, 25L, 28L, 29L, 28L, 29L, 26L, 24L, 25L, 26L,
29L, 27L, NA, NA, 26L, 29L, 29L, 30L, 25L, 24L, 25L, 24L, 28L,
25L, 29L, 28L, 24L, 24L, 24L, 24L, 28L, 30L, 27L, 27L, 26L, 25L,
25L, 25L, 25L, 25L, 28L, 25L, 25L, 30L, 28L, 25L, 22L, 24L, 25L,
24L, NA, NA, NA, NA, 5L, 7L, 4L, 5L, 21L, 20L, 22L, 24L, 25L,
27L, 25L, 28L, 32L, 31L, NA, NA, 19L, 26L, 20L, NA, 26L, 26L,
30L, 25L, 28L, 31L, 30L, 26L, 5L, 8L, 4L, 8L, 25L, 25L, 28L,
25L, 28L, 28L, 27L, 26L, 30L, 27L, 27L, 24L, 32L, 29L, 31L, 25L,
30L, 30L, 27L, 28L, 16L, 20L, 16L, 21L, 25L, 22L, 25L, 20L, 24L,
25L, 18L, 25L, 25L, 26L, 29L, 29L, 21L, 20L, 22L, 21L, 19L, 22L,
19L, 21L, 28L, 25L, 26L, 24L, 28L, 26L, 24L, 25L, NA, NA, NA,
NA, 25L, NA, NA, NA, 23L, 21L, 19L, 23L, 25L, 24L, 25L, NA, 22L,
30L, 29L, 26L, 25L, 25L, 24L, 24L), PLANT = structure(c(1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,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 3L, 7L, 8L, 1L, 3L, 7L, 8L, 1L, 3L, 7L, 8L, 1L
), .Label = c("24", "12", "21", "11", "13", "14", "22", "23"
), class = "factor")), row.names = c(NA, -536L), class = "data.frame")
My dataset looks like this:
> head(GLM_df)
hour Feeding Foraging Standing ID Area Feeding_Foraging
1 0 0.119 0.789 0.0339 41361 Seronera 0.908
2 1 0.0920 0.819 0.0339 41361 Seronera 0.911
3 2 0.0847 0.824 0.0678 41361 Seronera 0.909
4 3 0.233 0.632 0.132 41361 Seronera 0.866
5 4 0.254 0.597 0.124 41361 Seronera 0.852
6 5 0.245 0.664 0.0832 41361 Seronera 0.909
And I'm trying to run a glmer() model as such to verify an interaction, the error associated is found below:
> m <- glmer(cbind(Feeding_Foraging,Standing) ~ poly(hour,2)*Area+(1|ID) , data=GLM_df , family=binomial)
Error in length(value <- as.numeric(value)) == 1L :
(maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate
In addition: Warning message:
In eval(family$initialize, rho) : non-integer counts in a binomial glm!
I apologize if I'm not asking on the right forum, but does somebody know what is the cause of this error? I've been using this dataset to run other glmer() models not having such issue, so I hope somebody can help me.
I can provide a dput() sample of the data below:
> dput(GLM_df)
structure(list(hour = c(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L), Feeding = c(0.118579234700529,
0.0919594065024507, 0.0846994533575204, 0.233092895639896, 0.254098360072561,
0.244523639258233, 0.238513660654777, 0.245289616923379, 0.211748633393801,
0.253514225911475, 0.275555554923133, 0.222477230819087, 0.232641165221989,
0.238368461591879, 0.30265937999754, 0.433661201190504, 0.178745053292422,
0.12125395428024, 0.10605844594333, 0.163238946470857, 0.174611180767811,
0.22483854891269, 0.177868852050793, 0.183918813004901, 0.241998438164344,
0.161698956409812, 0.158105646267371, 0.36138433432542, 0.468670308578279,
0.333151183206247, 0.32072859671381, 0.301413227120555, 0.295571885509692,
0.313952640445209, 0.343315117609149, 0.309435336266141, 0.345573769698683,
0.307176684176607, 0.322987248803344, 0.303788706042306, 0.266520946564997,
0.179710144515087, 0.151781420416677, 0.272293057460473, 0.384777516681307,
0.358157688483229, 0.370418942683556, 0.295571885509692, 0.194038747691774,
0.0980730512560762, 0.104719324151116, 0.287394007254483, 0.360255008280653,
0.356867030146353, 0.303788706042306, 0.297908422154037, 0.295883423728938,
0.309435336266141, 0.335409835295781, 0.294754097684171, 0.329763205071946,
0.311693988355675, 0.252969034027794, 0.320554854245385, 0.269908924699298,
0.114670029160951, 0.145400728263743, 0.208925318281884, 0.252065573191981,
0.343637782193368, 0.234552332374672, 0.25071038193826, 0.139938227286338,
0.127049180036281, 0.0779234970889187, 0.271038250744065, 0.37923497180722,
0.365027321566604, 0.313661201465914, 0.342076501947147, 0.292896174191167,
0.283060108639971, 0.271038250744065, 0.238251365573412, 0.196721311023918,
0.191256830162143, 0.16601092858074, 0.0626775954845651, 0.134426229199678,
0.105704917790185, 0.11195058182907, 0.140192198660723, 0.14806719253611,
0.21262483463543, 0.226733921295516, 0.21891551021636, 0.120612021581109,
0.140939890386914, 0.0931693986932724, 0.2142076497816, 0.228415300022216,
0.194244079699913, 0.181821493207477, 0.186922931547631, 0.153588342088304,
0.15187488188245, 0.135519125372033, 0.171657558804575, 0.144302772386887,
0.113322027250751, 0.0931693986932724, 0.0657666343717217, 0.126775955993192,
0.0912147959234835, 0.0966201171633936, 0.143219075677262, 0.127049180036281,
0.145683059774935, 0.171657558804575, 0.140731399424803, 0.238570126957016,
0.109339294334254, 0.14013909555517, 0.190856101565613, 0.175240248325904,
0.217486338298665, 0.251366119641673, 0.295081966535877, 0.278688523950551,
0.268852458399355, 0.349726775153633, 0.328961747878886, 0.351912567498343,
0.284153004812326, 0.220218578729553, 0.179437360446302, 0.283460837236502,
0.156693988711413, 0.114187411193102, 0.207187893597627, 0.198761383878981,
0.22134790477432, 0.199890709923748, 0.218466176246294), Foraging = c(0.78939890529209,
0.81876138245603, 0.824408012679865, 0.632422585069486, 0.59741347768171,
0.66404371432296, 0.599672129771244, 0.632422585069486, 0.629034606935185,
0.575956282831139, 0.525136610816626, 0.588378869323575, 0.577085608875906,
0.574826956786372, 0.482222221115483, 0.336377829048438, 0.677595626860163,
0.811985426187429, 0.797304187605459, 0.744225863501412, 0.727285972829908,
0.702440799845036, 0.721639342606074, 0.744225863501412, 0.593480307663729,
0.692276865442133, 0.705828777979336, 0.29136611954987, 0.178520386307389,
0.320647930567756, 0.343470886718772, 0.422913132626516, 0.393706424572198,
0.350480496651808, 0.350091073877751, 0.339966081752254, 0.289107467460336,
0.294403617187519, 0.226644054501503, 0.185602280400827, 0.465282330443979,
0.671948996636328, 0.677595626860163, 0.525136610816626, 0.359125682235886,
0.398652093802729, 0.407725644438271, 0.496903459697453, 0.519489980592792,
0.647103823651456, 0.618870672532282, 0.247583017506598, 0.159987856341983,
0.170810564270999, 0.290898812221001, 0.315807961804469, 0.2952380945605,
0.274543055710583, 0.21405861848537, 0.274947456283643, 0.241067674940635,
0.254098360072561, 0.192437158028286, 0.1589743586095, 0.334732239668921,
0.591766847457876, 0.587638966052866, 0.500018841889913, 0.436807180886641,
0.401884302827407, 0.44922080447396, 0.438017173077463, 0.748633878063245,
0.820765025438681, 0.896174861331183, 0.336612021085371, 0.116546447819948,
0.204633879311769, 0.282720933965792, 0.313952640445209, 0.293235348865346,
0.217959926640019, 0.244687309699503, 0.267759562227, 0.256357012162095,
0.20666666619235, 0.110109289364776, 0.0532396563961557, 0.284590163281268,
0.810928959887485, 0.790163932612739, 0.619999998577049, 0.523384208333367,
0.47682655223493, 0.493009231956877, 0.637874503906291, 0.632422585069486,
0.726775954616143, 0.817486336921616, 0.340983605774792, 0.142779078516963,
0.193598750531475, 0.256357012162095, 0.254682494233647, 0.206783493024567,
0.19198542761038, 0.221428570920375, 0.213793102957603, 0.203278688058049,
0.194157208465701, 0.112932604476694, 0.0948633877604228, 0.380582877086458,
0.787978140268028, 0.810928959887485, 0.719125681409657, 0.625136610587118,
0.562404370293935, 0.366120217738959, 0.535519124454, 0.655009105964824,
0.782513659406253, 0.757377047442085, 0.18996877395901, 0.158105646267371,
0.182574377237322, 0.24367381196702, 0.248087431124608, 0.269869982421893,
0.283586317908142, 0.23846153791425, 0.29272131080359, 0.220218578729553,
0.13834244048395, 0.101639344029024, 0.0846994533575204, 0.23846153791425,
0.745355189546179, 0.686338796239004, 0.605318759995079, 0.500936767000192,
0.414375787195254, 0.393442622047837, 0.509364988467295), Standing = c(0.0338797813430082,
0.0338797813430082, 0.0677595626860163, 0.131754705222809, 0.124225864924363,
0.0831594632964746, 0.162622950446439, 0.101639344029024, 0.112932604476694,
0.0931693986932724, 0.0975737702678635, 0.101639344029024, 0.12046144477514,
0.128743169103431, 0.137059115433078, 0.14761904728025, 0.0677595626860163,
0.0338797813430082, 0.0338797813430082, 0.0639951425367932, 0.0423497266787602,
0.0677595626860163, 0.107285974252859, 0.054207650148813, 0.0790528231336857,
0.0609836064174147, 0.0451730417906775, 0.195749847759603, 0.229629629102611,
0.225865208953388, 0.198259461192418, 0.160928961379289, 0.183201780595526,
0.203278688058049, 0.149321999252517, 0.198605614769358, 0.212958625584623,
0.281462798849606, 0.306128024277895, 0.398379497860889, 0.111677797760286,
0.0677595626860163, 0.0547288775540901, 0.0931693986932724, 0.145830363172079,
0.153350589236774, 0.105403764178248, 0.149071037909236, 0.152459016043537,
0.135519125372033, 0.119882303213721, 0.254098360072561, 0.296740153831865,
0.255227686117328, 0.178182553729895, 0.206102003169966, 0.186338797386545,
0.175045536938875, 0.264028640811029, 0.235903662684649, 0.235855400887864,
0.189259468191977, 0.333151183206247, 0.403169397981797, 0.203278688058049,
0.0884638735067435, 0.116461748366591, 0.127819175066803, 0.183918813004901,
0.155538996165628, 0.179710144515087, 0.15951730382333, 0.190573770054421,
0.167140254625507, 0.11067395238716, 0.392349725875482, 0.526775955075159,
0.469945354112694, 0.421857922529069, 0.365901638504488, 0.43278688425262,
0.506010927800412, 0.515846993351608, 0.493989069904506, 0.555191255556392,
0.608743168001792, 0.768306009165636, 0.947540981431873, 0.590163933071755,
0.169398906715041, 0.163752276491206, 0.297658078942143, 0.42228727459678,
0.412398717726961, 0.432306009936784, 0.283743168747693, 0.300400727908006,
0.183201780595526, 0.132573057429162, 0.444808742148526, 0.6426229493448,
0.637158468483024, 0.575956282831139, 0.58688524455469, 0.657923495757771,
0.690710380928424, 0.664480872791902, 0.633879779965959, 0.690710380928424,
0.731147539305563, 0.828415298645167, 0.933333331191257, 0.504918031628057,
0.161580495635885, 0.141411261257773, 0.231511839177222, 0.389617485444594,
0.325245900892878, 0.467759561767984, 0.370341058128744, 0.244523639258233,
0.255094824229708, 0.184927139830586, 0.643715845517155, 0.774863386199767,
0.676502730687808, 0.544262293832841, 0.456830600044432, 0.468852457940339,
0.48415300435331, 0.450273223010302, 0.43497267659733, 0.449180326837947,
0.608743168001792, 0.724590162271432, 0.816393440749261, 0.525683058902804,
0.196825396373666, 0.2766848809679, 0.298142075818472, 0.393247462017059,
0.468475597191251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L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Loliondo",
"Seronera"), class = "factor"), Feeding_Foraging = c(0.907978139992619,
0.910720788958481, 0.909107466037385, 0.865515480709382,
0.851511837754272, 0.908567353581193, 0.838185790426022,
0.877712201992865, 0.840783240328986, 0.829470508742613,
0.800692165739759, 0.810856100142662, 0.809726774097895,
0.81319541837825, 0.784881601113022, 0.770039030238942, 0.856340680152585,
0.933239380467668, 0.903362633548788, 0.90746480997227, 0.901897153597719,
0.927279348757726, 0.899508194656866, 0.928144676506314,
0.835478745828073, 0.853975821851945, 0.863934424246708,
0.65275045387529, 0.647190694885669, 0.653799113774003, 0.664199483432583,
0.724326359747071, 0.68927831008189, 0.664433137097017, 0.6934061914869,
0.649401418018395, 0.634681237159019, 0.601580301364126,
0.549631303304847, 0.489390986443134, 0.731803277008976,
0.851659141151415, 0.82937704727684, 0.797429668277099, 0.743903198917193,
0.756809782285958, 0.778144587121826, 0.792475345207145,
0.713528728284566, 0.745176874907532, 0.723589996683398,
0.534977024761081, 0.520242864622636, 0.527677594417352,
0.594687518263307, 0.613716383958506, 0.591121518289437,
0.583978391976724, 0.54946845378115, 0.569701553967814, 0.570830880012581,
0.565792348428236, 0.44540619205608, 0.479529212854885, 0.604641164368219,
0.706436876618826, 0.733039694316609, 0.708944160171797,
0.688872754078621, 0.745522085020775, 0.683773136848632,
0.688727555015723, 0.888572105349583, 0.947814205474962,
0.974098358420102, 0.607650271829437, 0.495781419627168,
0.569661200878373, 0.596382135431706, 0.656029142392356,
0.586131523056514, 0.501020035279991, 0.515725560443569,
0.506010927800412, 0.453078323186013, 0.397923496354493,
0.276120217945516, 0.115917251880721, 0.419016392480946,
0.916633877677671, 0.902114514441809, 0.760192197237773,
0.671451400869477, 0.68945138687036, 0.719743153252393, 0.856790014122652,
0.753034606650595, 0.867715845003057, 0.910655735614888,
0.555191255556392, 0.371194378539179, 0.387842830231389,
0.438178505369572, 0.441605425781279, 0.360371835112871,
0.34386030949283, 0.356947696292407, 0.385450661762178, 0.347581460444935,
0.307479235716452, 0.206102003169966, 0.160630022132145,
0.50735883307965, 0.879192936191512, 0.907549077050879, 0.862344757086919,
0.752185790623399, 0.70808743006887, 0.537777776543534, 0.676250523878803,
0.89357923292184, 0.891852953740506, 0.897516142997256, 0.380824875524623,
0.333345894593276, 0.400060715535987, 0.495039931608694,
0.543169397660485, 0.548558506372443, 0.552438776307497,
0.588188313067882, 0.621683058682476, 0.572131146227896,
0.422495445296276, 0.321857922758577, 0.264136813803823,
0.521922375150751, 0.902049178257592, 0.800526207432105,
0.812506653592706, 0.699698150879173, 0.635723691969573,
0.593333331971585, 0.727831164713589)), row.names = c(NA,
-144L), vars = "hour", indices = list(c(0L, 24L, 48L, 72L, 96L,
120L), c(1L, 25L, 49L, 73L, 97L, 121L), c(2L, 26L, 50L, 74L,
98L, 122L), c(3L, 27L, 51L, 75L, 99L, 123L), c(4L, 28L, 52L,
76L, 100L, 124L), c(5L, 29L, 53L, 77L, 101L, 125L), c(6L, 30L,
54L, 78L, 102L, 126L), c(7L, 31L, 55L, 79L, 103L, 127L), c(8L,
32L, 56L, 80L, 104L, 128L), c(9L, 33L, 57L, 81L, 105L, 129L),
c(10L, 34L, 58L, 82L, 106L, 130L), c(11L, 35L, 59L, 83L,
107L, 131L), c(12L, 36L, 60L, 84L, 108L, 132L), c(13L, 37L,
61L, 85L, 109L, 133L), c(14L, 38L, 62L, 86L, 110L, 134L),
c(15L, 39L, 63L, 87L, 111L, 135L), c(16L, 40L, 64L, 88L,
112L, 136L), c(17L, 41L, 65L, 89L, 113L, 137L), c(18L, 42L,
66L, 90L, 114L, 138L), c(19L, 43L, 67L, 91L, 115L, 139L),
c(20L, 44L, 68L, 92L, 116L, 140L), c(21L, 45L, 69L, 93L,
117L, 141L), c(22L, 46L, 70L, 94L, 118L, 142L), c(23L, 47L,
71L, 95L, 119L, 143L)), group_sizes = c(6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L), biggest_group_size = 6L, labels = structure(list(
hour = 0:23), row.names = c(NA, -24L), class = "data.frame", vars = "hour"), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
Any input is appreciated!
Here is my dataframe:
structure(list(replicate = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L,
7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L), press_id = c(1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), start_time = c(164429106370979,
164429411618825, 164429837271940, 164430399454285, 164429106370980,
164429411618826, 164429837271941, 164430399454286, 164429106370981,
164429411618827, 164429837271942, 164430399454287, 164429106370982,
164429411618828, 164429837271943, 164430399454288, 164429106370983,
164429411618829, 164429837271944, 164430399454289, 164429106370984,
164429411618830, 164429837271945, 164430399454290, 164429106370985,
164429411618831, 164429837271946, 164430399454291, 164429106370986,
164429411618832, 164429837271947, 164430399454292, 164429106370987,
164429411618833, 164429837271948, 164430399454293, 164429106370988,
164429411618834, 164429837271949, 164430399454294, 164429106370989,
164429411618835, 164429837271950, 164430399454295, 164429106370990,
164429411618836, 164429837271951, 164430399454296, 164429106370991,
164429411618837, 164429837271952, 164430399454297, 164429106370992,
164429411618838, 164429837271953, 164430399454298, 164429106370993,
164429411618839, 164429837271954, 164430399454299), end_time = c(164429182443825,
164429512525748, 164429903243170, 164430465927555, 164429182443826,
164429512525749, 164429903243171, 164430465927556, 164429182443827,
164429512525750, 164429903243172, 164430465927557, 164429182443828,
164429512525751, 164429903243173, 164430465927558, 164429182443829,
164429512525752, 164429903243174, 164430465927559, 164429182443830,
164429512525753, 164429903243175, 164430465927560, 164429182443831,
164429512525754, 164429903243176, 164430465927561, 164429182443832,
164429512525755, 164429903243177, 164430465927562, 164429182443833,
164429512525756, 164429903243178, 164430465927563, 164429182443834,
164429512525757, 164429903243179, 164430465927564, 164429182443835,
164429512525758, 164429903243180, 164430465927565, 164429182443836,
164429512525759, 164429903243181, 164430465927566, 164429182443837,
164429512525760, 164429903243182, 164430465927567, 164429182443838,
164429512525761, 164429903243183, 164430465927568, 164429182443839,
164429512525762, 164429903243184, 164430465927569)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -60L), vars = c("replicate",
"press_id"), drop = TRUE, indices = list(0L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 55L, 56L, 57L, 58L, 59L), group_sizes = c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), biggest_group_size = 1L, labels = structure(list(
replicate = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L,
7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L), press_id = c(1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,
1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L)), class = "data.frame", row.names = c(NA,
-60L), vars = c("replicate", "press_id"), drop = TRUE, indices = list(
0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L,
26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L,
38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L), group_sizes = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), biggest_group_size = 1L, labels = structure(list(
replicate = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L,
7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L), press_id = c(1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,
1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L)), class = "data.frame", row.names = c(NA,
-60L), vars = c("replicate", "press_id"), drop = TRUE, .Names = c("replicate",
"press_id")), .Names = c("replicate", "press_id")), .Names = c("replicate",
"press_id", "start_time", "end_time"))
I want to get the inter press_id time diff for example:
replicate press_id start_time end_time time_diff
1 1 1.644291e+14 1.644292e+14 0 (it's a first row)
1 2 1.644294e+14 1.644295e+14 1.644294e+14 - 1.644292e+14
1 3 1.644298e+14 1.644299e+14 1.644298e+14 - 1.644295e+14
1 4 1.644304e+14 1.644305e+14 .....
2 1 1.644291e+14 1.644292e+14
2 2 1.644294e+14 1.644295e+14
2 3 1.644298e+14 1.644299e+14
2 4 1.644304e+14 1.644305e+14
I am trying to do this using mutate, lag, lead and diff but without any luck. I have grouped, and ungrouped the dataset, nothing helped me.
df %>%
group_by(replicate) %>%
mutate(d = ifelse(row_number() == 1, 0, lead(start_time) - end_time))
df %>%
group_by(replicate) %>%
mutate(d = start_time - lag(end_time))
And if you want zeroes except NAs for the first row of each unique value in the replicate column, you could do:
df %>%
group_by(replicate) %>%
mutate(d = start_time - lag(end_time),
d = ifelse(is.na(d), 0, d))
Or just:
df %>%
group_by(replicate) %>%
mutate(d = ifelse(row_number() == 1, 0, start_time - lag(end_time)))
I have data of participants that had numerous trials, where certain trials had one condition, and other trials were another.
My analyses show that for condition 1, there is a linear null effect (flat line), while for condition 2 there is a cubic effect. I want to plot them together.
The code below creates a plot that gives the cubic function for both groups:
ggplot(dat, aes(x=trial, y=y, group=condition, colour=condition)) +
geom_point() + geom_jitter(height=0.2) +
geom_smooth(alpha=0.1, method="lm", formula = y ~ poly(x,3, raw=TRUE)) +
labs(x="Trial", y="y") +
scale_x_discrete(breaks=c(1,9,18,27,36,45,54,63))
What I want is to not have the cubic function for condition 2, but have a linear function. I tried to force this through aes() calls within geom_smooth(), but this seems to give me a much flatter cubic function for condition 1:
ggplot(dat, aes(x=trial, y=y)) +
geom_point(aes(group=condition, colour=condition)) + geom_jitter(height=0.2, aes(group=condition, colour=condition)) +
geom_smooth(alpha=0.1, method="lm", formula = y ~ poly(x,3, raw=TRUE), aes(group=(condition="1"), colour=(condition="1"))) +
geom_smooth(alpha=0.1, method="lm", aes(group=(condition="2"), colour=(condition="2"))) +
labs(x="Trial", y="y") +
scale_x_discrete(breaks=c(1,9,18,27,36,45,54,63))
Obviously this is not the way to go. How would I accomplish this? Script for reproducible example (first 250 lines of the total dataset, so your figures will be different) below:
structure(list(id = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3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25L,
26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L,
39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L,
52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L,
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L,
58L, 59L, 60L, 61L, 62L, 63L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L,
61L), condition = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 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L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 0L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L,
1L, 0L, 1L, 1L, 1L, NA, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L,
1L, 1L, 0L, 1L, 1L, NA, NA, NA, 0L, NA, 0L, NA, 1L, 1L, 0L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, NA, 0L, 0L, 1L, 0L, 0L, 1L,
1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, NA, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, NA,
0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, NA, 1L, NA, NA, 1L, 1L,
1L, 1L, NA, 1L, 1L, 1L, 1L, NA, 1L, 0L, 1L, 1L, 1L, 0L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L,
1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L)), .Names = c("id",
"trial", "condition", "y"), row.names = c(NA, 250L), class = "data.frame")
Edit: The reason I'm not using geom_smooth() using gam or loess, is because there are multiple polynomials in condition 1, so it will show more than just the cubic function if I use that solution. I wish to show the cubic function, not the composite of multiple polynomials.
You could filter your data inside geom_smooth.
library(tidyverse)
ggplot(dat, aes(x=trial, y=y, colour=as.factor(condition))) +
geom_point() + geom_jitter(height=0.2) +
geom_smooth(data = filter(dat, condition == 2), alpha=0.1, method="lm", formula = y ~ poly(x,3, raw=TRUE)) +
geom_smooth(data = filter(dat, condition == 1), alpha=0.1, method="lm", formula = y ~ 1) +
labs(x="Trial", y="y") +
scale_x_continuous(breaks=c(1,9,18,27,36,45,54,63))
Which gives you this plot
There seem to be two popular ways of calculating VIFs (Variance Inflation Factors, to detect collinearity among variables in regression) in R:
The vif() function in the car package, where the input is the model. This requires you to first fit a model before you can check for VIFs among variables in the model.
The corvif() function, where the input are the actual candidate explanatory variables (i.e. a list of variables, before the model is even fitted). This function is part of the AED package (Zuur et al. 2009), which has been discontinued. This one seems to work only on a list of variables, not on a fitted regression model.
Here is a data example:
MyData<-structure(list(site = structure(c(3L, 1L, 5L, 1L, 2L, 3L, 2L,
4L, 1L, 2L, 2L, 3L, 4L, 3L, 2L, 2L, 4L, 1L, 1L, 3L, 3L, 1L, 4L,
3L, 1L, 3L, 4L, 5L, 1L, 3L, 1L, 2L, 4L, 2L, 1L, 1L, 5L, 3L, 1L,
3L, 4L, 3L, 1L, 4L, 4L, 2L, 5L, 2L, 1L, 4L, 1L, 1L, 1L, 4L, 4L,
3L, 5L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 4L, 5L, 1L, 5L, 1L, 4L, 1L,
4L, 1L, 2L, 5L, 2L, 3L, 1L, 5L, 4L, 1L, 1L, 3L, 2L, 1L, 3L, 5L,
3L, 3L, 5L, 2L, 1L, 3L, 5L, 4L, 5L, 5L, 1L, 3L, 2L, 5L, 4L, 3L,
3L, 2L, 5L, 2L, 1L, 1L, 3L, 3L, 5L, 5L, 5L, 3L, 1L, 1L, 5L, 5L,
5L, 2L, 3L, 5L, 1L, 3L, 3L, 4L, 4L, 4L, 5L, 2L, 3L, 1L, 4L, 2L,
4L, 3L, 4L, 3L, 3L, 4L, 1L, 3L, 4L, 1L, 4L, 4L, 5L, 4L, 4L, 1L,
4L, 1L, 2L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, 3L, 4L, 4L, 4L, 5L, 1L,
3L, 2L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 4L, 3L, 3L, 4L,
4L, 4L), .Label = c("East", "Flat", "North", "South", "West"
), class = "factor"), height = c(515L, 60L, 60L, 30L, 70L,
70L, 40L, 70L, 50L, 75L, 160L, 85L, 40L, 90L, 70L, 210L,
30L, 60L, 45L, 60L, 410L, 50L, 40L, 210L, 140L, 120L, 70L,
35L, 30L, 90L, 40L, 240L, 40L, 55L, 120L, 200L, 65L, 40L,
95L, 140L, 220L, 70L, 40L, 30L, 50L, 95L, 50L, 50L, 50L,
70L, 160L, 45L, 35L, 50L, 70L, 230L, 110L, 300L, 50L, 105L,
60L, 50L, 60L, 70L, 30L, 60L, 30L, 110L, 80L, 80L, 30L, 60L,
70L, 80L, 60L, 40L, 220L, 140L, 110L, 40L, 40L, 40L, 90L,
125L, 90L, 100L, 270L, 420L, 60L, 70L, 53L, 40L, 80L, 90L,
30L, 40L, 65L, 40L, 110L, 90L, 40L, 190L, 110L, 70L, 52L,
120L, 95L, 50L, 50L, 140L, 75L, 30L, 50L, 60L, 125L, 60L,
80L, 35L, 55L, 140L, 140L, 240L, 65L, 40L, 200L, 80L, 60L,
65L, 120L, 80L, 230L, 150L, 40L, 50L, 60L, 210L, 50L, 130L,
140L, 210L, 60L, 50L, 90L, 120L, 55L, 50L, 20L, 50L, 40L,
70L, 40L, 100L, 80L, 85L, 60L, 50L, 20L, 200L, 40L, 70L,
50L, 200L, 60L, 43L, 30L, 60L, 40L, 70L, 40L, 40L, 40L, 50L,
110L, 70L, 30L, 50L, 85L, 70L, 40L, 100L, 40L, 50L, 100L,
40L, 70L, 40L, 40L, 50L, 210L, 50L, 140L, 80L, 75L, 90L,
40L, 50L, 60L, 50L, 80L, 50L, 60L, 40L, 60L, 170L, 60L, 80L,
80L, 15L, 40L, 70L, 45L, 45L, 45L, 110L, 200L, 30L, 60L,
40L, 60L, 160L, 40L, 90L, 80L, 30L, 40L, 270L, 50L, 50L,
60L, 60L, 50L, 30L, 70L, 170L, 50L, 30L, 50L, 60L, 40L, 60L,
60L, 140L, 80L, 80L, 220L, 45L, 80L, 130L, 50L, 40L, 220L,
40L, 70L, 60L, 80L, 50L, 200L, 115L, 50L, 90L, 400L, 50L,
360L, 40L, 60L, 60L, 65L, 100L, 50L, 55L, 60L, 50L, 130L,
40L, 130L, 40L, 40L, 120L, 66L, 55L, 100L, 75L, 60L, 80L,
60L, 90L, 160L, 50L, 210L, 35L, 60L, 40L, 55L, 50L, 90L,
220L, 60L, 120L, 62L, 60L, 40L, 60L, 70L, 60L, 90L, 50L,
50L, 30L, 110L, 70L, 80L, 90L, 210L, 70L, 65L, 160L, 100L,
25L, 55L, 40L, 60L, 110L, 70L, 50L, 60L, 70L, 60L, 60L, 170L,
45L, 60L, 120L, 40L, 60L, 130L, 40L, 170L, 50L, 80L, 60L,
150L, 90L, 60L, 120L, 120L, 80L, 30L, 110L, 230L, 190L, 70L,
110L, 50L, 60L, 82L, 60L, 30L, 60L, 200L, 90L, 30L, 140L,
60L, 70L, 70L, 100L, 60L, 415L, 115L, 90L, 60L, 60L, 80L,
60L, 55L, 90L, 65L, 60L, 40L, 40L, 90L, 50L, 70L, 70L, 120L,
40L, 50L, 110L, 45L, 30L, 95L, 30L, 70L), width = c(310L,
50L, 40L, 30L, 60L, 70L, 20L, 80L, 70L, 20L, 220L, 40L, 60L,
30L, 230L, 110L, 20L, 40L, 25L, 60L, 240L, 90L, 30L, 130L,
120L, 110L, 60L, 70L, 30L, 110L, 30L, 180L, 20L, 80L, 110L,
310L, 40L, 10L, 80L, 160L, 134L, 30L, 20L, 40L, 20L, 230L,
100L, 180L, 40L, 120L, 130L, 30L, 40L, 100L, 30L, 180L, 70L,
110L, 170L, 40L, 30L, 50L, 30L, 40L, 30L, 50L, 80L, 50L,
80L, 90L, 70L, 70L, 190L, 60L, 50L, 30L, 150L, 150L, 50L,
80L, 30L, 40L, 130L, 390L, 60L, 130L, 400L, 200L, 110L, 30L,
15L, 300L, 70L, 140L, 30L, 50L, 30L, 40L, 110L, 240L, 50L,
90L, 70L, 20L, 40L, 100L, 50L, 30L, 30L, 130L, 40L, 70L,
70L, 60L, 10L, 30L, 60L, 50L, 40L, 120L, 90L, 210L, 50L,
20L, 100L, 100L, 110L, 100L, 100L, 80L, 120L, 80L, 5L, 40L,
50L, 60L, 15L, 100L, 120L, 200L, 30L, 80L, 60L, 70L, 30L,
30L, 20L, 50L, 50L, 60L, 15L, 80L, 60L, 130L, 40L, 60L, 30L,
100L, 20L, 130L, 60L, 120L, 70L, 20L, 60L, 20L, 40L, 50L,
15L, 120L, 60L, 50L, 300L, 40L, 30L, 25L, 70L, 130L, 30L,
50L, 60L, 50L, 50L, 50L, 20L, 30L, 70L, 35L, 180L, 40L, 50L,
70L, 40L, 70L, 50L, 20L, 40L, 40L, 40L, 40L, 50L, 20L, 30L,
180L, 30L, 130L, 30L, 15L, 25L, 50L, 40L, 40L, 40L, 50L,
170L, 20L, 50L, 20L, 50L, 110L, 30L, 90L, 15L, 50L, 40L,
150L, 30L, 30L, 30L, 20L, 40L, 20L, 100L, 60L, 40L, 30L,
30L, 140L, 40L, 50L, 120L, 150L, 100L, 70L, 300L, 30L, 60L,
120L, 30L, 50L, 100L, 60L, 90L, 50L, 40L, 140L, 130L, 60L,
60L, 70L, 200L, 30L, 40L, 50L, 20L, 20L, 20L, 80L, 35L, 70L,
15L, 40L, 360L, 70L, 50L, 50L, 30L, 110L, 30L, 30L, 90L,
50L, 30L, 70L, 40L, 110L, 70L, 40L, 150L, 100L, 40L, 40L,
40L, 20L, 250L, 180L, 40L, 60L, 20L, 120L, 40L, 50L, 60L,
260L, 110L, 30L, 30L, 40L, 100L, 50L, 50L, 100L, 150L, 190L,
70L, 110L, 50L, 10L, 40L, 50L, 60L, 80L, 30L, 20L, 150L,
70L, 25L, 30L, 40L, 50L, 30L, 50L, 210L, 40L, 100L, 30L,
80L, 20L, 30L, 70L, 130L, 60L, 50L, 50L, 70L, 50L, 30L, 150L,
130L, 110L, 50L, 40L, 80L, 90L, 40L, 40L, 40L, 40L, 200L,
140L, 40L, 25L, 50L, 50L, 40L, 20L, 40L, 340L, 70L, 60L,
50L, 20L, 80L, 60L, 25L, 260L, 20L, 15L, 40L, 30L, 300L,
120L, 60L, 100L, 50L, 40L, 20L, 90L, 50L, 40L, 80L, 30L,
40L), length = c(450L, 80L, 55L, 50L, 90L, 90L, 30L, 90L,
90L, 30L, 240L, 50L, 70L, 40L, 380L, 200L, 40L, 40L, 35L,
110L, 250L, 120L, 70L, 150L, 130L, 140L, 90L, 90L, 40L, 390L,
40L, 190L, 40L, 110L, 140L, 360L, 50L, 30L, 130L, 500L, 200L,
30L, 25L, 60L, 30L, 350L, 110L, 180L, 70L, 180L, 200L, 40L,
70L, 110L, 70L, 180L, 90L, 150L, 400L, 100L, 60L, 70L, 70L,
60L, 30L, 50L, 80L, 180L, 110L, 100L, 110L, 110L, 210L, 80L,
70L, 40L, 500L, 210L, 50L, 80L, 40L, 50L, 350L, 400L, 150L,
200L, 400L, 280L, 240L, 40L, 50L, 360L, 140L, 140L, 50L,
50L, 40L, 50L, 210L, 370L, 70L, 110L, 80L, 50L, 50L, 100L,
80L, 50L, 35L, 140L, 60L, 90L, 110L, 60L, 130L, 180L, 70L,
70L, 40L, 230L, 130L, 290L, 90L, 40L, 100L, 100L, 120L, 150L,
110L, 80L, 220L, 90L, 5L, 50L, 50L, 60L, 30L, 150L, 120L,
200L, 60L, 170L, 80L, 90L, 40L, 50L, 70L, 50L, 60L, 100L,
15L, 90L, 70L, 150L, 60L, 90L, 50L, 120L, 20L, 220L, 80L,
140L, 120L, 30L, 60L, 40L, 40L, 70L, 30L, 180L, 60L, 110L,
300L, 50L, 60L, 50L, 110L, 160L, 40L, 70L, 70L, 60L, 70L,
50L, 25L, 30L, 215L, 70L, 220L, 70L, 80L, 90L, 60L, 130L,
60L, 20L, 60L, 50L, 40L, 60L, 100L, 40L, 70L, 210L, 40L,
500L, 40L, 30L, 50L, 80L, 40L, 60L, 80L, 50L, 220L, 20L,
70L, 50L, 50L, 180L, 50L, 90L, 15L, 120L, 80L, 170L, 30L,
30L, 60L, 20L, 60L, 30L, 140L, 80L, 40L, 50L, 40L, 200L,
80L, 80L, 120L, 160L, 210L, 120L, 400L, 60L, 60L, 180L, 70L,
70L, 150L, 70L, 110L, 70L, 80L, 250L, 140L, 90L, 60L, 180L,
400L, 60L, 50L, 60L, 40L, 30L, 50L, 100L, 40L, 110L, 30L,
80L, 400L, 70L, 50L, 80L, 30L, 180L, 70L, 60L, 100L, 70L,
50L, 100L, 60L, 220L, 70L, 70L, 200L, 110L, 50L, 110L, 50L,
60L, 250L, 220L, 60L, 80L, 35L, 210L, 70L, 70L, 110L, 320L,
280L, 60L, 50L, 60L, 100L, 70L, 70L, 170L, 170L, 230L, 80L,
130L, 90L, 10L, 60L, 70L, 60L, 120L, 40L, 50L, 160L, 100L,
30L, 40L, 40L, 90L, 30L, 80L, 240L, 100L, 170L, 60L, 120L,
20L, 40L, 70L, 150L, 80L, 50L, 90L, 130L, 70L, 60L, 480L,
150L, 130L, 90L, 70L, 150L, 100L, 70L, 50L, 40L, 60L, 400L,
200L, 80L, 30L, 120L, 70L, 50L, 40L, 40L, 360L, 90L, 70L,
60L, 40L, 110L, 80L, 25L, 270L, 40L, 25L, 50L, 30L, 320L,
150L, 100L, 100L, 60L, 40L, 50L, 100L, 50L, 50L, 200L, 30L,
80L), ground = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 3L, 1L,
2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,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", "species", "aspect", "height", "width",
"length", "ground", "sun", "leaf", "Presence"), row.names = c(NA,
393L), class = "data.frame")
After the model selection, this is the optimal model:
model <- glm(Presence ~ site + species + aspect + length + sun
+ leaf, data=MyData, family=binomial)
With respect to the 1st way referred to above, one can do the following:
library(car)
vif(model)
to obtain VIFs based on the model as an input.
But with respect to 2nd way, one could look at VIFs of variables, before fitting the model:
library(AED) # note that his package has been discontinued
vars <- cbind(MyData$site, MyData$species,
MyData$aspect , MyData$length ,
MyData$width, MyData$height,
MyData$ground, MyData$sun, MyData$leaf)
corvif(vars)
(the corvif() function code can be found here: http://www.highstat.com/Book2/HighstatLibV6.R)
The underlying mathematics of the two functions appear to be the same, but the way the functions are written, they accept different types of objects as input.
My questions are:
Do you prefer to calculate VIFs based
on a list of variables prior to model fitting,
on a fitted model, or
both?
Are there any functions (in additions to the two referred to already) that people recommend and/or use to calculate VIFs?
Is anyone aware of a single R function that works on both the list of variables and the fitted model as in input?
My (opinionated) answer to the question: whether it's more appropriate to use vif on a model object or on the data itself, would be that it would be best practice to do it before the model is constructed as part of the process of understanding the relationships within the data before modeling. But truth be told, I think most of the time it's done as an afterthought because of unexpected results (standard errors that blow up, usually).
If you want a function that can take either a fit object or a dimensioned data-object (matrix or dataframe), then I think you may need to "roll your own". I have used the rms/Hmisc pair of packages extensively and there is also a vif in the 'rms'-package as well as a which.influence function that lets you know the combinations that are responsible for the multicollinearity. It only accepts a fit-object. Because the versions that handle fit-objects can look at both the result of vcov and the terms in the RHS of the formula, you would only need to have single argument. However, if you want to specify which columns to examine in a dimensioned object, then you would need to provide function code to handle a second parameter.
I did a search with:
sos::findFn("vif")
... and the fourth page examined (function vif in package "HH") appears to offer a choice of which strategy to use: http://finzi.psych.upenn.edu/R/library/HH/html/vif.html
If you wanted to write your own, then you already have the code in the form of the corvif and myvif functions on the page you linked to. The corvif function uses the myvif function, which is model-based. So you could insert code to check for the presence of the first argument's class in the vector of methods returned by methods(vcov).