Home » date » 2008 » Jan » 30 » attachments

Binghnetty Logistic Regression 4 (males)

R Software Module: rwasp_logisticregression.wasp (opens new window with default values)
Title produced by software: Bias-Reduced Logistic Regression
Date of computation: Wed, 30 Jan 2008 04:57:29 -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/Jan/30/t1201694416qocyfa271e5fls3.htm/, Retrieved Wed, 30 Jan 2008 13:00:19 +0100
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
1 70.6 1 7.8 1 71.3 1 6.0 1 67.5 1 6.0 1 73.2 1 7.1 1 81.2 1 5.9 1 75.5 1 3.6 1 66.7 1 6.9 1 68.7 1 8.0 1 73.0 1 5.6 1 78.4 1 6.1 1 76.1 1 5.1 1 65.7 1 5.0 1 66.7 1 5.2 1 72.3 1 2.9 1 66.2 1 4.9 1 67.7 1 4.7 1 64.9 1 6.5 1 72.2 1 7.5 1 69.4 1 3.9 1 72.8 1 3.2 1 75.4 1 4.5 1 74.7 1 6.5 1 77.4 1 7.4 1 68.8 1 3.3 1 75.3 1 5.9 1 72.4 1 4.8 1 72.7 1 4.4 1 65.3 1 5.4 1 67.0 1 5.9 1 66.7 1 6.1 1 67.0 1 5.4 1 67.5 1 6.0 1 69.9 1 4.9 1 72.5 1 5.3 1 73.8 1 6.0 1 71.9 1 3.2 1 69.9 1 6.5 1 71.4 1 3.6 1 64.9 1 5.9 1 70.2 1 5.2 1 65.3 1 7.3 1 67.5 1 8.9 1 68.1 1 1.8 1 82.9 1 6.5 1 66.2 1 3.0 1 74.0 1 7.0 1 69.8 1 7.0 1 81.3 1 5.9 1 76.9 1 6.3 1 76.6 1 3.8 1 72.7 1 7.6 1 78.6 1 6.3 1 70.2 1 5.6 1 69.5 1 6.4 1 73.8 1 7.5 1 66.1 1 7.0 1 77.8 1 1.1 1 73.2 1 6.0 1 72.8 1 6.5 1 74.8 1 5.7 1 67.2 1 5.5 1 80.7 1 6.4 1 67.2 1 6.5 1 75.4 1 1.9 1 75.3 1 3.4 1 73.2 1 6.4 1 65.3 1 1.6 1 71.8 1 6.8 1 67.3 1 6.1 1 73.7 1 6.3 1 80.6 0 5.1 1 75.7 0 4.7 1 73.0 0 4.1 1 71.3 0 3.0 1 70.8 0 6.5 1 69.6 0 5.3 1 66.1 0 6.4 1 65.6 0 6.8 0 65.0 1 12.0 0 65.0 1 7.0 0 65.0 0 6.0 0 65.0 1 5.0 0 65.0 1 7.0 0 65.0 1 8.0 0 65.0 0 5.0 0 65.0 1 8.0 0 65.0 1 5.0 0 65.0 1 6.0 0 65.0 1 9.0 0 65.0 0 7.0 0 65.0 1 6.0 0 65.0 0 6.0 0 65.0 0 7.0 0 65.0 0 6.0 0 65.0 0 6.0 0 65.0 0 8.0 0 65.0 0 7.0 0 65.0 0 5.0 0 65.0 0 7.0 0 65.0 0 7.0 0 65.0 1 6.0 0 65.0 1 5.0 0 65.0 1 7.0 0 65.0 0 8.0 0 65.0 1 8.0 0 65.0 0 9.0 0 65.0 0 99.0 0 65.0 0 8.0 0 65.0 0 6.0 0 65.0 1 5.0 0 65.0 1 9.0 0 65.0 1 7.0 0 65.0 1 6.0 0 65.0 1 7.0 0 65.0 0 6.0 0 65.0 0 6.0 0 65.0 1 7.0 0 65.0 1 7.0 0 65.0 0 6.0 0 65.0 1 6.0 0 65.0 0 6.0 0 65.0 0 8.0 0 65.0 1 6.0 0 65.0 0 7.0 0 65.0 1 7.0 0 65.0 1 5.0 0 65.0 0 8.0 0 65.0 1 4.0 0 65.0 1 7.0 0 65.0 1 8.0 0 65.0 1 10.0 0 65.0 1 6.0 0 65.0 0 7.0 0 65.0 1 5.0 0 65.0 0 6.0 0 65.0 0 6.0 0 65.0 0 10.0 0 65.0 0 7.0 0 65.0 0 6.0
 
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 time3 seconds
R Server'George Udny Yule' @ 72.249.76.132


