On Wed, 2010-08-18 at 17:37 +0800, elaine kuo wrote: <snip /> > => I posted it for help, after following the manual with the > command dredge but receiving an error message two days ago. > > command target<-dredge(mig.stds, subset = temp_max) > error in eval(expr, envir, enclos) : 'temp_max' not found
You really don't get it, do you? I can't see what the problem is with your data + script, because I don't have your data! So I can't run your script, reproduce your error and work round it, then send you the solution. How many times do I have to ask for your data or, if not possible, some dummy data that reproduces the same problem? If your data weren't available to send, this is what I would have expected, as requested by the posting guide: ## dummy data - this could be anything really dat <- data.frame(FOO = rnorm(100), BAR = rnorm(100, mean = 10, sd = 4), OTHER = seq(1, 100000, length = 100), Y = runif(100)) ## standardise data dat.std <- data.frame(scale(dat, center = TRUE, scale = TRUE)) ## load MuMIn require(MuMIn) ## fit full model mod <- lm(Y ~ FOO + BAR + OTHER, data = dat.std) ## data dredge dredged.mod <- dredge(mod, subset = OTHER) dredged.mod The above works: > ## dummy data > dat <- data.frame(FOO = rnorm(100), BAR = rnorm(100, mean = 10, sd = 4), + OTHER = seq(1, 100000, length = 100), + Y = runif(100)) > > ## standardise data > dat.std <- data.frame(scale(dat, center = TRUE, scale = TRUE)) > > ## load MuMIn > require(MuMIn) Loading required package: MuMIn > > ## fit full model > mod <- lm(Y ~ FOO + BAR + OTHER, data = dat.std) > mod Call: lm(formula = Y ~ FOO + BAR + OTHER, data = dat.std) Coefficients: (Intercept) FOO BAR OTHER 1.908e-16 -3.463e-02 1.635e-02 -1.299e-01 > summary(mod) Call: lm(formula = Y ~ FOO + BAR + OTHER, data = dat.std) Residuals: Min 1Q Median 3Q Max -1.83375 -0.80706 0.01736 0.81847 1.72803 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.908e-16 1.006e-01 1.90e-15 1.000 FOO -3.463e-02 1.013e-01 -0.342 0.733 BAR 1.635e-02 1.011e-01 0.162 0.872 OTHER -1.299e-01 1.013e-01 -1.282 0.203 Residual standard error: 1.006 on 96 degrees of freedom Multiple R-squared: 0.01901, Adjusted R-squared: -0.01165 F-statistic: 0.62 on 3 and 96 DF, p-value: 0.6037 > dredged.mod <- dredge(mod, subset = OTHER) > dredged.mod Global model: lm(formula = Y ~ FOO + BAR + OTHER, data = dat.std) --- Model selection table (Int) BAR FOO OTH k R.sq Adj.R.sq RSS AIC AICc 1 1.886e-16 -0.1324 3 0.01754 0.007514 97.26 287.0 287.3 3 1.886e-16 -0.03471 -0.1302 4 0.01874 -0.001493 97.14 288.9 289.3 2 1.908e-16 0.01652 -0.1322 4 0.01781 -0.002439 97.24 289.0 289.4 4 1.908e-16 0.01635 -0.03463 -0.1299 5 0.01901 -0.011650 97.12 290.9 291.5 delta weight 1 0.000 0.549 3 2.049 0.197 2 2.143 0.188 4 4.239 0.066 So is this due to the way your names are formed? dat2 <- data.frame(dat, SOME_THING = rpois(100, 4)) dat2.std <- data.frame(scale(dat2, center = TRUE, scale = TRUE)) mod2 <- lm(Y ~ FOO + BAR + OTHER + SOME_THING, data = dat2.std) ## data dredge dredged.mod2 <- dredge(mod2, subset = SOME_THING) dredged.mod2 No! So I can't reproduce your problem and until you send the *exact* code you enter into R plus your data I can no longer help you. Apologies if I am beginning to sound harsh, but you aren't doing what I have asked you to do (repeatedly) and what the posting guide for this list asks you to. If you want free help here, the least you can do is respect the rules. Feel free to send the above data/code off list to me if you wish. But I won't answer anything further on this thread until they are provided. I am wasting my time in a futile attempt to help you with your problem because you won't do what I ask. G > One possible cause could be data = datam.std. > datam.std was produced as the code below, which seemed to make it > hard to find explanatory variables. > Please kindly share your experience in R, because I am unsure if my > assumption is logical or not. > > > Also, please kindly advise how to modify the command for dredging > subset if possible. > ( command target<-dredge(mig.stds, subset = temp_max)) > Thank you in advance. > > > Elaine > > > code > library(MuMIn) > datam <-read.csv("c:/migration/Mig_ratio_20100817.csv",header=T, > row.names=1) > > # std regression model (16 indep. variables) > datam.sd<-scale(datam) > datam.std<-as.data.frame(datam.sd) > summary (datam.std) > mean(datam.std) > > > # obtain standard deviation > sd(datam.std) > > > mig.stds <-lm(SummerM_ratio~temp_ran+temp_mean+temp_max+temp_min > +evi_ran+evi_mean+evi_max+evi_min+prec_ran+prec_mean+prec_max+prec_min > +topo_var+topo_mean+coast+Iso_index_0808,data=datam.std) > > summary(mig.stds) > > > > -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ 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.