Displaying 20 results from an estimated 5000 matches similar to: "scoping problem when calling step inside a function"
2005 Jul 01
1
scope argument in step function
Thanks a lot for help in advance. I am switching from matlab to R and I guess I need some time to get rolling. I was wondering why this code :
> fit.0 <- lm( Response ~ 1, data = ds3)
> step(fit.0,scope=list(upper=~.,lower=~1),data=ds3)
Start: AIC= -32.66
Response ~ 1
Call:
lm(formula = Response ~ 1, data = ds3)
Coefficients:
(Intercept)
1.301
is not working
2006 May 24
1
Problem with pasteing formulas (PR#8897)
Hi,
If I create a formula with say 100 terms and then paste it:
xnam <- paste("x", 1:100, sep="")
fmla <- as.formula(paste("y ~ ", paste(xnam, collapse= "+")))
paste(fmla)
The result seems to cut off everything after the first 500 characters
and gives no warning message.
I have the most recent version of R from the R website and the problem
occurs
2004 Oct 14
0
random forest problem when calculating variable importanc e
Are the results dramatically different?
The result would be expected to be somewhat different, as setting
importance=TRUE would make many calls to the random number generator (for
permuting OOB data in each variable), making all but the first tree in the
forest different than if importance=FALSE.
Cheers,
Andy
> From: Scott Gilpin
>
> Hi -
>
> When using the randomForest
2004 Oct 14
0
random forest problem when calculating variable importance
Hi -
When using the randomForest function for regression, I get different
results for mean-squared error of the predictions depending on whether
or not I specify to calculate variable importance. There is an
example below. I looked briefly at the source code, but couldn't find
anything that would indicate why calculating variable importance would
(or should) change predictions.
I'm
2000 Jun 07
1
forward stepwise selection
Dear R-Help,
My problem/bug came to light,when fitting a linear model using stepwise
selection. I'd started with the straightfoward command
step(lm(y~., dataset))
This worked fine, but because this starts with all the possible
explanatory variables, it results in a model with too many explanatory
variables. Hence I wanted to start with just a constant and do forward
selection, to get a
2005 Jun 11
2
Performance difference between 32-bit build and 64-bit bu ild on Solaris 8
I'm not familiar with Solaris, so take this with appropriate dose of NaCl...
For the 64-bit build, why not have the -O2 for gcc, since you have it for
g77 and g++? If you just run vanilla configure for the 32-bit build, I
believe it uses -O2 for all three compilers by default. If that's the
difference, perhaps it's sufficient to explain the performance difference.
The other thing
2005 Jun 24
1
"Error in contrasts" in step wise regression
Hi,
I have a problem in getting step function work. I am getting the following error:
> fit1 <- lm(Response~1)
> fmla <- as.formula(paste(" ~ ",paste(colnames,collapse="+")))
> sfit <- step(fit1,scope=list(upper= fmla,lower= ~1),k=log(nrow(dat)))
Start: AIC= -1646.66
Response ~ 1
Error in "contrasts<-"(`*tmp*`, value =
2012 Jan 25
4
formula error inside function
I want use survfit() and basehaz() inside a function, but it doesn't work.
Could you take a look at this problem. Thanks for your help. Following is my
codes:
library(survival)
n <- 50 # total sample size
nclust <- 5 # number of clusters
clusters <- rep(1:nclust,each=n/nclust)
beta0 <- c(1,2)
set.seed(13)
#generate phmm data set
Z <- cbind(Z1=sample(0:1,n,replace=TRUE),
2008 Feb 28
0
use of step.gam (from package 'gam') and superassignment inside functions
Hello,
I am using the function step.gam() from the 'gam' package (header info
from library(help=gam) included below) and have come across some
behavior that I cannot understand. In short, I have written a function
that 1) creates a dataframe, 2) calls gam() to create a gam object, then
3) calls step.gam() to run stepwise selection on the output from gam().
When I do this, gam()
2005 Dec 08
1
mle.stepwise versus step/stepAIC
Hello,
I have a question pertaining to the stepwise regression which I am trying to
perform. I have a data set in which I have 14 predictor variables
accompanying my response variable. I am not sure what the difference is
between the function "mle.stepwise" found in the wle package and the
functions "step" or "stepAIC"? When would one use
2005 Oct 24
1
Error in step() (or stepAIC) for Cox model
Hello all,
I am trying to use stepwise procedure to select covariates in Cox model
and use bootstrap to repeat stepwise selection, then record how many
times variables are chosen by step() in bootstrap replications. When I
use step() (or stepAIC) to do model selection, I got errors. Here is the
part of my code
for (j in 1:mm){ #<--mm=10
for (b in 1:nrow(reg.bs)){ #<--bootstrap 10
2003 May 08
2
Forward Stepwise regression with stepAIC and step
Dear all,
I cannot seem to get the R functions step or stepAIC to perform forward
or stepwise regression as I expect. I have enclosed the example data in
a dataframe at the end of this mail. Note rubbish is and rnorm(17) variable
which I have deliberately added to the data to test the stepwise procedure.
I have used
wateruse.lm<-lm(waterusage~.,data=wateruse) # Fit full model
2005 Oct 25
0
One more about Error in step() (or stepAIC) for Cox model
Thank you for Prof.Ripley's suggestion. I fixed the program by adding a
lower scope, and the program ran, but I still got warning messages, and
don't know what is going on, would this affect my results?
...
Step: AIC= 12337.74
Surv(tlfup, cen) ~ MI[[j]]$trt + MI[[j]]$agem40 + MI[[j]]$agem40sq +
mhtypeed1 + mhtypeed2
Df AIC
<none> 12338
-
2012 May 10
0
disagreement in loglikelihood and deviace in GLM with weights leads to different models selected using step()
In species distribution modeling where one uses a large sample of
background points to capture background variation in
presence\pseudo-absence or use\available models (0\1 response) it is
frequently recommended that one weight the data so the sum of the absence
weights is equal to the sum of presence weights so that the model isn?t
swamped by an overwhelming and arbitrary number of background
2006 May 08
1
ob.step$anova interpretation
hello
I built logistic regression model.
To model check I used stepAIC. But I don't know how it
is interpreted . I could not any find any explanation about it
For instance which model is preferable ? What are the critarias
to choose beter model
I will appreciate if you give me an explanation ?
models
---------
> lo1.step$anova
Stepwise Model Path
Analysis of Deviance Table
Initial
2008 Dec 02
4
Variables inside a for
Hi!
I had a database with some variables in sequence. Let me say: TX01, TX02,
TX03 and TX04.
But I need to run some regressions changing the variables... so:
variable <- paste("TX0", 1:4, sep="")
for(i in 1:4){
test[i] <- lm(variable[i] ~ INCOME, data=database)
}
But doesn't work... lm tries to find a variable inside database named
variable[i] ...
Suggestions?
2003 Sep 25
1
data lost in cv.tree?
Greetings -- I'm programming a data mining system
in R for protein structural data. As a seasoned
Perl and Python and Ada and ML, et al., programmer,
I am severely befuddled by the environment problem,
where data is not found in a 3rd level nested
function. I did peruse the parent frame not on the
search path idea, and came up with a hack which
kinda works, also below with the code which
2011 Sep 19
1
Constrained regressions (suggestions welcome)
All,
Could anyone recommend a package that allows the user to constrain the
coefficients from a multiple regression equation?
I tried using the gl1ce function in lasso2, but couldn't get it to
work. I created a contrived example to illustrate my starting point.
data(cars)
fmla <- formula(dist ~ speed)
gl1c.E <- gl1ce(fmla, data = cars)
gl1c.E
gl1c.E <- gl1ce(fmla, data =
2003 Mar 02
1
model.frame.default problem in function definition
Could someone point me in the right direction for the following issue:
A function is defined as follows:
tfun <- function(dat)
{
fmla <- as.formula("y~x+z")
dat2 <- dat
mdl <- lm(fmla,dat2)
mdl <- step(mdl)
}
Then the following code
dat <- data.frame(x=1:10,z=1:10,y=(1:10)^2+10*(1:10))
tfun(dat)
generates the output
Start: AIC= 43.67
2005 Aug 16
4
as.character and a formula
Dear list,
given this formula:
> fmla <- formula(y1 ~ spp1 + spp2 + spp3 + spp5)
> fmla[[3]]
spp1 + spp2 + spp3 + spp5
is this the intended behaviour of as.character:
> as.character(fmla[[3]])
[1] "+" "spp1 + spp2 + spp3" "spp5"
? Where does the extra "+" come from?
> as.character(fmla)
[1] "~"