Hi

Finally, I did leave-one-out cross validation in R for prediction error of 
logistic regression by cv.glm. But I don't know what are the produced 
data(almost 700)? does delta show me error estimation? 


cost<-function(a,b)mean(abs(a-b))
#SALIC=binary response
salic.lr<-glm(profilesample$SALIC~profilesample$wetnessindex , profilesample, 
family=binomial('logit'))
>loadpackage(boot)
> cv.err<-cv.glm(profilesample, salic.lr, cost, K=100)
> cv.err

$call
cv.glm(data = profilesample, glmfit = salic.lr, cost = cost, 
K = 100)

$K
[1] 100

$delta
1 1 
0.4278 0.4278 

$seed
[1] 403 133 1654269195 -1877109783 -961256264 1403523942
[7] 124639233 261424787 1836448066 1034917620 -13630729 468718317
[13] 1694379396 1559298986 1935866133 -1450855505 2105396150 1802260960
[19] 1077391651 539731521 122505520 230898510 -1940184647 1223031755
[25] -1597886342 -1854140036 -1783225921 1484611221 1365746860 -346485118
[31] 1206044253 1201793367 956757054 350214264 -1324711077
.
.
.
please help me

Thanks alot

--- On Wed, 5/26/10, Joris Meys <jorism...@gmail.com> wrote:


From: Joris Meys <jorism...@gmail.com>
Subject: Re: [R] validation logistic regression
To: "azam jaafari" <azamjaaf...@yahoo.com>
Cc: r-help@r-project.org
Date: Wednesday, May 26, 2010, 5:00 AM


Hi,

first of all, you shouldn't backtransform your prediction, use the option 
type=response instead :

salichpred<-predict(salic.lr, newdata=profilevalidation,type="response")

limit <- 0.5
salichpredcat <- ifelse(salichpred<limit,0,1) # prediction of categories.

Read in on sensitivity, specificity and ROC-curves. With changing the limit, 
you can calculate sensitivity and specificity, and you can construct a ROC 
curve that will tell you how well your predictions are. It all depends on how 
much error you allow on the predictions.

Cheers
Joris



On Wed, May 26, 2010 at 10:04 AM, azam jaafari <azamjaaf...@yahoo.com> wrote:

Hi
 
I did validation for prediction by logistic regression according to following:
 
validationsize <- 23
set.seed(1)
random<-runif(123)
order(random)
nrprofilesinsample<-sort(order(random)[1:100])
profilesample <- data[nrprofilesinsample,]
profilevalidation <- data[-nrprofilesinsample,]
salich<-profilesample$SALIC.H.1
salic.lr<-glm(salich~wetnessindex, profilesample, family=binomial('logit'))
summary(salic.lr)
salichpred<-predict(salic.lr, newdata=profilevalidation)
expsalichpred<-exp(salichpred)
salichprediction<-(expsalichpred/(1+expsalichpred))

So,
 table(salichprediction, profilevalidation$SALIC.H.1)

in result:
salichprediction            0 1
  0.0408806327422231 1 0
  0.094509645033899  1 0
  0.118665480273383  1 0
  0.129685441514168  1 0
  0.13545295569511    1 0
  0.137580612201769  1 0
  0.197265822234215  1 0
  0.199278585548248  0 1
  0.202436276322278  1 0
  0.211278767985746  1 0
  0.261036846823867  1 0
  0.283792703256058  1 0
  0.362229486187581  0 1
  0.362795636267779  1 0
  0.409067386115694  1 0
  0.410860613509484  0 1
  0.423960962956254  1 0
  0.428164288793652  1 0
  0.448509687866763  0 1
  0.538401659478058  0 1
  0.557282539294224  1 0
  0.603881788227797  0 1
  0.63633478460736   0 1

So, I have salichprediction between 0 to 1 and binary variable(observed values) 
0 or 1. I want to compare these data together and I want to know is ok this 
model(logistic regression) for prediction or no?
 
please help me?
 
Thanks alot
 
Azam




       [[alternative HTML version deleted]]


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering 
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be 
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to