##### Start here ####
library(dplyr)
library(readxl)
library(janitor)
library(ggplot2)
library(emmeans)
library(lme4)
library(lmerTest)

Load data

data_long = readxl::read_xlsx("data_wide.xlsx") |>
    janitor::clean_names()

Prepare data

eda = data_long |>
  mutate(
    year = factor(year),
    variety = factor(variety),
    spacing = factor(spacing),
    trt_vs = interaction(variety, spacing, sep = " | ")
  )

Boxplot by treatment for tuber_num_total_marketable

ggplot(
  eda |> filter(!is.na(tuber_num_total_marketable)),
  aes(x = trt_vs, y = tuber_num_total_marketable, fill = variety)
) +
  geom_boxplot(outlier.alpha = 0.6) +
  geom_jitter(width = 0.12, alpha = 0.6, size = 1.8) +
  facet_wrap(~year, scales = "free_y") +
  labs(
    title = "Marketable tuber number by treatment",
    x = "Treatment (Variety | Spacing)",
    y = "tuber_num_total_marketable",
    fill = "Variety"
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

Boxplot by treatment for cwt_per_a_total_marketable

ggplot(
  eda |> filter(!is.na(cwt_per_a_total_marketable)),
  aes(x = trt_vs, y = cwt_per_a_total_marketable, fill = variety)
) +
  geom_boxplot(outlier.alpha = 0.6) +
  geom_jitter(width = 0.12, alpha = 0.6, size = 1.8) +
  facet_wrap(~year, scales = "free_y") +
  labs(
    title = "Marketable yield (cwt/acre) by treatment",
    x = "Treatment (Variety | Spacing)",
    y = "cwt_per_a_total_marketable",
    fill = "Variety"
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

Interaction plot (tuber number marketable)

plot_num = data_long |>
  filter(!is.na(tuber_num_total_marketable)) |>
  group_by(year, variety, spacing) |>
  summarise(
    mean = mean(tuber_num_total_marketable),
    se = sd(tuber_num_total_marketable) / sqrt(n()),
    n = n(),
    .groups = "drop"
  ) |>
  arrange(year, variety, spacing)

ggplot(plot_num, aes(x = as.numeric(as.character(spacing)), y = mean, color = variety, group = variety)) +
  geom_line(linewidth = 1) +
  geom_point(size = 2) +
  geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, alpha = 0.35) +
  facet_wrap(~year) +
  labs(
    title = "Variety × Spacing by Year",
    subtitle = "Response: tuber_num_total_marketable (mean ± SE)",
    x = "Spacing",
    y = "Marketable tuber number",
    color = "Variety"
  ) +
  theme_minimal()

Interaction plot (marketable yield weight)

plot_cwt = data_long |>
  filter(!is.na(cwt_per_a_total_marketable)) |>
  group_by(year, variety, spacing) |>
  summarise(
    mean = mean(cwt_per_a_total_marketable),
    se = sd(cwt_per_a_total_marketable) / sqrt(n()),
    n = n(),
    .groups = "drop"
  ) |>
  arrange(year, variety, spacing)

ggplot(plot_cwt, aes(x = as.numeric(as.character(spacing)), y = mean, color = variety, group = variety)) +
  geom_line(linewidth = 1) +
  geom_point(size = 2) +
  geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = 0.2, alpha = 0.35) +
  facet_wrap(~year) +
  labs(
    title = "Variety × Spacing by Year",
    subtitle = "Response: cwt_per_a_total_marketable (mean ± SE)",
    x = "Spacing",
    y = "Marketable yield (cwt/acre)",
    color = "Variety"
  ) +
  theme_minimal()

Models

Model for cwt_per_a_total_marketable 2025 data

dat = data_long |>
    filter(!is.na(cwt_per_a_total_marketable )) |>
    mutate(
        year = factor(year),
        rep = factor(rep),
        variety = factor(variety),
        spacing = factor(spacing)  # treat as categorical levels for RCBD
    )

dat_2025 = dat |>
    filter(year == "2025")

m_2025 = lmer(
    cwt_per_a_total_marketable  ~ variety * spacing + (1 | rep),
    data = dat_2025,
    REML = TRUE
)

