########full data######### library(lme4) library(dplyr) #description of Variables in Dataset "Exp2" #Subject: generic number (1-21) for all participants #Response: # Values ranging from 0 (location near wrist) to 250 (location near elbow) #ExpCondition: # "Exp" -> motion trial; "Con" -> control trial #lastpos: (final location of stimulus) --> "0", "(-)3,5" & "(-)7" # "0" -> central location # "(-)3,5" -> outer location (3,5 cm distance to the central location) # "(-)7" -> outermost location (7 cm distance to the central location) # Negative (positive) values: locations toward the elbow (wrist) Exp2 <- read.table("Z:/U-Laufwerk/ifsp/Exp.Series - Motion path/P1 - tactile RM/AP&P Revision/Reanalyse/Exp2.txt", header = TRUE, na.strings="NA", dec=".", strip.white=TRUE) #filter all trials not needed for proximal direction analysis Exp2proxV1 <- filter(Exp2, lastpos <= "0") Exp2prox <- filter(Exp2proxV1, ExpCondition != "Exp" | Comparison != "HG") #standard/baseline model LME.prox.4_st <- lmer(Response ~ 1 + (1|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_st) LME.prox.4_stv <- lmer(Response ~ 1 + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_stv) #Model mit Haupteffect lastpos LME.prox.4_help <- lmer(Response ~ lastpos + (1|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_help) anova(LME.prox.4_st,LME.prox.4_help) LME.prox.4_helpv <- lmer(Response ~ lastpos + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_helpv) anova(LME.prox.4_stv,LME.prox.4_helpv) #Model mit HE lastpos und ExpCondition LME.prox.4_heec <- lmer(Response ~ lastpos + ExpCondition + (1|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_heec) anova(LME.prox.4_help,LME.prox.4_heec) LME.prox.4_heecv <- lmer(Response ~ lastpos + ExpCondition + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_heecv) anova(LME.prox.4_helpv,LME.prox.4_heecv) #Modell mit beiden HE und IA LME.prox.4_ia <- lmer(Response ~ lastpos*ExpCondition + (1|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_ia) anova(LME.prox.4_heec,LME.prox.4_ia) Exp2prox.Coef <- coef(LME.prox.4_ia) write.table(Exp2prox.Coef$Subject,"Exp2_coefprox.txt",sep=";") LME.prox.4_iav <- lmer(Response ~ lastpos*ExpCondition + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2prox, REML=FALSE) summary(LME.prox.4_iav) anova(LME.prox.4_heecv,LME.prox.4_iav) ################# ##Distal Data## ################# #filter all trials not needed for distal direction analysis Exp2distV1 <- filter(Exp2, lastpos >= "0") Exp2dist <- filter(Exp2distV1, ExpCondition != "Exp" | Comparison != "EB") #standard/baseline model LME.dist.4_st <- lmer(Response ~ 1 + (1|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_st) LME.dist.4_stv <- lmer(Response ~ 1 + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_stv) #Model mit Haupteffect lastpos LME.dist.4_help <- lmer(Response ~ lastpos + (1|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_help) anova(LME.dist.4_st,LME.dist.4_help) LME.dist.4_helpv <- lmer(Response ~ lastpos + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_helpv) anova(LME.dist.4_stv,LME.dist.4_helpv) #Model mit HE lastpos und ExpCondition LME.dist.4_heec <- lmer(Response ~ lastpos + ExpCondition + (1|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_heec) anova(LME.dist.4_help,LME.dist.4_heec) LME.dist.4_heecv <- lmer(Response ~ lastpos + ExpCondition + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_heecv) anova(LME.dist.4_helpv,LME.dist.4_heecv) #Modell mit beiden HE und IA LME.dist.4_ia <- lmer(Response ~ lastpos*ExpCondition + (1|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_ia) anova(LME.dist.4_heec,LME.dist.4_ia) Exp2dist.Coef <- coef(LME.dist.4_ia) write.table(Exp2dist.Coef$Subject,"Exp2_coefdist.txt",sep=";") LME.dist.4_iav <- lmer(Response ~ lastpos*ExpCondition + (1+lastpos+ExpCondition+lastpos*ExpCondition|Subject), data=Exp2dist, REML=FALSE) summary(LME.dist.4_iav) anova(LME.dist.4_heecv,LME.dist.4_iav) coef(LME.dist.4_iav) ######################## #######Central tactor location - t-test comparison ######################## Exp2cen <- filter(Exp2, lastpos == "0") attach(Exp2cen) Exp2cen$Cond[ExpCondition == "Exp" & Comparison == "EB"] <- "Prox" Exp2cen$Cond[ExpCondition == "Exp" & Comparison == "HG"] <- "Dist" Exp2cen$Cond[ExpCondition == "Con"] <- "Con" detach(Exp2cen) Exp2cen_agg <- aggregate(Exp2cen$Response, list(Exp2cen$Subject, Exp2cen$Cond), mean) names(Exp2cen_agg)<-c("Subject","Cond","Response") t.test(Exp2cen_agg$Response[Exp2cen_agg$Cond=="Con"], Exp2cen_agg$Response[Exp2cen_agg$Cond=="Dist"], paired=T) t.test(Exp2cen_agg$Response[Exp2cen_agg$Cond=="Con"], Exp2cen_agg$Response[Exp2cen_agg$Cond=="Prox"], paired=T) t.test(Exp2cen_agg$Response[Exp2cen_agg$Cond=="Prox"], Exp2cen_agg$Response[Exp2cen_agg$Cond=="Dist"], paired=T) ############# #Forward-shift comparison - prox vs. dist at central location ############# Exp2cen_no_dist <- filter(Exp2cen_agg, Cond != "Dist") Exp2cen_fs_prox <- aggregate(Exp2cen_no_dist$Response, list(Exp2cen_no_dist$Subject), diff) names(Exp2cen_fs_prox)<-c("Subject","Response") Exp2cen_no_prox <- filter(Exp2cen_agg, Cond != "Prox") Exp2cen_fs_dist <- aggregate(Exp2cen_no_prox$Response, list(Exp2cen_no_prox$Subject), diff) names(Exp2cen_fs_dist)<-c("Subject","Response") #Recode that positive values resemble a Forward-shift Exp2cen_fs_dist$Response <- -Exp2cen_fs_dist$Response t.test(Exp2cen_fs_dist$Response, Exp2cen_fs_prox$Response, paired=T) ############ Exp2_agg <- aggregate(Exp2$Response, list(Exp2$Subject, Exp2$Comparison, Exp2$ExpCondition, Exp2$lastpos), mean) names(Exp2_agg)<-c("Subject","Comparison","ExpCondition","lastpos","Response") write.table(Exp2_agg,"Exp2_agg.txt",sep=";")