Home » date » 2008 » Feb » 02 » attachments

OOF brlr 1

R Software Module: rwasp_logisticregression.wasp (opens new window with default values)
Title produced by software: Bias-Reduced Logistic Regression
Date of computation: Sat, 02 Feb 2008 04:01:18 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2008/Feb/02/t1201950411vwntoxlf914gcb0.htm/, Retrieved Sat, 02 Feb 2008 12:06:51 +0100
 
User-defined keywords:
schakel, brlr
 
Dataseries X:
» Textbox « » Textfile « » CSV «
0 780.8 93 1 699.1 193 1 598.5 112 0 735.3 71 0 700.5 105 0 706.9 119 0 656.3 162 1 1025.1 277 0 639.4 96 0 637.2 24 1 1065.6 231 0 576.1 99 0 525.6 27 1 377.5 112 0 627.8 96 0 646 95 1 999.31 143 1 168.3 13 0 219.5 22 0 507.4 27 1 227.1 56 1 821.6 278 0 144.7 10 0 761.6 55 1 817.7 61 0 547.8 44 0 313.4 10 0 291.8 28 0 650.3 53 0 679.4 41 1 736.5 135 0 842.6 85 0 904.9 14 0 263.7 12 1 446.5 93 0 511.8 22 1 645.6 101 1 873.9 201 0 871.6 2 0 287.3 9 0 505.7 49 1 597.7 112 1 791 27 0 725.8 93 0 919.4 49 0 114.7 1 0 866.8 69 0 870.7 108 0 700.2 108 0 636.5 70 1 890.3 165 0 879.1 208 0 100.5 4 0 782.8 153 0 738.1 67 1 762.3 163 1 857 75 1 712.5 238 1 609.9 90 0 940.1 137 0 586.7 133 1 49.3 17 0 9.7 0 0 786.7 33 1 755.7 123 1 749.2 153 1 630.1 126 0 835.6 164 0 1024.3 14 1 896.2 102 1 410.7 16 0 120.2 6 1 700.7 140 0 704.8 120 0 1042.4 124 1 831.8 49 1 854.1 99 1 547 23 0 999.4 80 0 532.6 56 0 826.4 152 0 670.9 78 1 837.1 105 0 1032.8 229 1 639.9 80 1 850.4 144 1 845 54 1 984.4 52 1 993.2 187 1 958.3 117 0 832.5 144 1 880.9 147 1 1020.9 182 1 764.8 117 1 601.6 104 1 686.2 46 1 821.2 138 0 836.9 89 0 985.5 120 1 973.2 314 1 702.9 111 1 929.2 80 0 747.2 187 1 654.3 166 1 628.8 70 0 564.6 91 0 981 202 1 705.3 112 0 397.9 40 0 56.3 2 1 929.7 69 0 559.7 75 1 669.2 78 0 923.5 128 1 539.8 38 1 401.7 19 0 923.5 171 1 688.3 124 0 324.5 4 1 613 27 0 930.5 255 0 348.6 6 1 582.9 143 1 919.7 113 0 786.5 87 1 637 85 1 917.1 110
 
Text written by user:
 
Output produced by software:

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!


Summary of compuational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 seconds
R Server'Herman Ole Andreas Wold' @ 193.190.124.10:1001


Coefficients of Bias-Reduced Logistic Regression
VariableParameterS.E.t-stat2-sided p-value
(Intercept)-0.9294382869014690.566357930375745-1.641079319371130.103315046769471
ws8.48316892050935e-050.0009647914830719430.08792748556919820.930076152681868
pe0.007961658330576620.003683284303765612.161564971359120.0325729358755396


Summary of Bias-Reduced Logistic Regression
Deviance166.660374217898
Penalized deviance137.745270895628
Residual Degrees of Freedom124
ROC Area0.657213930348259
Hosmer–Lemeshow test
Chi-square6.19362066324741
Degrees of Freedom8
P(>Chi)0.625553436536364