anova(m_2025)      # fixed effects tests
Type III Analysis of Variance Table with Satterthwaite's method
                Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
variety         6203.0  6203.0     1 14.134  3.0175 0.1041
spacing         8619.1  4309.6     2 14.130  2.0965 0.1595
variety:spacing 3836.7  1918.3     2 14.130  0.9332 0.4162
summary(m_2025)    # estimates
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: cwt_per_a_total_marketable ~ variety * spacing + (1 | rep)
   Data: dat_2025

REML criterion at convergence: 190.5

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.53534 -0.70236 -0.05073  0.64071  1.67185 

Random effects:
 Groups   Name        Variance Std.Dev.
 rep      (Intercept) 1264     35.56   
 Residual             2056     45.34   
Number of obs: 23, groups:  rep, 4

Fixed effects:
                          Estimate Std. Error       df t value Pr(>|t|)    
(Intercept)               493.8911    32.0490  12.6090  15.410 1.49e-09 ***
varietyLakeview             0.6773    34.9997  14.2482   0.019    0.985    
spacing10                  62.8100    34.9997  14.2482   1.795    0.094 .  
spacing12                   3.0674    34.9997  14.2482   0.088    0.931    
varietyLakeview:spacing10 -64.8197    47.4637  14.1652  -1.366    0.193    
varietyLakeview:spacing12 -36.7080    47.4637  14.1652  -0.773    0.452    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) vrtyLk spcn10 spcn12 vrL:10
varietyLkvw -0.634                            
spacing10   -0.634  0.580                     
spacing12   -0.634  0.580  0.580              
vrtyLkvw:10  0.467 -0.737 -0.737 -0.428       
vrtyLkvw:12  0.467 -0.737 -0.428 -0.737  0.544
# Get the estimated marginal means ----------------------------------------

emm = emmeans(m_2025, ~ variety * spacing)
emm
 variety  spacing emmean   SE   df lower.CL upper.CL
 Caribou  8          494 32.2 12.5      424      564
 Lakeview 8          495 28.8 10.1      430      559
 Caribou  10         557 28.8 10.1      493      621
 Lakeview 10         493 28.8 10.1      428      557
 Caribou  12         497 28.8 10.1      433      561
 Lakeview 12         461 28.8 10.1      397      525

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 
pairs(emm)                 # all pairwise
 contrast                                estimate   SE   df t.ratio p.value
 Caribou spacing8 - Lakeview spacing8      -0.677 35.2 14.2  -0.019  1.0000
 Caribou spacing8 - Caribou spacing10     -62.810 35.2 14.2  -1.785  0.5038
 Caribou spacing8 - Lakeview spacing10      1.332 35.2 14.2   0.038  1.0000
 Caribou spacing8 - Caribou spacing12      -3.067 35.2 14.2  -0.087  1.0000
 Caribou spacing8 - Lakeview spacing12     32.963 35.2 14.2   0.937  0.9301
 Lakeview spacing8 - Caribou spacing10    -62.133 32.1 14.0  -1.938  0.4207
 Lakeview spacing8 - Lakeview spacing10     2.010 32.1 14.0   0.063  1.0000
 Lakeview spacing8 - Caribou spacing12     -2.390 32.1 14.0  -0.075  1.0000
 Lakeview spacing8 - Lakeview spacing12    33.641 32.1 14.0   1.049  0.8930
 Caribou spacing10 - Lakeview spacing10    64.142 32.1 14.0   2.001  0.3886
 Caribou spacing10 - Caribou spacing12     59.743 32.1 14.0   1.863  0.4606
 Caribou spacing10 - Lakeview spacing12    95.773 32.1 14.0   2.987  0.0839
 Lakeview spacing10 - Caribou spacing12    -4.400 32.1 14.0  -0.137  1.0000
 Lakeview spacing10 - Lakeview spacing12   31.631 32.1 14.0   0.987  0.9148
 Caribou spacing12 - Lakeview spacing12    36.031 32.1 14.0   1.124  0.8636

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 6 estimates 
pairs(emm, by = "variety") # spacing comparisons within variety
variety = Caribou:
 contrast              estimate   SE   df t.ratio p.value
 spacing8 - spacing10    -62.81 35.2 14.2  -1.785  0.2098
 spacing8 - spacing12     -3.07 35.2 14.2  -0.087  0.9958
 spacing10 - spacing12    59.74 32.1 14.0   1.863  0.1858