Coefficients of Bias-Reduced Logistic Regression
VariableParameterS.E.t-stat2-sided p-value
(Intercept)-254.66975716759585.1818396820186-2.989718913306750.00331920749560477
age3.900242298823971.302548742167562.994315815263560.00327270654856004
snoring1.071616648011220.9161609787741161.169681609279100.244190073162315
sleep_time-0.2775561362100370.273565258291474-1.014588394533310.312116999755588


Summary of Bias-Reduced Logistic Regression
Deviance29.5179828359480
Penalized deviance25.3731748071590
Residual Degrees of Freedom135
ROC Area0.990332072299285


Fit of Logistic Regression
IndexActualFittedError
110.9999999969067023.0932982841847e-09
210.999999999877611.22391208279282e-10
310.9996656132418770.000334386758123029
410.99999999999991.00364161426114e-13
5110
6110
710.9903670247510510.00963297524894868
810.9999945943276775.40567232254485e-06
910.9999999999998551.44551037806195e-13
10110
11110
1210.779025734587910.220974265412090
1310.9939686146477710.00603138535222902
1410.9999999999989521.04760644603630e-12
1510.9622349505545550.0377650494454449
1610.9998931255899510.000106874410048863
1710.09308546133040260.906914538669597
1810.9999999999944525.54756240944698e-12
1910.9999998870370781.12962921572368e-07
2010.9999999999998381.61870516990348e-13
21110
22112.22044604925031e-16
23110
2410.9999990070597879.92940213162541e-07
25110
2610.9999999999987981.20192744645919e-12
2710.9999999999996663.33733041202322e-13
2810.3986432269542290.601356773045771
2910.9977182137311270.00228178626887288
3010.9922703221132140.00772967788678602
3110.9980132974898420.00198670251015809
3210.9996656132418770.000334386758123029
3310.9999999787895352.12104653840584e-08
3410.9999999999990659.34807786734382e-13
3510.9999999999999937.105427357601e-15
3610.9999999999945815.41899858319539e-12
3710.999999966931393.30686109606404e-08
3810.9999999999574344.25663948533384e-11
3910.1081290014420590.89187099855794
4010.9999999928458777.1541232937733e-09
4110.2812078414171950.718792158582805
4210.9992524526167170.000747547383282643
4310.999989958349121.00416508808099e-05
44110
4510.9773620898011440.0226379101988561
4610.9999999999999964.21884749357559e-15
4710.9999999438859185.61140820476425e-08
48110
49110
50110
5110.9999999999991898.11350986396064e-13
52110
5310.999999992005847.99416033370193e-09
5410.999999846925351.53074649289486e-07
5510.999999999999991.08801856413265e-14
5610.9059350811548050.0940649188451953
57110
5810.9999999999999267.39408534400354e-14
5910.9999999999995954.04787314778332e-13
60112.22044604925031e-16
6110.999062712918370.000937287081629656
62110
6310.9987632454093840.00123675459061612
64110
65110
6610.9999999999999178.28226376370367e-14
6710.6555649344862180.344435065513782
6810.999999999978262.17399431790000e-11
6910.9992502897443060.00074971025569448
7010.9999999999999881.15463194561016e-14
71110
72110
7310.9999999999997222.78443934575989e-13
7410.9999999998445741.55426116421609e-10
7510.9999999971136782.88632229228369e-09
7610.9999997769922992.23007701194433e-07
7710.7957433654480610.204256634551939
7810.3315364545867660.668463545413233
7900.0318896451354848-0.0318896451354848
8000.116573713341479-0.116573713341479
8100.0562877399798279-0.0562877399798279
8200.186916506102960-0.186916506102960
8300.116573713341479-0.116573713341479
8400.0908880110667426-0.0908880110667426
8500.0729800868819681-0.0729800868819681
8600.0908880110667426-0.0908880110667426
8700.186916506102960-0.186916506102960
8800.148334003794352-0.148334003794352
8900.0704107859750647-0.0704107859750647
9000.0432352793163922-0.0432352793163922
9100.148334003794352-0.148334003794352
9200.0562877399798279-0.0562877399798279
9300.0432352793163922-0.0432352793163922
9400.0562877399798279-0.0562877399798279
9500.0562877399798279-0.0562877399798279
9600.0331033593898801-0.0331033593898801
9700.0432352793163922-0.0432352793163922
9800.0729800868819681-0.0729800868819681
9900.0432352793163922-0.0432352793163922
10000.0432352793163922-0.0432352793163922
10100.148334003794352-0.148334003794352
10200.186916506102960-0.186916506102960
10300.116573713341479-0.116573713341479
10400.0331033593898801-0.0331033593898801
10500.0908880110667426-0.0908880110667426
10600.0252830485335928-0.0252830485335928
10703.67495533956679e-13-3.67495533956679e-13
10800.0331033593898801-0.0331033593898801
10900.0562877399798279-0.0562877399798279
11000.186916506102960-0.186916506102960
11100.0704107859750647-0.0704107859750647
11200.116573713341479-0.116573713341479
11300.148334003794352-0.148334003794352
11400.116573713341479-0.116573713341479
11500.0562877399798279-0.0562877399798279
11600.0562877399798279-0.0562877399798279
11700.116573713341479-0.116573713341479
11800.116573713341479-0.116573713341479
11900.0562877399798279-0.0562877399798279
12000.148334003794352-0.148334003794352
12100.0562877399798279-0.0562877399798279
12200.0331033593898801-0.0331033593898801
12300.148334003794352-0.148334003794352
12400.0432352793163922-0.0432352793163922
12500.116573713341479-0.116573713341479
12600.186916506102960-0.186916506102960
12700.0331033593898801-0.0331033593898801
12800.232791456908998-0.232791456908998
12900.116573713341479-0.116573713341479
13000.0908880110667426-0.0908880110667426
13100.0542716973274171-0.0542716973274171
13200.148334003794352-0.148334003794352
13300.0432352793163922-0.0432352793163922
13400.186916506102960-0.186916506102960
13500.0562877399798279-0.0562877399798279
13600.0562877399798279-0.0562877399798279
13700.0192733756628649-0.0192733756628649
13800.0432352793163922-0.0432352793163922
13900.0562877399798279-0.0562877399798279


