Learn R Programming

CARRoT (version 3.0.2)

get_predictions: Predictions for multinomial regression

Description

Function which makes a prediction for multinomial/logistic regression based on the given cut-off value and probabilities.

Usage

get_predictions(p,k,cutoff,cmode,mode)

Value

Outputs the array of the predictions of the size of p.

Arguments

p

probabilities of the outcomes for the test set given either by an array (logistic regression) or by a matrix (multinomial regression)

k

size of the test set

cutoff

cut-off value of the probability

cmode

'det' or ''; 'det' always predicts the more likely outcome as determined by the odds ratio; '' predicts certain outcome with probability corresponding to its odds ratio (more conservative). Option available for multinomial/logistic regression

mode

'binary' (logistic regression), 'multin' (multinomial regression)

See Also

Examples

Run this code
#binary mode

get_predictions(runif(20,0.4,0.6),20,0.5,'det','binary')

#creating a data-set for multinomial mode

p1<-runif(20,0.4,0.6)
p2<-runif(20,0.1,0.2)
p3<-1-p1-p2

#running the function

get_predictions(matrix(c(p1,p2,p3),ncol=3),20,0.5,'det','multin')

Run the code above in your browser using DataLab