variety = Lakeview:
 contrast              estimate   SE   df t.ratio p.value
 spacing8 - spacing10      2.01 32.1 14.0   0.063  0.9978
 spacing8 - spacing12     33.64 32.1 14.0   1.049  0.5594
 spacing10 - spacing12    31.63 32.1 14.0   0.987  0.5969

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 3 estimates 
pairs(emm, by = "spacing") # variety comparisons within spacing
spacing = 8:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview   -0.677 35.2 14.2  -0.019  0.9849

spacing = 10:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview   64.142 32.1 14.0   2.001  0.0652

spacing = 12:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview   36.031 32.1 14.0   1.124  0.2800

Degrees-of-freedom method: kenward-roger 

Conclusions on 2025

For 2025, the RCBD mixed model (cwt_per_a_total_marketable ~ variety * spacing + (1|rep)) found no statistically significant effects of variety (p = 0.104), spacing (p = 0.160), or variety×spacing interaction (p = 0.416) on marketable yield. Estimated marginal means were broadly similar across treatment combinations. Tukey-adjusted pairwise tests did not detect significant differences within varieties or within spacings. A possible Caribou advantage at spacing 10 appeared as a nominal trend in simple-effects comparisons (difference ≈ 64.1 cwt/ac, p = 0.065), but this was not significant under broader family-wise adjustment. Overall, 2025 evidence supports comparable marketable yield across tested variety-spacing combinations, with limited power due to small/unbalanced data and a need for confirmation using additional years.

Model for cwt_per_a_total_marketable 2024 data

dat_2024 = dat |>
    filter(year == "2024")

m_2024 = lmer(
    cwt_per_a_total_marketable  ~ variety * spacing + (1 | rep),
    data = dat_2024,
    REML = TRUE
)

anova(m_2024)
Type III Analysis of Variance Table with Satterthwaite's method
                 Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
variety         23110.0 23110.0     1    18  4.6356 0.04512 *
spacing         12585.9  6293.0     2    18  1.2623 0.30689  
variety:spacing  2390.2  1195.1     2    18  0.2397 0.78932  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m_2024)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: cwt_per_a_total_marketable ~ variety * spacing + (1 | rep)
   Data: dat_2024

REML criterion at convergence: 212.7

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.99544 -0.57408  0.06128  0.47099  1.66761 

Random effects:
 Groups   Name        Variance Std.Dev.
 rep      (Intercept)    0      0.00   
 Residual             4985     70.61   
Number of obs: 24, groups:  rep, 4

Fixed effects:
                          Estimate Std. Error      df t value Pr(>|t|)    
