# Scale predicted probability in logistic regression

I am trying to

1) classify a bunch of [0,1] ratios into two groups Group 0: Ratio = 0, Group 1: Ratio != 0.

2) predict the actual response with multiple predictors in R.

My question would then be:

Q1: Can I use the scaled predicted probability as the predicted response?

Q2: Should I classify the group before the regression before running the regression to solve the warning message? Would the data structure/predicted be affected?

I thought of achieving Goal 1 and Goal 2 separately but I can't seem to find a way to fit a unbalanced [0,1] non-censored data with good prediction.

Basically my response is something like this

y<-c(rep(0,100),0.3,0.4,0.8,1.0)
x<-cbind(rnorm(104,20,2),as.factor(c(rep(0,90),rep(1,5),rep(0,8),rep(1,1)))
,as.factor(sample(c(1:3),104,TRUE,prob = c(0.6,0.3,0.1))))

data<-data.frame(cbind(y,x))


and y is strictly between 0 to 1.

I then fit it with a logistic regression and get the predicted probability:

fit<-glm(y~.,data=data, family = "binomial")
fit.prob<-predict(fit,type="response")


I used the probability to make classification model (Goal 1)

class<-y;class[y==0]="0";class[y!=0]="1"

cutoff<-0.06
fit.pred=rep(0,length(fit.prob)); fit.pred[fit.prob >=cutoff]=1
table(fit.pred,class)


However, I also want to predict y from new data set, this is probably wrong, but here's what I did

se<-fit.prob<-predict(fit,type="response",se=T)\$se.fit
scaled.fit<-fit.prob/max(fit.prob)
scale.fit.UL<-scaled.fit+1.96*se
scale.fit.LL<-scaled.fit-1.96*se


and I used this to be the prediction interval for y. Is there any other way to do it other than this?

• What exactly are the y-values? They certainly aren't Bernoulli (yes/no) data. You call them "ratios"; what are they ratios of? In the example, they seem to occur only at fixed values, is that true of the real / full data? – gung Dec 2 '15 at 21:08
• they are x/(x+y) kind of ratio, so it is continuous on [0,1]. But most of the values for x is 0, resulting a lot of zeros in the ratios. My main goal is to classify those x = 0 group and to predict that x/(x+y) number given a testing data. – Matthew Lau Dec 2 '15 at 21:11
• What are the original x & y? Will they only ever occur at a few fixed values? – gung Dec 2 '15 at 21:16
• Thanks, you should have included all of this at the outset. The question is largely uninterpretable w/o that info. "Pay" is a person's monthly net pay, and "balance" is the outstanding balance on the person's loan, is that right? So, when the ratio is 1, that is b/c they actually have no outstanding loan balance at all, & when it's 0, that is b/c they are (say) unemployed, correct? – gung Dec 2 '15 at 21:56
• You wouldn't be using linear regression; you'd use something like Gamma or a count regression model. Also, the idea of having pay & loan on both sides of the equation makes no sense. What is the dataset? Do you have a set of historical records w/ people, various covariates, & how much was ultimately recouped? How are you taking time into account, is it the amount recouped w/i a given interval? (I assume you can get more & more money from someone as time goes by.) Is there any censoring in the data? – gung Dec 2 '15 at 22:31