0

I work on calibration of probabilities. I'm using a probability mapping approach called generalized additive models.

The algorithm I wrote is:

probMapping = function(x, y, datax, datay) {

    if(length(x) < length(y))stop("train smaller than test")
    if(length(datax) < length(datay))stop("train smaller than test")

    datax$prob = x # trainset: data and raw probabilities
    datay$prob = y # testset: data and raw probabilities

    prob_map = gam(Target ~ prob, data = datax, familiy = binomial, trace = TRUE)
    prob_map_prob = predict(prob_map, newdata = datay, type = "prob")

  # return(str(datax))
  return(prob_map_prob)
}

The package I'm using is mgcv.

  1. x - prediction on train dataset
  2. y - prediction on test dataset
  3. datax - traindata
  4. datay - testdata

Problems:

  1. The output values are not between 0 and 1
  2. I get the following warning message:

    In predict.gam(prob_map, newdata = datay, type = "prob") :
    Unknown type, reset to terms.
    
Alex A.
  • 5,466
  • 4
  • 26
  • 56

1 Answers1

0

The warning is telling you that predict.gam doesn't recognize the value you passed to the type parameter. Since it didn't understand, it decided to use the default value of type, which is "terms".

Note that predict.gam with type="terms" returns information about the model terms, not probabilties. Hence the output values are not between 0 and 1.

For more information about mgcv::predict.gam, take a look here.

Alex A.
  • 5,466
  • 4
  • 26
  • 56
  • hey Alex, thank u very much for your answer! two points i have learned: i) type must be "response", ii) in fitting there is a mistake, i wrote "familiy" - must be "family". I am sorry for that. Alex, could u please also comment on: http://stackoverflow.com/questions/29948919/calibration-of-the-posterior-probabilities - i have tried the answer provided, but the result is still not between 0 and 1 – user4847048 Apr 29 '15 at 22:58