(Intercept)                471.227     35.304  18.000  13.348 8.93e-11 ***
varietyLakeview             84.684     49.927  18.000   1.696    0.107    
spacing10                   36.254     49.927  18.000   0.726    0.477    
spacing12                   -5.196     49.927  18.000  -0.104    0.918    
varietyLakeview:spacing10  -19.315     70.607  18.000  -0.274    0.788    
varietyLakeview:spacing12  -48.553     70.607  18.000  -0.688    0.500    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) vrtyLk spcn10 spcn12 vrL:10
varietyLkvw -0.707                            
spacing10   -0.707  0.500                     
spacing12   -0.707  0.500  0.500              
vrtyLkvw:10  0.500 -0.707 -0.707 -0.354       
vrtyLkvw:12  0.500 -0.707 -0.354 -0.707  0.500
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
emm_2024 = emmeans(m_2024, ~ variety * spacing)
emm_2024
 variety  spacing emmean   SE df lower.CL upper.CL
 Caribou  8          471 35.3 18      397      545
 Lakeview 8          556 35.3 18      482      630
 Caribou  10         507 35.3 18      433      582
 Lakeview 10         573 35.3 18      499      647
 Caribou  12         466 35.3 18      392      540
 Lakeview 12         502 35.3 18      428      576

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 
pairs(emm_2024) 
 contrast                                estimate   SE df t.ratio p.value
 Caribou spacing8 - Lakeview spacing8      -84.68 49.9 15  -1.696  0.5540
 Caribou spacing8 - Caribou spacing10      -36.25 49.9 15  -0.726  0.9755
 Caribou spacing8 - Lakeview spacing10    -101.62 49.9 15  -2.035  0.3686
 Caribou spacing8 - Caribou spacing12        5.20 49.9 15   0.104  1.0000
 Caribou spacing8 - Lakeview spacing12     -30.94 49.9 15  -0.620  0.9878
 Lakeview spacing8 - Caribou spacing10      48.43 49.9 15   0.970  0.9205
 Lakeview spacing8 - Lakeview spacing10    -16.94 49.9 15  -0.339  0.9993
 Lakeview spacing8 - Caribou spacing12      89.88 49.9 15   1.800  0.4939
 Lakeview spacing8 - Lakeview spacing12     53.75 49.9 15   1.077  0.8832
 Caribou spacing10 - Lakeview spacing10    -65.37 49.9 15  -1.309  0.7758
 Caribou spacing10 - Caribou spacing12      41.45 49.9 15   0.830  0.9571
 Caribou spacing10 - Lakeview spacing12      5.32 49.9 15   0.107  1.0000
 Lakeview spacing10 - Caribou spacing12    106.82 49.9 15   2.140  0.3196
 Lakeview spacing10 - Lakeview spacing12    70.69 49.9 15   1.416  0.7177
 Caribou spacing12 - Lakeview spacing12    -36.13 49.9 15  -0.724  0.9759

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 6 estimates 
pairs(emm_2024, by = "variety") 
variety = Caribou:
 contrast              estimate   SE df t.ratio p.value
 spacing8 - spacing10     -36.3 49.9 15  -0.726  0.7521
 spacing8 - spacing12       5.2 49.9 15   0.104  0.9940
 spacing10 - spacing12     41.4 49.9 15   0.830  0.6906

variety = Lakeview:
 contrast              estimate   SE df t.ratio p.value
 spacing8 - spacing10     -16.9 49.9 15  -0.339  0.9388
 spacing8 - spacing12      53.7 49.9 15   1.077  0.5424
 spacing10 - spacing12     70.7 49.9 15   1.416  0.3581

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 3 estimates 
pairs(emm_2024, by = "spacing") 
spacing = 8:
 contrast           estimate   SE df t.ratio p.value
 Caribou - Lakeview    -84.7 49.9 15  -1.696  0.1105

spacing = 10:
 contrast           estimate   SE df t.ratio p.value
 Caribou - Lakeview    -65.4 49.9 15  -1.309  0.2101

spacing = 12:
 contrast           estimate   SE df t.ratio p.value
 Caribou - Lakeview    -36.1 49.9 15  -0.724  0.4804

Degrees-of-freedom method: kenward-roger 

Conclusions on 2024

For 2024, the RCBD mixed model (cwt_per_a_total_marketable ~ variety * spacing + (1|rep)) found a statistically significant main effect of variety (p = 0.04512), but no significant effects of spacing (p = 0.30689) or variety×spacing interaction (p = 0.78932) on marketable yield. Estimated marginal means showed Lakeview higher than Caribou across all spacings (8: 556 vs 471; 10: 573 vs 507; 12: 502 vs 466 cwt/ac). Tukey-adjusted pairwise tests did not detect significant differences among the six treatment combinations, nor significant variety differences within individual spacings (spacing 8: p = 0.1105; spacing 10: p = 0.2101; spacing 12: p = 0.4804), and spacing contrasts within each variety were also non-significant. The model also had a singular (boundary) fit with block variance estimated at zero (SD_rep = 0.00; Var_rep = 0), while residual variation was substantial (SD_residual = 70.61; Var_residual = 4985), so blocking contributed little in 2024 and inference should be interpreted with that in mind. Overall, 2024 evidence suggests an average yield advantage for Lakeview across spacings, without evidence of spacing-dependent effects or interaction.

Combined model

m_all = lmer(
    cwt_per_a_total_marketable ~ year * variety * spacing + (1 | year:rep),
    data = dat,
    REML = TRUE
)

