Displaying 5 results from an estimated 5 matches for "grandmean".
2009 Sep 09
1
Stats help with calculating between and within subject variance and confidence intervals
...8
Residual standard error: 0.4264094
> confint<-95
> a<-(1-(confint/100))/2
> #str(BGaov) # get structure of BGAOV object
> #str(summary(BGaov)) # get structure of BGaov summary
> #summary(aov.1.e)[[2]][[1]]$"Df" # Could also use this syntax
> grandmean<-as.vector(BGaov$"(Intercept)"[[1]][1]) # Grand Mean (I think)
> within<-summary(BGaov)$"Error: Within"[[1]]$"Mean Sq" # S2^2Mean
Square Value for Within Machine = 0.1819
> dfMachine<-summary(BGaov)$"Error: Machine"[[1]]$"Df" #...
2007 Nov 22
3
anova planned comparisons/contrasts
...be more appropriate, or am I (likely)
misinterpreting this?
Thanks!
Tyler
MyContrast <- function(Var, Group, G1, G2, G3=NULL) {
## Var == data vector, Group == factor
## G1, G2, G3 == character vectors of factor levels to contrast
nG1 = sum(Group %in% G1)
nG2 = sum(Group %in% G2)
GrandMean = mean(Var[Group %in% c(G1, G2, G3)])
G1Mean = mean(Var[Group %in% G1])
G2Mean = mean(Var[Group %in% G2])
if(is.null(G3))
MScontr = nG1 * ((G1Mean - GrandMean)^2) +
nG2 * ((G2Mean - GrandMean)^2)
else {
nG3 = sum(Group %in% G3)
G3Mean = mean(Var[Group %in% G3])...
2009 Jul 13
1
Add grand mean to every entry in a matrix
Hi,
I have a matrix:
mymat <- matrix(runif(10*4), ncol=4)
I wish to subtract the column means, down the colums, subtract the row means from the rows and add back the grand mean - all the means should be the means of mymat rather than of the new matrix.
How can I do this?
Any help much appreciated.
Thanks
Tom
_________________________________________________________________
2011 Aug 25
2
within-groups variance and between-groups variance
...on(variable,groupvariable)
{
# find out how many values the group variable can take
groupvariable2 <- as.factor(groupvariable[[1]])
levels <- levels(groupvariable2)
numlevels <- length(levels)
# calculate the overall grand mean:
grandmean <- mean(variable)
# get the mean and standard deviation for each group:
numtotal <- 0
denomtotal <- 0
for (i in 1:numlevels)
{
leveli <- levels[i]
levelidata <- variable[groupvariable==leveli,]
levelile...
2008 Oct 15
1
Parameter estimates from an ANCOVA
...11]*2))+rnorm(mean=0, sd=.05, 22)
fit=lm(y~categ*cont)
scatterplot(y~cont|categ) # shows interaction
scatterplot(y~categ|cont) # shows effect of the categorical variable,
irrespective of cont
summary(fit); anova(fit)
coeff=coef(summary(fit))[,1] # column of estimates to "coeff"
grandmean=coeff[1]+ mean(cont)*coeff[3] #GM = intercept +
mean(cont)*regression_slope = 45.00677
slope_A=coeff[3]+coeff[4] #slope of individual regression for A = 3.998
slope_B=coeff[3]+(-coeff[4]) #slope of individual regression for B = 2.002
tapply(y, categ, mean) #these are what I want to get back ou...