|
ElMaestro ★★★ Denmark, 2026-05-27 12:22 (22 d 17:54 ago) Posting: # 24633 Views: 1,224 |
|
|
Hi all, long post, I apologise. Some time ago a weirdo published a paper about fitting mixed models for semi-replicated designs, where he showed how it is possible to work directly in the observational covariance matrix V, rather than using V=ZGZt+R and working in G and R. This allows us to avoid fitting a model that involves a within-T variance component, since it does not exist with the semi-replicated designs. Great concept, eh? ![]() The author gave some working R code for it. The code did not, however, include derivation of a 90% CI with Satterthwaite's df approximation (or any other approximation for that matter). I have been through literature incl. SAS's helpfiles for Proc Mixed and read into papers on mixed models. As I am not a mathematician, much of it is quite inaccessible to me. So, I asked https://deepai.org for help with deriving the 90% CI for T-R based on Satt dfs, and so far I failed miserably. At my end Deepai readily takes on the challenge, and produces all sorts of complicated code which ends up with extremely wrong estimates of the df. For example anywhere from -37165346958870.86 to 1e10. It ends up in anobscure debate with itself about Hessians, ill-conditioned matrices, ridge-stabilisation, regularisation constants, Fishbutt adjustment, Cojones-Krasilnikoff correction, L-BFGS-B, and much other incomprehensible stuff. It then oscillates between dysfunctional solutions. Whatever I do I seem to end up with severely ill-conditioned Hessians which I guess may be the (or a) reason for badly estmated df's. Can someone find a way to do it, with or without AI help? Below is some code to get you started, the code is a slightly adjusted version of the weirdo's spew. All we need is "the rest" which derives the 90% CI with Satt df.
— Pass or fail! ElMaestro |
|
ElMaestro ★★★ Denmark, 2026-05-30 05:36 (20 d 00:40 ago) @ ElMaestro Posting: # 24634 Views: 1,048 |
|
|
I am so impressed, it did not take long for mittyri to propose code that seems to do it. His code looks like this:
Impressive. ![]() — Pass or fail! ElMaestro |
|
Helmut ★★★ ![]() Vienna, Austria, 2026-05-30 11:33 (19 d 18:43 ago) @ ElMaestro Posting: # 24635 Views: 1,025 |
|
|
Hi to both of you! Sorry that the forum has hiccups and is not accessible most of the time. Fucking DoS-attacks again… ❝ His code looks like this:
But if I try the code, I get:
Am I missing something? — Dif-tor heh smusma 🖖🏼 Довге життя Україна! ![]() Helmut Schütz ![]() The quality of responses received is directly proportional to the quality of the question asked. 🚮 Science Quotes |
|
ElMaestro ★★★ Denmark, 2026-05-30 13:52 (19 d 16:24 ago) @ Helmut Posting: # 24636 Views: 987 |
|
|
Hi Hötzi, ❝ But if I try the code, I get: ❝
❝ Am I missing something? Yes, it looks like you are missing a function called Create.CovM ![]() Try this:
You then beam up Scotty with a call such as:
u=Run.REML.from.file("John300526.csv", parIni=c(1, 1, .5, 1))And you should get something that might look like dis:
Var.Component Ini.guess REML.EstimateFor this dataset it is apparently troublesome to figure out a good initial guess (at least the default code doesn't do it too well); the variances are rather high. So we just supply something that works better. I was at some point looking into writing a loop that tries e.g. 20 different approaches to initial guesses and simply reports when one of them results in convergence. There is a bit of work to do. Initial guesses have always been a sore topic for optimisers. If WNL or SAS did not converge, then I bet it is due to a bad combination of initial guesses and optimiser. When the user does not supply some proper initial guesses, the software either not start the optimiser or it will need to guess on its own. That's where the trouble is. I can't upload the file using the forum's upload function, so I will send it to you directly. ![]() — Pass or fail! ElMaestro |
|
ElMaestro ★★★ Denmark, 2026-05-30 15:08 (19 d 15:08 ago) @ ElMaestro Posting: # 24637 Views: 981 |
|
|
The following code makes a few different attempts. It first tries the plain old guesses. if that doesn't work it adds a little scatter to the guesses. This seems to do the trick. I have not tested anything thoroughly here. Am horizontal in Vadodara.
— Pass or fail! ElMaestro |
|
ElMaestro ★★★ Denmark, 2026-05-30 20:56 (19 d 09:20 ago) @ ElMaestro Posting: # 24638 Views: 939 |
|
|
Hi again, I looked back at some of the remarks in the old thread with John's data. And I was reminded how precision of an estimate is, to some people, much like a holy grail. The difference between .12345 and .12346 is of importance... well... to some ![]() So I will likely be murdered when someone notices I used tol=1e-8 for the Nelder-Mead optimiser in my previous post and therefore the estimates are way off, right? So I bring you Remoulade. This is just code delivering a kind of proof of concept. It is not final, it is not release-grade, it is not pretty and it is not conformant to any standards. But it does the job on my machine. The function proto is Remoulade=function(sFN, tol.varWR=1e-6)(full portion of Remoulade at the end of this post) where tol.varWR simply indicates how well (more or less "at which decimal place") we wish to know the estimate on the intrasubject variability for Ref. We start by finding a set of starter values that will make Nelder-Mead converge. We do so using a cheap, fast and dirty level of tol. Once that is done, we iteratively decrease tol for Nelder-Mead (using the starter values that work), until we can't improve the estimate of varWR more than tol.varWR. Then we have our estimate to the desired precision. set.seed(2173)and I get:
This can be improved much further. For example, if someone specifies a too low value of tol.varWR then Nelder-Mead will not and/or can not converge. And so on. Such matters could be captured. And much else. Note that the curvature of the likelihood surface depends on the data. That's why a universal tol for NM can't be defined, or at least I do not see a good way to do so. Here's Remoulade:
— Pass or fail! ElMaestro |
|
Helmut ★★★ ![]() Vienna, Austria, 2026-05-31 12:46 (18 d 17:30 ago) @ ElMaestro Posting: # 24639 Views: 887 |
|
|
— Dif-tor heh smusma 🖖🏼 Довге життя Україна! ![]() Helmut Schütz ![]() The quality of responses received is directly proportional to the quality of the question asked. 🚮 Science Quotes |
|
ElMaestro ★★★ Denmark, 2026-05-31 13:43 (18 d 16:33 ago) @ Helmut Posting: # 24640 Views: 883 |
|
|
Hi Hötzi, ❝ Can you try John’s 2nd data set as well? Our compiled results in this post. Sure, at tol=1e-8 for NM I get:
Var.Component Ini.guess REML.EstimateAt 1e-12 I get:
Var.Component Ini.guess REML.Estimate— Pass or fail! ElMaestro |



![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
![[image]](https://static.bebac.at/img/CC by.png)

