-
Notifications
You must be signed in to change notification settings - Fork 5
Started a mixed effects example for one variable RCBD. #42
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
Open
moorepants
wants to merge
2
commits into
master
Choose a base branch
from
rcbd-one-var-mixed-effects
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # This is an example of a single variate RCBD that has an addition random | ||
| # effect. | ||
| # | ||
| # To run the script type: | ||
| # source('rcbd_one_var_year.R', print.eval = TRUE) | ||
| # | ||
| # The code that will be displayed to the user is bounded by this separator: | ||
| #-----------------------------------------------------------------------------# | ||
|
|
||
| # Load the necessary libraries. | ||
| #-----------------------------------------------------------------------------# | ||
| library('nlme') # for lme() | ||
| #-----------------------------------------------------------------------------# | ||
|
|
||
| sep <- function(n){ | ||
| # This function simply prints a line of "=" to the screen as a separator and | ||
| # will not show up in the app. It is only here for nice printing. | ||
| line <- paste0(paste(replicate(n, "="), collapse = ""), '\n') | ||
| cat(line) | ||
| } | ||
|
|
||
| # Load the data. | ||
| #-----------------------------------------------------------------------------# | ||
| my.data <- read.csv("wheat_yield_data_with_year.csv") | ||
| #-----------------------------------------------------------------------------# | ||
|
|
||
| # Set Block, Treatment, and Year as factors. | ||
| #-----------------------------------------------------------------------------# | ||
| my.data$Block <- as.factor(my.data$Block) | ||
| my.data$Treatment <- as.factor(my.data$Treatment) | ||
| my.data$Year <- as.factor(my.data$Year) | ||
| #-----------------------------------------------------------------------------# | ||
|
|
||
| # Construct a mized effects model and print the summary results. | ||
| cat('Linear mixed effect model results\n') | ||
| sep(79) | ||
| #-----------------------------------------------------------------------------# | ||
| model <- lme(fixed = Yield ~ Treatment, random = ~1|Block/Year, data = my.data) | ||
| summary(model) | ||
| #-----------------------------------------------------------------------------# | ||
| sep(79) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| Year,Block,Treatment,Yield | ||
| 1999,1,Variety A,4.776113643 | ||
| 1999,2,Variety A,4.167309262 | ||
| 1999,3,Variety A,7.449164952 | ||
| 1999,4,Variety A,7.757967337 | ||
| 1999,1,Variety B,8.6989031 | ||
| 1999,2,Variety B,6.332884039 | ||
| 1999,3,Variety B,9.673666482 | ||
| 1999,4,Variety B,10.81933243 | ||
| 1999,1,Variety C,9.663780964 | ||
| 1999,2,Variety C,7.861877074 | ||
| 1999,3,Variety C,12.72423637 | ||
| 1999,4,Variety C,8.837111214 | ||
| 1999,1,Variety D,5.968923961 | ||
| 1999,2,Variety D,7.078335949 | ||
| 1999,3,Variety D,9.021241207 | ||
| 1999,4,Variety D,8.428939255 | ||
| 2000,1,Variety A,3.91823493 | ||
| 2000,2,Variety A,4.58761123 | ||
| 2000,3,Variety A,7.64636576 | ||
| 2000,4,Variety A,7.91800989 | ||
| 2000,1,Variety B,9.06640113 | ||
| 2000,2,Variety B,6.31342374 | ||
| 2000,3,Variety B,7.57774909 | ||
| 2000,4,Variety B,10.95260769 | ||
| 2000,1,Variety C,9.41454649 | ||
| 2000,2,Variety C,8.40584383 | ||
| 2000,3,Variety C,13.03441029 | ||
| 2000,4,Variety C,7.72061644 | ||
| 2000,1,Variety D,6.65400835 | ||
| 2000,2,Variety D,6.56413817 | ||
| 2000,3,Variety D,8.33194168 | ||
| 2000,4,Variety D,8.85568545 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 block is nested within year. Thus, it should be ~1|Year/Block. I'll look into this some more to be sure.
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 you might be right.
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.
This seems to be true based on other examples, so I'll edit it.