-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added an RCBD design example with two main independent variables. #34
Conversation
sep(50) | ||
|
||
# Plot the mean yield with respect to each virus level. | ||
# TODO : Is the default plot ok here, or is something different desired? |
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.
The type of plots is good, but I think the units should be added to the y axis in parentheses. Can an option be added to the GUI where the user enters the units?
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.
Yes, we can add units to plots via the GUI, but let's just leave that as icing on the cake for now. I opened an issue: #37
cat("Levene's Test\n") | ||
sep(79) | ||
#------------------------------------------------------------------------------# | ||
#leveneTest(model) |
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.
@msimmond I don't know what I'm doing here. Levene's test is giving me an error for this model. (Note that you can pass in the formula and the data, or like here, just the lm/aov model object.)
#------------------------------------------------------------------------------# | ||
sep(79) | ||
|
||
# The user will select the alpha level from the app. |
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.
I think we should keep this fixed at p = 0.05
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.
Ok, that makes it easier. I forget why I thought it should be selectable by the user, maybe someone said that at some point.
#------------------------------------------------------------------------------# | ||
sep(50) | ||
|
||
# Show the confidence intervals for the intercept and each virus level. |
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.
is this comment left over from something else? there's no virus or intercept that I know of
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.
yes, copy paste error
Ok, maybe the only thing left on this one is to add in the correct transformation. |
sep(50) | ||
|
||
# Run Levene's Test for a one-way ANOVA of each of the main factors. | ||
# TODO : clone is significant in Levene's test so transformation is necessary. |
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.
transformations added above. log-transformation was best fit.
@msimmond I'm reading the transformation code here. What transformations do you want to support? Just base 10 log and raising to a power? Should we be doing the calculation to get the best exponent be done for the user should we simply let the user type in the desired value of the exponent? |
For now I think 3 transformations should be available: base 10 log, square root, and raising to a power using the algorithm to find best fit. |
Ok, that sounds fine. |
@msimmond I've updated this example to strictly use the log10 transform and added a bar plot for the LSD.test. Is this correct? See the results at the top of this PR. |
Should the |
I think the two interaction plots are redundant, is that the case? |
From Maegen: The different transformations weren't meant to be run in sequence. I was using it to test each one to see how it affected the assumption tests - sorry for not specifying. For the app, it would need functions to identify each transformation as a new variable (which I think you did). Ex. possible dependent variables: factorA, log10.factorA, power.factorA. And each time the user selects a new transformation (without reloading data), I assume it's applying it to the original variable that's selected in the dropdown for 'dependent variable'. That would be the correct way. @msimmond One question for this one: You had a triple transformation, something like sqrt(log10(Y))^power and I changed it to simply a log10(Y) tranformation because that is what you had in the comments. Is this correct? |
With the log10 transform I'm still seeing a sig p value in the Levene Test for clone. |
sep(79) | ||
#------------------------------------------------------------------------------# | ||
leveneTest(yield ~ clone, data=my.data) | ||
leveneTest(yield ~ nitrogen, data=my.data) |
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.
Noticed the Levene's tests are still using the original units, and not log10. It seems like it's corrected in the app at least for this example.
I'm not seeing the sig p value in levene's for clone with the log 10 transform in the app. |
sep(79) | ||
#------------------------------------------------------------------------------# | ||
lsd.results <- LSD.test(model, c('clone', 'nitrogen'), console = TRUE) | ||
#------------------------------------------------------------------------------# |
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.
Since talking with Lauren, we decided that we don't need to back-transform the LS means (lsd.results$means$yield or lsd.results$groups$means). However, what we want here is for the user to view 2 outputs: First, a table for the lsd.results of the transformed dataset (done in line 148), and second, a partial amended table of the lsd.results of the original dataset. For this second table based on the original dataset: i.e., aov(yield ~ block + clone + nitrogen + clone:nitrogen, data=my.data), we want the user to see the lsd.results$means table with the corresponding LSD letters (lsd.results$groups$M) from the transformed dataset copied to it, by matching treatments. The second dataframe would be used for generating the post-hoc plot(s).
This is where I need your help. I've been working on creating the second table, but since there isn't a column within lsd.results$means specifying the treatment names, I don't know how join the column lsd.results$groups$M from transformed dataframe to the original dataframe lsd.results$means using 'by' statement.
Whatever we create from this, will be fed into the ggplot, and I want to make sure that we don't show or use the lsd letters from the original dataset.
Not sure how to do this.
This is the workflow I have so far:
'# When there is a transformed variable, as in this example, do second lsd.test on original dataset to obtain dataframe '# lsd.results.original, but replace lsd.results.original$groups$M with lsd.results$groups$M from transformed dataset.
'# Do lsd test on original data
model.original <- aov(yield ~ block + clone + nitrogen + clone:nitrogen,
data=my.data)
get.orig.LSmeans <- LSD.test(model.original, c('clone', 'nitrogen')) #Don't show output yet
'# Replace get.orig.LSmeans$groups$M with lsd.test$groups$M
??
'# Show single table with LS mean, std, r, LCL, UCL, min, max, and lsd.test$groups$M. Display with heading:
' # 'Lease square means of original dataset. Note that LSD test was performed on log-transformed dataset.' Followed by 'ATTENTION: When reporting LSD groups in the original units shown here, remember to specify that the LSD test was performed on log-transformed data.'
Ok, I'll look at this soon. In the meantime does this do what you want?: https://github.com/ucd-ipo/aip-analysis/pull/51/files#diff-07838b7a58641aa441c07b70abcfaa1fR843 I wrote this code to merge the summarySE and lsd.results$groups tables. |
Yes, but not for the case where you have a transformed variable. If it's for an analysis of a transformed variable, columns 5, 6, 7, 8, and 9 would be replaced with the output from the original variable. Column 10 'M' would stay the same. |
Added an RCBD design example with two main independent variables.
@msimmond I've moved this RCBD example to this pull request. I'll make a pull request for each example so we can discuss the code for each example.
Stuff:
confint()
call?