Displaying 20 results from an estimated 9000 matches similar to: "Bug(?) in predict.tree() --- Evaluation order of Boolean operators"
2011 Jul 29
1
help with predict.rpart
? data=read.table("http://statcourse.com/research/boston.csv", ,
sep=",", header = TRUE)
? library(rpart)
? fit=rpart (MV~ CRIM+ZN+INDUS+CHAS+NOX+RM+AGE+DIS+RAD+TAX+
PT+B+LSTAT)
predict(fit,data[4,])
plot only reveals part of the tree in contrast to the results on obtains
with CART or C5
-------- Original Message --------
Subject: Re: [R] help with rpart
From: Sarah
2011 May 12
1
Saving misclassified records into dataframe within a loop
Greetings R world,
I know some version of the this question has been asked before, but i need
to save the output of a loop into a data frame to eventually be written to a
postgres data base with dbWriteTable. Some background. I have developed
classifications models to help identify problem accounts. The logic is this,
if the model classifies the record as including variable X and it turns out
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 absent (1.0000000
2011 Dec 27
0
Using minsplit and unequal weights in rpart
Dear r-help mailing list,
Is there a way to incorporate weights into the minsplit criteria in rpart,
when the weights are uneven? I could not find a way for the minsplit
threshold to take the weights into account, and when the weights are uneven
it becomes an issue, as the following example shows.
My current workaround is to expand the data into one in which each row is
an observation, but that
2004 May 07
0
rpart for CART with weights/priors
Hi,
I have a technical question about rpart:
according to Breiman et al. 1984, different costs 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)
2007 Nov 08
1
Bug (?) in read.fwf
Hi,
I'm trying to use read.fwf
temp = read.fwf ("Raw data.txt", widths = c (11, 21, 10, rep
(16, 6)) ,skip = 2, n = 2, stringsAsFactors = FALSE, strip.white = TRUE)
but no matter what I do the strings are turned into factors. I believe
it's the "n=2" parameter that causes the problem as it seems to work
without this. Am I missing something?
Thanks in advance,
2008 Aug 11
1
A zoo question / problem
Hi
I'm having a problem using the zoo library and I can't see what I'm
doing wrong. For example setting up the data
> t1 = zoo (matrix (1:12, nrow = 3), order.by = as.Date
(c("2008-08-01","2008-08-02","2008-08-03")))
> colnames (t1) = c ("A", "B", "C", "D")
> t2 = zoo (matrix (1:12, nrow = 3), order.by =
2006 Sep 28
3
Evaluation of defaults in functions
Hello,
and sorry if this is already explained somewhere. I couldn't find anything.
R (2.3.1, Windows) seems to perform some kind of lazy evaluation when
evaluating defaults in function calls that, at least for me, leads to
unexpected results. Consider the following, seemingly equivalent functions:
> foo1 <- function(x, y=x) {
+ x <- 0
+ y
+ }
> foo1(1)
[1] 0
> foo2
2009 May 31
1
warning message when running quantile regression
Hi All,
I am running quantile regression in a "for loop" starting with 1
variable and adding a variable at a time reaching a maximum of 20
variables.
I get the following warning messages after my "for" loop runs. Should I
be concerned about these messages? I am building predictive models and
am not interested in inference.
Warning messages:
1: In
2009 Aug 10
1
model.matrix evaluation challenges
I am having difficulty with evaluation/environment construction
for a formula to be evaluated by model.matrix(). Basically, I
want to construct a model matrix that first looks in "newdata"
for the values of the model parameters, then in "object at data".
Here's what I've tried:
1. model.matrix(~f,data=c(newdata,object at data)) -- fails because
something (terms()?)
2007 Feb 05
2
Rconsole - setting the size and location of Windows help files (Rgui)
Hi,
Using the Rconsole file I can specify the size and location of the Rgui
windows on NT.
e.g.
# Dimensions (in characters) of the console.
rows = 51
columns = 100
How can I specify the size of the help windows that popups
when I ask for help? e.g. '?help'
I would like the popup window to have say rows = 51 and columns = 100,
just like the main window but a different location on the
2010 Oct 27
2
Which version control system to learn for managing Rprojects?
Gabor
As someone trying to the rest of my team using Subversion (which I have used for a while, but more as a backup / record of changes), have you a neat / automated way of building a package from a subversion repository?
Thanks
David Jessop
--------------------------
David Jessop
Global Head of Quantitative Research
UBS Investment Research
+44 20 7567 9882
----- Original Message -----
2006 Sep 28
2
calling R from within Java, using jri
Hi,
I want to call R from within Java, using jri as per
http://www.rosuda.org/software/jri/
So I am following the instructions in the README file for JRI 0.2-4.
I have run 'sh configure.win' and 'make' and they seemed to be
successful.
(See below for the output from make, for example.)
But when I try 'run.bat rtest' (with and without R command line
arguments)
the output
2006 Jun 19
1
lattice xyplot - aligning date labels so that they align with the grid lines in panel.grid
Hi,
I have a basic question about aligning date labels for the x-axis
in an xyplot so that they align with the grid lines
from the panel.grid argument.
For example, with
x <- data.frame(
date = seq(as.Date("2005/01/01"), as.Date("2006/06/01"),
length.out = 20), value = runif(20))
xyplot(value ~ date, data = x,
panel = function(x, y, subscripts, ...)
{
2011 Jan 26
2
Extracting the terms from an rpart object
Hello all,
I wish to extract 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 <-
2004 Oct 06
3
lapply with argument "X"
Hi,
I am probably making a simple mistake but I can't see it
> X
Error: Object "X" not found
> exists("X")
[1] FALSE
> lapply("X", exists)
[[1]]
[1] TRUE
Why is lapply producing true?
Is it something to do with the first
argument of lapply also being called 'X'?
> version
_
platform i386-pc-mingw32
arch i386
2004 Sep 29
2
defining a template for functions via do.call and substitute.
Hi,
Given a function
fun <- function(a, b) a + b
how do I generate the function 'function(x, y) x + y'?
Working from the help files and Bill Venables' R-news article (June 2002),
I have tried various permutations with substitute without success.
e.g.
do.call("substitute", list(fun, list(a = as.name("x"), b = as.name("y"))))
Regards,
John.
2004 Sep 29
2
defining a template for functions via do.call and substit ute.
Here's one not-so-straightforward way:
> f <- function(a, b) a + b
> flist <- as.list(f)
> names(flist)[1:2] <- c("x", "y")
> flist[[3]] <- do.call("substitute", list(body(f), list(a=as.name("x"),
b=as.name("y"))))
> g <- as.function(flist)
> g
function (x, y)
x + y
HTH,
Andy
> From: john.gavin at ubs.com
2012 May 17
0
Evaluation without the parent frame
Duncan,
I agree completely with "don't use attach"; if I could get all the
users of the survival package to agree as well the problem in question
would go away :-) I'm thinking about ways to add more effective error
surveillance.
Your suggestion was not horribly complex and I'll look into it
further. My first foray failed because what I want (I think) is the
2012 May 16
1
Evaluation without using the parent frame
I've been tracking down a survival problem from R-help today. A short
version of the primary issue is reconstructed by the following simple
example:
library(survival)
attach(lung)
fit <- coxph(Surv(time, status) ~ log(age))
predict(fit, newdata=data.frame(abe=45))
Note the typo in the last line of "abe" instead of "age". Instead of an
error message, this returns