How to bring model predict line in front of geom_rect - r

I am investigating the effect of time since fire on species diversity. I am attempting to make a graph that has different colours at different time since fire ages. However, putting the colours onto the graph has made the model prediction line fade away. I am wondering if there is some way to bring the line in front of geom_rect?
Loaded packages:
library(voxel)
library(gamm4)
library(ggplot2)
My data:
data <- read.csv('StacksOverflow.csv')
structure(list(Lscape = c(158L, 158L, 158L, 158L, 158L, 158L),
TSF = c(5, 5, 5, 18.5, 5, 18.5), VegtypeNew = structure(c(1L,
1L, 1L, 2L, 1L, 1L), .Label = c("spinsandplain", "woodlndsandplain"
), class = "factor"), FF = c(2L, 2L, 2L, 1L, 2L, 1L), ThreeYearRain = c(913.799997,
913.799997, 913.799997, 913.799997, 913.799997, 913.799997
), Div = c(2.2629743, 1.9630117, 1.7336569, 1.2816843, 2.4155056,
1.4240443), triodia_low = c(19L, 6L, 21L, 32L, 11L, 32L)), row.names = c(NA,
6L), class = "data.frame")
Extended data:
structure(list(Lscape = c(158L, 158L, 158L, 158L, 158L, 158L,
158L, 158L, 201L, 201L, 201L, 201L, 201L, 201L, 201L, 201L, 235L,
235L, 235L, 235L, 235L, 235L, 235L, 235L, 237L, 237L, 237L, 237L,
237L, 237L, 237L, 237L, 254L, 254L, 254L, 254L, 254L, 254L, 254L,
254L, 287L, 287L, 287L, 287L, 287L, 287L, 287L, 287L, 304L, 304L,
304L, 304L, 304L, 304L, 304L, 304L, 311L, 311L, 311L, 311L, 311L,
311L, 311L, 311L, 312L, 312L, 312L, 312L, 312L, 312L, 312L, 312L,
323L, 323L, 323L, 323L, 323L, 323L, 323L, 323L, 326L, 326L, 326L,
326L, 326L, 326L, 326L, 326L, 327L, 327L, 327L, 327L, 327L, 327L,
327L, 327L, 337L, 337L, 337L, 337L, 337L, 337L, 337L, 337L, 355L,
355L, 355L, 355L, 355L, 355L, 355L, 355L, 370L, 370L, 370L, 370L,
370L, 370L, 370L, 370L, 379L, 379L, 379L, 379L, 379L, 379L, 379L,
379L, 411L, 411L, 411L, 411L, 411L, 411L, 411L, 411L, 414L, 414L,
414L, 414L, 414L, 414L, 414L, 414L, 435L, 435L, 435L, 435L, 435L,
435L, 435L, 435L, 437L, 437L, 437L, 437L, 437L, 437L, 437L, 437L,
438L, 438L, 438L, 438L, 438L, 438L, 438L, 438L, 447L, 447L, 447L,
447L, 447L, 447L, 447L, 447L, 452L, 452L, 452L, 452L, 452L, 452L,
452L, 452L), TSF = c(5, 5, 5, 18.5, 5, 18.5, 18.5, 18.5, 11.5,
4.5, 0.5, 20, 11.5, 0.5, 1, 4.5, 1, 1, 4.5, 5, 4.5, 2, 5, 1,
6, 6, 4.5, 6, 14.5, 17, 4.5, 6, 1, 1, 7, 4.5, 2, 2, 7, 7, 20,
4, 3.5, 4, 3.5, 3.5, 11.5, 20, 6, 0.5, 5, 6, 6, 0.5, 7, 6, 3.5,
3.5, 3.5, 11.5, 11.5, 1, 1, 11.5, 1, 1, 4, 1, 1, 4, 1, 10.5,
7, 17.5, 0.5, 0.5, 0.5, 17.5, 7, 0.5, 18, 1.5, 3.5, 18, 18, 5,
3.5, 18.5, 14.5, 1.5, 7, 1.5, 7, 7, 7, 7, 10.5, 1.5, 0, 1.5,
7, 3, 7, 10.5, 0.5, 20, 0.5, 2, 2, 1.5, 2, 3, 20, 1, 1.5, 10.5,
17, 1.5, 1.5, 10.5, 3, 1, 1, 1, 4.5, 1, 6.5, 1, 10, 1.5, 12.5,
1.5, 1.5, 1.5, 1.5, 1.5, 2, 7, 12.5, 2, 7, 2, 2, 2, 1.5, 18.5,
18.5, 1.5, 7, 1.5, 1.5, 5, 12.5, 6.5, 1.5, 1.5, 1.5, 1.5, 1.5,
1.5, 6.5, 6.5, 1.5, 6.5, 18.5, 6.5, 7, 1.5, 1, 7, 7, 1, 7, 1,
7.5, 7.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5), VegtypeNew = structure(c(1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L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, 1L, 3L, 3L, 4L, 4L, 3L, 4L, 3L, 3L,
4L, 5L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 4L, 3L, 6L, 4L, 4L, 3L, 3L,
4L, 0L, 2L, 4L, 3L, 2L, 3L, 3L, 0L, 2L, 2L, 1L, 1L, 2L, 2L, 1L,
3L, 2L, 5L, 6L, 3L, 3L, 3L, 3L, 2L, 4L, 3L, 4L, 5L, 4L, 3L, 3L,
6L, 4L, 3L, 5L, 5L, 5L, 5L, 4L, 3L, 2L, 1L, 2L, 2L, 3L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 3L,
2L, 2L, 2L, 3L, 2L, 4L, 2L, 3L, 4L, 5L, 5L, 3L, 4L, 3L, 3L, 4L
), ThreeYearRain = c(913.799997, 913.799997, 913.799997, 913.799997,
913.799997, 913.799997, 913.799997, 913.799997, 938.899988, 938.899988,
938.899988, 938.600004, 938.899988, 938.899988, 938.899988, 938.499989,
930.700005, 932.800001, 930.700005, 930.700005, 932.800001, 930.700005,
930.700005, 932.800001, 932.699991, 934.799987, 934.799987, 934.799987,
932.699991, 934.799987, 932.699991, 934.799987, 896.99999, 896.99999,
908.999991, 908.999991, 908.999991, 908.999991, 910.199991, 898.399994,
928.000009, 939.800006, 935.500004, 928.000009, 928.000009, 923.700007,
931.499996, 931.499996, 866.200004, 866.200004, 867.000003, 867.000003,
867.000003, 867.300002, 867.000003, 869.3, 926.800003, 926.800003,
926.800003, 926.800003, 933.800003, 934.600006, 934.600006, 934.600006,
924.2, 925.100002, 924.2, 924.2, 924.2, 922.2, 924.2, 924.7,
974.799995, 983.500006, 983.500006, 983.500004, 983.500006, 974.799995,
974.799994, 983.500006, 839.1, 839.1, 839.1, 839.100001, 839.300001,
839.1, 838.699999, 839.100001, 839.100001, 838.699999, 842.300004,
842.300004, 842.900006, 842.300004, 842.900006, 842.300004, 936.900014,
936.900014, 936.900014, 932.999984, 933.099983, 932.999984, 936.900014,
936.900014, 870.499995, 870.499995, 877.399998, 877.399998, 876.099997,
876.099997, 876.099997, 859.199997, 957.199982, 966.299982, 955.699998,
955.699998, 957.199982, 955.699998, 955.699998, 956.299985, 852.2,
852.2, 852.600006, 852.500001, 852.500001, 852.500001, 852.600006,
852.500001, 906.700011, 904.700001, 912.600007, 912.600007, 914.600007,
906.700001, 906.399998, 914.600007, 925.599982, 933.299992, 933.299992,
933.299992, 933.299992, 926.500012, 935.899994, 935.199992, 916.800001,
916.100001, 916.800001, 916.400003, 918.700003, 904.100001, 916.800001,
918.700003, 899.1, 904.100001, 906.000003, 903.400002, 904.100001,
903.400002, 906.000003, 906.000003, 905.7, 903.099999, 903.099999,
905.7, 912.199994, 893.200002, 905.399999, 904.999998, 933.700012,
933.700012, 933.700012, 933.700012, 933.700012, 932.30001, 932.300008,
932.300008, 878.500006, 878.500006, 878.500006, 879.300004, 879.300004,
879.300004, 879.300004, 873.200008), Div = c(2.2629743, 1.9630117,
1.7336569, 1.2816843, 2.4155056, 1.4240443, 1.5178948, 0.8993031,
1.2022801, 1.9287665, 2.0237769, 2.004871, 1.5020684, 2.1776591,
2.093787, 2.3139276, 2.7244402, 2.7026829, 1.6644725, 2.0696347,
1.9561853, 2.6018987, 2.5800017, 2.1867866, 2.4144821, 1.7389892,
2.1427451, 1.6544538, 1.8651966, 1.7569776, 1.8257533, 1.4048204,
2.7384914, 2.9344488, 2.2306909, 2.5085619, 1.8874836, 2.3431509,
1.8401602, 1.8620274, 1.8038997, 2.5909049, 2.2265328, 2.0882065,
2.4737837, 2.2995223, 1.4231311, 2.0577752, 1.6463134, 2.1464331,
2.2636437, 2.0992589, 1.7666974, 1.835061, 1.7732171, 2.0813243,
1.865505, 2.0200607, 1.2510612, 1.021761, 0.8111482, 0.2617645,
2.0282081, 1.1145976, 2.2596683, 2.3517629, 1.9424972, 1.9191269,
1.4222035, 2.6007698, 2.0071984, 1.9049132, 1.073374, 0.9576897,
1.6273043, 1.7701581, 0.6890092, 1.5764456, 0.384906, 1.5099996,
1.6713486, 2.5483064, 2.2033185, 2.0798843, 1.9082985, 2.1580972,
1.6952798, 1.6303402, 1.9461221, 1.4116405, 1.5347693, 2.6924921,
1.727278, 1.9384415, 1.6659585, 1.612819, 1.6592884, 2.7129796,
0, 2.7098898, 1.3785924, 2.7635218, 1.1481271, 1.8597007, 2.2191531,
1.088549, 2.431015, 1.3702099, 2.1018035, 2.3442348, 2.3599146,
2.789816, 1.8340235, 1.0606126, 2.5852679, 1.7791063, 1.2273106,
2.2432636, 2.5642458, 1.3306642, 2.6771856, 1.5062567, 2.0903266,
2.0398412, 2.4821503, 0.5979376, 1.479214, 1.9188301, 1.2267089,
2.4491421, 1.5366949, 2.516592, 2.4084849, 2.4385928, 2.549348,
2.7090074, 2.3337573, 1.8982968, 1.7956341, 2.3752386, 1.6587394,
2.6663039, 2.4853204, 1.9325793, 2.4431141, 1.6976331, 0.8791745,
2.6625573, 1.9596877, 1.9287565, 2.4590816, 2.4963942, 1.8767916,
1.3954333, 2.5155936, 2.2327274, 2.6613726, 2.580748, 2.3142567,
2.2280879, 1.7925025, 1.663008, 2.3488945, 2.0746398, 1.7050203,
2.0108246, 1.7317251, 2.4936515, 0.9556999, 1.3716151, 2.0694067,
1.4944032, 1.0984774, 1.2868726, 1.6429103, 1.3720737, 1.8037795,
1.8745583, 1.8921264, 1.8320377, 1.201682, 1.8489571, 1.798546,
0.8486856), triodia_low = c(19L, 6L, 21L, 32L, 11L, 32L, 16L,
29L, 17L, 20L, 0L, 24L, 37L, 0L, 3L, 29L, 4L, 2L, 31L, 28L, 20L,
12L, 6L, 6L, 26L, 28L, 27L, 32L, 37L, 26L, 15L, 27L, 2L, 1L,
19L, 5L, 13L, 10L, 33L, 14L, 25L, 22L, 15L, 34L, 15L, 7L, 36L,
25L, 25L, 0L, 25L, 4L, 21L, 0L, 33L, 16L, 16L, 15L, 22L, 25L,
25L, 0L, 0L, 18L, 2L, 0L, 26L, 0L, 0L, 7L, 0L, 13L, 28L, 35L,
0L, 0L, 0L, 31L, 29L, 0L, 14L, 5L, 14L, 11L, 12L, 16L, 21L, 26L,
22L, 7L, 23L, 10L, 23L, 17L, 19L, 7L, 27L, 3L, 0L, 2L, 29L, 14L,
30L, 12L, 0L, 35L, 0L, 29L, 4L, 5L, 14L, 15L, 33L, 0L, 3L, 21L,
34L, 0L, 2L, 28L, 16L, 0L, 1L, 0L, 11L, 0L, 32L, 0L, 27L, 2L,
28L, 3L, 0L, 4L, 1L, 6L, 14L, 27L, 25L, 12L, 7L, 10L, 16L, 9L,
4L, 15L, 40L, 2L, 18L, 5L, 3L, 6L, 1L, 33L, 2L, 5L, 12L, 4L,
7L, 3L, 17L, 30L, 5L, 7L, 17L, 15L, 16L, 9L, 0L, 26L, 16L, 0L,
24L, 1L, 27L, 32L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), class = "data.frame", row.names = c(NA,
-184L))
The model:
m1b <-gamm4(Div~TSF+FF+s(triodia_low, k=6)+VegtypeNew+ThreeYearRain,random=~(1|Lscape),data=data)
Plotting:
p <-plotGAMM (m1b,smooth.cov="triodia_low",groupCovs = NULL,orderedAsFactor=T,rawOrFitted="raw",plotCI=T,grouping = NULL)
p + labs(x= "Years since fire") +
labs(y="Species diversity (H')") +
theme_bw() +
theme(panel.grid.major = element_blank()) +
theme(panel.grid.minor = element_blank()) +
theme(panel.border = element_blank()) +
theme(axis.line = element_line(colour="black")) +
theme(axis.title = element_text(size=22)) + # face="bold"
theme(axis.ticks = element_line()) +
scale_x_continuous(breaks = seq(0,40,by=5)) +
geom_rect(aes(xmin=0,xmax=0.6,ymin=-Inf,ymax=Inf),alpha=0.002, fill="coral4") +
geom_rect(aes(xmin=.6,xmax=1,ymin=-Inf,ymax=Inf),alpha=0.002, fill="gold") +
geom_rect(aes(xmin=1,xmax=5,ymin=-Inf,ymax=Inf),alpha=0.002, fill="darkred") +
geom_rect(aes(xmin=5,xmax=10,ymin=-Inf,ymax=Inf),alpha=0.002,fill="chocolate") +
geom_rect(aes(xmin=10,xmax=40,ymin=-Inf,ymax=Inf),alpha=0.002,fill="orangered") +
theme(axis.text = element_text(size=18, colour="black")) +
theme(text = element_text(family = "Arial")) +
theme(legend.position= "none")
The plot:
Any help would be greatly appreciated :)

Using the development version of gratia you can replicate the plot you showed with a few simple calls to create the data, predict etc.
To install the development version of gratia do
# install.packages("remotes")
remotes::install_github("gavinsimpson/gratia")
Once installed you can produce an object suitable for plotting using:
library('mgcv')
library('gamm4')
library('gratia')
library('ggplot2')
library('dplyr')
## model fit
m1b <- gamm4(Div ~ TSF + FF + s(triodia_low, k=6) + VegtypeNew + ThreeYearRain,
random = ~ (1|Lscape), data = df)
## data to predict at
new_df <- data_slice(m1b, var1 = 'triodia_low', n = 100)
## predict and cast to a tibble
pred_df <- as_tibble(predict(m1b[["gam"]], new_df, se.fit = TRUE))
## add to the data we're predicting at
pred_df <- bind_cols(new_df, pred_df)
## grab the inverse link of the model (not needed here, but is for non-Normal fits)
ilink <- inv_link(m1b)
## create the upper and lower credible interval
pred_df <- mutate(pred_df,
lwr = ilink(fit - (2 * se.fit)),
upr = ilink(fit + (2 * se.fit)),
fit = ilink(fit))
The plot itself can be created using:
ggplot(pred_df, aes(x = triodia_low, y = fit)) +
labs(x = "Years since fire", y = "Species diversity (H')") +
theme_bw() +
theme(panel.grid.major = element_blank()) +
theme(panel.grid.minor = element_blank()) +
theme(panel.border = element_blank()) +
theme(axis.line = element_line(colour="black")) +
theme(axis.title = element_text(size=22)) +
theme(axis.ticks = element_line()) +
scale_x_continuous(breaks = seq(0,40,by=5)) +
geom_rect(aes(xmin=0, xmax=0.6, ymin=-Inf, ymax=Inf), alpha=0.01, fill="coral4") +
geom_rect(aes(xmin=0.6, xmax=1, ymin=-Inf, ymax=Inf), alpha=0.01, fill="gold") +
geom_rect(aes(xmin=1, xmax=5, ymin=-Inf, ymax=Inf), alpha=0.01, fill="darkred") +
geom_rect(aes(xmin=5, xmax=10, ymin=-Inf, ymax=Inf), alpha=0.01, fill="chocolate") +
geom_rect(aes(xmin=10, xmax=40, ymin=-Inf, ymax=Inf), alpha=0.01, fill="orangered") +
geom_point(data = df, mapping = aes(x = triodia_low, y = Div)) +
geom_ribbon(aes(ymin = lwr, ymax = upr), alpha = 0.4) +
geom_line()
Most of the ggplot code is your's, but now that we have full control, we can put the data layers in the foreground by leaving those layers until the end.
Note that I'm not convinced this is a great plot. The fitted function you are showing is conditional upon the other covariates in the data set. Here, and as with voxel::plotGAMM(), we're predicting from the model and hence we have to supply something for the other covariates. Following voxel::plotGAMM and mgcv::vis.gam, we fix the other covariates not shown at
the value of the data observation closest to the median (for continuous variables), or
the modal category (for factor parametric terms)
So, the resulting figure is the fit conditional upon those values. In particular it is for the spinsandplain level of VegTypeNew. As such it is a little misleading.

Related

Multi-level Model in R missing one predictor [duplicate]

I am using the lme4 package and running a linear mixed model but I am confused but the output and expect that I am encountering an error even though I do not get an error message.
The basic issue is when I fit a model like lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
and then look at the results using something like summary I see all the model fixed (and random) effects as I would expect however the habitat effect is always displayed as habitatForest. Like this:
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 996.63179 8.16633 31.22730 122.042 < 2e-16 ***
stimuliBHCO -3.57541 1.28877 8750.89273 -2.774 0.005544 **
stimuliCOHA -10.17037 1.29546 8754.17156 -7.851 4.62e-15 ***
timeperiod 0.19900 0.05516 8744.95307 3.608 0.000310 ***
scale(poly(distance.code, 3, raw = FALSE))1 -3.87613 0.71431 8745.70773 -5.426 5.90e-08 ***
scale(poly(distance.code, 3, raw = FALSE))2 2.65854 0.71463 8745.19353 3.720 0.000200 ***
scale(poly(distance.code, 3, raw = FALSE))3 4.66340 0.72262 8745.67948 6.453 1.15e-10 ***
habitatForest -68.82430 11.83009 29.95226 -5.818 2.34e-06 ***
wind.speed -0.35853 0.07631 8403.15191 -4.698 2.66e-06 ***
scale(poly(distance.code, 3, raw = FALSE))1:habitatForest 2.89860 1.03891 8745.46534 2.790 0.005282 **
scale(poly(distance.code, 3, raw = FALSE))2:habitatForest -3.49758 1.03829 8745.11371 -3.369 0.000759 ***
scale(poly(distance.code, 3, raw = FALSE))3:habitatForest -4.67300 1.03913 8745.30579 -4.497 6.98e-06 ***
---
This is happening even though there are two levels of habitat (Forest and Grassland)
at first, I thought this might be because my model had an interaction term but it happens when I try a simpler model like lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
Why would it say "habitatForest" and not just "habitat" or if it were going to include a factor by name why not say "habitatForest" and "habitatGrassland"?
A quick look at the expected output from this function here: https://rpubs.com/palday/mixed-interactions or here: https://ase.tufts.edu/bugs/guide/assets/mixed_model_guide.html (among others)
shows that the out put that I am getting is not what is expected or normal.
Other output I have seen simply have factors with two levels, like mine, as a single line (eg habitat).
Here is a portion of the data I am using. I used dput and subseting to produce this. I couldn't figure out how to make the data set smaller and still reproduce the error so I apologize if this is too large. The data set that it comes from is MUCH bigger! (also please let me know if I have used dput incorrectly.(Still new to R and stackoverflow)
structure(list(location.code = structure(c(1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 4L, 4L, 4L, 3L, 3L, 3L, 3L,
3L,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2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("Grassland",
"Forest"), class = "factor"), distance.code = c(0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L,
30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0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9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55,
55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65,
65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55,
55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65,
65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9), timeperiod = c(6L, 6L, 6L,
6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L,
17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L,
20L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L), Values = c(910.721895276374, 922.652711611841,
926.219785713456, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 992.059286431433,
1042.05240231832, 1018.99804250179, 911.976009884021, 918.215389274037,
931.037495260958, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 994.583211567691,
1006.58290843226, 1005.52479816571, 908.665064025178, 917.940176257067,
922.746174825048, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 982.154409713674,
1008.54477137219, 996.577798511801, 912.914857937818, 916.937508116615,
920.933077377339, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 983.866984633392,
1002.04551764872, 986.791628665069, 907.695668282537, 917.845214744473,
932.330755620455, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 1000.3672969178,
1021.78461788922, 1011.40975353271, 915.037273600535, 914.099859036178,
924.116937361394, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 974.273124973661,
1145.99211507205, 1013.58184367388, 913.467056616881, 920.213007520924,
919.794369158301, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 1015.24811721269,
1070.61183211249, 1016.57332551186, 910.196695694198, 923.403802532832,
905.400995326023, 1036.98011238981, 963.147077473505, 916.899569521736,
931.240844862156, 919.11781354823, 995.408916523572, 960.825305234446,
1026.22960551445, 1000.13773127026, 962.347584090332, 904.090295814044,
908.836747102913, 928.867625382891, 918.100799763641, 906.282906701285,
913.146312873635, 977.094140033575, 972.599778534534, 964.658406857446,
921.91272768213, 910.507770576621, 942.269786765654, 1014.34022271036,
1128.29327664605, 1043.1365958913, 919.185972424773, 925.486310755197,
908.769520270226, 1030.20866627018, 956.104935565803, 922.01947330213,
934.451182538208, 928.626906337293, 986.326936258622, 1003.40797963907,
1021.91264348048, 995.68658929192, 993.102343807935, 901.633626404701,
908.255562868123, 922.840049924103, 917.012733437446, 907.541530752433,
915.050696506642, 983.542956895186, 972.236377246083, 965.082329354352,
918.337944633569, 910.137012141557, 952.89462134025, 977.420371016686,
1154.17994731565, 1022.82998099991, 927.061613377597, 926.745527716988,
908.284054932259, 966.157586219165, 974.986841619676, 916.559494755925,
935.817296050643, 918.835719171662, 1023.62078549133, 1009.23121097376,
1005.81651905991, 981.715747809821, 953.127134375762, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 974.889830301362, 970.58615968713, 963.029605541189,
915.889893279581, 908.147726780027, 942.742415528349, 979.939535179807,
1153.51966568673, 1020.93502990084, 916.246150801212, 936.016759720656,
914.4488779132, 962.397352323664, 986.957848140285, 985.364195731404,
932.548910038465, 917.363220594089, 1085.89850605988, 1031.66330597084,
1005.64983154588, 991.988118229379, 975.384741587994, 902.60240793926,
907.989086075871, 923.287310593779, 912.878571722023, 904.107623756648,
905.563259817979, 991.530368160932, 975.190212414434, 965.951810135591,
915.334621878897, 910.857441830446, 936.093336975328, 972.074491630181,
1106.77459226532, 993.45400883741, 951.911391767329, 927.688604859773,
915.194279622847, 971.414103170297, 956.138106650696, 965.458656222347,
944.097918792458, 947.157460200658, 1029.14870726558, 992.151638322899,
954.129642526236, 981.48182339388, 968.10870393618, 906.941701681267,
917.956716926981, 923.05649603805, 934.459432014683, 922.801034508827,
920.724850575215, 981.478432929603, 1012.67364507927, 966.471299899978,
912.640460101352, 906.34455384334, 923.738349342148, 970.987788560016,
1210.42940542072, 975.753397539076, 911.747488522664, 928.34872697947,
910.852487444859, 982.304620375747, 1028.52794775628, 913.408967803895,
934.334726415048, 916.354017093653, 1036.08727658415, 974.408618327141,
1004.71633485176, 995.142763465394, 987.00017276687, 906.86826042139,
915.355833226192, 930.395950341189, 911.742114273539, 905.725754800821,
912.194776217353, 979.488696998854, 998.766511802223, 968.436523426865,
916.299279627464, 907.645161223541, 925.30056793674, 978.067851389738,
1142.91274685359, 1001.53234105611, 916.842758017232, 924.907983103717,
922.470305986631, 992.855613565408, 955.757560902304, 929.20232030375,
943.535934437766, 923.58180450271, 1035.68330820385, 962.09501965608,
1035.71434011945, 999.021624049638, 1037.74929152155, 904.65540329816,
907.898446182233, 915.586965865012, 912.540978342886, 904.648950841522,
910.146698786639, 970.655222414677, 969.045225438776, 961.588678057607,
922.252864714149, 904.866433981365, 921.496292021655, 971.871605044557,
1075.02261709497, 1018.63215987506, 925.837889075039, 937.313874872585,
919.393974179406, 984.865480173384, 998.38173566307, 923.591922218561,
935.764591123357, 914.144404904734, 1064.07484543951, 1009.55385037395,
1003.07982307794, 1019.96770677478, 1023.43370663799, 1075.23648079772,
918.40638740207, 930.381596850856, 911.431923384541, 908.158538518039,
913.917742396318, 972.975539521988, 969.261073622988, 966.900828461146,
912.922987528198, 906.204515258546, 917.349668426986, 965.167090686302,
1033.80724280751, 1019.96323854891, 923.466492256566, 923.247012056591,
911.896005256495, 983.55323734271, 987.195939413696, 948.013535459932,
946.283282150572, 946.996017019961, 1018.55920835599, 983.790383328001,
1044.1241515621, 1025.44806232873, 1013.07125415424, 936.438305947314,
914.845558304809, 919.627558974215, 912.08306092659, 905.506361055768,
925.863591354922, 980.84672626416, 1034.50509678374, 999.432501149952,
914.013428128551, 903.385280147577, 914.982720974316, 987.521728519027,
1026.27371444455, 1003.6659923071, 936.860089156893, 922.376363123921,
909.301601087255, 949.125313633903, 983.891808931205, 928.514242776379,
931.528375870523, 934.663002673557, 983.163630767407, 958.520107194186,
1028.60002280789, 1027.26325499148, 1026.49504978946, 904.375575893285,
912.523756638651, 919.179127414697, 913.641605762865, 905.043751380124,
918.017612913947, 966.955539088111, 1083.03489991906, 982.779995986195,
913.039005945342, 901.569366267589, 924.344189118069, 986.456388413752,
1053.70140237407, 1012.4655295529, 918.216939699045, 924.376017342816,
912.32335834515, 962.020663167786, 968.751653626515, 923.781426521514,
934.702280304594, 945.072040784087, 972.171048113648, 980.160384144599,
1029.12422797868, 1045.60159108586, 1069.71097019503, 904.989955563463,
911.137606736246, 913.282276988181, 911.62618760385, 904.022814213797,
917.471586361699, 969.239603596626, 1092.64417075988, 995.598256664543,
911.352468377778, 903.930535551161, 934.598647851096, 968.529282541217,
1014.22774561852, 992.123001836286, 955.008951781314, 928.638327604534,
930.057703919378, 979.117036821698, 961.435436233545, 927.430280788518,
933.188144311621, 938.849731346915, 975.793676023678, 984.576641002029,
953.148108722352, 1025.14511979605, 987.536969976085, 904.469118373204,
919.724696002539, 921.494112907094, 933.99081130992, 910.883621211755,
919.830805764804, 973.217375644616, 1097.82345512272, 955.321702833728,
914.950887550846, 907.869650845588, 930.21996042144, 988.365255219924,
1072.82537699421, 941.505101156388, 912.978755227237, 924.00211814663,
926.073413421038, 975.963524978988, 966.347030574186, 927.813889117707,
938.87057229942, 937.20592642584, 1049.77079831674, 993.369595475566,
941.988672609005, 1036.52896057029, 1025.79874961742, 909.778142305324,
926.05520033663, 930.593948095488, 927.731349235947, 909.012240248148,
918.177023640935, 965.119279536339, 1100.04708794994, 950.187396378294,
913.95540287581, 908.285198789598, 928.585928045517, 1009.11449170465,
1048.43494462072, 1070.81842375631, 919.615682872958, 927.180388372158,
911.229890874478, 979.675336133848, 975.987038362197, 936.015685237366,
944.935422587313, 934.084922337254, 1065.1158215132, 960.558846324124,
954.324007605299, 1036.19891812821, 1000.52619841385, 904.622130948163,
911.66456482634, 952.40730926852, 925.617846758624, 907.103270618455,
921.775155162068, 962.660086144894, 1089.5423829539, 976.343009650736,
917.002530477079, 905.207509685187, 920.30422426818, 985.37894037379,
1032.27384329955, 974.803996932782)), class = "data.frame", row.names = c(85L,
86L, 87L, 89L, 90L, 91L, 99L, 100L, 101L, 103L, 104L, 105L, 113L,
114L, 115L, 117L, 118L, 119L, 127L, 128L, 129L, 131L, 132L, 133L,
141L, 142L, 143L, 145L, 146L, 147L, 155L, 156L, 157L, 159L, 160L,
161L, 169L, 170L, 171L, 173L, 174L, 175L, 183L, 184L, 185L, 187L,
188L, 189L, 197L, 198L, 199L, 201L, 202L, 203L, 211L, 212L, 213L,
215L, 216L, 217L, 225L, 226L, 227L, 229L, 230L, 231L, 239L, 240L,
241L, 243L, 244L, 245L, 253L, 254L, 255L, 257L, 258L, 259L, 267L,
268L, 269L, 271L, 272L, 273L, 615L, 616L, 617L, 619L, 620L, 622L,
623L, 624L, 626L, 627L, 629L, 630L, 631L, 640L, 641L, 642L, 643L,
644L, 645L, 647L, 648L, 649L, 651L, 652L, 653L, 655L, 656L, 657L,
659L, 660L, 661L, 663L, 664L, 666L, 667L, 668L, 670L, 671L, 673L,
674L, 675L, 684L, 685L, 686L, 687L, 688L, 689L, 691L, 692L, 693L,
695L, 696L, 697L, 699L, 700L, 701L, 703L, 704L, 705L, 707L, 708L,
710L, 711L, 712L, 714L, 715L, 717L, 718L, 719L, 728L, 729L, 730L,
731L, 732L, 733L, 735L, 736L, 737L, 739L, 740L, 741L, 743L, 744L,
745L, 747L, 748L, 749L, 751L, 752L, 754L, 755L, 756L, 758L, 759L,
761L, 762L, 763L, 772L, 773L, 774L, 775L, 776L, 777L, 779L, 780L,
781L, 783L, 784L, 785L, 787L, 788L, 789L, 791L, 792L, 793L, 795L,
796L, 798L, 799L, 800L, 802L, 803L, 805L, 806L, 807L, 816L, 817L,
818L, 819L, 820L, 821L, 823L, 824L, 825L, 827L, 828L, 829L, 831L,
832L, 833L, 835L, 836L, 837L, 839L, 840L, 842L, 843L, 844L, 846L,
847L, 849L, 850L, 851L, 860L, 861L, 862L, 863L, 864L, 865L, 867L,
868L, 869L, 871L, 872L, 873L, 875L, 876L, 877L, 879L, 880L, 881L,
883L, 884L, 886L, 887L, 888L, 890L, 891L, 893L, 894L, 895L, 904L,
905L, 906L, 907L, 908L, 909L, 911L, 912L, 913L, 915L, 916L, 917L,
919L, 920L, 921L, 923L, 924L, 925L, 927L, 928L, 930L, 931L, 932L,
934L, 935L, 937L, 938L, 939L, 948L, 949L, 950L, 951L, 952L, 953L,
955L, 956L, 957L, 959L, 960L, 961L, 963L, 964L, 965L, 967L, 968L,
969L, 971L, 972L, 974L, 975L, 976L, 978L, 979L, 981L, 982L, 983L,
992L, 993L, 994L, 995L, 996L, 997L, 999L, 1000L, 1001L, 1003L,
1004L, 1005L, 1007L, 1008L, 1009L, 1011L, 1012L, 1013L, 1015L,
1016L, 1018L, 1019L, 1020L, 1022L, 1023L, 1025L, 1026L, 1027L,
1036L, 1037L, 1038L, 1039L, 1040L, 1041L, 1043L, 1044L, 1045L,
1047L, 1048L, 1049L, 1051L, 1052L, 1053L, 1055L, 1056L, 1057L,
1059L, 1060L, 1062L, 1063L, 1064L, 1066L, 1067L, 1069L, 1070L,
1071L, 1080L, 1081L, 1082L, 1083L, 1084L, 1085L, 1087L, 1088L,
1089L, 1091L, 1092L, 1093L, 1095L, 1096L, 1097L, 1099L, 1100L,
1101L, 1103L, 1104L, 1106L, 1107L, 1108L, 1110L, 1111L, 1113L,
1114L, 1115L, 1124L, 1125L, 1126L, 1127L, 1128L, 1129L, 1131L,
1132L, 1133L, 1135L, 1136L, 1137L, 1139L, 1140L, 1141L, 1143L,
1144L, 1145L, 1147L, 1148L, 1150L, 1151L, 1152L, 1154L, 1155L,
1157L, 1158L, 1159L, 1168L, 1169L, 1170L, 1171L, 1172L, 1173L,
1175L, 1176L, 1177L, 1179L, 1180L, 1181L, 1183L, 1184L, 1185L,
1187L, 1188L, 1189L, 1191L, 1192L, 1194L, 1195L, 1196L, 1198L,
1199L, 1201L, 1202L, 1203L, 1212L, 1213L, 1214L, 1215L, 1216L,
1217L, 1219L, 1220L, 1221L, 1223L, 1224L, 1225L, 1227L, 1228L,
1229L))
Here is the code (I think) that would be needed to fit the model and see the summary after the above data is loaded:
library(lme4)
library(lmerTest)
fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
fit2 <- lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
summary(fit1)
#or
summary(fit2)
I think this has to do with my data structure and the programming but if it is actually something to do with the stats I am happy to take this post down and re-post over at the stats stackexchange.
Thanks for any help!
note: although your question is about the lmer() function, this answer also applies to lm() and other R functions that fit linear models.
The way that coefficient estimates from linear models in R are presented can be confusing. To understand what's going on, you need to understand how R fits linear models when the predictor is a factor variable.
Coefficients on factor variables in R linear models
Before we look at factor variables, let's look at the more straightforward situation where the predictor is continuous. In your example dataset, one of the predictors is wind speed (continuous variable). The estimated coefficient is about -0.35. It's easy to interpret this: averaged across the other predictors, for every increase of 1 km/h in wind speed, your response value is predicted to decrease by 0.35.
But what about if the predictor is a factor? A categorical variable cannot increase or decrease by 1. Instead it can take several discrete values. So what the lmer() or lm() function does by default is automatically code your factor variable as a set of so-called "dummy variables." Dummy variables are binary (they can take values of 0 or 1). If the factor variable has n levels, you need n-1 dummy variables to encode it. The reference level or control group acts like an intercept.
In the case of your habitat variable, there are only 2 levels so you have only 1 dummy variable which will be 0 if habitat is not Forest and 1 if it is Forest. Now we can interpret the coefficient estimate of -68.8: the average value of your response is expected to be 68.8 less in forest habitat relative to the reference level of grassland habitat. You don't need a second dummy variable for grassland because you only need to estimate the one coefficient to compare the two habitats.
If you had a third habitat, let's say wetland, there would be a second dummy variable that would be 0 if not wetland and 1 if wetland. The coefficient estimate there would be the expected difference between the value of the response variable in wetland habitat compared to grassland habitat. Grassland will be the reference level for all the coefficients.
Default setting of reference level
Now to directly address your question of why habitatForest is the coefficient name.
Because by default no reference level or control group is specified, the first one in the factor level ordering becomes the reference level to which all other levels are compared. Then the coefficients are named by appending the variable's name to the name of the level being compared to the reference level. Your factor is ordered with grassland first and forest second. So the coefficient is the effect of the habitat being forest habitat, compared to the reference level, which is grassland in this case. If you switched the habitat factor level ordering, Forest would be the reference level and you would get habitatGrassland as the coefficient instead. (Note that default factor level ordering is alphabetical, so without specifically ordering the factor levels as you seem to have done, Forest would be the reference level by default).
Incidentally, the two links you give in your question (guides to mixed models from Phillip Alday and Tufts) do in fact have the same kind of output as you are getting. For example in Alday's tutorial, the factor recipe has 3 levels: A, B, and C. There are two coefficients in the fixed effects summary, recipeB and recipeC, just as you would expect from dummy coding using A as reference level. You may be confusing the fixed effects summary with the ANOVA table presented elsewhere in his post. The ANOVA table does only have a single line for recipe which gives you the ratio of variance due to recipe (across all its levels) and the total variance. So that would only be one ratio regardless of how many levels recipe has.
Further reading
This is not the place for a full discussion of contrast coding in linear models in R. The dummy coding (which you may also see called one-hot encoding) I described here is just one way to do it. These resources may be helpful:
Documentation for the base R function contrasts()
description of different types of categorical variable coding in R from UCLA IDRE Stats
Marissa Barlaz' tutorial on R contrast coding

Why does the output of of a linear mixed model using lme4 show one level of a factor but not another?

I am using the lme4 package and running a linear mixed model but I am confused but the output and expect that I am encountering an error even though I do not get an error message.
The basic issue is when I fit a model like lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
and then look at the results using something like summary I see all the model fixed (and random) effects as I would expect however the habitat effect is always displayed as habitatForest. Like this:
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 996.63179 8.16633 31.22730 122.042 < 2e-16 ***
stimuliBHCO -3.57541 1.28877 8750.89273 -2.774 0.005544 **
stimuliCOHA -10.17037 1.29546 8754.17156 -7.851 4.62e-15 ***
timeperiod 0.19900 0.05516 8744.95307 3.608 0.000310 ***
scale(poly(distance.code, 3, raw = FALSE))1 -3.87613 0.71431 8745.70773 -5.426 5.90e-08 ***
scale(poly(distance.code, 3, raw = FALSE))2 2.65854 0.71463 8745.19353 3.720 0.000200 ***
scale(poly(distance.code, 3, raw = FALSE))3 4.66340 0.72262 8745.67948 6.453 1.15e-10 ***
habitatForest -68.82430 11.83009 29.95226 -5.818 2.34e-06 ***
wind.speed -0.35853 0.07631 8403.15191 -4.698 2.66e-06 ***
scale(poly(distance.code, 3, raw = FALSE))1:habitatForest 2.89860 1.03891 8745.46534 2.790 0.005282 **
scale(poly(distance.code, 3, raw = FALSE))2:habitatForest -3.49758 1.03829 8745.11371 -3.369 0.000759 ***
scale(poly(distance.code, 3, raw = FALSE))3:habitatForest -4.67300 1.03913 8745.30579 -4.497 6.98e-06 ***
---
This is happening even though there are two levels of habitat (Forest and Grassland)
at first, I thought this might be because my model had an interaction term but it happens when I try a simpler model like lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
Why would it say "habitatForest" and not just "habitat" or if it were going to include a factor by name why not say "habitatForest" and "habitatGrassland"?
A quick look at the expected output from this function here: https://rpubs.com/palday/mixed-interactions or here: https://ase.tufts.edu/bugs/guide/assets/mixed_model_guide.html (among others)
shows that the out put that I am getting is not what is expected or normal.
Other output I have seen simply have factors with two levels, like mine, as a single line (eg habitat).
Here is a portion of the data I am using. I used dput and subseting to produce this. I couldn't figure out how to make the data set smaller and still reproduce the error so I apologize if this is too large. The data set that it comes from is MUCH bigger! (also please let me know if I have used dput incorrectly.(Still new to R and stackoverflow)
structure(list(location.code = structure(c(1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 4L, 4L, 4L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 4L, 4L, 4L, 3L, 3L, 3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, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("Grassland",
"Forest"), class = "factor"), distance.code = c(0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L,
30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L,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 50, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65,
65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55,
55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65,
65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9), timeperiod = c(6L, 6L, 6L,
6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L,
17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L,
20L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L), Values = c(910.721895276374, 922.652711611841,
926.219785713456, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 992.059286431433,
1042.05240231832, 1018.99804250179, 911.976009884021, 918.215389274037,
931.037495260958, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 994.583211567691,
1006.58290843226, 1005.52479816571, 908.665064025178, 917.940176257067,
922.746174825048, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 982.154409713674,
1008.54477137219, 996.577798511801, 912.914857937818, 916.937508116615,
920.933077377339, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 983.866984633392,
1002.04551764872, 986.791628665069, 907.695668282537, 917.845214744473,
932.330755620455, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 1000.3672969178,
1021.78461788922, 1011.40975353271, 915.037273600535, 914.099859036178,
924.116937361394, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 974.273124973661,
1145.99211507205, 1013.58184367388, 913.467056616881, 920.213007520924,
919.794369158301, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 1015.24811721269,
1070.61183211249, 1016.57332551186, 910.196695694198, 923.403802532832,
905.400995326023, 1036.98011238981, 963.147077473505, 916.899569521736,
931.240844862156, 919.11781354823, 995.408916523572, 960.825305234446,
1026.22960551445, 1000.13773127026, 962.347584090332, 904.090295814044,
908.836747102913, 928.867625382891, 918.100799763641, 906.282906701285,
913.146312873635, 977.094140033575, 972.599778534534, 964.658406857446,
921.91272768213, 910.507770576621, 942.269786765654, 1014.34022271036,
1128.29327664605, 1043.1365958913, 919.185972424773, 925.486310755197,
908.769520270226, 1030.20866627018, 956.104935565803, 922.01947330213,
934.451182538208, 928.626906337293, 986.326936258622, 1003.40797963907,
1021.91264348048, 995.68658929192, 993.102343807935, 901.633626404701,
908.255562868123, 922.840049924103, 917.012733437446, 907.541530752433,
915.050696506642, 983.542956895186, 972.236377246083, 965.082329354352,
918.337944633569, 910.137012141557, 952.89462134025, 977.420371016686,
1154.17994731565, 1022.82998099991, 927.061613377597, 926.745527716988,
908.284054932259, 966.157586219165, 974.986841619676, 916.559494755925,
935.817296050643, 918.835719171662, 1023.62078549133, 1009.23121097376,
1005.81651905991, 981.715747809821, 953.127134375762, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 974.889830301362, 970.58615968713, 963.029605541189,
915.889893279581, 908.147726780027, 942.742415528349, 979.939535179807,
1153.51966568673, 1020.93502990084, 916.246150801212, 936.016759720656,
914.4488779132, 962.397352323664, 986.957848140285, 985.364195731404,
932.548910038465, 917.363220594089, 1085.89850605988, 1031.66330597084,
1005.64983154588, 991.988118229379, 975.384741587994, 902.60240793926,
907.989086075871, 923.287310593779, 912.878571722023, 904.107623756648,
905.563259817979, 991.530368160932, 975.190212414434, 965.951810135591,
915.334621878897, 910.857441830446, 936.093336975328, 972.074491630181,
1106.77459226532, 993.45400883741, 951.911391767329, 927.688604859773,
915.194279622847, 971.414103170297, 956.138106650696, 965.458656222347,
944.097918792458, 947.157460200658, 1029.14870726558, 992.151638322899,
954.129642526236, 981.48182339388, 968.10870393618, 906.941701681267,
917.956716926981, 923.05649603805, 934.459432014683, 922.801034508827,
920.724850575215, 981.478432929603, 1012.67364507927, 966.471299899978,
912.640460101352, 906.34455384334, 923.738349342148, 970.987788560016,
1210.42940542072, 975.753397539076, 911.747488522664, 928.34872697947,
910.852487444859, 982.304620375747, 1028.52794775628, 913.408967803895,
934.334726415048, 916.354017093653, 1036.08727658415, 974.408618327141,
1004.71633485176, 995.142763465394, 987.00017276687, 906.86826042139,
915.355833226192, 930.395950341189, 911.742114273539, 905.725754800821,
912.194776217353, 979.488696998854, 998.766511802223, 968.436523426865,
916.299279627464, 907.645161223541, 925.30056793674, 978.067851389738,
1142.91274685359, 1001.53234105611, 916.842758017232, 924.907983103717,
922.470305986631, 992.855613565408, 955.757560902304, 929.20232030375,
943.535934437766, 923.58180450271, 1035.68330820385, 962.09501965608,
1035.71434011945, 999.021624049638, 1037.74929152155, 904.65540329816,
907.898446182233, 915.586965865012, 912.540978342886, 904.648950841522,
910.146698786639, 970.655222414677, 969.045225438776, 961.588678057607,
922.252864714149, 904.866433981365, 921.496292021655, 971.871605044557,
1075.02261709497, 1018.63215987506, 925.837889075039, 937.313874872585,
919.393974179406, 984.865480173384, 998.38173566307, 923.591922218561,
935.764591123357, 914.144404904734, 1064.07484543951, 1009.55385037395,
1003.07982307794, 1019.96770677478, 1023.43370663799, 1075.23648079772,
918.40638740207, 930.381596850856, 911.431923384541, 908.158538518039,
913.917742396318, 972.975539521988, 969.261073622988, 966.900828461146,
912.922987528198, 906.204515258546, 917.349668426986, 965.167090686302,
1033.80724280751, 1019.96323854891, 923.466492256566, 923.247012056591,
911.896005256495, 983.55323734271, 987.195939413696, 948.013535459932,
946.283282150572, 946.996017019961, 1018.55920835599, 983.790383328001,
1044.1241515621, 1025.44806232873, 1013.07125415424, 936.438305947314,
914.845558304809, 919.627558974215, 912.08306092659, 905.506361055768,
925.863591354922, 980.84672626416, 1034.50509678374, 999.432501149952,
914.013428128551, 903.385280147577, 914.982720974316, 987.521728519027,
1026.27371444455, 1003.6659923071, 936.860089156893, 922.376363123921,
909.301601087255, 949.125313633903, 983.891808931205, 928.514242776379,
931.528375870523, 934.663002673557, 983.163630767407, 958.520107194186,
1028.60002280789, 1027.26325499148, 1026.49504978946, 904.375575893285,
912.523756638651, 919.179127414697, 913.641605762865, 905.043751380124,
918.017612913947, 966.955539088111, 1083.03489991906, 982.779995986195,
913.039005945342, 901.569366267589, 924.344189118069, 986.456388413752,
1053.70140237407, 1012.4655295529, 918.216939699045, 924.376017342816,
912.32335834515, 962.020663167786, 968.751653626515, 923.781426521514,
934.702280304594, 945.072040784087, 972.171048113648, 980.160384144599,
1029.12422797868, 1045.60159108586, 1069.71097019503, 904.989955563463,
911.137606736246, 913.282276988181, 911.62618760385, 904.022814213797,
917.471586361699, 969.239603596626, 1092.64417075988, 995.598256664543,
911.352468377778, 903.930535551161, 934.598647851096, 968.529282541217,
1014.22774561852, 992.123001836286, 955.008951781314, 928.638327604534,
930.057703919378, 979.117036821698, 961.435436233545, 927.430280788518,
933.188144311621, 938.849731346915, 975.793676023678, 984.576641002029,
953.148108722352, 1025.14511979605, 987.536969976085, 904.469118373204,
919.724696002539, 921.494112907094, 933.99081130992, 910.883621211755,
919.830805764804, 973.217375644616, 1097.82345512272, 955.321702833728,
914.950887550846, 907.869650845588, 930.21996042144, 988.365255219924,
1072.82537699421, 941.505101156388, 912.978755227237, 924.00211814663,
926.073413421038, 975.963524978988, 966.347030574186, 927.813889117707,
938.87057229942, 937.20592642584, 1049.77079831674, 993.369595475566,
941.988672609005, 1036.52896057029, 1025.79874961742, 909.778142305324,
926.05520033663, 930.593948095488, 927.731349235947, 909.012240248148,
918.177023640935, 965.119279536339, 1100.04708794994, 950.187396378294,
913.95540287581, 908.285198789598, 928.585928045517, 1009.11449170465,
1048.43494462072, 1070.81842375631, 919.615682872958, 927.180388372158,
911.229890874478, 979.675336133848, 975.987038362197, 936.015685237366,
944.935422587313, 934.084922337254, 1065.1158215132, 960.558846324124,
954.324007605299, 1036.19891812821, 1000.52619841385, 904.622130948163,
911.66456482634, 952.40730926852, 925.617846758624, 907.103270618455,
921.775155162068, 962.660086144894, 1089.5423829539, 976.343009650736,
917.002530477079, 905.207509685187, 920.30422426818, 985.37894037379,
1032.27384329955, 974.803996932782)), class = "data.frame", row.names = c(85L,
86L, 87L, 89L, 90L, 91L, 99L, 100L, 101L, 103L, 104L, 105L, 113L,
114L, 115L, 117L, 118L, 119L, 127L, 128L, 129L, 131L, 132L, 133L,
141L, 142L, 143L, 145L, 146L, 147L, 155L, 156L, 157L, 159L, 160L,
161L, 169L, 170L, 171L, 173L, 174L, 175L, 183L, 184L, 185L, 187L,
188L, 189L, 197L, 198L, 199L, 201L, 202L, 203L, 211L, 212L, 213L,
215L, 216L, 217L, 225L, 226L, 227L, 229L, 230L, 231L, 239L, 240L,
241L, 243L, 244L, 245L, 253L, 254L, 255L, 257L, 258L, 259L, 267L,
268L, 269L, 271L, 272L, 273L, 615L, 616L, 617L, 619L, 620L, 622L,
623L, 624L, 626L, 627L, 629L, 630L, 631L, 640L, 641L, 642L, 643L,
644L, 645L, 647L, 648L, 649L, 651L, 652L, 653L, 655L, 656L, 657L,
659L, 660L, 661L, 663L, 664L, 666L, 667L, 668L, 670L, 671L, 673L,
674L, 675L, 684L, 685L, 686L, 687L, 688L, 689L, 691L, 692L, 693L,
695L, 696L, 697L, 699L, 700L, 701L, 703L, 704L, 705L, 707L, 708L,
710L, 711L, 712L, 714L, 715L, 717L, 718L, 719L, 728L, 729L, 730L,
731L, 732L, 733L, 735L, 736L, 737L, 739L, 740L, 741L, 743L, 744L,
745L, 747L, 748L, 749L, 751L, 752L, 754L, 755L, 756L, 758L, 759L,
761L, 762L, 763L, 772L, 773L, 774L, 775L, 776L, 777L, 779L, 780L,
781L, 783L, 784L, 785L, 787L, 788L, 789L, 791L, 792L, 793L, 795L,
796L, 798L, 799L, 800L, 802L, 803L, 805L, 806L, 807L, 816L, 817L,
818L, 819L, 820L, 821L, 823L, 824L, 825L, 827L, 828L, 829L, 831L,
832L, 833L, 835L, 836L, 837L, 839L, 840L, 842L, 843L, 844L, 846L,
847L, 849L, 850L, 851L, 860L, 861L, 862L, 863L, 864L, 865L, 867L,
868L, 869L, 871L, 872L, 873L, 875L, 876L, 877L, 879L, 880L, 881L,
883L, 884L, 886L, 887L, 888L, 890L, 891L, 893L, 894L, 895L, 904L,
905L, 906L, 907L, 908L, 909L, 911L, 912L, 913L, 915L, 916L, 917L,
919L, 920L, 921L, 923L, 924L, 925L, 927L, 928L, 930L, 931L, 932L,
934L, 935L, 937L, 938L, 939L, 948L, 949L, 950L, 951L, 952L, 953L,
955L, 956L, 957L, 959L, 960L, 961L, 963L, 964L, 965L, 967L, 968L,
969L, 971L, 972L, 974L, 975L, 976L, 978L, 979L, 981L, 982L, 983L,
992L, 993L, 994L, 995L, 996L, 997L, 999L, 1000L, 1001L, 1003L,
1004L, 1005L, 1007L, 1008L, 1009L, 1011L, 1012L, 1013L, 1015L,
1016L, 1018L, 1019L, 1020L, 1022L, 1023L, 1025L, 1026L, 1027L,
1036L, 1037L, 1038L, 1039L, 1040L, 1041L, 1043L, 1044L, 1045L,
1047L, 1048L, 1049L, 1051L, 1052L, 1053L, 1055L, 1056L, 1057L,
1059L, 1060L, 1062L, 1063L, 1064L, 1066L, 1067L, 1069L, 1070L,
1071L, 1080L, 1081L, 1082L, 1083L, 1084L, 1085L, 1087L, 1088L,
1089L, 1091L, 1092L, 1093L, 1095L, 1096L, 1097L, 1099L, 1100L,
1101L, 1103L, 1104L, 1106L, 1107L, 1108L, 1110L, 1111L, 1113L,
1114L, 1115L, 1124L, 1125L, 1126L, 1127L, 1128L, 1129L, 1131L,
1132L, 1133L, 1135L, 1136L, 1137L, 1139L, 1140L, 1141L, 1143L,
1144L, 1145L, 1147L, 1148L, 1150L, 1151L, 1152L, 1154L, 1155L,
1157L, 1158L, 1159L, 1168L, 1169L, 1170L, 1171L, 1172L, 1173L,
1175L, 1176L, 1177L, 1179L, 1180L, 1181L, 1183L, 1184L, 1185L,
1187L, 1188L, 1189L, 1191L, 1192L, 1194L, 1195L, 1196L, 1198L,
1199L, 1201L, 1202L, 1203L, 1212L, 1213L, 1214L, 1215L, 1216L,
1217L, 1219L, 1220L, 1221L, 1223L, 1224L, 1225L, 1227L, 1228L,
1229L))
Here is the code (I think) that would be needed to fit the model and see the summary after the above data is loaded:
library(lme4)
library(lmerTest)
fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
fit2 <- lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
summary(fit1)
#or
summary(fit2)
I think this has to do with my data structure and the programming but if it is actually something to do with the stats I am happy to take this post down and re-post over at the stats stackexchange.
Thanks for any help!
note: although your question is about the lmer() function, this answer also applies to lm() and other R functions that fit linear models.
The way that coefficient estimates from linear models in R are presented can be confusing. To understand what's going on, you need to understand how R fits linear models when the predictor is a factor variable.
Coefficients on factor variables in R linear models
Before we look at factor variables, let's look at the more straightforward situation where the predictor is continuous. In your example dataset, one of the predictors is wind speed (continuous variable). The estimated coefficient is about -0.35. It's easy to interpret this: averaged across the other predictors, for every increase of 1 km/h in wind speed, your response value is predicted to decrease by 0.35.
But what about if the predictor is a factor? A categorical variable cannot increase or decrease by 1. Instead it can take several discrete values. So what the lmer() or lm() function does by default is automatically code your factor variable as a set of so-called "dummy variables." Dummy variables are binary (they can take values of 0 or 1). If the factor variable has n levels, you need n-1 dummy variables to encode it. The reference level or control group acts like an intercept.
In the case of your habitat variable, there are only 2 levels so you have only 1 dummy variable which will be 0 if habitat is not Forest and 1 if it is Forest. Now we can interpret the coefficient estimate of -68.8: the average value of your response is expected to be 68.8 less in forest habitat relative to the reference level of grassland habitat. You don't need a second dummy variable for grassland because you only need to estimate the one coefficient to compare the two habitats.
If you had a third habitat, let's say wetland, there would be a second dummy variable that would be 0 if not wetland and 1 if wetland. The coefficient estimate there would be the expected difference between the value of the response variable in wetland habitat compared to grassland habitat. Grassland will be the reference level for all the coefficients.
Default setting of reference level
Now to directly address your question of why habitatForest is the coefficient name.
Because by default no reference level or control group is specified, the first one in the factor level ordering becomes the reference level to which all other levels are compared. Then the coefficients are named by appending the variable's name to the name of the level being compared to the reference level. Your factor is ordered with grassland first and forest second. So the coefficient is the effect of the habitat being forest habitat, compared to the reference level, which is grassland in this case. If you switched the habitat factor level ordering, Forest would be the reference level and you would get habitatGrassland as the coefficient instead. (Note that default factor level ordering is alphabetical, so without specifically ordering the factor levels as you seem to have done, Forest would be the reference level by default).
Incidentally, the two links you give in your question (guides to mixed models from Phillip Alday and Tufts) do in fact have the same kind of output as you are getting. For example in Alday's tutorial, the factor recipe has 3 levels: A, B, and C. There are two coefficients in the fixed effects summary, recipeB and recipeC, just as you would expect from dummy coding using A as reference level. You may be confusing the fixed effects summary with the ANOVA table presented elsewhere in his post. The ANOVA table does only have a single line for recipe which gives you the ratio of variance due to recipe (across all its levels) and the total variance. So that would only be one ratio regardless of how many levels recipe has.
Further reading
This is not the place for a full discussion of contrast coding in linear models in R. The dummy coding (which you may also see called one-hot encoding) I described here is just one way to do it. These resources may be helpful:
Documentation for the base R function contrasts()
description of different types of categorical variable coding in R from UCLA IDRE Stats
Marissa Barlaz' tutorial on R contrast coding

Error using 'poly': 'degree' must be less than number of unique points while using 'effects' package

I am trying to use the effects package to create plots of effects in a linear mixed model. I specify the model
fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)
For this model I can generate results for analysis as I expect using summary or anova but when I try to look at specific effects:
allEffects(fit1)
#or
plot(allEffects(fit1))
#or
emmeans(fit1, pairwise ~ stimuli)
An error is returned:
Error in poly(distance.code, 3, raw = FALSE) :
'degree' must be less than number of unique points
(with the plot function the error is different but is probably arising from the error with allEffects)
I understand, based on the responses to this question and this question, that "numerical overflow" can be an issue with poly terms. However, I am not clear on what this means or how to overcome the issue.
I also saw in this post and in another post about lme4 that I can no longer find, that I might need to update packages so I have updated 'effects' and 'lme4' in an attempt to remedy this but to no avail.
So if this error is happening because of "numerical overflow" how can I remedy the problem? or if it is not numerical overflow what is happening and how can I work around this?
a subset of my data using dput is:
structure(list(location.code = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 4L, 4L, 4L, 4L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 4L, 1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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, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("before",
"during", "after"), class = "factor"), timeperiod = c(6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L), distance.code = c(0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L,
120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
120L, 0L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 120L, 0L,
60L, 120L, 0L, 30L, 60L, 120L, 0L, 60L, 120L, 0L, 30L, 60L),
Values = c(910.721895276374, 922.652711611841, 926.219785713456,
918.776924477918, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 917.610324052986,
992.059286431433, 1042.05240231832, 1018.99804250179, 911.976009884021,
918.215389274037, 931.037495260958, 913.49701806948, 981.032280455129,
983.700699744073, 989.716307418049, 911.476759038955, 918.554393750162,
920.391856289719, 911.795802370903, 994.583211567691, 1006.58290843226,
1005.52479816571, 908.665064025178, 917.940176257067, 922.746174825048,
921.752449434568, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 924.221021573334,
982.154409713674, 1008.54477137219, 996.577798511801, 912.914857937818,
916.937508116615, 920.933077377339, 917.443294381608, 997.669828575817,
1007.44452218386, 1151.25894192961, 909.463528658898, 915.293665875472,
921.917039784441, 912.073280663674, 983.866984633392, 1002.04551764872,
986.791628665069, 907.695668282537, 917.845214744473, 932.330755620455,
917.500330773026, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 914.498616645498,
1000.3672969178, 1021.78461788922, 1011.40975353271, 915.037273600535,
914.099859036178, 924.116937361394, 913.523739017819, 994.428182266452,
1123.09745015276, 1004.1485272116, 914.431649376896, 915.27037594587,
929.411251949862, 910.549315840806, 974.273124973661, 1145.99211507205,
1013.58184367388, 913.467056616881, 920.213007520924, 919.794369158301,
912.333012054637, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 913.432298686233,
1015.24811721269, 1070.61183211249, 1016.57332551186, 910.196695694198,
923.403802532832, 905.400995326023, 934.612035397761, 1036.98011238981,
963.147077473505, 953.792949959199, 916.899569521736, 931.240844862156,
919.11781354823, 938.028220926723, 995.408916523572, 960.825305234446,
993.019295484939, 1026.22960551445, 1000.13773127026, 962.347584090332,
1074.31979099791, 904.090295814044, 908.836747102913, 928.867625382891,
918.100799763641, 906.282906701285, 913.146312873635, 921.224088728859,
977.094140033575, 972.599778534534, 964.658406857446, 1197.35130424458,
921.91272768213, 910.507770576621, 942.269786765654, 922.718235872787,
1014.34022271036, 1128.29327664605, 1043.1365958913, 1238.18704569961,
919.185972424773, 925.486310755197, 908.769520270226, 919.644447501213,
1030.20866627018, 956.104935565803, 955.159231718685, 922.01947330213,
934.451182538208, 928.626906337293, 941.089746683706, 986.326936258622,
1003.40797963907, 1007.57786522109, 1021.91264348048, 995.68658929192,
993.102343807935, 1114.80420865448, 901.633626404701, 908.255562868123,
922.840049924103, 917.012733437446, 907.541530752433, 915.050696506642,
925.95358291661, 983.542956895186, 972.236377246083, 965.082329354352,
1205.36753472358, 918.337944633569, 910.137012141557, 952.89462134025,
923.334999242316, 977.420371016686, 1154.17994731565, 1022.82998099991,
1186.66254220951, 927.061613377597, 926.745527716988, 908.284054932259,
921.213190559531, 966.157586219165, 974.986841619676, 959.421220417498,
916.559494755925, 935.817296050643, 918.835719171662, 912.457217113586,
1023.62078549133, 1009.23121097376, 978.938675917385, 1005.81651905991,
981.715747809821, 953.127134375762, 1088.16577366048, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 918.91715550342, 974.889830301362, 970.58615968713,
963.029605541189, 1182.94093491074, 915.889893279581, 908.147726780027,
942.742415528349, 928.20319656241, 979.939535179807, 1153.51966568673,
1020.93502990084, 1154.799618481, 916.246150801212, 936.016759720656,
914.4488779132, 918.823772018551, 962.397352323664, 986.957848140285,
972.131488585193, 985.364195731404, 932.548910038465, 917.363220594089,
919.124801182577, 1085.89850605988, 1031.66330597084, 974.763804119707,
1005.64983154588, 991.988118229379, 975.384741587994, 1064.14809010237,
902.60240793926, 907.989086075871, 923.287310593779, 912.878571722023,
904.107623756648, 905.563259817979, 917.423553921906, 991.530368160932,
975.190212414434, 965.951810135591, 1192.3330908297, 915.334621878897,
910.857441830446, 936.093336975328, 932.960789822422, 972.074491630181,
1106.77459226532, 993.45400883741, 1138.94109332484, 951.911391767329,
927.688604859773, 915.194279622847, 920.98264624041, 971.414103170297,
956.138106650696, 969.385400747507, 965.458656222347, 944.097918792458,
947.157460200658, 915.929397317864, 1029.14870726558, 992.151638322899,
964.680220137879, 954.129642526236, 981.48182339388, 968.10870393618,
1097.48462256339, 906.941701681267, 917.956716926981, 923.05649603805,
934.459432014683, 922.801034508827, 920.724850575215, 935.811146196027,
981.478432929603, 1012.67364507927, 966.471299899978, 1192.4066704659,
912.640460101352, 906.34455384334, 923.738349342148, 916.883929696437,
970.987788560016, 1210.42940542072, 975.753397539076, 1138.97675920151,
911.747488522664, 928.34872697947, 910.852487444859, 916.227875349016,
982.304620375747, 1028.52794775628, 999.236663664046, 913.408967803895,
934.334726415048, 916.354017093653, 918.660674732388, 1036.08727658415,
974.408618327141, 1006.21629092128, 1004.71633485176, 995.142763465394,
987.00017276687), wind.speed = c(0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8,
0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8,
0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8,
0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2,
0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 65, 65, 65,
65, 65, 65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9,
0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50, 50,
50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0.9, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55,
55, 55, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65,
65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50, 50, 50, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 65, 65, 55, 55, 55, 55, 50,
50, 50, 0, 0, 0)), row.names = c(85L, 86L, 87L, 88L, 89L,
90L, 91L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 113L, 114L,
115L, 116L, 117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L,
133L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 155L, 156L, 157L,
158L, 159L, 160L, 161L, 169L, 170L, 171L, 172L, 173L, 174L, 175L,
183L, 184L, 185L, 186L, 187L, 188L, 189L, 197L, 198L, 199L, 200L,
201L, 202L, 203L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 225L,
226L, 227L, 228L, 229L, 230L, 231L, 239L, 240L, 241L, 242L, 243L,
244L, 245L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 267L, 268L,
269L, 270L, 271L, 272L, 273L, 615L, 616L, 617L, 618L, 619L, 620L,
621L, 622L, 623L, 624L, 625L, 626L, 627L, 628L, 629L, 630L, 631L,
632L, 640L, 641L, 642L, 643L, 644L, 645L, 646L, 647L, 648L, 649L,
650L, 651L, 652L, 653L, 654L, 655L, 656L, 657L, 658L, 659L, 660L,
661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 669L, 670L, 671L,
672L, 673L, 674L, 675L, 676L, 684L, 685L, 686L, 687L, 688L, 689L,
690L, 691L, 692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L,
701L, 702L, 703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L,
712L, 713L, 714L, 715L, 716L, 717L, 718L, 719L, 720L, 728L, 729L,
730L, 731L, 732L, 733L, 734L, 735L, 736L, 737L, 738L, 739L, 740L,
741L, 742L, 743L, 744L, 745L, 746L, 747L, 748L, 749L, 750L, 751L,
752L, 753L, 754L, 755L, 756L, 757L, 758L, 759L, 760L, 761L, 762L,
763L, 764L, 772L, 773L, 774L, 775L, 776L, 777L, 778L, 779L, 780L,
781L, 782L, 783L, 784L, 785L, 786L, 787L, 788L, 789L, 790L, 791L,
792L, 793L, 794L, 795L, 796L, 797L, 798L, 799L, 800L, 801L, 802L,
803L, 804L, 805L, 806L, 807L, 808L, 816L, 817L, 818L, 819L, 820L,
821L, 822L, 823L, 824L, 825L, 826L, 827L, 828L, 829L, 830L, 831L,
832L, 833L, 834L, 835L, 836L, 837L, 838L, 839L, 840L, 841L, 842L,
843L, 844L, 845L, 846L, 847L, 848L, 849L, 850L, 851L), class = "data.frame")
> ex.df <- head(ex.df, 100)
> dput(ex.df)
structure(list(location.code = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L), .Label = c("BSF1",
"BSG1", "RLF3", "RLG3", "CCBSF1", "CCBSG1", "CPF1", "CPF2", "CPG1",
"CPG2", "OSG1", "OSG2", "RLF4", "RLF5", "RLF1", "RLF2", "RLG1",
"RLG2", "BNPF1", "BNPG1", "OSG3", "OSF1", "CMG3", "CMF1", "BSG2",
"BSG3", "WSF1", "WSF2", "HPG1", "HPG2"), class = "factor"), stimuli = structure(c(3L,
3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 1L), .Label = c("FOSP", "BHCO", "COHA", "YEWA", "TUTI"
), class = "factor"), habitat = structure(c(2L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L), .Label = c("Grassland",
"Forest"), class = "factor"), exp.period = 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, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
1L, 1L), .Label = c("before", "during", "after"), class = "factor"),
timeperiod = c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
6L, 6L), distance.code = c(0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L,
30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L,
120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L,
30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L,
60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L,
0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L,
60L, 120L, 0L, 30L, 60L, 0L, 30L, 60L, 120L, 0L, 30L, 60L,
0L, 30L, 60L, 120L, 0L, 30L, 60L, 0L, 30L), Values = c(910.721895276374,
922.652711611841, 926.219785713456, 918.776924477918, 1030.28919690464,
1121.98321368732, 992.741416151102, 910.878353926705, 920.201901019659,
922.134996121665, 917.610324052986, 992.059286431433, 1042.05240231832,
1018.99804250179, 911.976009884021, 918.215389274037, 931.037495260958,
913.49701806948, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 911.795802370903,
994.583211567691, 1006.58290843226, 1005.52479816571, 908.665064025178,
917.940176257067, 922.746174825048, 921.752449434568, 986.419049170517,
1042.41789735969, 1082.89658057517, 916.02310296116, 918.254868924698,
931.01648294424, 924.221021573334, 982.154409713674, 1008.54477137219,
996.577798511801, 912.914857937818, 916.937508116615, 920.933077377339,
917.443294381608, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 912.073280663674,
983.866984633392, 1002.04551764872, 986.791628665069, 907.695668282537,
917.845214744473, 932.330755620455, 917.500330773026, 972.609449456089,
1155.55960936774, 1083.40557091613, 909.903267624225, 914.846316952797,
921.279328283221, 914.498616645498, 1000.3672969178, 1021.78461788922,
1011.40975353271, 915.037273600535, 914.099859036178, 924.116937361394,
913.523739017819, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 910.549315840806,
974.273124973661, 1145.99211507205, 1013.58184367388, 913.467056616881,
920.213007520924, 919.794369158301, 912.333012054637, 983.816025282468,
1103.11322201674, 974.792027063404, 910.532609655114, 917.616832229923,
923.462599912213, 913.432298686233, 1015.24811721269, 1070.61183211249,
1016.57332551186, 910.196695694198, 923.403802532832), wind.speed = c(0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8,
0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8,
0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2,
0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2,
0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8,
0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8,
0.8, 0.8, 0.8, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8, 0.2, 0.2,
0.2, 65, 65)), row.names = c(85L, 86L, 87L, 88L, 89L, 90L,
91L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 113L, 114L, 115L,
116L, 117L, 118L, 119L, 127L, 128L, 129L, 130L, 131L, 132L, 133L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 155L, 156L, 157L, 158L,
159L, 160L, 161L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 183L,
184L, 185L, 186L, 187L, 188L, 189L, 197L, 198L, 199L, 200L, 201L,
202L, 203L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 225L, 226L,
227L, 228L, 229L, 230L, 231L, 239L, 240L, 241L, 242L, 243L, 244L,
245L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 267L, 268L, 269L,
270L, 271L, 272L, 273L, 615L, 616L), class = "data.frame")
Thanks for any help!
EDIT!!
I ran terms(fit1) as suggested in the comments, the results were as follows:
terms(fit1)
Values ~ stimuli + timeperiod + scale(poly(distance.code, 3,
raw = FALSE)) * habitat + wind.speed
attr(,"variables")
list(Values, stimuli, timeperiod, scale(poly(distance.code, 3,
raw = FALSE)), habitat, wind.speed)
attr(,"factors")
stimuli timeperiod scale(poly(distance.code, 3, raw = FALSE)) habitat wind.speed
Values 0 0 0 0 0
stimuli 1 0 0 0 0
timeperiod 0 1 0 0 0
scale(poly(distance.code, 3, raw = FALSE)) 0 0 1 0 0
habitat 0 0 0 1 0
wind.speed 0 0 0 0 1
scale(poly(distance.code, 3, raw = FALSE)):habitat
Values 0
stimuli 0
timeperiod 0
scale(poly(distance.code, 3, raw = FALSE)) 1
habitat 1
wind.speed 0
attr(,"term.labels")
[1] "stimuli" "timeperiod"
[3] "scale(poly(distance.code, 3, raw = FALSE))" "habitat"
[5] "wind.speed" "scale(poly(distance.code, 3, raw = FALSE)):habitat"
attr(,"order")
[1] 1 1 1 1 1 2
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
attr(,"predvars")
list(Values, stimuli, timeperiod, scale(poly(distance.code, 3,
raw = FALSE)), habitat, wind.speed)
Here is a simple parallel example illustrating that wrapping poly() in scale() is the culprit:
> library(emmeans)
> mod1 = lm(mpg ~ am + poly(disp, 3), data = mtcars)
> ref_grid(mod1)
'emmGrid' object with variables:
am = 0, 1
disp = 230.72
> mod2 = lm(mpg ~ am + scale(poly(disp, 3)), data = mtcars)
> ref_grid(mod2)
Error in poly(disp, 3) :
'degree' must be less than number of unique points
Specifically, the call to scale() messes up the predvars attribute in the model's terms component:
> attr(terms(mod1), "predvars")
list(mpg, am, poly(disp, 3, coefs = list(alpha = c(230.721875,
279.549822668452, 298.198735227759), norm2 = c(1, 32, 476184.7946875,
5315202742.2241, 64139299346388.8))))
This provides the coefficients needed to construct the orthogonal polynomial basis; whereas...
> attr(terms(mod2), "predvars")
list(mpg, am, scale(poly(disp, 3)))
That information is excluded.
Note that the scale() call is completely unnecessary anyway, as poly() generates an orthonormal matrix of predictors.

