Possible bias when fitting linear regression with errors in variables using TMB

49 views
Skip to first unread message

DM Gillis

unread,
Jul 20, 2023, 8:09:25 AM7/20/23
to TMB Users
I am trying to develop a simple errors in variables (measurement error) example using TMB,  by including erros in X as a random variable. It is not specified as Random in making the objective function, since I do not want its effects to be integrated out. The slope returned is an improvement from the OLS solution, but the 95% CI falls short or the "true" value (simulated data) rather than being centered around it. I have posted details with a full code listing on Stack Overflow:


since my attempt to post it all here was rejected by the server. Any suggestions would be appreciated. Thank you for taking thetime to consider my problem.

Regards, Darren

Hans Skaug

unread,
Jul 21, 2023, 3:20:26 AM7/21/23
to TMB Users
Hi, I think this is more a statistical theory question than a question about TMB. There are different
assumptions that can be made for this model:
Your approach seems to add one parameter (del) per observation, which may be problematic.

DM Gillis

unread,
Jul 21, 2023, 8:47:11 AM7/21/23
to TMB Users
Thank you for the quick response.  There may be different model assumptions that work better, but I am interested in this form:



because it would be straight forward to extend it to other models besides linear regression. However, I am not sure that either 1) this form can be coded in TMB, and 2) if I have done it correctly. In this code, both have random components: Y (represented in the classic errors) and X (the del's) . If this formulation cannot be executed in TMB then I will seek other solutions (JAGS or STAN, perhaps), but I was hoping to stay in the world of likelihood (and learn some TMB at the same time).  Thanks again for taking the time to review this issue.

Regards, Darren

Mollie Brooks

unread,
Jul 21, 2023, 12:23:55 PM7/21/23
to DM Gillis, TMB Users
In response to Han’s comment, I tried running it with del as a random variable and didn’t do any better. I don’t know why, because the Wikipedia article seems to say it should be identifiable in this case.

Obj <- MakeADFun(data=Data, 
parameters=Params, 
random=c("del"),
DLL=model_name,
silent=FALSE)

Mollie

-- 
To post to this group, send email to us...@tmb-project.org. Before posting, please check the wiki and issuetracker at https://github.com/kaskr/adcomp/. Please try to create a simple repeatable example to go with your question (e.g issues 154, 134, 51). Use the issuetracker to report bugs.
--- 
You received this message because you are subscribed to the Google Groups "TMB Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmb-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tmb-users/aa366d14-40f1-4841-84df-9bdd7584e2c9n%40googlegroups.com.

DM Gillis

unread,
Jul 21, 2023, 3:15:16 PM7/21/23
to TMB Users
Yes, when I do the same it returns the OLS slope, which makes sense to me since setting it to "random" means it will be integrated out and should not impact the estimates (just their SEs). However, I want it to have an impact and move the slope around the true value of 2 :(  Perhaps TMB only works with latent random variables/effects and not variation added to predictors that are not not LRVs to be integrated out.Thanks for taking the time to check and enjoy the weekend! 

Darren

Reply all
Reply to author
Forward
0 new messages