## Load the Switzerland data
data(Switzerland)
## Summarise the Switzerland data
summary(Switzerland)
## Fit a DI model
m1 <- DI(y = "yield", prop = 4:7, treat = 'nitrogen', DImodel = 'AV',
density = 'density', estimate_theta = FALSE, data = Switzerland)
summary(m1)
## Contrasts for difference between monocultures of p1 and p2, p3 and p4, p2 and p3
con1 <- contrasts_DI(object = m1,
contrast = list('p1vp2 Mono' = c(1, -1, 0, 0, 0, 0, 0),
'p3vp4 Mono' = c(0, 0, 1, -1, 0, 0, 0),
'p2vp3 Mono' = c(0, -1, 1, 0, 0, 0, 0)))
summary(con1)
## Contrasts for 50:50 mixture of p1 and p2 vs 50:50 mixture of p3 and p4
con2 <- contrasts_DI(object = m1,
contrast = list('p1p2 vs p3p4' = c(0.5, 0.5, -0.5, -0.5, 0, 0, 0)))
summary(con2)
## Example using contrast_vars
data(sim2)
### Fit model with block
m2 <- DI(y = "response", prop = 3:6, DImodel = 'FULL', block = 'block',
estimate_theta = FALSE, data = sim2)
summary(m2)
### contrast for average of first two blocks vs third block
con3 <- contrasts_DI(object = m2,
contrast_vars = list('block' = list('1_2vs3' = c(0.5, 0.5, -1, 0))))
summary(con3)
Run the code above in your browser using DataLab