Repository navigation
Conversation
|
Thank you for additional objective function. |
64f1b03 to
c89070a
Compare
|
Thanks, i updated the yaml so the new public functions are in the index. The low level helpers are already |
|
Hi @kaibagley, |
|
Hey, sorry for the delay! I'll get to work on addressing some of these issues now, but please feel free to make any changes you'd like if you need things to move a bit faster. I've been quite busy with PhD stuff recently, sorry! |
# Conflicts: # DESCRIPTION # _pkgdown.yml
|
Alright made a couple changes + merged. Please let me know what you think |
b10e143 to
61cdde6
Compare
wvjgsuhp
left a comment
There was a problem hiding this comment.
A few things here with these variables for reproducibility:
require(speed)
df <- initialise_design_df(items = 6, nrows = 4, ncols = 6, block_nrows = 1, block_ncols = 6)
score <- objective_function_info- The score from D criterion can be negative where
speed's simulated annealing stops when the score <= 0.res <- speed( df, swap = "treatment", swap_within = "block", obj_function = score, criterion = "D", iterations = 5000, seed = 1 ) res$scores
- If
Sigmaprovided, order matters.grid_index(seecalculate_adjacency_score) might work here in case users are calling the function outsidespeedcalls. The ideal is the scoring should work regardless of the order of dataframe order (again, reusinggrid_indexmight help).sigma <- cor_ar1_ar1(4, 6, rho_row = 0.6, rho_col = 0.3) c( as_built = score(df, "treatment", c("row", "col"), Sigma = Sigma)$score, sorted = score(df_sorted, "treatment", c("row", "col"), Sigma = Sigma)$score )
- When there is <= 1 block, the error should be raised accordingly. Docstring should state that a blocked design is required.
|
Again, sorry for the ultra late reply... Been very busy recently but I'm working on the branch now!! |
|
That's alright. No rush here. (I was quite late to check) |
|
Just made a bunch of changes, let me know what you think! |
wvjgsuhp
left a comment
There was a problem hiding this comment.
A few minor adjustments and we good.
An unnamed contrast_matrix can lead to unintended score calculation because it's matched to alphabetically sorted treatments (levels(factor(treatments)) -> T1, T10, T2, ...). See example below.
devtools::load_all()
df <- initialise_design_df(items = 10, nrows = 2, ncols = 10, block_nrows = 1, block_ncols = 10)
sigma <- cor_ar1_ar1(2, 10, rho_row = 0.6, rho_col = 0.3)
score <- objective_function_info
unnamed <- matrix(c(1, -1, rep(0, 8)), nrow = 1) # T1 vs T2
named <- unnamed
colnames(named) <- paste0("T", 1:10)
res_unnamed <- speed(
df,
swap = "treatment",
swap_within = "block",
obj_function = score,
Sigma = sigma,
contrast_matrix = unnamed,
seed = 1
)
res_named <- speed(
df,
swap = "treatment",
swap_within = "block",
obj_function = score,
Sigma = sigma,
contrast_matrix = named,
seed = 1
)
# T1 vs T2 variance of each optimised design
c(
unnamed = score(res_unnamed$design_df, "treatment", c("row", "col"), Sigma = sigma, contrast_matrix = named)$score,
named = score(res_named$design_df, "treatment", c("row", "col"), Sigma = sigma, contrast_matrix = named)$score
)08fd194 to
3b36184
Compare
|
New changes. Let me know what you think!! |
|
Added a lower bound parameter, and tweaked strings and tests, and simplified stopping |
# Conflicts: # R/optim_params.R # R/speed.R # man/optim_params.Rd
Fisher information based objective function, with A and D optimality criterion, and optimises spatially using a user-supplied covariance structure. It is calculated from treatment contrasts, adjusted for nuisance fixed effects like block and intercept.
And L removes nuisance effects under a spatial correlation structure from user-supplied$n \times n$ covariance $\Sigma$ and nuisance effects $X_2$
With A-optimality$\mathrm{tr}(I^-)$ or contrast-space D-optimality (pseudo determinant since I has rank $\nu - 1$ ) $-\log \left| I \right|$ .
So basically the user specifies the correlation structure they want to use at analysis, such as$AR1 \times AR1$ , and the design is optimised to be efficient under that spatial structure. So it should be directly targeting the Cramér-Rao lower bound rather than the adjacency proxy currently used in
speed.