anova(m_all)
Type III Analysis of Variance Table with Satterthwaite's method
                      Sum Sq Mean Sq NumDF   DenDF F value  Pr(>F)  
year                  1134.7  1134.7     1  6.1202  0.3125 0.59601  
variety               2522.3  2522.3     1 29.2974  0.6946 0.41135  
spacing              20828.9 10414.4     2 29.2916  2.8680 0.07286 .
year:variety         26111.7 26111.7     1 29.2974  7.1907 0.01191 *
year:spacing           456.9   228.4     2 29.2916  0.0629 0.93915  
variety:spacing       4682.9  2341.5     2 29.2916  0.6448 0.53206  
year:variety:spacing  1858.1   929.1     2 29.2916  0.2558 0.77597  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m_all)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: cwt_per_a_total_marketable ~ year * variety * spacing + (1 |  
    year:rep)
   Data: dat

REML criterion at convergence: 406.4

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-2.02626 -0.51610  0.04661  0.45532  1.77339 

Random effects:
 Groups   Name        Variance Std.Dev.
 year:rep (Intercept)  562.1   23.71   
 Residual             3631.3   60.26   
Number of obs: 47, groups:  year:rep, 8

Fixed effects:
                                   Estimate Std. Error      df t value Pr(>|t|)
(Intercept)                         471.227     32.378  32.261  14.554 9.93e-16
year2025                             21.062     49.252  33.315   0.428   0.6717
varietyLakeview                      84.684     42.611  29.139   1.987   0.0563
spacing10                            36.254     42.611  29.139   0.851   0.4018
spacing12                            -5.196     42.611  29.139  -0.122   0.9038
year2025:varietyLakeview            -82.405     62.931  29.586  -1.309   0.2005
year2025:spacing10                   28.158     62.931  29.586   0.447   0.6578
year2025:spacing12                    9.865     62.931  29.586   0.157   0.8765
varietyLakeview:spacing10           -19.315     60.260  29.139  -0.321   0.7509
varietyLakeview:spacing12           -48.553     60.260  29.139  -0.806   0.4269
year2025:varietyLakeview:spacing10  -47.107     87.130  29.373  -0.541   0.5928
year2025:varietyLakeview:spacing12   10.243     87.130  29.373   0.118   0.9072
                                      
(Intercept)                        ***
year2025                              
varietyLakeview                    .  
spacing10                             
spacing12                             
year2025:varietyLakeview              
year2025:spacing10                    
year2025:spacing12                    
varietyLakeview:spacing10             
varietyLakeview:spacing12             
year2025:varietyLakeview:spacing10    
year2025:varietyLakeview:spacing12    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) yr2025 vrtyLk spcn10 spcn12 yr2025:L y2025:10 y2025:12
year2025    -0.657                                                       
varietyLkvw -0.658  0.433                                                
spacing10   -0.658  0.433  0.500                                         
spacing12   -0.658  0.433  0.500  0.500                                  
yr2025:vrtL  0.446 -0.692 -0.677 -0.339 -0.339                           
yr2025:sp10  0.446 -0.692 -0.339 -0.677 -0.339  0.542                    
yr2025:sp12  0.446 -0.692 -0.339 -0.339 -0.677  0.542    0.542           
vrtyLkvw:10  0.465 -0.306 -0.707 -0.707 -0.354  0.479    0.479    0.239  
vrtyLkvw:12  0.465 -0.306 -0.707 -0.354 -0.707  0.479    0.239    0.479  
yr2025:L:10 -0.322  0.500  0.489  0.489  0.245 -0.722   -0.722   -0.391  
yr2025:L:12 -0.322  0.500  0.489  0.245  0.489 -0.722   -0.391   -0.722  
            vrL:10 vrL:12 y2025:L:10
year2025                            
varietyLkvw                         
spacing10                           
spacing12                           
yr2025:vrtL                         
yr2025:sp10                         
yr2025:sp12                         
vrtyLkvw:10                         
vrtyLkvw:12  0.500                  
yr2025:L:10 -0.692 -0.346           
yr2025:L:12 -0.346 -0.692  0.522    
# Year-specific treatment means
emm_by_year = emmeans(m_all, ~ variety * spacing | year)
emm_by_year
year = 2024:
 variety  spacing emmean   SE   df lower.CL upper.CL
 Caribou  8          471 32.4 32.2      405      537
 Lakeview 8          556 32.4 32.2      490      622
 Caribou  10         507 32.4 32.2      442      573
 Lakeview 10         573 32.4 32.2      507      639
 Caribou  12         466 32.4 32.2      400      532
 Lakeview 12         502 32.4 32.2      436      568

