Relating to joint_tests doesn't recognize asin.sqrt transformation via make.tran() I have emmeans
1.8.8
set.seed(83)
library(emmeans)
dummy <- expand.grid(
covar = runif(72, min = 0, max = 1),
resp = runif(72, min = 0, max = 2),
site = c("a", "b", "c", "d", "e", "g"),
C = 1:4,
R = c("i", "j", "k")
)
as.tran <- make.tran("asin.sqrt")
mod <- with(as.tran, lm(sqrt(resp) ~ site + C * R * linkfun(covar), data = dummy))
This joint_tests
command did not give any row that involved the covar.
joint_tests(mod)
model term df1 df2 F.ratio p.value
site 5 373231 0.000 1.0000
C 1 373231 0.000 1.0000
R 2 373231 0.000 1.0000
C:R 2 373231 0.000 1.0000
Switching resp
and covar
, and the joint_tests(mod2)
below gave the full ancova model
mod2 <- with(as.tran, lm( linkfun(covar) ~ site + C * R * sqrt(resp), data = dummy))
joint_tests(mod2)
model term df1 df2 F.ratio p.value
site 5 373231 0.000 1.0000
C 1 373231 0.000 1.0000
R 2 373231 0.000 1.0000
resp 1 373231 0.000 1.0000
C:R 2 373231 0.000 1.0000
C:resp 1 373231 0.000 1.0000
R:resp 2 373231 0.000 1.0000
C:R:resp 2 373231 0.000 1.0000
With asin
, joint_tests
recognize on-the-fly transformation of the covariate outside of make.tran()
mod3 <- lm( sqrt(resp) ~ site + C * R * asin(covar), data = dummy)
joint_tests(mod3)
model term df1 df2 F.ratio p.value
site 5 373231 0.000 1.0000
C 1 373231 0.000 1.0000
R 2 373231 0.000 1.0000
covar 1 373231 0.000 1.0000
C:R 2 373231 0.000 1.0000
C:covar 1 373231 0.000 1.0000
R:covar 2 373231 0.000 1.0000
C:R:covar 2 373231 0.000 1.0000
but not in make.tran()
a.tran = make.tran("asin")
mod4 <- with(a.tran, lm(sqrt(resp) ~ site + C * R * linkfun(covar), data = dummy))
joint_tests(mod4)
model term df1 df2 F.ratio p.value
site 5 373231 0.000 1.0000
C 1 373231 0.000 1.0000
R 2 373231 0.000 1.0000
C:R 2 373231 0.000 1.0000
Thanks for stopping by.
As was explained in the related GitHub issue page, the problem is that by default, covariates are reduced to an interval of two values that differ by 2. That throws both ends outside the legal interval of [0,1] for this transformation, resulting in
NaN
values and the covariate terms being hidden because they have 0 d.f. You will see results if you do, for example,... so that a much shorter interval is used that puts everything within bounds.