Why does strip text color from facet_wrap not correspond to element_text color?

Please, find my data sample p below.
Question: why does the strip text color from facet_wrap() not change as specified in element_text(colour)?
I have produced this plot
I would like the strip text color (UICC Stage I, II, III and IV) to match the color of the geom_point as specified in cols. It currently loads #E1B930 on all text items.
What is wrong with the following script?
cols = c("#E1B930", "#2C77BF","#E38072","#6DBCC3")
ggplot(p, aes(x=n.fjernet,y=os.neck)) + geom_point(aes(color=uiccc),shape=20, size=5,alpha=0.7) +
geom_quantile(quantiles = 0.5,col="black", size=1,linetype=2) + facet_wrap(.~factor(uiccc)) +
scale_fill_manual(values=cols) +
scale_colour_manual(values=cols) +
scale_x_continuous(breaks = seq(0,50, by=10), name="Lymph nodal yield") +
scale_y_continuous(name="Time to death") +
theme(strip.text.x = element_text(size=12,face="bold", colour = cols),
strip.text.y = element_text(size=12, face="bold"),
strip.background = element_rect(fill="white"),
legend.position="none")
My data
p <- structure(list(uiccc = structure(c(4L, 3L, 3L, 2L, 2L, 2L, 2L,
4L, 1L, 1L, 2L, 1L, 4L, 2L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 1L, 2L,
3L, 2L, 4L, 1L, 1L, 2L, 4L, 4L, 1L, 3L, 3L, 4L, 3L, 1L, 4L, 2L,
3L, 4L, 4L, 4L, 3L, 2L, 4L, 1L, 4L, 2L, 4L, 4L, 2L, 4L, 4L, 1L,
4L, 2L, 3L, 2L, 2L, 3L, 2L, 4L, 4L, 2L, 2L, 3L, 1L, 4L, 4L, 4L,
4L, 4L, 3L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 4L,
2L, 4L, 1L, 2L, 1L, 1L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 3L,
3L, 4L, 1L, 1L, 3L, 1L, 4L, 2L, 1L, 3L, 1L, 2L, 1L, 1L, 4L, 1L,
1L, 4L, 1L, 1L, 3L, 2L, 2L, 1L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 2L,
2L, 4L, 4L, 2L, 3L, 4L, 2L, 4L, 1L, 1L, 3L, 3L, 1L, 1L, 3L, 4L,
4L, 2L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 2L, 2L, 4L, 3L,
1L, 4L, 3L, 4L, 4L, 3L, 1L, 4L, 4L, 4L, 4L, 2L, 2L, 4L, 4L, 1L,
4L, 4L, 2L, 4L, 4L, 4L, 3L, 4L, 3L, 3L, 4L, 4L, 2L, 4L, 4L, 2L,
4L, 4L, 4L, 4L, 1L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 2L, 3L, 1L, 2L, 1L, 2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 1L,
3L, 4L, 4L, 1L, 3L, 3L, 4L, 3L), .Label = c("UICC Stage I", "UICC Stage II",
"UICC Stage III", "UICC Stage IV"), class = "factor"), os.neck = c(11.5,
74.38, 17.02, 7.89, 96.03, 40.48, 17.74, 14.65, 62.46, 12.55,
9.92, 26.05, 45.47, 17.38, 39.72, 51.45, 8.61, 76.98, 67.09,
94.79, 72.15, 93.93, 17.05, 12.48, 91.6, 15.87, 11.04, 67.22,
67.02, 8.94, 6.6, 5.09, 10.68, 17.15, 0.07, 5.19, 40.77, 0.2,
170.88, 5.55, 1.61, 38.28, 10.58, 32.99, 110.98, 103.69, 122.32,
14.78, 42.74, 4.04, 8.28, 84.96, 11.7, 49.97, 120.48, 52.6, 71.26,
16.3, 100.14, 55.03, 6.51, 89.89, 51.71, 24.97, 55.66, 21.91,
81.48, 30.92, 1.58, 7.52, 30.75, 3.45, 19.22, 5.42, 17.68, 45.54,
76.22, 125.34, 83.62, 30.82, 90.32, 1.84, 19.98, 20.53, 32.59,
54.77, 2.3, 106.84, 22.28, 45.18, 4.47, 39.66, 32.3, 16.23, 3.88,
2.23, 0.23, 18.73, 0.79, 28.75, 79.54, 14.46, 15.15, 54.97, 48.59,
34.83, 58.42, 35.29, 45.73, 57.53, 63.11, 65.05, 29.54, 77.21,
63.48, 83.35, 34.3, 64.49, 29.54, 62.69, 21.62, 49.35, 99.02,
15.8, 41.89, 12.98, 13.8, 43.6, 57.23, 31.38, 70.74, 39.46, 20.76,
67.22, 127.15, 74.12, 1.97, 7.39, 25.17, 28.22, 14, 36.53, 20.83,
19.55, 40.77, 27.76, 45.31, 34.46, 35.55, 26.94, 9.43, 10.51,
6.8, 8.18, 8.02, 14.29, 6.11, 13.8, 4.9, 4.04, 14.82, 11.66,
73.07, 92.91, 99.98, 10.64, 10.05, 95.8, 7.23, 12.81, 43.99,
13.9, 10.25, 16.36, 18.2, 18.76, 12.32, 8.64, 11.79, 112.04,
70.97, 31.28, 28.85, 21.49, 19.94, 22.14, 29.44, 67.62, 11.01,
45.24, 110.72, 20.24, 14.06, 12.88, 31.51, 8.08, 13.08, 21.45,
24.28, 21.98, 32.89, 23.26, 15.41, 15.41, 13.8, 40.12, 8.02,
15.77, 49.81, 18.17, 24.21, 47.08, 6.6, 37.16, 13.01, 8.38, 14.36,
18.27, 17.28, 73.76, 68.21, 22.83, 2.66, 69.06, 17.05, 8.61,
23.33, 13.34, 12.65, 8.77, 128.92, 16.1, 4.99, 11.73, 22.97,
40.12, 20.37, 2.04, 45.73), mors = 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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L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, 7L, 4L, 11L, 13L, 13L, 9L, 9L, 9L, 12L, 11L, 16L, 6L,
13L, 8L, 17L, 5L, 8L, 22L, 19L, 3L, 15L, 14L, 7L, 18L, 9L, 10L,
18L, 24L, 11L, 15L, 7L, 6L, 4L, 24L, 23L, 8L, 20L, 9L, 22L, 11L,
2L, 24L, 15L, 5L, 8L, 11L, 11L, 11L, 15L, 6L, 16L, 7L, 9L, 16L,
11L, 33L, 27L, 16L, 57L, 5L, 7L, 8L, 11L, 15L, 15L, 12L, 5L,
9L, 49L, 11L, 28L, 19L, 13L, 23L, 11L, 12L, 10L, 4L, 14L, 6L,
12L, 32L, 13L, 12L, 4L, 11L, 17L, 10L, 5L, 15L, 21L, 19L, 11L,
31L, 9L, 20L, 11L, 16L, 12L, 6L, 16L, 27L, 30L, 18L, 18L, 10L,
7L, 23L, 16L, 15L, 4L, 12L, 9L, 10L, 11L, 7L, 8L, 8L, 7L, 6L,
9L, 9L, 13L, 15L, 12L, 35L, 12L, 5L, 19L, 27L, 34L, 10L, 16L,
18L, 6L, 22L)), row.names = c(3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 20L, 22L, 24L, 28L, 29L,
31L, 34L, 35L, 39L, 40L, 42L, 43L, 44L, 47L, 48L, 49L, 50L, 54L,
56L, 57L, 58L, 59L, 60L, 62L, 63L, 66L, 67L, 68L, 69L, 70L, 71L,
72L, 73L, 74L, 75L, 76L, 80L, 81L, 82L, 83L, 86L, 87L, 88L, 89L,
94L, 97L, 99L, 101L, 102L, 106L, 113L, 115L, 117L, 122L, 129L,
132L, 136L, 142L, 143L, 145L, 146L, 148L, 153L, 154L, 158L, 159L,
163L, 164L, 167L, 169L, 171L, 174L, 175L, 178L, 179L, 185L, 188L,
191L, 197L, 210L, 218L, 220L, 230L, 236L, 238L, 239L, 240L, 241L,
242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L, 252L, 253L,
254L, 255L, 256L, 257L, 258L, 259L, 261L, 262L, 263L, 264L, 265L,
266L, 270L, 275L, 277L, 278L, 280L, 282L, 284L, 286L, 289L, 293L,
295L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 308L, 310L, 312L,
313L, 314L, 315L, 316L, 317L, 318L, 319L, 320L, 321L, 322L, 323L,
325L, 327L, 328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L,
338L, 348L, 349L, 351L, 352L, 353L, 354L, 357L, 358L, 359L, 360L,
361L, 362L, 363L, 365L, 366L, 368L, 371L, 372L, 374L, 376L, 378L,
379L, 380L, 381L, 382L, 383L, 384L, 385L, 386L, 387L, 388L, 389L,
390L, 391L, 392L, 393L, 394L, 395L, 396L, 397L, 398L, 399L, 400L,
401L, 402L, 403L, 405L, 407L, 409L, 410L, 411L, 412L, 413L, 414L,
415L, 416L, 417L, 418L, 419L, 421L, 422L, 424L, 425L, 426L, 427L,
428L, 429L, 430L), class = "data.frame")
This is a modification of grob values for strip.text color using the grid package:
library(grid)
library(ggplot2)
g <- ggplot_gtable(ggplot_build(plot))
strip_both <- which(grepl('strip-', g$layout$name))
colors = c("#E38072","#6DBCC3", "#E1B930", "#2C77BF")
k <- 1
for (i in strip_both) {
j <- which(grepl("text", g$grobs[[i]]$grobs[[1]]$childrenOrder))
g$grobs[[i]]$grobs[[1]]$children[[j]]$children[[1]]$gp$col <- colors[k]
k <- k+1
}
grid.draw(g)
Assigning plot object to plot:
cols = c("#E1B930", "#2C77BF","#E38072","#6DBCC3")
plot <- ggplot(p, aes(x=n.fjernet,y=os.neck)) + geom_point(aes(color=uiccc),shape=20, size=5,alpha=0.7) +
geom_quantile(quantiles = 0.5,col="black", size=1,linetype=2) + facet_wrap(.~factor(uiccc)) +
scale_fill_manual(values=cols) +
scale_colour_manual(values=cols) +
scale_x_continuous(breaks = seq(0,50, by=10), name="Lymph nodal yield") +
scale_y_continuous(name="Time to death") +
theme(strip.text.x = element_text(size=12,face="bold"),
strip.text.y = element_text(size=12, face="bold"),
strip.background = element_rect(fill="white"),
legend.position="none")
Alternatively, plot them per group, then combine:
# named colours per group
cols <- setNames(c("#E1B930", "#2C77BF","#E38072","#6DBCC3"),
levels(p$uiccc))
# set pretty limits
Xlim <- round(range(p$n.fjernet), -1)
Ylim <- round(range(p$os.neck), -1)
ggList <- lapply(split(p, p$uiccc), function(i){
title <- i[1, "uiccc"]
ggplot(i, aes(x = n.fjernet, y = os.neck)) +
geom_point(aes(color = uiccc), shape = 20, size = 5, alpha = 0.7, show.legend = FALSE) +
geom_quantile(quantiles = 0.5, col = "black", size = 1, linetype = 2) +
ggtitle(title) +
scale_fill_manual(values = cols) +
scale_colour_manual(values = cols) +
scale_x_continuous(limits = Xlim) +
scale_y_continuous(limits = Ylim) +
theme_classic() +
theme(plot.title = element_text(colour = cols[ title ]))
})
Then use patchwork or cowplot to combine:
patchwork::wrap_plots(ggList)
#or
cowplot::plot_grid(plotlist = ggList)
Alternatively to #Greg's answer (that I think should be the validated answer), you can get the same plot by adding annotation in place of facet labeling:
library(tidyverse)
ggplot(df, aes(x=n.fjernet,y=os.neck)) + geom_point(aes(color=uiccc),shape=20, size=5,alpha=0.7) +
geom_quantile(quantiles = 0.5,col="black", size=1,linetype=2) + facet_wrap(.~factor(uiccc)) +
scale_fill_manual(values=cols) +
scale_colour_manual(values=cols) +
scale_x_continuous(breaks = seq(0,50, by=10), name="Lymph nodal yield") +
scale_y_continuous(name="Time to death") +
theme(#strip.text.x = element_text(size=12,face="bold", colour = cols),
#strip.text.y = element_text(size=12, face="bold"),
#strip.background = element_rect(fill="white"),
strip.background = element_blank(),
strip.text = element_text(color = "transparent"),
legend.position="none",
plot.margin = unit(c(1,3,1,1), "lines")) +
coord_cartesian(clip = "off",ylim = c(0,175))+
geom_text(data = . %>% distinct(uiccc),
aes(label = factor(uiccc), color = uiccc), y = 200, x = 30, hjust = 0.5, fontface = "bold")

