similar to: predict.rpart question

Displaying 20 results from an estimated 400 matches similar to: "predict.rpart question"

2010 May 26
1
how to Store loop output from a function
HI, Dear R community, I am writing the following function to create one data set(*tree.pred*) and one vector(*valid.out*) from loops. Later, I want to use the data set from this loop to plot curves. I have tried return, list, but I can not use the *tree.pred* data and *valid.out* vector. auc.tree<- function(msplit,mbucket) { * tree.pred<-data.frame()
2007 Dec 10
1
Multiple Reponse CART Analysis
Dear R friends- I'm attempting to generate a regression tree with one gradient predictor and multiple responses, trying to test if change in size (turtle.data$Clength) acts as a single predictor of ten multiple diet taxa abundances (prey.data) Neither rpart or mvpart seem to allow me to do multiple responses. (Or if they can, I'm not using the functions properly.) > library(rpart)
2008 Jul 31
1
predict rpart: new data has new level
Hi. I uses rpart to build a regression tree. Y is continuous. Now, I try to predict on a new set of data. In the new set of data, one of my x (call Incoterm, a factor) has a new level. I wonder why the error below appears as the guide says "For factor predictors, if an observation contains a level not used to grow the tree, it is left at the deepest possible node and
2001 Jul 02
1
text.rpart: Unwanted NA labels on terminal nodes (PR#1009)
Brian The following (which is new to rw1030) occurs with both Windows 98 & Windows ME. I have not tested behaviour under Unix or Linux, but I expect it is no different. text.rpart() prints unwanted NAs (presumably in the splitting criterion position) on terminal nodes. Criterion <- factor(paste("Leaf", 1:5)) Node <- factor(1:5)
2005 Dec 07
0
Are minbucket and minsplit rpart options working as expected?
Dear r-list: I am using rpart to build a tree on a dataset. First I obtain a perhaps too large tree: > arbol.bsvg.02 <- rpart(formula, data = bsvg, subset=grp.entr, control=rpart.control(cp=0.001)) > arbol.bsvg.02 n= 100000 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 100000 6657 0 (0.93343000 0.06657000) 2) meses_antiguedad_svg>=10.5 73899 3658
2012 Mar 06
1
PLS Error message
Hi, I work with hyperspectral remote sensing data and I try to built a pls model with this data. I already built the model but if I try to calculate the RMSEP and R2 with a test data set I get the following error message: Error: variable 'subX' was fitted with type "nmatrix.501" but type "nmatrix.73" was supplied The problem is that I don't get the message for
2008 Jul 22
2
rpart$where and predict.rpart
Hello there. I have fitted a rpart model. > rpartModel <- rpart(y~., data=data.frame(y=y,x=x),method="class", ....) and can use rpart$where to find out the terminal nodes that each observations belongs. Now, I have a set of new data and used predict.rpart which seems to give only the predicted value with no information similar to rpart$where. May I know how
2010 Jan 18
2
Predict polynomial problem
I have a function that fits polynomial models for the orders in n: lmn <- function(d,n){ models=list() for(i in n){ models[[i]]=lm(y~poly(x,i),data=d) } return(models) } My data is: > d=data.frame(x=1:10,y=runif(10)) So first just do it for a cubic: > mmn = lmn(d,3) > predict(mmn[[3]]) 1 2 3 4 5 6 7 8
2004 Oct 20
2
Odd behaviour with scale()
Moi! A student here has been getting a bit irritated with some side effects of scale() (OS is Windows XP, the behaviour occurs in R 2.0.0, but not 1.7.1). The problem is that she scales a variable in a data frame, then does a regression, and tries to get some predictions for some new data. However, at this point she gets an error (see the example below). This seems to be because the
2007 Jan 03
1
User defined split function in Rpart
Dear all, I'm trying to manage with user defined split function in rpart (file rpart\tests\usersplits.R in http://cran.r-project.org/src/contrib/rpart_3.1-34.tar.gz - see bottom of the email). Suppose to have the following data.frame (note that x's values are already sorted) > D y x 1 7 0.428 2 3 0.876 3 1 1.467 4 6 1.492 5 3 1.703 6 4 2.406 7 8 2.628 8 6 2.879 9 5 3.025 10 3 3.494
2010 Dec 04
2
Problem storing lm() model in a list
Hi all, I recently wrote some code to store a number of polynomial models in a list and return this list. The model is returned fine, but when I make a subsequent call to predict(), I have an error. The code for polyModel selection is listed at the end of the email. Here is an example of the error: > poly.fit <- polyModelSelection(x,y,10,F) > for (d in 1:4) { + lm.model <-
2005 Jun 02
4
repeated vector in matrix
Hallo, I'll need a matrix with n rows of the an identical vector. > h [1] 3 3 3 3 2 2 2 The nmatrix should look like this: > x<-rbind(h,h,h) > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] h 3 3 3 3 2 2 2 h 3 3 3 3 2 2 2 h 3 3 3 3 2 2 2 but I need n rows which must be variable. Can anyone help me? thanks Andreas
2008 Aug 13
3
issue building dataframes with matrices.
Hello, Is this a bug or a feature? I am using R 2.7.1 on Apple OS X. > y <- matrix(1:3,nrow=3) # y is a single-column matrix > df <-data.frame(x=1:3,y=y) > sapply(df,data.class) x y "numeric" "numeric" > df$yy <- y > sapply(df,data.class) x y yy "numeric" "numeric" "matrix"
2011 Apr 19
1
How to Extract Information from SIMEX Output
Below is a SIMEX object that was generated with the "simex" function from the "simex" package applied to a logistic regression fit. From this mountain of information I would like to extract all of the values summarized in this line: .. ..$ variance.jackknife: num [1:5, 1:4] 1.684 1.144 0.85 0.624 0.519 ... Can someone suggest how to go about doing this? I can extract the
2012 Jan 19
1
ctree question
Hello. I have used the "party" package to generate a regression tree as follows: >origdata<-read.csv("origdata.csv") >ctrl<-ctree_control(mincriterion=0.99,maxdepth=10,minbucket=10) >test.ct<-ctree(Y~X1+X2+X3,data=origdata,control=ctrl) The above works fine. Orig data was my training data. I now have a test data file (testdata), and
2006 Apr 07
1
rpart.predict error--subscript out of bounds
Hi, I am using rpart to do leave one out cross validation, but met some problem, Data is a data frame, the first column is the subject id, the second column is the group id, and the rest columns are numerical variables, > Data[1:5,1:10] sub.id group.id X3262.345 X3277.402 X3369.036 X3439.895 X3886.935 X3939.054 X3953.777 X3970.352 1 32613 HAM_TSP 417.7082 430.4895 619.4776 720.8246
2007 Feb 27
3
rpart minimum sample size
Is there an optimal / minimum sample size for attempting to construct a classification tree using /rpart/? I have 27 seagrass disturbance sites (boat groundings) that have been monitored for a number of years. The monitoring protocol for each site is identical. From the monitoring data, I am able to determine the level of recovery that each site has experienced. Recovery is our
2009 Oct 08
0
predict.lm() out-of-sample predictions - problem with data classes
Hello! I'm still working on my problem, which also occurs with the predict.lm() function. - Providing newdata, which is a data.frame with all variables being "numeric", as str() shows, R tells me the following: ar1.xpred.test.pred <- predict(ar1.xpred.fitted, regdata.test, se.fit = FALSE) Fehler: variable 'lag(ret1)' was fitted with type "numeric" but type
2010 Feb 03
0
mboost: how to implement cost-sensitive boosting family
mboost contains a blackboost method to build tree-based boosting models. I tried to write my own "cost-sensitive" ada family. But obviously my understanding to implement ngradient, loss, and offset functions is not right. I would greatly appreciate if anyone can help me out, or show me how to write a cost-sensitive family, thanks! Follows are some families I wrote ngradient <-
2002 Feb 13
0
tree size in rpart()
Dear all, I know in rpart(), one can control the tree size (i.e. number of terminal nodes) through rpart.control(), e.g. minsplit, minbucket, maxdepth etc. But is there any more direct way to specify the number of terminal nodes when rpart() does the recursive partitioning? Your help is highly appreciated! Regards, -Ji