Type I & II errors for various threshold values
ThresholdType IType II
0.0100.98360655737705
0.0200.967213114754098
0.0300.950819672131147
0.0400.852459016393443
0.0500.721311475409836
0.0600.508196721311475
0.0700.508196721311475
0.0800.442622950819672
0.0900.442622950819672
0.10.01282051282051280.377049180327869
0.110.02564102564102560.377049180327869
0.120.02564102564102560.229508196721311
0.130.02564102564102560.229508196721311
0.140.02564102564102560.229508196721311
0.150.02564102564102560.114754098360656
0.160.02564102564102560.114754098360656
0.170.02564102564102560.114754098360656
0.180.02564102564102560.114754098360656
0.190.02564102564102560.0163934426229508
0.20.02564102564102560.0163934426229508
0.210.02564102564102560.0163934426229508
0.220.02564102564102560.0163934426229508
0.230.02564102564102560.0163934426229508
0.240.02564102564102560
0.250.02564102564102560
0.260.02564102564102560
0.270.02564102564102560
0.280.02564102564102560
0.290.03846153846153850
0.30.03846153846153850
0.310.03846153846153850
0.320.03846153846153850
0.330.03846153846153850
0.340.05128205128205130
0.350.05128205128205130
0.360.05128205128205130
0.370.05128205128205130
0.380.05128205128205130
0.390.05128205128205130
0.40.06410256410256410
0.410.06410256410256410
0.420.06410256410256410
0.430.06410256410256410
0.440.06410256410256410
0.450.06410256410256410
0.460.06410256410256410
0.470.06410256410256410
0.480.06410256410256410
0.490.06410256410256410
0.50.06410256410256410
0.510.06410256410256410
0.520.06410256410256410
0.530.06410256410256410
0.540.06410256410256410
0.550.06410256410256410
0.560.06410256410256410
0.570.06410256410256410
0.580.06410256410256410
0.590.06410256410256410
0.60.06410256410256410
0.610.06410256410256410
0.620.06410256410256410
0.630.06410256410256410
0.640.06410256410256410
0.650.06410256410256410
0.660.07692307692307690
0.670.07692307692307690
0.680.07692307692307690
0.690.07692307692307690
0.70.07692307692307690
0.710.07692307692307690
0.720.07692307692307690
0.730.07692307692307690
0.740.07692307692307690
0.750.07692307692307690
0.760.07692307692307690
0.770.07692307692307690
0.780.08974358974358970
0.790.08974358974358970
0.80.1025641025641030
0.810.1025641025641030
0.820.1025641025641030
0.830.1025641025641030
0.840.1025641025641030
0.850.1025641025641030
0.860.1025641025641030
0.870.1025641025641030
0.880.1025641025641030
0.890.1025641025641030
0.90.1025641025641030
0.910.1153846153846150
0.920.1153846153846150
0.930.1153846153846150
0.940.1153846153846150
0.950.1153846153846150
0.960.1153846153846150
0.970.1282051282051280
0.980.1410256410256410
0.990.1410256410256410
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Jan/30/t1201694416qocyfa271e5fls3/1leb81201694245.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Jan/30/t1201694416qocyfa271e5fls3/1leb81201694245.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Jan/30/t1201694416qocyfa271e5fls3/21dpn1201694245.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Jan/30/t1201694416qocyfa271e5fls3/21dpn1201694245.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
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.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