[R] Missing data problem and ROC curves
dwinsemius at comcast.net
Mon Jul 1 20:56:33 CEST 2013
On Jul 1, 2013, at 10:57 AM, tfj24 wrote:
> Hello all,
> Trying to get this piece of code to work on my data set. It is from
> logit.roc <- function(model, steps=100)
> field.name <- attr(attr(terms(formula(model)), "factors"),
> eval(parse(text=paste("tmp <- ", ifelse(class(model$data) == "data.frame",
> "model$data$", ""), field.name, sep="")))
> r <- data.frame(pts = seq(0, 1-(1/steps), by=1/steps), sens = 0, spec=0);
> for (i in 0:steps)
> thresh <- i/steps;
> r$sens[i] <- sum((fitted(model) >= thresh) & tmp)/sum(tmp);
> r$spec[i] <- sum((fitted(model) < thresh) & !tmp)/sum(!tmp)
> where model is the output of a glm.
> The problem is the "sum((fitted(model) >= thresh) & tmp)" bit. The lengths
> of fitted(model) and tmp are not equal because some of the cases were
> deleted from the model due to missing data! fitted(model) is a set of named
> numbers while tmp is a set of integers.
> My question is:
> - How do I determine which cases were deleted from the model and then delete
> the associated cases from tmp?
> I hope this makes sense and would really appreciate any help that people may
> View this message in context: http://r.789695.n4.nabble.com/Missing-data-problem-and-ROC-curves-tp4670661.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Alameda, CA, USA
More information about the R-help