Hi All,
For those still interested the code submitted by Phil (see below) worked a
treat and produced a vector with the optimal 'nsplit' collated from 50 runs
of the rpart model. I then produced a histogram for the vector called answer
and chose my modal number for nsplits from which I had my appr
thanks Phil, I have your solution and another which I will attempt in the
next day or so and will post results to the list then.
cheers
andy
On Wed, Oct 13, 2010 at 10:30 AM, Phil Spector wrote:
> Andrew -
> I think
>
> answer = replicate(50,{fit1 <- rpart(CHAB~.,data=chabun, method="anova",
I think you want something like this:
optimal.nSplit = rep(NA, 50) # This will hold the result
for (run in 1:50)
{
fit1 = rpart(...)
cpTable = fit1$cptable
bestRow = which.min(cpTable[, "xerror"]);
optimal.nSplit[run] = cpTable[bestRow, "nsplit"]
}
In any case, look at
?rpart
?printcp
?r
Andrew -
I think
answer = replicate(50,{fit1 <- rpart(CHAB~.,data=chabun, method="anova",
control=rpart.control(minsplit=10,
cp=0.01, xval=10));
x = printcp(fit1);
Hi All,
I have to say upfront that I am a complete neophyte when it comes to
programming. Nevertheless I enjoy the challenge of using R because of its
incredible statistical resources.
My problem is this .I am running a regression tree analysis using
"rpart" and I need to run the calculat
5 matches
Mail list logo