Displaying 20 results from an estimated 36 matches for "kyphosis".
2011 May 12
1
Saving misclassified records into dataframe within a loop
...that record does not have X then it should be reviewed(ie i need the row
number/ID saved to a database). Generally i want to look at the
misclassified records. This is a little hack i know, anyone got a better
idea please let me know. Here is an example
library(rpart)
# grow tree
fit <- rpart(Kyphosis ~ Age + Number + Start,
method="class", data=kyphosis)
#predict
prediction<-predict(fit, kyphosis)
#misclassification index function
predict.function <- function(x){
for (i in 1:length(kyphosis$Kyphosis)) {
#the idea is that if the record is "absent" but the predictio...
2011 Dec 27
0
Using minsplit and unequal weights in rpart
...ay), thus - turning for help.
Thanks in advance for your help,
-Saar
The following code shows what the issue is; the first 3 trees are the same,
but the following two (with uneven weights) turn out differently:
## playing with rpart weights
require(rpart)
dev.new()
par(mfrow=c(2,3), xpd=NA)
data(kyphosis)
fitOriginal <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis,
control=rpart.control(minsplit=15))
plot(fitOriginal)
text(fitOriginal, use.n=TRUE)
# this dataset is the original data repeated 3 times
kyphosisRepeated <- rbind(kyphosis, kyphosis, kyphosis)
fitRepeated <- rpart(Kyph...
2004 May 07
0
rpart for CART with weights/priors
...for misclassification in
CART can be modelled
either by means of modifying the loss matrix or by means of using different
prior probabilities for the classes,
which again should have the same effect as using different weights for the
response classes.
What I tried was this:
library(rpart)
data(kyphosis)
#fit1 from original unweighted data set
fit1 <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
#modify loss matrix
loss<-matrix(c(0,1,2,0),nrow=2,ncol=2)
# true class?
# [,1] [,2]
#[1,] 0 2
#[2,] 1 0 predicted class?
#modify priors
prior=c(1/3,2/3)
fit2<- rp...
2011 Jan 26
2
Extracting the terms from an rpart object
...ract the terms from an rpart object.
Specifically, I would like to be able to know what is the response variable
(so I could do some manipulation on it).
But in general, such a method for rpart will also need to handle a "." case
(see fit2)
Here are two simple examples:
fit1 <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
fit1$call
fit2 <- rpart(Kyphosis ~ ., data=kyphosis)
fit2$call
Is there anything "prettier" then using string manipulation?
Thanks.
----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Ga...
2005 Sep 26
4
p-level in packages mgcv and gam
Hi,
I am fairly new to GAM and started using package mgcv. I like the
fact that optimal smoothing is automatically used (i.e. df are not
determined a priori but calculated by the gam procedure).
But the mgcv manual warns that p-level for the smooth can be
underestimated when df are estimated by the model. Most of the time
my p-levels are so small that even doubling them would not result
2011 Apr 22
3
Parametrized object name in Save statement
...parameter into the internal
object name when tying to save it. Solving this one porblem will help me
start blasting though 100's of models and saving their output for later use.
I would call the script from command line as
Rscript file_name.R argument
for this example
Rscript rpart_code.R Kyphosis
#/bin/R
args <- commandArgs(TRUE) # Read the argument
require(rpart, quietly = TRUE)
#for this example lets use the kyphosis data in the rpart package
args <- "Kyphosis"
X<-paste(args," ~.", sep ="") # create model formula call. X = "Kyphosis ~."...
2007 Jun 15
2
model.frame: how does one use it?
...with how rpart evaluates a formula and
supporting arguments, in particular 'weights'.
A simple contrived example is
-----------------------------------------------------------------------------
library(rpart)
## using data from help(rpart), set up simple example
myformula <- formula(Kyphosis ~ Age + Number + Start)
mydata <- kyphosis
myweight <- abs(rnorm(nrow(mydata)))
goodFunction <- function(mydata, myformula, myweight) {
hyp <- rpart(myformula, data=mydata, weights=myweight, method="class")
prev <- hyp
}
goodFunction(mydata, myformula, myweight)
cat(&q...
2003 May 24
1
...listable functions...
Hi R-helpers.
I have the following problem:
I would like to apply my function gain(df,X,A) to a
list of arguments.
df is a data frame
X,A are the varibales od data frame.
When I do
> gain(kyphosis,"Kyphosis",c("Start","Number"))
[1] "Start" "Number"
I get the following error...
Error in unique.default(x) : unique() applies only to
vectors
I tried lapply and apply, it didn't seem to work...
Can anybody tell me how to apply my function ga...
2012 Mar 04
1
rpart package, text function, and round of class counts
I run the following code:
library(rpart)
data(kyphosis)
fit <- rpart(Kyphosis ~ ., data=kyphosis)
plot(fit)
text(fit, use.n=TRUE)
The text labels represent the count of each class at the leaf node.
Unfortunately, the numbers are rounded and in scientific notation rather
than the exact number of examples sorted by that node in each class.
The plot...
2009 Dec 14
1
RPART - printing full splitting rule number on tree plot
...ays the splitting rules in full. I have tried using digits option in text function but this only alters digits of the mean displayed at terminal nodes. How do I get the full splitting rule number displayed on the tree plot?
Below is an example.
library(rpart)
temp <- as.data.frame(cbind(kyphosis, Start2=kyphosis$Start))
temp$Start2 <- temp$Start2+10000
fit1 <- rpart(Age~ Kyphosis +Number + Start2, data=temp)
plot(fit1)
text(fit1, use.n=TRUE, digits=5)
Thanks
Dr Rebecca O'Leary, PhD
Biostatistician
Senior Research Officer
UWA Centre for Child Health Research
Tel...
2002 Apr 29
2
RPart
I am using the rpart package and seem to have trouble with data sets that
have columns with no data. I look at the column data in R and all values are
NA. When this occurs, I get nothing back from the rpart function. Is there a
way to get the rpart package to ignore these columns, without knowing what
columns are empty? I have tried the na.action=na.omit and
na.action=na.exclude, but neither one
2010 Dec 13
2
rpart.object help
Hi,
Suppose i have generated an object using the following :
fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
And when i print fit, i get the following :
n= 81
node), split, n, loss, yval, (yprob)
* denotes terminal node
1) root 81 17 absent (0.7901235 0.2098765)
2) Start>=8.5 62 6 absent (0.9032258 0.0967742)
4) Start>=14.5 29 0 absen...
2006 Dec 27
1
Question about predict function
I am working with a non-parametic smoothing operation using a
Generalized Additive Model. It is a bivariate data set. I know how to
do the smooth, and out comes a nice smooth curve.
Now I want to find the value of the smoothed curve for several values
of x (the abscissa). This can be done (please correct me if I am
wrong) by using the predict.gam function. You feed the predict.gam
function a
2012 Apr 12
2
enableJIT(2) causes major slow-up in rpart
...nableJIT(2) can *slow* the rpart
function (from the {rpart} package) by a magnitude of about 10 times.
Here is an example code to run:
library(rpart)
require(compiler)
enableJIT(0) # just making sure that JIT is off # We could also use
enableJIT(1) and it would be fine
fo <- function() {rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)}
system.time(fo())
# user system elapsed
# 0 0 0 # this can also be 0.01 sometimes.
enableJIT(2) # also happens for enableJIT(3)
system.time(fo())
# user system elapsed
# 0.12 0.00 0.12
Which brings me to my *questions*:
1)...
2011 Mar 31
2
fit.mult.impute() in Hmisc
...of the Harrell (2001) book Googling
located a thread in R-help back in 2003, which seemed dated.
Many thanks in advance for the help,
Yuelin.
http://idecide.mskcc.org
-------------------------------
> library(Hmisc)
Loading required package: survival
Loading required package: splines
> data(kyphosis, package = "rpart")
> kp <- lapply(kyphosis, function(x)
+ { is.na(x) <- sample(1:length(x), size = 10); x })
> kp <- data.frame(kp)
> kp$kyp <- kp$Kyphosis == "present"
> set.seed(7)
> imp <- aregImpute( ~ kyp + Age + Start + Number, dat = k...
2010 May 03
1
rpart, cross-validation errors question
...k-R web page (
http://www.statmethods.net/advstats/cart.html) but my cross-validation
errors increase instead of decrease (same thing happens with an unrelated
data set).
Why does this happen?
Am I doing something wrong?
# Classification Tree with rpart
library(rpart)
# grow tree
fit <- rpart(Kyphosis ~ Age + Number + Start,
method="class", data=kyphosis)
printcp(fit) # display the results
plotcp(fit) # visualize cross-validation results
Thank you,
Claudia
[[alternative HTML version deleted]]
2011 Aug 08
1
Classification trees problem.
...ssification trees with categorical explanatory variables using library rpart and I would like to do a prediction for some data imputs. I don't know where's a function or how can I do it?. Is there someone can help ?? ¿. Here's the code that I'm using.
library(rpart)
fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
plot(fit)
text(fit, use.n=TRUE)
#Someone can help me??
I hope someone can help!
Respect,
José Bustos
[[alternative HTML version deleted]]
2009 Feb 25
1
how to label the branches of a tree
Hi,
I am using rpart package to fit classification trees.
library(rpart)
fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
plot(fit,uniform=T)
text(fit, use.n=TRUE)
But I am unable to label the branches (not the nodes) of the tree. Can somebody help me out in this?
Thank you,
Regards
Utkarsh Singhal | Amba Research
Ph +91 80 3980 8017 | Mob +91 99 0295 8815
Bangalore...
2009 Sep 14
1
summary of rpart-Object in tktext window?
Hi,
is it possible to put a summary of an rpart-Object into a tktext-window?
Here is what I'm trying to do:
fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
tt <- tktoplevel()
tex <- tktext(tt)
tkpack(tex)
tkinsert(tex, "end", summary(fit))
But since the summary of an object is a list, I always get back the
following error-message:
cannot handle object of mode 'list'
So, is there a dif...
2010 Mar 07
1
Is there an equivalence of lm's “anova” for an rpart object ?
Simple example:
# Classification Tree with rpart
library(rpart)
# grow tree
fit <- rpart(Kyphosis ~ Age + Number + Start,
method="class", data=kyphosis)
Now I would like to know how can I measure the "importance" of each of my
three explanatory variables (Age, Number, Start) in the model?
If this was a regression model, I could have looked at p values from the
"...