Fit of Logistic Regression
IndexActualFittedError
100.469346620796885-0.469346620796885
210.6607117461547380.339288253845262
310.5032597568426140.496740243157386
400.425121475400066-0.425121475400066
500.491490930624266-0.491490930624266
600.519481776086645-0.519481776086645
700.602531772965839-0.602531772965839
810.7962309496758180.203769050324182
900.472308937100362-0.472308937100362
1000.335301431513776-0.335301431513776
1110.7310785215881360.268921478411864
1200.476925757228949-0.476925757228949
1300.338522373119333-0.338522373119333
1410.4985728560751560.501427143924844
1500.472063686467112-0.472063686467112
1600.470464556894217-0.470464556894217
1710.5729389060609530.427061093939047
1810.3075369673128890.692463032687111
1900.323953637063134-0.323953637063134
2000.338176733361602-0.338176733361602
2110.3859614673979860.614038532602014
2210.7947176335376870.205282366462313
2300.302051758671776-0.302051758671776
2400.394857443357395-0.394857443357395
2510.4074757795185530.592524220481447
2600.369897976244151-0.369897976244151
2700.305077295132243-0.305077295132243
2800.335869055642874-0.335869055642874
2900.388813026582237-0.388813026582237
3000.366937958530794-0.366937958530794
3110.5517797264711340.448220273528866
3200.454819040797021-0.454819040797021
3300.322739415570033-0.322739415570033
3400.307564926169421-0.307564926169421
3510.4622900667832860.537709933216714
3600.32940774712041-0.32940774712041
3710.4823714456842290.517628554315771
3810.6780859468067290.321914053193271
3900.30162416034027-0.30162416034027
4000.302924269646613-0.302924269646613
4100.378382904462766-0.378382904462766
4210.5032427912221640.496757208777836
4310.3435820751222050.656417924877795
4400.468184737421961-0.468184737421961
4500.386672072132718-0.386672072132718
4600.286642595851246-0.286642595851246
4700.423956638998722-0.423956638998722
4800.501070939510219-0.501070939510219
4900.497455012374279-0.497455012374279
5000.421132320568926-0.421132320568926
5110.612957474921310.38704252507869
5200.690223028616242-0.690223028616242
5300.291302595638712-0.291302595638712
5400.58785417486599-0.58785417486599
5500.417415305881618-0.417415305881618
5610.6065848532522750.393415146747725
5710.4354588057760390.56454119422396
5810.7361161693802340.263883830619766
5910.4597994135968340.540200586403166
6000.559974649864694-0.559974649864694
6100.544688686395893-0.544688686395893
6210.312188446917450.68781155308255
6300.283205700277772-0.283205700277772
6400.354351364467991-0.354351364467991
6510.5284574614644150.471542538535585
6610.5871634161438860.412836583856114
6710.5317529872455620.468247012754438
6800.60996355804703-0.60996355804703
6900.324957341245778-0.324957341245778
7010.4896707254747350.510329274525265
7110.3170826495014170.682917350498583
7200.294948191622305-0.294948191622305
7310.5608556634199380.439144336580062
7400.521424395501767-0.521424395501767
7500.536493962802357-0.536493962802357
7610.3849111904519850.615088809548015
7710.4828119336837470.517188066316253
7810.3318305834072910.668169416592709
7900.44825472444424-0.44825472444424
8000.39212131479393-0.39212131479393
8100.586820943618734-0.586820943618734
8200.437450553361287-0.437450553361287
8310.4943873469739410.505612653026059
8400.727385053914676-0.727385053914676
8510.4407246010353450.559275398964655
8610.5717957096946920.428204290305308
8710.3946455916396460.605354408360354
8810.3936670541762930.606332945823707
8910.6555773260224750.344422673977525
9010.5208304225454110.479169577454589
9100.571423874649817-0.571423874649817
9210.5782646674285930.421735332571407
9310.6470707895803690.352929210419631
9410.5167325029392410.483267497060759
9510.4874048960008650.512595103999135
9610.3763686018317140.623631398168286
9710.5594510188771960.440548981122804
9800.462606188088298-0.462606188088298
9900.527363218966757-0.527363218966757
10010.8393069716587470.160693028341253
10110.5034834391730380.496516560826962
10210.4467823318165190.553217668183481
10300.650850110774755-0.650850110774755
10410.6100928132186040.389907186781396
10510.4209730907771950.579026909222806
10600.460822620960866-0.460822620960866
10700.681795734595339-0.681795734595339
10810.5055245842920480.494475415707952
10900.359573115252250-0.359573115252250
11000.287257957171120-0.287257957171120
11110.4252602877746010.574739712225399
11200.429269151314273-0.429269151314273
11310.4374150644407140.562584935559286
11400.541900512057102-0.541900512057102
11510.3586788042498410.641321195750159
11610.3221104458178040.677889554182196
11700.624887898497627-0.624887898497627
11810.5290166088888910.470983391111109
11900.295241032874722-0.295241032874722
12010.3401846002216890.659815399778311
12100.764897540559039-0.764897540559039
12200.298993356504975-0.298993356504975
12310.5642742218495620.435725778150438
12410.5120598627839810.487940137216019
12500.457588683980164-0.457588683980164
12610.4504978101799480.549502189820052
12710.5060355247364460.493964475263554