year = 2025:
 variety  spacing emmean   SE   df lower.CL upper.CL
 Caribou  8          492 37.4 33.9      416      568
 Lakeview 8          495 32.4 32.2      429      561
 Caribou  10         557 32.4 32.2      491      623
 Lakeview 10         493 32.4 32.2      427      558
 Caribou  12         497 32.4 32.2      431      563
 Lakeview 12         461 32.4 32.2      395      527

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 
# Pairwise within each year (all 6 combos per year)
pairs(emm_by_year, adjust = "tukey")
year = 2024:
 contrast                                estimate   SE   df t.ratio p.value
 Caribou spacing8 - Lakeview spacing8      -84.68 42.6 29.0  -1.987  0.3734
 Caribou spacing8 - Caribou spacing10      -36.25 42.6 29.0  -0.851  0.9550
 Caribou spacing8 - Lakeview spacing10    -101.62 42.6 29.0  -2.385  0.1947
 Caribou spacing8 - Caribou spacing12        5.20 42.6 29.0   0.122  1.0000
 Caribou spacing8 - Lakeview spacing12     -30.94 42.6 29.0  -0.726  0.9771
 Lakeview spacing8 - Caribou spacing10      48.43 42.6 29.0   1.137  0.8620
 Lakeview spacing8 - Lakeview spacing10    -16.94 42.6 29.0  -0.398  0.9986
 Lakeview spacing8 - Caribou spacing12      89.88 42.6 29.0   2.109  0.3106
 Lakeview spacing8 - Lakeview spacing12     53.75 42.6 29.0   1.261  0.8029
 Caribou spacing10 - Lakeview spacing10    -65.37 42.6 29.0  -1.534  0.6460
 Caribou spacing10 - Caribou spacing12      41.45 42.6 29.0   0.973  0.9229
 Caribou spacing10 - Lakeview spacing12      5.32 42.6 29.0   0.125  1.0000
 Lakeview spacing10 - Caribou spacing12    106.82 42.6 29.0   2.507  0.1552
 Lakeview spacing10 - Lakeview spacing12    70.69 42.6 29.0   1.659  0.5683
 Caribou spacing12 - Lakeview spacing12    -36.13 42.6 29.0  -0.848  0.9556

year = 2025:
 contrast                                estimate   SE   df t.ratio p.value
 Caribou spacing8 - Lakeview spacing8       -2.28 46.6 29.8  -0.049  1.0000
 Caribou spacing8 - Caribou spacing10      -64.41 46.6 29.8  -1.383  0.7363
 Caribou spacing8 - Lakeview spacing10      -0.27 46.6 29.8  -0.006  1.0000
 Caribou spacing8 - Caribou spacing12       -4.67 46.6 29.8  -0.100  1.0000
 Caribou spacing8 - Lakeview spacing12      31.36 46.6 29.8   0.674  0.9836
 Lakeview spacing8 - Caribou spacing10     -62.13 42.6 29.0  -1.458  0.6923
 Lakeview spacing8 - Lakeview spacing10      2.01 42.6 29.0   0.047  1.0000
 Lakeview spacing8 - Caribou spacing12      -2.39 42.6 29.0  -0.056  1.0000
 Lakeview spacing8 - Lakeview spacing12     33.64 42.6 29.0   0.789  0.9671
 Caribou spacing10 - Lakeview spacing10     64.14 42.6 29.0   1.505  0.6637
 Caribou spacing10 - Caribou spacing12      59.74 42.6 29.0   1.402  0.7255
 Caribou spacing10 - Lakeview spacing12     95.77 42.6 29.0   2.248  0.2478
 Lakeview spacing10 - Caribou spacing12     -4.40 42.6 29.0  -0.103  1.0000
 Lakeview spacing10 - Lakeview spacing12    31.63 42.6 29.0   0.742  0.9748
 Caribou spacing12 - Lakeview spacing12     36.03 42.6 29.0   0.846  0.9561

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 6 estimates 
# Spacing comparisons within variety, by year
pairs(emm_by_year, by = c("year","variety"), adjust = "tukey")
year = 2024, variety = Caribou:
 contrast              estimate   SE   df t.ratio p.value
 spacing8 - spacing10    -36.25 42.6 29.0  -0.851  0.6750
 spacing8 - spacing12      5.20 42.6 29.0   0.122  0.9918
 spacing10 - spacing12    41.45 42.6 29.0   0.973  0.5996

