R Under development (unstable) (2024-09-21 r87186 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library("mlt") Loading required package: basefun Loading required package: variables > > set.seed(28) > n <- 100 > g <- gl(2, n) > y <- rnorm(length(g), mean = c(2, 1)[g], sd = c(.5, 1.5)[g]) > mydata <- data.frame(g = g, y = y) > > by <- polynomial_basis(numeric_var("y", support = range(y)), coef = c(1, 1), ci = c(-Inf, 0)) > m1 <- ctm(by, interacting = as.basis(~ g - 1, data = mydata)) > fm1 <- mlt(m1, data = mydata) > logLik(fm1) 'log Lik.' -259.6152 (df=4) > vcov(fm1) (Intercept):g1 y:g1 (Intercept):g2 y:g2 (Intercept):g1 0.08823089 -0.03935633 0.00000000 0.00000000 y:g1 -0.03935633 0.01979935 0.00000000 0.00000000 (Intercept):g2 0.00000000 0.00000000 0.01091145 -0.00136613 y:g2 0.00000000 0.00000000 -0.00136613 0.00204762 > cf1 <- coef(fm1) > 1 / cf1[c(2, 4)] y:g1 y:g2 0.5025271 1.5626449 > -cf1[c(1, 3)] / cf1[c(2,4)] (Intercept):g1 (Intercept):g2 1.9877592 0.6671799 > > ### no constraints here! > m2 <- ctm(by, interacting = as.basis(~ g, data = mydata)) > fm2 <- mlt(m2, data = mydata) > logLik(fm2) 'log Lik.' -259.6152 (df=4) > vcov(fm2) (Intercept):(Intercept) y:(Intercept) (Intercept):g2 (Intercept):(Intercept) 0.08823092 -0.03935634 -0.08823092 y:(Intercept) -0.03935634 0.01979935 0.03935634 (Intercept):g2 -0.08823092 0.03935634 0.09914238 y:g2 0.03935634 -0.01979935 -0.04072247 y:g2 (Intercept):(Intercept) 0.03935634 y:(Intercept) -0.01979935 (Intercept):g2 -0.04072247 y:g2 0.02184697 > (cf2 <- coef(fm2)) (Intercept):(Intercept) y:(Intercept) (Intercept):g2 -3.955527 1.989943 3.528571 y:g2 -1.350002 > c(cf1[1:2], cf1[3:4] - cf1[1:2]) (Intercept):g1 y:g1 (Intercept):g2 y:g2 -3.955526 1.989942 3.528571 -1.350002 > > 1 / cf2[2] y:(Intercept) 0.5025269 > 1 / sum(cf2[c(2, 4)]) [1] 1.562645 > > -cf2[1] / cf2[2] (Intercept):(Intercept) 1.987759 > -sum(cf2[c(1, 3)]) / sum(cf2[c(2, 4)]) [1] 0.6671799 > > proc.time() user system elapsed 1.62 0.23 1.84