Type I & II errors for various threshold values
ThresholdType IType II
0.0101
0.0201
0.0301
0.0401
0.0501
0.0601
0.0701
0.0801
0.0901
0.101
0.1101
0.1201
0.1301
0.1401
0.1501
0.1601
0.1701
0.1801
0.1901
0.201
0.2101
0.2201
0.2301
0.2401
0.2501
0.2601
0.2701
0.2801
0.2900.955223880597015
0.300.895522388059702
0.310.01666666666666670.82089552238806
0.320.050.82089552238806
0.330.06666666666666670.761194029850746
0.340.08333333333333330.701492537313433
0.350.1166666666666670.701492537313433
0.360.1333333333333330.671641791044776
0.370.1333333333333330.64179104477612
0.380.150.626865671641791
0.390.1833333333333330.597014925373134
0.40.2166666666666670.567164179104478
0.410.2333333333333330.567164179104478
0.420.2333333333333330.552238805970149
0.430.2666666666666670.492537313432836
0.440.30.477611940298507
0.450.3333333333333330.462686567164179
0.460.3666666666666670.432835820895522
0.470.3833333333333330.373134328358209
0.480.3833333333333330.313432835820896
0.490.450.313432835820896
0.50.4833333333333330.283582089552239
0.510.5666666666666670.268656716417910
0.520.60.253731343283582
0.530.650.223880597014925
0.540.6666666666666670.208955223880597
0.550.6666666666666670.179104477611940
0.560.70.164179104477612
0.570.7333333333333330.164179104477612
0.580.7833333333333330.149253731343284
0.590.80.119402985074627
0.60.80.119402985074627
0.610.8166666666666670.0895522388059701
0.620.850.0895522388059701
0.630.850.0746268656716418
0.640.850.0746268656716418
0.650.8666666666666670.0746268656716418
0.660.8833333333333330.0597014925373134
0.670.90.0597014925373134
0.680.9166666666666670.0597014925373134
0.690.9166666666666670.0447761194029851
0.70.9166666666666670.0298507462686567
0.710.9166666666666670.0298507462686567
0.720.9166666666666670.0298507462686567
0.730.9166666666666670.0149253731343284
0.740.950.0149253731343284
0.750.950.0149253731343284
0.760.950.0149253731343284
0.770.950
0.780.950
0.790.950
0.80.9833333333333330
0.810.9833333333333330
0.820.9833333333333330
0.830.9833333333333330
0.8410
0.8510
0.8610
0.8710
0.8810
0.8910
0.910
0.9110
0.9210
0.9310
0.9410
0.9510
0.9610
0.9710
0.9810
0.9910
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Feb/02/t1201950411vwntoxlf914gcb0/1y4kt1201950070.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Feb/02/t1201950411vwntoxlf914gcb0/1y4kt1201950070.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Feb/02/t1201950411vwntoxlf914gcb0/21vjy1201950070.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Feb/02/t1201950411vwntoxlf914gcb0/21vjy1201950070.ps (open in new window)


 
Parameters (Session):
 
Parameters (R input):
 
