OneSampleMR icon indicating copy to clipboard operation
OneSampleMR copied to clipboard

Issue adding covariates to tsps model

Open isabelamorita opened this issue 7 months ago • 1 comments

Hi,

I'm encountering an issue when specifying different covariates for the first and second stages in a tsps model.

For example: tsps("outcome ~ exposure + covariates_stage2 | instrument + covariates_stage1")

I'd like to include covariates only in the second stage (covariates_stage2) and not in the first stage (covariates_stage1). However, when I try this, I get the following error:

Error in moments[, i] <- (X - linearpredictor) * Zwithcons[, i] : incorrect number of subscripts on matrix

Do I need to include the same covariates in both stages? Or is there a way to specify covariates only for the second stage without this error?

Any help would be appreciated!

isabelamorita avatar May 27 '25 18:05 isabelamorita

Hi there.

It's my understanding that one should include the same covariates in the first and second stages for both the TSPS and TSRI models.

If you know of a reference that argues against this do let me know.

I think I should issue a more informative error message when different covariates are included, so I'm grateful you could work out what was causing your error.

remlapmot avatar May 29 '25 14:05 remlapmot