Repeated Measures Anova in r using mean grain sizes
up vote
0
down vote
favorite
I am trying to run a repeated measures anova using r studio. I have in my possession mean sand grain sizes that were collected over a 12 year period from nine sites. Samples were collected from 4 sections of the beach: Foreshore, Backshore, MidBeach, Dune and saved in .csv format. I am testing to see if there is variation between mean grain sizes over time according to the site and shore position. Ex: I want to run a repeated measures anova of the mean grain sizes for "Foreshore" between all nine sites. I am not too sure if I am actually coding this properly and would like some help if possible.Sand Data p
Here is my line of code without specifying a section of the beach
```{r}
Years <- c(1,2,3,4,5,6,7,8,9,10,11,12)
YearFactor <- as.factor(Years)
YearFrame <- data.frame(YearFactor)
YearBind <- cbind(SandData$X2001, SandData$X2002, SandData$X2004, SandData$X2006, SandData$X2007, SandData$X2010, SandData$X2012, SandData$X2014, SandData$X2015, SandData$X2016, SandData$X2017, SandData$X2018)
library(car)
SandDataModel <- lm(YearBind ~ 1)
summary(SandDataModel)
```
This is code I used to run the same analysis but with only Foreshore mean grain values being tested.
```{r}
SandData_Foreshore <- subset(SandData, ShorePosition == "Foreshore", select= c("Site", "ShorePosition", "X2001", "X2002", "X2004", "X2006", "X2007", "X2010", "X2012", "X2014", "X2015", "X2016", "X2017", "X2018"))
SandData_Foreshore
YearBind_Foreshore <- cbind(SandData_Foreshore$X2001, SandData_Foreshore$X2002, SandData_Foreshore$X2004, SandData_Foreshore$X2006, SandData_Foreshore$X2007, SandData_Foreshore$X2010, SandData_Foreshore$X2012, SandData_Foreshore$X2014, SandData_Foreshore$X2015, SandData_Foreshore$X2016, SandData_Foreshore$X2017, SandData_Foreshore$X2018)
SandData_Foreshore <- lm(YearBind_Foreshore ~ 1)
analysis_Foreshore <- Anova(SandData_Foreshore, idata = YearFrame, idesign = ~YearFactor)
summary(analysis_Foreshore)
```
I am getting the following error message when I run the chunk above: error in eigen(qr.coef(SSPE.qr, x$SSPH), symmetric = FALSE) : infinite or missing values in 'x'
I know that the issue is related to the missing values in the data set. What would you all recommend to alleviate this error?
Essentially I need to know the following three things.
1.) Does my code look correct for this type of analysis?
2.) If my code is not correct, what steps do I need to take so my analysis is correct?
3.) How to deal with that error in the second chunk of code?
Thanks in advance
r anova manova
New contributor
add a comment |
up vote
0
down vote
favorite
I am trying to run a repeated measures anova using r studio. I have in my possession mean sand grain sizes that were collected over a 12 year period from nine sites. Samples were collected from 4 sections of the beach: Foreshore, Backshore, MidBeach, Dune and saved in .csv format. I am testing to see if there is variation between mean grain sizes over time according to the site and shore position. Ex: I want to run a repeated measures anova of the mean grain sizes for "Foreshore" between all nine sites. I am not too sure if I am actually coding this properly and would like some help if possible.Sand Data p
Here is my line of code without specifying a section of the beach
```{r}
Years <- c(1,2,3,4,5,6,7,8,9,10,11,12)
YearFactor <- as.factor(Years)
YearFrame <- data.frame(YearFactor)
YearBind <- cbind(SandData$X2001, SandData$X2002, SandData$X2004, SandData$X2006, SandData$X2007, SandData$X2010, SandData$X2012, SandData$X2014, SandData$X2015, SandData$X2016, SandData$X2017, SandData$X2018)
library(car)
SandDataModel <- lm(YearBind ~ 1)
summary(SandDataModel)
```
This is code I used to run the same analysis but with only Foreshore mean grain values being tested.
```{r}
SandData_Foreshore <- subset(SandData, ShorePosition == "Foreshore", select= c("Site", "ShorePosition", "X2001", "X2002", "X2004", "X2006", "X2007", "X2010", "X2012", "X2014", "X2015", "X2016", "X2017", "X2018"))
SandData_Foreshore
YearBind_Foreshore <- cbind(SandData_Foreshore$X2001, SandData_Foreshore$X2002, SandData_Foreshore$X2004, SandData_Foreshore$X2006, SandData_Foreshore$X2007, SandData_Foreshore$X2010, SandData_Foreshore$X2012, SandData_Foreshore$X2014, SandData_Foreshore$X2015, SandData_Foreshore$X2016, SandData_Foreshore$X2017, SandData_Foreshore$X2018)
SandData_Foreshore <- lm(YearBind_Foreshore ~ 1)
analysis_Foreshore <- Anova(SandData_Foreshore, idata = YearFrame, idesign = ~YearFactor)
summary(analysis_Foreshore)
```
I am getting the following error message when I run the chunk above: error in eigen(qr.coef(SSPE.qr, x$SSPH), symmetric = FALSE) : infinite or missing values in 'x'
I know that the issue is related to the missing values in the data set. What would you all recommend to alleviate this error?
Essentially I need to know the following three things.
1.) Does my code look correct for this type of analysis?
2.) If my code is not correct, what steps do I need to take so my analysis is correct?
3.) How to deal with that error in the second chunk of code?
Thanks in advance
r anova manova
New contributor
Welcome So. Please add reproducible example or link to your data in a repository.
– paoloeusebi
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to run a repeated measures anova using r studio. I have in my possession mean sand grain sizes that were collected over a 12 year period from nine sites. Samples were collected from 4 sections of the beach: Foreshore, Backshore, MidBeach, Dune and saved in .csv format. I am testing to see if there is variation between mean grain sizes over time according to the site and shore position. Ex: I want to run a repeated measures anova of the mean grain sizes for "Foreshore" between all nine sites. I am not too sure if I am actually coding this properly and would like some help if possible.Sand Data p
Here is my line of code without specifying a section of the beach
```{r}
Years <- c(1,2,3,4,5,6,7,8,9,10,11,12)
YearFactor <- as.factor(Years)
YearFrame <- data.frame(YearFactor)
YearBind <- cbind(SandData$X2001, SandData$X2002, SandData$X2004, SandData$X2006, SandData$X2007, SandData$X2010, SandData$X2012, SandData$X2014, SandData$X2015, SandData$X2016, SandData$X2017, SandData$X2018)
library(car)
SandDataModel <- lm(YearBind ~ 1)
summary(SandDataModel)
```
This is code I used to run the same analysis but with only Foreshore mean grain values being tested.
```{r}
SandData_Foreshore <- subset(SandData, ShorePosition == "Foreshore", select= c("Site", "ShorePosition", "X2001", "X2002", "X2004", "X2006", "X2007", "X2010", "X2012", "X2014", "X2015", "X2016", "X2017", "X2018"))
SandData_Foreshore
YearBind_Foreshore <- cbind(SandData_Foreshore$X2001, SandData_Foreshore$X2002, SandData_Foreshore$X2004, SandData_Foreshore$X2006, SandData_Foreshore$X2007, SandData_Foreshore$X2010, SandData_Foreshore$X2012, SandData_Foreshore$X2014, SandData_Foreshore$X2015, SandData_Foreshore$X2016, SandData_Foreshore$X2017, SandData_Foreshore$X2018)
SandData_Foreshore <- lm(YearBind_Foreshore ~ 1)
analysis_Foreshore <- Anova(SandData_Foreshore, idata = YearFrame, idesign = ~YearFactor)
summary(analysis_Foreshore)
```
I am getting the following error message when I run the chunk above: error in eigen(qr.coef(SSPE.qr, x$SSPH), symmetric = FALSE) : infinite or missing values in 'x'
I know that the issue is related to the missing values in the data set. What would you all recommend to alleviate this error?
Essentially I need to know the following three things.
1.) Does my code look correct for this type of analysis?
2.) If my code is not correct, what steps do I need to take so my analysis is correct?
3.) How to deal with that error in the second chunk of code?
Thanks in advance
r anova manova
New contributor
I am trying to run a repeated measures anova using r studio. I have in my possession mean sand grain sizes that were collected over a 12 year period from nine sites. Samples were collected from 4 sections of the beach: Foreshore, Backshore, MidBeach, Dune and saved in .csv format. I am testing to see if there is variation between mean grain sizes over time according to the site and shore position. Ex: I want to run a repeated measures anova of the mean grain sizes for "Foreshore" between all nine sites. I am not too sure if I am actually coding this properly and would like some help if possible.Sand Data p
Here is my line of code without specifying a section of the beach
```{r}
Years <- c(1,2,3,4,5,6,7,8,9,10,11,12)
YearFactor <- as.factor(Years)
YearFrame <- data.frame(YearFactor)
YearBind <- cbind(SandData$X2001, SandData$X2002, SandData$X2004, SandData$X2006, SandData$X2007, SandData$X2010, SandData$X2012, SandData$X2014, SandData$X2015, SandData$X2016, SandData$X2017, SandData$X2018)
library(car)
SandDataModel <- lm(YearBind ~ 1)
summary(SandDataModel)
```
This is code I used to run the same analysis but with only Foreshore mean grain values being tested.
```{r}
SandData_Foreshore <- subset(SandData, ShorePosition == "Foreshore", select= c("Site", "ShorePosition", "X2001", "X2002", "X2004", "X2006", "X2007", "X2010", "X2012", "X2014", "X2015", "X2016", "X2017", "X2018"))
SandData_Foreshore
YearBind_Foreshore <- cbind(SandData_Foreshore$X2001, SandData_Foreshore$X2002, SandData_Foreshore$X2004, SandData_Foreshore$X2006, SandData_Foreshore$X2007, SandData_Foreshore$X2010, SandData_Foreshore$X2012, SandData_Foreshore$X2014, SandData_Foreshore$X2015, SandData_Foreshore$X2016, SandData_Foreshore$X2017, SandData_Foreshore$X2018)
SandData_Foreshore <- lm(YearBind_Foreshore ~ 1)
analysis_Foreshore <- Anova(SandData_Foreshore, idata = YearFrame, idesign = ~YearFactor)
summary(analysis_Foreshore)
```
I am getting the following error message when I run the chunk above: error in eigen(qr.coef(SSPE.qr, x$SSPH), symmetric = FALSE) : infinite or missing values in 'x'
I know that the issue is related to the missing values in the data set. What would you all recommend to alleviate this error?
Essentially I need to know the following three things.
1.) Does my code look correct for this type of analysis?
2.) If my code is not correct, what steps do I need to take so my analysis is correct?
3.) How to deal with that error in the second chunk of code?
Thanks in advance
r anova manova
r anova manova
New contributor
New contributor
New contributor
asked Nov 21 at 0:21
user10682953
1
1
New contributor
New contributor
Welcome So. Please add reproducible example or link to your data in a repository.
– paoloeusebi
2 days ago
add a comment |
Welcome So. Please add reproducible example or link to your data in a repository.
– paoloeusebi
2 days ago
Welcome So. Please add reproducible example or link to your data in a repository.
– paoloeusebi
2 days ago
Welcome So. Please add reproducible example or link to your data in a repository.
– paoloeusebi
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
user10682953 is a new contributor. Be nice, and check out our Code of Conduct.
user10682953 is a new contributor. Be nice, and check out our Code of Conduct.
user10682953 is a new contributor. Be nice, and check out our Code of Conduct.
user10682953 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403581%2frepeated-measures-anova-in-r-using-mean-grain-sizes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome So. Please add reproducible example or link to your data in a repository.
– paoloeusebi
2 days ago