-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support sample weights in all circa*() functions #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Alex - thanks for the PR and new feature.
I've made some feedback - could you please make those suggested changes?
Also, there are currently no new tests. Could you please add a test or two to ensure that the weights arguments are being used appropriately? For example, you could fit a model and then check that the nls model within contains a weights vector within the object.
df <- make_data(phi1 = 6)
out <- circacompare(
x = df, col_time = "time", col_group = "group",
col_outcome = "measure"
)
expect_true(all(out$fit$weights) == 1)
sw <- jitter(rep(1, nrow(df)), factor=2)
out2 <- circacompare(
x = df, col_time = "time", col_group = "group",
col_outcome = "measure", sample_weights = sw
)
expect_false(all(out2$fit$weights == 1))
or something to that effect?
Thank you!!
Rex
Also, I'm pretty sure you're right about the use of The function documentation could explicitly state that these weights are passed using Thanks! |
Hi Rex, thanks for the review, good points made. I resolved all requested changes, implemented weights for the mixed functions and added tests for all four Please let me know if I missed anything or other changes are necessary. best, |
Thanks Alex - all your changes look good to me. I've just made a couple commits but these are just formatting changes. |
Dear Rex,
following up late on #7 I added sample weights support to both
circacompare()
,circa_single()
andmodel_each_group()
(thenls()
part of it) and added a toy example to the@examples
.I intentionally did not add it to the mixed effect functions as it is unclear to me how. I think it is via something like
nlme(..., weights = varPower(form=~sample_weights))
but nlme documentation and google search did not make me confident enough to add it.Right now
circacompare()
andcirca_single()
have a new argumentsample_weights
that write the sample weights to thenls()
input data, or when weights are NULL (the default) it simply adds a1
per sample, so no weighting takes place.Please have a look if you have time.
best,
Alex