I'm still fixing up a one-within one-between function. I was working on
pairwise comparisons between the within subjects effects, between subjects
effects, and the interaction. I separately created a function that only
examines repeated measures, and it works fine. While trying to troubleshoot
this 1W-1B function, I've figured out what the problem is (I think), but
can't seem to think of the solution. The problem is with the "formula"
portion. 

 

I needed to create this "formula" because the "iv" is going to change based
on what is entered (whether it's Group, Gender, etc. when it's actually
run). In the repeated measures function, I didn't need to make this formula,
because it was always going to be repdat~constrasts. When I actually examine
the "owobanova", it lists "Fixed: formula" instead of "Fixed: repdat ~
contrasts + [iv] + contrasts:[iv]". Thus when I try to run the glht command,
it obviously cannot find "contrasts" in the fixed effects, because all that
it lists is formula.

 

This is, at least, the only conclusion I can reach at this point. Is there
some way I can have it ACTUALLY paste what the "formula" represents instead
of pasting in "formula" and running as it should? I apologize if this is a
bit long, or a bit confusing. I've posted below the code I have so far for
my function.

 

onewithin.onebetween <- function(dvs, iv, id, data){

  

  dataframe <- cbind(data[id], data[dvs], data[iv])

  myexpr.df <- make.rm(constant=c(id, iv), repeated=c(dvs), data=dataframe);

  

  

  formula <- as.formula(paste("repdat~contrasts +",iv, "+ contrasts:",iv));;

  random1 <- as.formula(paste("~1|",id));

  owobanova <- lme(formula, data=myexpr.df, random=random1);

  anova <- anova(owobanova);

  

  #pairwise1 <- summary(glht(owobanova , linfct = mcp(contrasts =
"Tukey")));

  

  #linfcts2 <- eval(parse(text=paste("mcp(",paste(iv,' ="Tukey"
',collapse=','),')')));

  #pairwise2 <- summary(glht(owobanova , linfct = linfcts2));

 

  #linfcts3 <- eval(parse(text=paste("mcp(",paste(contrasts,':',iv,'
="Tukey" ',collapse=','),')')));

  #pairwise3 <- summary(glht(owobanova , linfct = linfcts3));

  

  

  output <- list();

  output$anova2 <- unclass(anova);

  #output$pairwise <- as.list(unclass(pairwise1$test$coefficients));

  #output$pairwise2 <- as.list(unclass(pairwise1$test$pvalues));

  #output$pairwise3 <- as.list(unclass(pairwise2$test$coefficients));

  #output$pairwise4 <- as.list(unclass(pairwise2$test$pvalues));

  #output$pairwise5 <- as.list(unclass(pairwise3$test$coefficients));

  #output$pairwise6 <- as.list(unclass(pairwise3$test$pvalues));

  #return(output)

  return(owobanova)

  

}

 


	[[alternative HTML version deleted]]