R code (references can be found in the software module):
library(brlr)
roc.plot <- function (sd, sdc, newplot = TRUE, ...)
{
sall <- sort(c(sd, sdc))
sens <- 0
specc <- 0
for (i in length(sall):1) {
sens <- c(sens, mean(sd >= sall[i], na.rm = T))
specc <- c(specc, mean(sdc >= sall[i], na.rm = T))
}
if (newplot) {
plot(specc, sens, xlim = c(0, 1), ylim = c(0, 1), type = 'l',
xlab = '1-specificity', ylab = 'sensitivity', main = 'ROC plot', ...)
abline(0, 1)
}
else lines(specc, sens, ...)
npoints <- length(sens)
area <- sum(0.5 * (sens[-1] + sens[-npoints]) * (specc[-1] -
specc[-npoints]))
lift <- (sens - specc)[-1]
cutoff <- sall[lift == max(lift)][1]
sensopt <- sens[-1][lift == max(lift)][1]
specopt <- 1 - specc[-1][lift == max(lift)][1]
list(area = area, cutoff = cutoff, sensopt = sensopt, specopt = specopt)
}
roc.analysis <- function (object, newdata = NULL, newplot = TRUE, ...)
{
if (is.null(newdata)) {
sd <- object$fitted[object$y == 1]
sdc <- object$fitted[object$y == 0]
}
else {
sd <- predict(object, newdata, type = 'response')[newdata$y ==
1]
sdc <- predict(object, newdata, type = 'response')[newdata$y ==
0]
}
roc.plot(sd, sdc, newplot, ...)
}
hosmerlem <- function (y, yhat, g = 10)
{
cutyhat <- cut(yhat, breaks = quantile(yhat, probs = seq(0,
1, 1/g)), include.lowest = T)
obs <- xtabs(cbind(1 - y, y) ~ cutyhat)
expect <- xtabs(cbind(1 - yhat, yhat) ~ cutyhat)
chisq <- sum((obs - expect)^2/expect)
P <- 1 - pchisq(chisq, g - 2)
c('X^2' = chisq, Df = g - 2, 'P(>Chi)' = P)
}
x <- as.data.frame(t(y))
r <- brlr(x)
summary(r)
rc <- summary(r)$coeff
hm <- hosmerlem(y[1,],r$fitted.values)
hm
bitmap(file='test0.png')
ra <- roc.analysis(r)
dev.off()
te <- array(0,dim=c(2,99))
for (i in 1:99) {
threshold <- i / 100
numcorr1 <- 0
numfaul1 <- 0
numcorr0 <- 0
numfaul0 <- 0
for (j in 1:length(r$fitted.values)) {
if (y[1,j] > 0.99) {
if (r$fitted.values[j] >= threshold) numcorr1 = numcorr1 + 1 else numfaul1 = numfaul1 + 1
} else {
if (r$fitted.values[j] < threshold) numcorr0 = numcorr0 + 1 else numfaul0 = numfaul0 + 1
}
}
te[1,i] <- numfaul1 / (numfaul1 + numcorr1)
te[2,i] <- numfaul0 / (numfaul0 + numcorr0)
}
bitmap(file='test1.png')
op <- par(mfrow=c(2,2))
plot((1:99)/100,te[1,],xlab='Threshold',ylab='Type I error', main='1 - Specificity')
plot((1:99)/100,te[2,],xlab='Threshold',ylab='Type II error', main='1 - Sensitivity')
plot(te[1,],te[2,],xlab='Type I error',ylab='Type II error', main='(1-Sens.) vs (1-Spec.)')
plot((1:99)/100,te[1,]+te[2,],xlab='Threshold',ylab='Sum of Type I & II error', main='(1-Sens.) + (1-Spec.)')
par(op)
dev.off()
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Coefficients of Bias-Reduced Logistic Regression',5,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Variable',header=TRUE)
a<-table.element(a,'Parameter',header=TRUE)
a<-table.element(a,'S.E.',header=TRUE)
a<-table.element(a,'t-stat',header=TRUE)
a<-table.element(a,'2-sided p-value',header=TRUE)
a<-table.row.end(a)
for (i in 1:length(rc[,1])) {
a<-table.row.start(a)
a<-table.element(a,labels(rc)[[1]][i],header=TRUE)
a<-table.element(a,rc[i,1])
a<-table.element(a,rc[i,2])
a<-table.element(a,rc[i,3])
a<-table.element(a,2*(1-pt(abs(rc[i,3]),r$df.residual)))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Summary of Bias-Reduced Logistic Regression',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Deviance',1,TRUE)
a<-table.element(a,r$deviance)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Penalized deviance',1,TRUE)
a<-table.element(a,r$penalized.deviance)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Residual Degrees of Freedom',1,TRUE)
a<-table.element(a,r$df.residual)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'ROC Area',1,TRUE)
a<-table.element(a,ra$area)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Hosmer–Lemeshow test',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Chi-square',1,TRUE)
a<-table.element(a,hm[1])
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Degrees of Freedom',1,TRUE)
a<-table.element(a,hm[2])
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'P(>Chi)',1,TRUE)
a<-table.element(a,hm[3])
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file='mytable1.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Fit of Logistic Regression',4,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Index',1,TRUE)
a<-table.element(a,'Actual',1,TRUE)
a<-table.element(a,'Fitted',1,TRUE)
a<-table.element(a,'Error',1,TRUE)
a<-table.row.end(a)
for (i in 1:length(r$fitted.values)) {
a<-table.row.start(a)
a<-table.element(a,i,1,TRUE)
a<-table.element(a,y[1,i])
a<-table.element(a,r$fitted.values[i])
a<-table.element(a,y[1,i]-r$fitted.values[i])
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable2.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Type I & II errors for various threshold values',3,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Threshold',1,TRUE)
a<-table.element(a,'Type I',1,TRUE)
a<-table.element(a,'Type II',1,TRUE)
a<-table.row.end(a)
for (i in 1:99) {
a<-table.row.start(a)
a<-table.element(a,i/100,1,TRUE)
a<-table.element(a,te[1,i])
a<-table.element(a,te[2,i])
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable3.tab')
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

  • personalize online software applications according to your needs
  • enforce strict security rules with respect to the data that you upload (e.g. statistical data)
  • manage user sessions of online applications
  • alert you about important changes or upgrades in resources or applications

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by