search for: frm1

Displaying 7 results from an estimated 7 matches for "frm1".

Did you mean: fm1
2017 Aug 22
4
boot.stepAIC fails with computed formula
...-3, 3) x6 <- runif(n, -3, 3) x7 <- runif(n, -3, 3) x8 <- runif(n, -3, 3) y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5) dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1) #the real data won't have these names... cn <- names(dat) trg <- "y1" xvars <- cn[cn!=trg] frm1<-as.formula(paste(trg,"~1")) frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+"))) strt=lm(y1~1,dat) # boot.stepAIC Works fine #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ## #strt=lm(frm1,dat) ## boot.stepAIC FAILS ## l...
2017 Aug 23
3
boot.stepAIC fails with computed formula
...nter.4567 at gmail.com] Sent: 22 August 2017 20:38 To: Stephen O'hagan <SOhagan at manchester.ac.uk> Cc: r-help at r-project.org Subject: Re: [R] boot.stepAIC fails with computed formula OK, here's the problem. Continuing with your example: strt1 <- lm(y1 ~1, dat) strt2 <- lm(frm1,dat) > strt1 Call: lm(formula = y1 ~ 1, data = dat) Coefficients: (Intercept) 41.73 > strt2 Call: lm(formula = frm1, data = dat) Coefficients: (Intercept) 41.73 Note that the formula objects of the lm object are different: strt2 does not evaluate the formula. So presumabl...
2017 Aug 23
0
boot.stepAIC fails with computed formula
It seems that if you build the formula as a character string, and postpone the "as.formula" into the lm call, it works. instead of frm1 <- as.formula(paste(trg,"~1")) use frm1a <- paste(trg,"~1") and then strt <- lm(as.formula(frm1a),dat) regards, Heinz Stephen O'hagan wrote/hat geschrieben on/am 23.08.2017 12:07: > Until I get a fix that works, a work-around would be to rename the 'y1'...
2017 Aug 22
0
boot.stepAIC fails with computed formula
OK, here's the problem. Continuing with your example: strt1 <- lm(y1 ~1, dat) strt2 <- lm(frm1,dat) > strt1 Call: lm(formula = y1 ~ 1, data = dat) Coefficients: (Intercept) 41.73 > strt2 Call: lm(formula = frm1, data = dat) Coefficients: (Intercept) 41.73 Note that the formula objects of the lm object are different: strt2 does not evaluate the formula. So presumabl...
2017 Aug 22
1
boot.stepAIC fails with computed formula
...3, 3) > x8 <- runif(n, -3, 3) > y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5) > > dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1) > #the real data won't have these names... > > cn <- names(dat) > trg <- "y1" > xvars <- cn[cn!=trg] > > frm1<-as.formula(paste(trg,"~1")) > frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+"))) > > strt=lm(y1~1,dat) # boot.stepAIC Works fine > > #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ## > > #strt=lm(frm1,...
2017 Aug 22
0
boot.stepAIC fails with computed formula
...> y1 <- 42+x3 + 2*x6 + 3*x8 + runif(n, -0.5, 0.5) >> >> dat <- data.frame(x1,x2,x3,x4,x5,x6,x7,x8,y1) >> #the real data won't have these names... >> >> cn <- names(dat) >> trg <- "y1" >> xvars <- cn[cn!=trg] >> >> frm1<-as.formula(paste(trg,"~1")) >> frm2<-as.formula(paste(trg,"~ 1 + ",paste(xvars,collapse = "+"))) >> >> strt=lm(y1~1,dat) # boot.stepAIC Works fine >> >> #strt=do.call("lm",list(frm1,data=dat)) ## boot.stepAIC FAILS ## >...
2017 Aug 22
1
boot.stepAIC fails with computed formula
...> frm2<-as.formula(paste(trg," ~ ", paste(xvars,collapse = "+"))) works fine, too. Anyway, doing this gives (but see end of output)" bst <- boot.stepAIC(strt,data = dat,B=50,alpha=0.05,direction='forward',steps=limit, scope=list(lower=frm1,upper=frm2)) > bst Summary of Bootstrapping the 'stepAIC()' procedure for Call: lm(formula = y1 ~ ., data = dat) Bootstrap samples: 50 Direction: forward Penalty: 2 * df Covariates selected (%) x1 100 x2 100 x3 100 x4 100 x5 100 x6 100 x7 100 x8 100 Coefficients Sign + (%) -...