Displaying 20 results from an estimated 30000 matches similar to: "How to calculate residual mean deviance in rpart"
2012 Jan 10
0
rpart vs. tree and deviance calculations
Hi Everyone,
I'm working on building some classification trees, and up to this point
I've been using rpart. However, I recently discovered the tree package,
and found that it had some useful functions (in particular deviance(),
which I would really like to use for my project). I can't seem to find
an equivalent function for rpart. I've considered using tree() in place
of
2011 Apr 08
1
multinom() residual deviance
Running a binary logit model on the data
df <- data.frame(y=sample(letters[1:3], 100, repl=T),
x=rnorm(100))
reveals some residual deviance:
summary(glm(y ~ ., data=df, family=binomial("logit")))
However, running a multinomial model on that data (multinom, nnet)
reveals a residual deviance:
summary(multinom(y ~ ., data=df))
On page 203, the MASS book says that "here the
2006 Apr 23
1
lme: null deviance, deviance due to the random effects, residual deviance
A maybe trivial and stupid question:
In the case of a lm or glm fit, it is quite informative (to me) to have
a look to the null deviance and the residual deviance of a model. This
is generally provided in the print method or the summary, eg:
Null Deviance: 658.8
Residual Deviance: 507.3
and (a bit simpled minded) I like to think that the proportion of
deviance 'explained' by the
2001 Jul 24
0
bug in residuals.rpart?
The following code
tr <- rpart(Y ~ ., dat, method="class")
dev <- residuals(tr, "deviance")
produces the following error
Error in log(x) : Non-numeric argument to mathematical function
> .Traceback
[[1]]
[1] "log(yhat)" # line 588 of rpart
[[2]]
[1] "switch(type, usual = as.integer(y != yhat), pearson = (1 -
yhat)/yhat, "
[2] "
2009 Jan 07
0
Residual deviance (cross-post from sci.stat.consult)
Dear all,
I'm trying to fit a statistical model to series of measurements.
Unfortunately, my knowledge of statistics is rather limited, so I'm a
bit at loss of what is going on with the model.
First of all, I've prepared a histogram. Then, I've tried to fit a Poisson model to express the relation between the middle points of
classes (mids) and the corresponding frequencies
2008 Jan 10
0
Residual deviance in glm
I'm running a categorical data analysis with a two-way design of
nominal by ordinal structure like the Political Ideology Example
(Table 9.5) in Agresti's book Categorical Data Analysis. The nominal
variable is Method while the ordinal variable is Quality (Bad,
Moderate, Good, Excellent). I rank/quantify Quality with another
variable QualityR (1, 2, 3, 4), and run the following:
2017 Oct 05
0
fraction of null deviance explained by each node/variable in regression trees
I have used packages rpart, mvpart and tree for classification and
regression trees. I want to calculate fraction of null deviance explained
by each node and variable in the tree. For instance, at the first split,
this would be (1 - (sum of residual deviance in each of the two
leaves)/deviance at the root). In the subsequent splits, this formula is
slightly different.
There probably is a function
2002 Aug 28
0
user defined function in rpart
Hi,
I am trying to use the rpart library with my own set of functions on a
survival object. I get an immeadiate segmentation fault when i try
calling rpart with my list of functions. I get the same problem with the
logrank example from Therneau,s S-rpart library though their anova
example works. Should I report this as a bug, as even if my functions
are structured improperly, that should lead to
2010 Aug 20
3
Deviance Residuals
Dear all,
I am running a logistic regression and this is the output:
glm(formula = educationUniv ~ brncntr, family = binomial)
Deviance Residuals:
Min 1Q Median 3Q Max # ???? ????? ?? ????????
-0.8825 -0.7684 -0.7684 1.5044 1.6516
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.06869 0.01155 -92.487 <2e-16 ***
brncntrNo
2006 Nov 30
0
Standardized deviance residuals in plot.lm
It seems that the standardized deviance residulas, that one gets on
plots of a glm.object x with plot(x) are calculated as
r <- residuals(x)
s <- sqrt(deviance(x)/df.residual(x))
w <- weights(x)
hii <- lm.influence(x)$hat
r.w <- if (is.null(w)) r else (sqrt(w) * r)
rs <- r.w/(s * sqrt(1 - hii))
This implies that, for example, for binomial B(ni,pi) data the devaince
residials
2007 Nov 21
0
How to extract the Deviance of a glm fit result
dear List:
glm(a~b+c,family=binomial,data=x)->fit
deviance(fit) returns the same as the residual deviance.
I don't not know much about logistic regression.Some book tells that:
"
Deviance (likelihood ratio statistic):
Deviance = -2log( likelihoodof the currentmodel /likelihoodof thesaturated
model)
Note:
(1). The current model is the model of interest.
(2). The saturated model
2005 Aug 26
1
Help in Compliling user -defined functions in Rpart
I have been trying to write my own user defined function in Rpart.I
imitated the anova splitting rule which is given as an example.In the
work I am doing ,I am calculating the concentration index(ci) ,which
is in between -1 and +1.So my deviance is given by
abs(ci)*(1-abs(ci)).Now when I run rpart incorporating this user
defined function i get the following error message:
Error in
2011 Jun 13
1
In rpart, how is "improve" calculated? (in the "class" case)
Hi all,
I apologies in advance if I am missing something very simple here, but since
I failed at resolving this myself, I'm sending this question to the list.
I would appreciate any help in understanding how the rpart function is
(exactly) computing the "improve" (which is given in fit$split), and how it
differs when using the split='information' vs split='gini'
2005 May 25
0
Error with user defined split function in rpart (PR#7895)
Full_Name: Bill Wheeler
Version: 2.0.1
OS: Windows 2000
Submission from: (NULL) (67.130.36.229)
The program to reproduce the error is below. I am calling rpart with a
user-defined split function for a binary response variable and one continuous
independent variable. The split function works for some datasets but not
others.
The error is:
Error in "$<-.data.frame"(`*tmp*`,
2002 Jan 04
1
glm deviance question
I am comparing the Splus and R fits of a simple glm.
In the following, foo is generated from rbinom with size = 20 p = 0.5.
The coefficients (and SE's0 of the fitted models are the same, but the
estimated deviances are quite different. Could someone please tell me why
they are so different? I am using R version 1.3.1 and Splus 2000 release 3
on windows 2000.
++++++++++++++++++++++
foo
2000 Jul 24
1
Questions about deviance
I have experimented with the cheese data example from McCullagh&Nelder,
page 175. With a proportional odds model they obtain a residual deviance
of
20.31.
Estimating the same model with polr(MASS) gives a residual deviance of
762.11 !, while using ordglm(gnlm) gives a deviance of 523.94. Can
anybody explain these differences?
The data frame with the data are:
> cheese
Cheese N
2013 Feb 12
0
Deviance and AIC in weighted NLS
Dear All,
I encounter some discrepancies when comparing the deviance of a weighted and
unweigthed model with the AIC values. A general example (from 'nls'):
DNase1 <- subset(DNase, Run == 1)
fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1)
Now for a weighted fit:
fm2DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal),
2005 Oct 14
1
Predicting classification error from rpart
Hi,
I think I'm missing something very obvious, but I am missing it, so I
would be very grateful for help. I'm using rpart to analyse data on
skull base morphology, essentially predicting sex from one or several
skull base measurements. The sex of the people whose skulls are being
studied is known, and lives as a factor (M,F) in the data. I want to
get back predictions of gender, and
2007 Feb 18
3
User defined split function in rpart
Dear R community,
I am trying to write my own user defined split function for rpart. I read
the example in the tests directory and I understand the general idea of the
how to implement user defined splitting functions. However, I am having
troubles with addressing the data frame used in calling rpart in my split
functions.
For example, in the evaluation function that is called once per node,
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