Hi R users
I try to use the lme but I can?t!!!!!
My script is (some words in french, sorry!!):
rm(list=ls(all=TRUE)) #Efface tous les objets en m?moire pour ?viter des
erreurs
library(MASS) #Chargement des Librairies
library(car)
library(Hmisc)
library(tkWidgets)
library(svDialogs)
library(multtest)
library(nlme)
#Rep <- "C:/Documents and Settings/U3M/Bureau/steph/Scripts R/"
Rep <- "C:/Documents and Settings/rafa/Mis
documentos/metabolomics/Scripts
R/Mod?les Mixtes/"
# Choix du fichier ? traiter
source(sprintf("%sinfile2bis.q",Rep))
para<-infile2bis() # Ouvre une petite interface permettant de s?lectionner
le fichier
# que l'on veut traiter
Fic <- para$fichier # fic est le fichier ? traiter
pat <- para$pat # R?pertoire de r?sultats
CLASSE <- noquote(para$classe[1:2]) # Facteurs ? ?tudier
.method<-which(para$checks2!=F) #M?thode d'ajustement des p-values
# V?rification qu'on est bien ds le bon r?pertoire de travail
if ( getwd()!=dirname(Fic[1]) ) setwd(dirname(Fic[1]))
## Quelques conditions ? v?rifier
if (sum(CLASSE=="")>=1) {
guiDlgMessage("Il faut sp?cificier deux variables cat?gorielles.",
title = "ERROR", type = "ok", icon =
c("error"), parent 0)
stop("Il faut sp?cificier deux variables cat?gorielles") }
if (sum(para$checks1==c(T,T))==2) {
guiDlgMessage("Il ne faut cocher qu'une seule case pour la ligne
Transformation des donn?es.",
title = "ERROR", type = "ok", icon =
c("error"), parent 0)
stop("Il ne faut cocher qu'une seule case pour la ligne
Transformation
des donn?es") }
if (length(which(para$checks2)==T)>1) {
guiDlgMessage("Vous ne pouvez choisir qu'une seule m?thode de
correction
des p-values, ne cochez qu'une seule case.",
title = "ERROR", type = "ok", icon =
c("error"), parent 0)
stop("Error : vous ne pouvez choisir qu'une seule m?thode de
correction
des p-values ")}
###################################### Manipulation sur le fichier de
donn?es
titi <- read.table(Fic[2],header=T,sep="\t") # Lecture du
fichier
Protocole
indiv <- as.character(titi[,1]) #Identifiant des
individus
Subject <- as.factor(titi[,1])
n <- dim(titi)[1] #Nb individus
toto1 <- read.table(Fic[1],header=T,sep="\t") # Lecture du
fichier de
donn?es
ions <- as.character(toto1[,1]) #Identifiant des ions
## La matrice des Intensit?s
if (sum(para$checks1==c(T,F))==2) {
toto <- log2(t(toto1[,-c(1:(dim(toto1)[2]-n))])+1) }
if (sum(para$checks1==c(F,T))==2) {
toto <- t(toto1[,-c(1:(dim(toto1)[2]-n))]) }
if (sum(para$checks1==c(F,F))==2) {
toto <- t(toto1[,-c(1:(dim(toto1)[2]-n))]) }
nvar <- dim(toto)[2] #Nb variables = Nb ions
if (is.numeric(toto)==F) {
guiDlgMessage("Probl?me de fichier :\r\n v?rifier vos donn?es.",
title = "ERROR", type = "ok", icon =
c("error"), parent 0)
stop("Nombre d'individus diff?rents dans les deux fichiers :
v?rifier
vos donn?es")}
Facteurs <- titi[,-1] #Les facteurs
#Cr?ation d'un r?pertoire o? enregistrer les r?sultats
if (any(dir(getwd())==strsplit(pat,"/"))==F) {
if (pat!="") { dir.create(file.path(getwd(),pat)) }
}
##################################### ANOVA 2 voies
v1 <- Facteurs[[CLASSE[1]]]
v2 <- Facteurs[[CLASSE[2]]]
if (is.null(v1) | is.null(v2)) {
guiDlgMessage("Vous n'avez pas sp?cifier un facteur cat?goriel
correct.\r\n\r\nAttention, il faut que le nom du facteur que vous entrez
\r\ndans l'interface et celui du fichier protocole soient \r\nexactement les
m?mes.\r\n\r\nR est sensible ? la case.",
title = "ERROR", type = "ok", icon =
c("error"),
parent = 0)
}
## ANOVA 2 facteurs
Resultats=NULL
Res=NULL
i=0
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
#summary(mixed)
#anova(mixed)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
if (i!=length(ions)) {
while(i!=length(ions)) {
i=i+1
myion=toto[,i]
mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
## effet al?atoire sujet(v1)
zz=anova(mixed)
Res <-
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
Resultats <- rbind(Resultats,Res)
}}
dimnames(zz)[[1]][-1] <-
c(para$classe[1],para$classe[2],sprintf("%s:%s",para$classe[1],para$classe[2]))
names(Resultats) <- c("IONS",
dimnames(toto1)[[2]][2:(dim(toto1)[2]-n)],
dimnames(zz)[[1]][-1],
dimnames(toto1)[[2]][c((dim(toto1)[2]-n+1):dim(toto1)[2])])
## Sauvegarde des r?sultats
if (.method==1) {
write.table(Resultats,sprintf("%sMod?leMIXED-%sfacteurs - %s-%s
avec interaction.txt",
pat,sum(CLASSE!=""),para$classe[1],para$classe[2]),
sep="\t",quote=F,row.names=F,
col.names=names(Resultats))
}
if (.method != 1) {
procs<-c("Bonferroni","BH") [.method-1]
adj1<-mt.rawp2adjp(Resultats[,2],procs)
Resultats[,2] <- adj1[[1]][,2][order(adj1$index)]
adj2<-mt.rawp2adjp(Resultats[,3],procs)
Resultats[,3] <- adj2[[1]][,2][order(adj2$index)]
adj3<-mt.rawp2adjp(Resultats[,4],procs)
Resultats[,4] <- adj3[[1]][,2][order(adj3$index)]
## Sauvegarde des p-values ajust?es avec la m?thode choisie
write.table(Resultats,
sprintf("%sMod?leMIXED-%sfacteurs - %s-%s avec
interaction - avec correction %s.txt",pat,sum(CLASSE!=""),
para$classe[1],para$classe[2],procs[.method-1]),
sep="\t",quote=F,row.names=F,
col.names=names(Resultats))
}
#################################### Calcul des moyennes par niveau de
facteurs
titi1=toto1[,-c(1:(dim(toto1)[2]-n))]
moy<-NULL
for ( u in 1:length(levels(v1)) ) {
y <- apply(titi1[v1==levels(v1)[u]],1,mean)
moy <- cbind(moy,y)
}
dimnames(moy)[[1]] <- ions
for ( u in 1:length(levels(v2)) ) {
y <- apply(titi1[v2==levels(v2)[u]],1,mean)
moy <- cbind(moy,y)
}
for ( u in 1:length(levels(v1:v2)) ) {
y <- apply(titi1[v1:v2==levels(v1:v2)[u]],1,mean)
moy <- cbind(moy,y)
}
dimnames(moy)[[2]] <- c(levels(v1),levels(v2),
levels(v1:v2))
## Sauvegarde des moyennes
write.table(data.frame(ions,moy),
sprintf("%sR?sum? - moyenne des diff?rents facteurs %s-%s
avec interaction.csv",pat,
para$classe[1],para$classe[2]),
sep=";",quote=F,row.names=F,
col.names=c("IONS",dimnames(moy)[[2]]) )
## Boite d'information que la mod?lisation est termin?e
guiDlgMessage("mod?lisation GLM 2-WAY termin?e.", title =
"Message",
type = c("ok"),
default = 1, icon = "info", parent = 0,
GUI = getOption("guiWwidgets"))
I got this error message:
Erro en lme.formula(myion ~ v1 * v2, random = ~1 | Subject/v1, method
"REML") :
nlminb problem, convergence error code = 1; message = false
convergence (8)
Some idea about what is happening???
Thanks in advance
--
View this message in context:
http://www.nabble.com/model-mix-problem.-FALSE-CONVERGENCE-tp18733762p18733762.html
Sent from the R help mailing list archive at Nabble.com.
Hello:
I have not seen a reply to this email, so I will offer a couple of
suggestions. The error "false convergence" often means that the model
is overparameterized. Sometimes, specifying lme(..., control =
list(returnObject=TRUE)) will convert this type of error into a
warning. If this happens, then you can typically do a nested model
"anova". (If the nested models involve a change in the random effect,
then you need to use method = "ML".)
If you'd like further help, I suggest you first, "PLEASE do read
the posting guide 'http://www.R-project.org/posting-guide.html' and
provide commented, minimal, self-contained, reproducible code." I'm
intimidated by several hundred lines of R code, especially when it
doesn't look like the data are accessible. If you can simplify it to a
few lines of R code using a publicly available data set, you will likely
receive more replies quicker.
?Buena Suerte!
Spencer Graves
mergullo wrote:> Hi R users
> I try to use the lme but I can?t!!!!!
> My script is (some words in french, sorry!!):
>
>
> rm(list=ls(all=TRUE)) #Efface tous les objets en m?moire pour ?viter des
> erreurs
>
> library(MASS) #Chargement des Librairies
> library(car)
> library(Hmisc)
> library(tkWidgets)
> library(svDialogs)
> library(multtest)
> library(nlme)
>
> #Rep <- "C:/Documents and Settings/U3M/Bureau/steph/Scripts
R/"
> Rep <- "C:/Documents and Settings/rafa/Mis
documentos/metabolomics/Scripts
> R/Mod?les Mixtes/"
>
> # Choix du fichier ? traiter
> source(sprintf("%sinfile2bis.q",Rep))
> para<-infile2bis() # Ouvre une petite interface permettant de
s?lectionner
> le fichier
> # que l'on veut traiter
> Fic <- para$fichier # fic est le fichier ? traiter
> pat <- para$pat # R?pertoire de r?sultats
> CLASSE <- noquote(para$classe[1:2]) # Facteurs ? ?tudier
> .method<-which(para$checks2!=F) #M?thode d'ajustement des
p-values
>
> # V?rification qu'on est bien ds le bon r?pertoire de travail
> if ( getwd()!=dirname(Fic[1]) ) setwd(dirname(Fic[1]))
>
> ## Quelques conditions ? v?rifier
> if (sum(CLASSE=="")>=1) {
> guiDlgMessage("Il faut sp?cificier deux variables
cat?gorielles.",
> title = "ERROR", type = "ok", icon =
c("error"), parent > 0)
> stop("Il faut sp?cificier deux variables cat?gorielles") }
>
> if (sum(para$checks1==c(T,T))==2) {
> guiDlgMessage("Il ne faut cocher qu'une seule case pour la
ligne
> Transformation des donn?es.",
> title = "ERROR", type = "ok", icon =
c("error"), parent > 0)
> stop("Il ne faut cocher qu'une seule case pour la ligne
Transformation
> des donn?es") }
>
> if (length(which(para$checks2)==T)>1) {
> guiDlgMessage("Vous ne pouvez choisir qu'une seule m?thode de
correction
> des p-values, ne cochez qu'une seule case.",
> title = "ERROR", type = "ok", icon =
c("error"), parent > 0)
> stop("Error : vous ne pouvez choisir qu'une seule m?thode de
correction
> des p-values ")}
>
>
> ###################################### Manipulation sur le fichier de
> donn?es
> titi <- read.table(Fic[2],header=T,sep="\t") # Lecture
du fichier
> Protocole
> indiv <- as.character(titi[,1]) #Identifiant des
> individus
> Subject <- as.factor(titi[,1])
> n <- dim(titi)[1] #Nb individus
>
> toto1 <- read.table(Fic[1],header=T,sep="\t") # Lecture du
fichier de
> donn?es
> ions <- as.character(toto1[,1]) #Identifiant des ions
>
> ## La matrice des Intensit?s
> if (sum(para$checks1==c(T,F))==2) {
> toto <- log2(t(toto1[,-c(1:(dim(toto1)[2]-n))])+1) }
>
> if (sum(para$checks1==c(F,T))==2) {
> toto <- t(toto1[,-c(1:(dim(toto1)[2]-n))]) }
>
> if (sum(para$checks1==c(F,F))==2) {
> toto <- t(toto1[,-c(1:(dim(toto1)[2]-n))]) }
>
> nvar <- dim(toto)[2] #Nb variables = Nb ions
>
> if (is.numeric(toto)==F) {
> guiDlgMessage("Probl?me de fichier :\r\n v?rifier vos
donn?es.",
> title = "ERROR", type = "ok", icon =
c("error"), parent > 0)
> stop("Nombre d'individus diff?rents dans les deux fichiers :
v?rifier
> vos donn?es")}
>
> Facteurs <- titi[,-1] #Les facteurs
>
> #Cr?ation d'un r?pertoire o? enregistrer les r?sultats
> if (any(dir(getwd())==strsplit(pat,"/"))==F) {
> if (pat!="") { dir.create(file.path(getwd(),pat))
}
> }
>
>
> ##################################### ANOVA 2 voies
>
> v1 <- Facteurs[[CLASSE[1]]]
> v2 <- Facteurs[[CLASSE[2]]]
>
> if (is.null(v1) | is.null(v2)) {
> guiDlgMessage("Vous n'avez pas sp?cifier un facteur
cat?goriel
> correct.\r\n\r\nAttention, il faut que le nom du facteur que vous entrez
> \r\ndans l'interface et celui du fichier protocole soient
\r\nexactement les
> m?mes.\r\n\r\nR est sensible ? la case.",
> title = "ERROR", type = "ok",
icon = c("error"),
> parent = 0)
> }
>
> ## ANOVA 2 facteurs
>
> Resultats=NULL
> Res=NULL
> i=0
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> #summary(mixed)
> #anova(mixed)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> if (i!=length(ions)) {
> while(i!=length(ions)) {
> i=i+1
> myion=toto[,i]
> mixed=lme(myion ~ v1*v2, random= ~ 1 |
Subject/v1,method="REML")
> ## effet al?atoire sujet(v1)
> zz=anova(mixed)
> Res <-
>
data.frame(ions[i],toto1[i,2:(dim(toto1)[2]-n)],t(zz[-1,4]),toto1[i,c((dim(toto1)[2]-n+1):dim(toto1)[2])])
> Resultats <- rbind(Resultats,Res)
> }}
> dimnames(zz)[[1]][-1] <-
>
c(para$classe[1],para$classe[2],sprintf("%s:%s",para$classe[1],para$classe[2]))
> names(Resultats) <- c("IONS",
> dimnames(toto1)[[2]][2:(dim(toto1)[2]-n)],
> dimnames(zz)[[1]][-1],
>
> dimnames(toto1)[[2]][c((dim(toto1)[2]-n+1):dim(toto1)[2])])
>
> ## Sauvegarde des r?sultats
> if (.method==1) {
> write.table(Resultats,sprintf("%sMod?leMIXED-%sfacteurs -
%s-%s
> avec interaction.txt",
>
pat,sum(CLASSE!=""),para$classe[1],para$classe[2]),
> sep="\t",quote=F,row.names=F,
> col.names=names(Resultats))
> }
>
> if (.method != 1) {
> procs<-c("Bonferroni","BH") [.method-1]
> adj1<-mt.rawp2adjp(Resultats[,2],procs)
> Resultats[,2] <- adj1[[1]][,2][order(adj1$index)]
> adj2<-mt.rawp2adjp(Resultats[,3],procs)
> Resultats[,3] <- adj2[[1]][,2][order(adj2$index)]
> adj3<-mt.rawp2adjp(Resultats[,4],procs)
> Resultats[,4] <- adj3[[1]][,2][order(adj3$index)]
>
> ## Sauvegarde des p-values ajust?es avec la m?thode choisie
> write.table(Resultats,
> sprintf("%sMod?leMIXED-%sfacteurs - %s-%s avec
> interaction - avec correction %s.txt",pat,sum(CLASSE!=""),
> para$classe[1],para$classe[2],procs[.method-1]),
> sep="\t",quote=F,row.names=F,
> col.names=names(Resultats))
> }
>
>
> #################################### Calcul des moyennes par niveau de
> facteurs
> titi1=toto1[,-c(1:(dim(toto1)[2]-n))]
> moy<-NULL
>
> for ( u in 1:length(levels(v1)) ) {
> y <- apply(titi1[v1==levels(v1)[u]],1,mean)
> moy <- cbind(moy,y)
> }
> dimnames(moy)[[1]] <- ions
> for ( u in 1:length(levels(v2)) ) {
> y <- apply(titi1[v2==levels(v2)[u]],1,mean)
> moy <- cbind(moy,y)
> }
>
> for ( u in 1:length(levels(v1:v2)) ) {
> y <- apply(titi1[v1:v2==levels(v1:v2)[u]],1,mean)
> moy <- cbind(moy,y)
> }
>
>
> dimnames(moy)[[2]] <- c(levels(v1),levels(v2),
> levels(v1:v2))
> ## Sauvegarde des moyennes
> write.table(data.frame(ions,moy),
> sprintf("%sR?sum? - moyenne des diff?rents facteurs
%s-%s
> avec interaction.csv",pat,
> para$classe[1],para$classe[2]),
> sep=";",quote=F,row.names=F,
> col.names=c("IONS",dimnames(moy)[[2]]) )
>
>
> ## Boite d'information que la mod?lisation est termin?e
> guiDlgMessage("mod?lisation GLM 2-WAY termin?e.", title =
"Message",
> type = c("ok"),
> default = 1, icon = "info", parent = 0,
> GUI = getOption("guiWwidgets"))
>
> I got this error message:
> Erro en lme.formula(myion ~ v1 * v2, random = ~1 | Subject/v1, method >
"REML") :
> nlminb problem, convergence error code = 1; message = false
> convergence (8)
> Some idea about what is happening???
> Thanks in advance
>