Em Qui 21 Fev 2008, David Winsemius escreveu: > Ronaldo Reis Junior <[EMAIL PROTECTED]> wrote in > > news:[EMAIL PROTECTED]: > > I try this update: > > > > mmaa <- update(mma,biomass~qvartemp) > > That does not look like it has proper arguments to update.formula. As > the update() help page suggests: > > ?update.formula > > You should have included the call that created "mma". Assuming that > "mma" is a model object, and the dependent variable in that model was > "biomass", then perhaps: > > mmaa <- update(mma, ~ . + qvartemp) # ... is what you wanted? > > On the other hand, I do not see "biomass" in your list of objects below, > so who knows? If these guesses are wrong, then re-read the posting guide > and provide more detail. > > > but I have this message: > > > > Error in eval(expr, envir, enclos) : object "qvartemp" not found > > > > but this object exist: > > > > [1] "cont" "i" "levelsord" "mma" "qvar" > > "qvarmma" [7] "qvartemp" "test" "yvar" > > > > but if I use the glm directly it work: > > > > mmaa <- glm(biomass~qvartemp) > > I guess "biomass" must exist <somewhere>. More guessing: Is it in one of > those other objects that you attach()ed before the call to glm()? > > <snipped summary output> > > > Anybody have any idea about this problem in update? > > I doubt that it is a problem in update.
David, I don't understand this problem, in console it work, but in script id don't work. Look a example: ### The data set > clippingdata <- structure(list(biomass = c(551L, 457L, 450L, 731L, 499L, 632L, 595L, 580L, 508L, 583L, 633L, 517L, 639L, 615L, 511L, 573L, 648L, 677L, 417L, 449L, 517L, 438L, 415L, 555L, 563L, 631L, 522L, 613L, 656L, 679L), clipping = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("control", "n25", "n50", "r10", "r5"), class = "factor")), .Names = c("biomass", "clipping" ), class = "data.frame", row.names = c(NA, -30L)) > attach(clippingdata) ### copying the variable > clipping2 <- clipping ### recode the variable to n-1 levels > levels(clipping2)[1] <- "controln25" > levels(clipping2)[2] <- "controln25" ### Show the levels > levels(clipping2) [1] "controln25" "n50" "r10" "r5" ### Make a model > m <- glm(biomass~clipping) ### View the model > m Call: glm(formula = biomass ~ clipping) Coefficients: (Intercept) clippingn25 clippingn50 clippingr10 clippingr5 465.17 88.17 104.17 145.50 145.33 Degrees of Freedom: 29 Total (i.e. Null); 25 Residual Null Deviance: 209400 Residual Deviance: 124000 AIC: 346.9 ### making a new formula, I need to make this to generalise the program. > new.form <- as.formula(gsub("clipping","clipping2",as.expression(m$formula))) > new.form biomass ~ clipping2 ### making a new model using this new form > mma <- update(m,new.form) > mma Call: glm(formula = biomass ~ clipping2) Coefficients: (Intercept) clipping2n50 clipping2r10 clipping2r5 509.25 60.08 101.42 101.25 Degrees of Freedom: 29 Total (i.e. Null); 26 Residual Null Deviance: 209400 Residual Deviance: 147300 AIC: 350.1 ### Comparing model > anova(m,mma,test="F") Analysis of Deviance Table Model 1: biomass ~ clipping Model 2: biomass ~ clipping2 Resid. Df Resid. Dev Df Deviance F Pr(>F) 1 25 124020 2 26 147340 -1 -23320 4.7009 0.03987 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 This is all idea of script, it work in console, but in script only the directly use of glm work, the update don't work. But is the same think. I don't find the error. using my script to make all automatic > contstep(yvar="biomass",qvar="clipping",mma=m,test="F") This the result is start: ------------------ Níveis atuais control n25 n50 r5 r10 ### this is the result of print(qvartemp) Resultado do contraste a 5% de significância [1] controln25 controln25 controln25 controln25 controln25 controln25 [7] n50 n50 n50 n50 n50 n50 [13] r5 r5 r5 r5 r5 r5 [19] controln25 controln25 controln25 controln25 controln25 controln25 [25] r10 r10 r10 r10 r10 r10 Levels: controln25 n50 r5 r10 ### this is the result of print (new.form) biomass ~ qvartemp ### This is the error resulted from line number 49 from my script ### mmaa <- update(mma,new.form) Error in eval(expr, envir, enclos) : object "qvartemp" not found. My script is in attach. The very strange is that in console the idea work but in script don't work. If is rebuild the model using glm from line 52, it work: This is the result using glm directly and not update. > contstep(yvar="biomass",qvar="clipping",mma=m,test="F") ------------------ Níveis atuais control n25 n50 r5 r10 Resultado do contraste a 5% de significância biomass ~ qvartemp control e n25 são diferentes ------------------ Níveis atuais control n25 n50 r5 r10 Resultado do contraste a 5% de significância biomass ~ qvartemp n25 e n50 são iguais ------------------ Níveis atuais control n25n50 r5 r10 Resultado do contraste a 5% de significância biomass ~ qvartemp n25n50 e r5 são iguais ------------------ Níveis atuais control n25n50r5 r10 Resultado do contraste a 5% de significância biomass ~ qvartemp n25n50r5 e r10 são iguais ----- Resultado final dos níveis agrupados -------- control n25n50r5r10 The problem in the use of glm and not update is that other parameters from original model need to be passed to contstep function. Using update, I change only the model formula and others parameter remain the same (family,weights,maxit,etc) Thanks for all comments Ronaldo -- You may call me by my name, Wirth, or by my value, Worth. -- Nicklaus Wirth -- > Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.