anova

How can I force dropping intercept or equivalent in this linear model?

若如初见. 提交于 2019-12-20 06:21:58
问题 Consider the following table : DB <- data.frame( Y =rnorm(6), X1=c(T, T, F, T, F, F), X2=c(T, F, T, F, T, T) ) Y X1 X2 1 1.8376852 TRUE TRUE 2 -2.1173739 TRUE FALSE 3 1.3054450 FALSE TRUE 4 -0.3476706 TRUE FALSE 5 1.3219099 FALSE TRUE 6 0.6781750 FALSE TRUE I'd like to explain my quantitative variable Y by two binary variables (TRUE or FALSE) without intercept. The argument of this choice is that, in my study, we can't observe X1=FALSE and X2=FALSE at the same time, so it doesn't make sense

substitute in r together with anova

余生长醉 提交于 2019-12-19 08:13:15
问题 I tried to run anova on different sets of data and didn't quite know how to do it. I goolged and found this to be useful: https://stats.idre.ucla.edu/r/codefragments/looping_strings/ hsb2 <- read.csv("https://stats.idre.ucla.edu/stat/data/hsb2.csv") names(hsb2) varlist <- names(hsb2)[8:11] models <- lapply(varlist, function(x) { lm(substitute(read ~ i, list(i = as.name(x))), data = hsb2) }) My understanding of what the above codes does is it creates a function lm() and apply it to each

How can I plot multiple residuals plots in a loop?

自古美人都是妖i 提交于 2019-12-18 09:28:42
问题 In the following example, I want to write the residuals plot of each model in a file. I do not need to see them in my display. for (i in 1:500){ temp.model<-lme(as.formula(paste("Var",i) ~ X1*X2, sep=""), data = example, random=~1| Exp/Person) jpeg(paste("C:/Myfolder", i, ".jpg", sep = ""), quality=50, bg="white") plot(temp.model) dev.off () graphics.off() } When I run this code without loop, I obtain what I want. However, it creates blank files within the loop. Any ideas? Thank you. 回答1: The

Is there an equivalent function for anova.lm() in Java?

China☆狼群 提交于 2019-12-18 09:15:08
问题 I am comparing two linear models in R with Anova, and I would like to do the same thing in Java. To simplify it, I took the example code from https://stats.stackexchange.com/questions/48854/why-am-i-getting-different-intercept-values-in-r-and-java-for-simple-linear-regr and modified it a bit below. The models are test_trait ~ geno_A + geno_B and test_trait ~ geno_A + geno_B + geno_A:geno_B . The coefficients of the models implemented in R and Java are the same. In R I use anova(fit, fit2)

Extract p-value from aov

☆樱花仙子☆ 提交于 2019-12-17 06:31:10
问题 I am looking to extract the p-value generated from an anova in R. Here is what I am running: test <- aov(asq[,9] ~ asq[,187]) summary(test) Yields: Df Sum Sq Mean Sq F value Pr(>F) asq[, 187] 1 3.02 3.01951 12.333 0.0004599 *** Residuals 1335 326.85 0.24483 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 12 observations deleted due to missingness When I look a the structure, this is what I see. I usually can work through lists to get what I need, but I am having a hard time

Inference() Function Insisting That I Use ANOVA Versus Two-Sided Hypothesis Test; R/RStudio

两盒软妹~` 提交于 2019-12-13 08:19:42
问题 I'm trying to use a custom function called Inference() as seen in the code below. There's no documentation for the function, but it is from my DASI class in Coursera. According to the feedback I have received, I am using the function properly. I'm trying to do a two-sided hypothesis test between my class variable and my wordsum variable, that is, between the two means of the categories low class and working class. So, the average wordsum for working class - average wordsum for lower class.

Loop through several post hoc tests in R

好久不见. 提交于 2019-12-13 07:24:28
问题 I have a dataframe called data. I have created a function that loop thorugh a list of variables and creates a linear model for each of them using lapply. This method is based on this post. library(datasets) testDF <- data.frame(Salaries) #creates list of variables varListTest <- names(testDF)[3:4] #creates a model for each of the variables in question model<- lapply(varListTest, function(x) { lm(substitute(i~Rank, list(i = as.name(x))), data = testDF)}) #output model lapply(model, summary)

One way ANOVA for every column

十年热恋 提交于 2019-12-13 02:49:36
问题 I need to run a one way ANOVA on every column in a data frame based on another column. My data frame has 57 columns, so it is very time consuming to type out every column name. Here is part of my data frame. So basically, I need this function run for every column aov(df$PGY_16 ~ df$Total_Time_cm_16, df) So I need a loop to run that for every column in my data frame. Any help would be greatly appreciated! 回答1: For reproducibility, the code below uses the built-in mtcars data frame and returns

post hoc test for a two way mixed model anova

自古美人都是妖i 提交于 2019-12-12 12:50:13
问题 I am doing a repeated measures anova with a mixed model. I would like to run a post hoc test to see the p-values of the interaction TREAT*TIME, but I only managed to use the following ghlt Tukey test which do not give me the interaction I am looking for. library(multcomp) library(nlme) oi<-lme(total ~ TREAT * TIME, data=TURN, random = ~1|NO_UNIT) anova(oi) summary(glht(oi, linfct=mcp(TIME="Tukey", TREAT="Tukey"))) what I would be looking for is something like: summary(glht(oi, linfct=mcp(TIME

Test for significance of specific multiple groups in R

a 夏天 提交于 2019-12-12 05:49:46
问题 The data looks as follows: > data <- read.csv("data.csv") > head(data) ï..class.1 rev.1 class.2 rev.2 1 7 136.9900 1318 31.9900 2 1223 24.0984 1001 0.0000 3 1318 61.9900 6851 104.2655 4 1014 39.9800 1318 29.9800 5 7 32.9800 7 52.9900 6 291 107.6674 797 31.2741 I want to perform a significance test to compare the means of rev.1 and rev.2 ONLY where groups class.1=class.2. I tried doing this with ANOVA but am having issues only comparing the groups that I want. Any guidance would be greatly