Function which computes probabilities of outcomes on the test set by applying regression parameters inferred by a run on the training set. Works for logistic or multinomial regression
get_probabilities(trset,testset,outc,mode,Rsq,p,n_tr)
Probabilities of the outcomes. In 'binary'
mode returns an array of the size of the number of observations in a testset. In 'multin'
returns an M x N matrix where M is the size of the number of observations in a testset
and N is the number of unique outcomes minus 1.
values of predictors on the training set
values of predictors on the test set
values of outcomes on the training set
'binary'
(logistic regression) or 'multin'
(multinomial regression)
whether R-squared statistics constrained is introduced
weight of the model
size of the training set
In binary mode this function computes the probabilities of the event '0'. In multinomial mode computes the probabilities of the events '0','1',...,'N-1'.
trset<-matrix(c(rbinom(70,1,0.5),runif(70,0.1)),ncol=2)
testset<-matrix(c(rbinom(10,1,0.5),runif(10,0.1)),ncol=2)
get_probabilities(trset,testset,rbinom(70,1,0.6),'binary')
Run the code above in your browser using DataLab