I am running polr on a dataset of response = quality rating (range=3:9). I have three problems in using multi-roc.
(1) r can't find df2s dataset. I have imported it as a jpg file ????
(2) definition of predictor (input parameter of multi_roc)
(3) correct syntax multi-roc function use
Can you help please. Thank you.
dput(head(df2, 25))
OUTPUT of fit.obj
fit.obj <- polr(as.factor(y) ~ z + x1 + x2 + x3 + x4 + x5 + x6 +
x7 + x8 + x9 + x10 + x11, data=df2, Hess=TRUE)
$ model :'data.frame': 6497 obs. of 13 variables:
..$ as.factor(y): Factor w/ 7 levels "3","4","5","6",..: 3 3 3 4 3 3 3 5 5 3 ...
..$ z : int [1:6497] 0 0 0 0 0 0 0 0 0 0 ...
..$ x1 : num [1:6497] 7.4 7.8 7.8 11.2 7.4 7.4 7.9 7.3 7.8 7.5 ...
..$ x2 : num [1:6497] 0.7 0.88 0.76 0.28 0.7 0.66 0.6 0.65 0.58 0.5 ...
..$ x3 : num [1:6497] 0 0 0.04 0.56 0 0 0.06 0 0.02 0.36 ...
..$ x4 : num [1:6497] 1.9 2.6 2.3 1.9 1.9 1.8 1.6 1.2 2 6.1 ...
..$ x5 : num [1:6497] 0.076 0.098 0.092 0.075 0.076 0.075 0.069 0.065 0.073 0.071 ...
..$ x6 : num [1:6497] 11 25 15 17 11 13 15 15 9 17 ...
..$ x7 : num [1:6497] 34 67 54 60 34 40 59 21 18 102 ...
..$ x8 : num [1:6497] 0.998 0.997 0.997 0.998 0.998 ...
..$ x9 : num [1:6497] 3.51 3.2 3.26 3.16 3.51 3.51 3.3 3.39 3.36 3.35 ...
..$ x10 : num [1:6497] 0.56 0.68 0.65 0.58 0.56 0.56 0.46 0.47 0.57 0.8 ...
..$ x11 : num [1:6497] 9.4 9.8 9.8 9.8 9.4 9.4 9.4 10 9.5 10.5 ...
I subset df2 and try to cbind. What is going on here?
Error in cbind(df2S$z, df2S$x1, df2S$x2, df2S$x3, df2S$x4, df2S$x5, df2S$x6, :
object 'df2S' not found
library(pROC)
head(df2)
df2s <- df2[1:25,]
write.csv(df2s,file="df2s.csv",row.names=FALSE)
print(df2s)
response=df2S$y
predictor <- c("df2$z","df2$x1","df2$x2","df2$x3","df2$x4","df2$x5",
"df2$x6","df2$x7","df2$x8","df2$x9","df2$x10","df2$x11")
predictor <- as.matrix(c(df2$z,df2$x1,df2$x2,df2$x3,df2$x4,df2$x5,
df2$x6,df2$x7,df2$x8,df2$x9,df2$x10,df2$x11))
predictor <- as.matrix(as.data.frame(c(df2$z,df2$x1,df2$x2,df2$x3,df2$x4,df2$x5,
df2$x6,df2$x7,df2$x8,df2$x9,df2$x10,df2$x11)))
predictor <- as.matrix(as.data.frame(c(df2S$z,df2S$x1,df2S$x2,df2S$x3,df2S$x4,df2S$x5,
df2S$x6,df2S$x7,df2S$x8,df2S$x9,df2S$x10,df2S$x11)))
# object 'df2S' not found
predictor <- as.matrix(as.data.frame(df2$z,df2$x1,df2$x2,df2$x3,df2$x4,df2$x5,
df2$x6,df2$x7,df2$x8,df2$x9,df2$x10,df2$x11))
# Warning: 'row.names' is not a character vector of length 6497 -- omitting it.
# Will be an error!Error in if (!optional) names(value) <- nm : the condition has length > 1
predictor <- as.matrix(as.data.frame(df2$z,df2$x1,df2$x2,df2$x3,df2$x4,df2$x5,
df2$x6,df2$x7,df2$x8,df2$x9,df2$x10,df2$x11))
#Warning: 'row.names' is not a character vector of length 6497 -- omitting it.
#Will be an error!Error in if (!optional) names(value) <- nm : the condition has length > 1
predictor <- as.matrix(as.data.frame("df2$z","df2$x1","df2$x2","df2$x3","df2$x4","df2$x5",
"df2$x6","df2$x7","df2$x8","df2$x9","df2$x10","df2$x11"))
#Error in !optional : invalid argument type
predictor <- as.data.frame("df2$z","df2$x1","df2$x2","df2$x3","df2$x4","df2$x5",
"df2$x6","df2$x7","df2$x8","df2$x9","df2$x10","df2$x11")
#invalid argument type error in !optional
class(predictor) #matrix, array
predictor <- cbind(df2S$z,df2S$x1,df2S$x2,df2S$x3,df2S$x4,df2S$x5,
df2S$x6,df2S$x7,df2S$x8,df2S$x9,df2S$x10,df2S$x11)))
multi_roc <- multiclass.roc(response, predictor)
multi_roc
multi_roc$auc
multi_roc$percent