true variable cannot also be in by
mikesweeting opened this issue · 2 comments
mikesweeting commented
We might want a situation where the true parameter value is varying across scenario settings
Currently simsum gives a warning message (rather than an error) if the true variable is also in by. But the nlp plot does not work.
A contrived example below is shown where esigma is assumed to be the true value of the parameter (estvarname)
s.nlp.true <- rsimsum::simsum(
data = nlp, estvarname = "b", true = "esigma", se = "se",
methodvar = "model", by = c("baseline", "ss", "esigma")
)
autoplot(s.nlp.true, stats = "bias", type = "nlp")
Work-around
A work-around is to create a copy of the true parameter.
nlp$esigma.copy <- nlp$esigma
s.nlp.true2 <- rsimsum::simsum(
data = nlp, estvarname = "b", true = "esigma.copy", se = "se",
methodvar = "model", by = c("baseline", "ss", "esigma")
)
autoplot(s.nlp.true2, stats = "bias", type = "nlp")
ellessenne commented
Now fixed in PR #53:
library(rsimsum)
s.nlp.true <- rsimsum::simsum(
data = nlp, estvarname = "b", true = "esigma", se = "se",
methodvar = "model", by = c("baseline", "ss", "esigma")
)
#> 'ref' method was not specified, 1 set as the reference
library(ggplot2)
autoplot(s.nlp.true, stats = "bias", type = "nlp")
Created on 2023-05-28 with reprex v2.0.2
If you'd like you can test it with:
remotes::install_github("ellessenne/rsimsum", ref = remotes::github_pull("53"))
ellessenne commented
This is fixed in {rsimsum} 0.13.0, which is now on CRAN.