R How to plot a "net interaction effect" (or marginal effect) when there are 'confounding' interactions

I want to draw the interaction effects between x1 and x2 for the following regression (let y be a positive count variable in a panel dataset)
library(lme4)
glmer.repex<-glmer.nb(y ~ x1 + x2 +I(x2^2) + x1:x2 +x1:I(x2^2) + (1|Year), data=repex, nAGQ = 1L)
The easy interaction plot is:
interaction.plot(x1,x2,y) ; interaction.plot(x1,x2,fitted(test.lmer,ndf, type="response"))
Now I want to acknowledge that if x1 changes the values of x1*x2 and x1^2 will also change which will change the fitted values. All of this should be taken into account when plotting the net interaction effect. It might e.g. be so that x1 and x2 both are positively correlated with y, but that their interaction attenuates this positive effect, potentially changing the direction of the prediction. This might additionally be conditional on the values of x1*x2...
So the simple interaction.plot does not really work anymore because the other variables are affecting the outcome as well.
Is there an easy way of doing this either with predict or effect ?
Here is a reproducible example data set (plm.data object) called repex
dput(repex)
structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L,
7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L), .Label = c("1", "2", "4", "6", "7",
"8", "9", "10", "11", "13", "15", "16", "17", "18", "20", "22",
"24", "26", "28", "29", "32", "34", "35", "36", "37", "39", "41",
"42", "44", "47"), class = "factor"), Year = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L,
6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L,
4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L,
2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L), .Label = c("1991",
"1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
"2000", "2001", "2002", "2003", "2004", "2005", "2006"), class = "factor"), y = c(5, 10, 6, 9, 9, 4, 2, 2, 3, 7, 12, 13, 0, 5, 5, 1, 1, 3, 0, 0, 1, 0, 3, 0, 0, 4, 9, 9, 12, 9, 10, 6, 14, 12, 6, 2, 20, 15, 18, 14, 26, 17, 0, 0, 0, 0, 2, 0, 5, 1, 2, 2, 5, 3, 0, 0, 0, 1, 0, 0), x1 = c(0L, 0L, 3L, 3L, 3L, 5L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 2L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 2L, 1L, 0L, 0L, 2L, 0L, 2L, 8L, 4L, 1L, 0L, 4L, 2L, 1L, 1L, 1L, 1L, 0L, 1L, 3L, 5L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 1L, 1L, 2L, 6L, 0L, 0L, 1L, 1L, 1L, 0L), x2 = structure(c(4.22657266700715, 7.07828323739468, 5.58155937520987, 6.09945741088926, 4.98990473760187, 13.1975509132969, 0.136363636363636, 0.164922480620155, 0.981640399790555, 1.61119564479727, 4.27951983102512, 4.52440902710094, 2.41282572727806,
2.77748331046807, 7.00223921984389, 3.55837337174436, 5.31590575343992, 2.61930006177923, 0.211351052048726, 0.525647451963241, 0.696630753538187, 0.666082288178836, 1.09492110512526, 3.8035303566375, 0.548336215316966, 0.85237681730237, 0.982747572848003, 6.59758768791534, 8.74094242997363, 9.29913186611362, 3.5542234379174, 3.24728026722101, 3.60927964544638, 3.33459121950297, 2.88526780610146, 4.56612429882729, 26.45256036788,
21.0190838535023, 19.3769702276769, 19.7227148506334, 17.6596029433548, 23.6531530880185, 0.138888888888889, 0.249009205804338, 0.394159544159544, 0.316399286987522, 0.0413533834586466, 3.02315977564407, 3.94214293703149, 1.9143052531528, 3.16707069146414, 5.70642767128218, 4.38285025038957, 4.23425019314604, 0, 0, 0, 0, 0.0416666666666667, 0), .Dim = 60L, .Dimnames = list(c("1990_ABT", "1991_ABT", "1992_ABT", "1993_ABT", "1994_ABT", "1995_ABT", "1990_AKN", "1991_AKN", "1992_AKN", "1993_AKN", "1994_AKN", "1995_AKN",
"1990_ALL", "1991_ALL", "1992_ALL", "1993_ALL", "1994_ALL",
"1995_ALL", "1990_AMG", "1991_AMG", "1992_AMG", "1993_AMG",
"1994_AMG", "1995_AMG", "1990_AZN", "1991_AZN", "1992_AZN",
"1993_AZN", "1994_AZN", "1995_AZN", "1990_BAX", "1991_BAX",
"1992_BAX", "1993_BAX", "1994_BAX", "1995_BAX", "1990_BAY",
"1991_BAY", "1992_BAY", "1993_BAY", "1994_BAY", "1995_BAY",
"1990_BIO", "1991_BIO", "1992_BIO", "1993_BIO", "1994_BIO",
"1995_BIO", "1990_BMS", "1991_BMS", "1992_BMS", "1993_BMS",
"1994_BMS", "1995_BMS", "1990_ABT", "1990_ABT", "1990_ABT",
"1990_ABT", "1994_CHU", "1990_ABT")))), .Names = c("ID",
"Year", "y", "x1", "x2"), row.names = c(1L, 2L, 3L, 4L, 160L,
5L, 172L, 173L, 174L, 175L, 176L, 177L, 188L, 12L, 190L, 191L,
192L, 13L, 212L, 213L, 214L, 215L, 216L, 217L, 22L, 23L, 230L,
231L, 232L, 233L, 28L, 29L, 30L, 31L, 248L, 249L, 36L, 37L, 38L,
39L, 40L, 41L, 276L, 156L, 52L, 158L, 159L, 281L, 56L, 57L, 58L,
295L, 59L, 297L, 588L, 391L, 392L, 393L, 187L, 395L), class = c("plm.dim",
"data.frame"))
Thanks!

Resources