year = 2025, variety = Caribou:
 contrast              estimate   SE   df t.ratio p.value
 spacing8 - spacing10    -64.41 46.6 29.8  -1.383  0.3622
 spacing8 - spacing12     -4.67 46.6 29.8  -0.100  0.9945
 spacing10 - spacing12    59.74 42.6 29.0   1.402  0.3530

year = 2024, variety = Lakeview:
 contrast              estimate   SE   df t.ratio p.value
 spacing8 - spacing10    -16.94 42.6 29.0  -0.398  0.9168
 spacing8 - spacing12     53.75 42.6 29.0   1.261  0.4278
 spacing10 - spacing12    70.69 42.6 29.0   1.659  0.2380

year = 2025, variety = Lakeview:
 contrast              estimate   SE   df t.ratio p.value
 spacing8 - spacing10      2.01 42.6 29.0   0.047  0.9988
 spacing8 - spacing12     33.64 42.6 29.0   0.789  0.7124
 spacing10 - spacing12    31.63 42.6 29.0   0.742  0.7406

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 3 estimates 
# Variety comparisons within spacing, by year
pairs(emm_by_year, by = c("year","spacing"), adjust = "tukey")
year = 2024, spacing = 8:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview   -84.68 42.6 29.0  -1.987  0.0564

year = 2025, spacing = 8:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview    -2.28 46.6 29.8  -0.049  0.9613

year = 2024, spacing = 10:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview   -65.37 42.6 29.0  -1.534  0.1358

year = 2025, spacing = 10:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview    64.14 42.6 29.0   1.505  0.1431

year = 2024, spacing = 12:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview   -36.13 42.6 29.0  -0.848  0.4034

year = 2025, spacing = 12:
 contrast           estimate   SE   df t.ratio p.value
 Caribou - Lakeview    36.03 42.6 29.0   0.846  0.4047

Degrees-of-freedom method: kenward-roger 

Conclusion on combined model

For the combined model, the RCBD mixed model (cwt_per_a_total_marketable ~ year * variety * spacing + (1|year:rep)) found no statistically significant main effects of year (p = 0.59601) or variety (p = 0.41135), no significant year×spacing (p = 0.93915), variety×spacing (p = 0.53206), or year×variety×spacing (p = 0.77597) interactions, and only marginal evidence for spacing (p = 0.07286). The only statistically significant term was year×variety (p = 0.01191), indicating that the relative difference between Caribou and Lakeview changed by year. Consistent with that interaction, year-specific estimated marginal means showed Lakeview > Caribou in 2024 at all spacings (8: 556 vs 471; 10: 573 vs 507; 12: 502 vs 466 cwt/ac), while in 2025 the pattern shifted (8: 495 vs 492, Lakeview slightly higher; 10: 557 vs 493, Caribou higher; 12: 497 vs 461, Caribou higher). Tukey-adjusted pairwise tests within each year did not detect significant differences among the six variety×spacing combinations, and spacing contrasts within variety were non-significant in both years; variety contrasts within spacing were also non-significant after adjustment, with only a nominal trend in 2024 at spacing 8 (Caribou − Lakeview = -84.68 cwt/ac, p = 0.0564). Random-effect estimates indicated moderate block-within-year variability (SD_year:rep = 23.71) relative to residual variability (SD_residual = 60.26). Overall, combined-year evidence suggests no robust spacing or interaction pattern involving spacing, but clear year-dependence in variety performance; therefore, variety recommendations should be interpreted in a year-specific framework and confirmed with additional years.