本文介绍了计算AUC和GAM并在R中设定一个比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个数据表格如下: xy chla sst ssha eke tuna ::::: :: $:b $我使用了GAM模型如下: / b> GAM 使用上面的模型,我可以处理chla,sst和ssha的数据。但是当我处理eke数据时,它并没有工作,R程序告诉我没有找到eval(expr,envir,enclos):object eke 中的错误。帮我解决这个问题? 我已经安装了ROCR软件包来计算AUC,但我不知道如何计算AUC。我也解决了这个问题吗? 我也使用下面的命令来制作一个图表: plot(GAM,xlab = ...,ylab = ..... font.lab = ... shade = ....) 但是当我运行这个命令时,结果并不是很好,我的意思是y轴上的刻度非常奇怪,我怎么设置刻度在y轴和x轴的1和5间隔(例如)分别为?解决方案由于您没有包括任何测试数据,我将使用 gam 包中的测试数据来计算AUC并绘制ROC曲线。 library(gam)库(ROCR) #样本二项回归数据(后凸畸形) GAM #获得每个样本的预测概率 gampred #make a ROCR预测对象使用来自#我们的模型的预测值和来自真实数据的真实值 rp #现在计算AUC auc auc #not plot ROC曲线 roc< ; - 绩效(rp,tpr,fpr) plot(roc) I have a data form as follows:x y chla sst ssha eke tuna: : : : : : : : : : : : : :I used GAM model as follow:GAM<-gam(tuna~s(chla), family=binomial, data=nonLinear)By using such as a model above, I can process the data for chla, sst and ssha. But when I processed the eke data, it was not working and R program told me that "error in eval(expr, envir, enclos) : object eke not found. Can anybody help me to solve this problem?I already installed ROCR package to calculate the AUC. But I do not know how (the syntax) to calculate the AUC. Can anybody help me to solve this problem too?I also used the following command to make a graph: plot(GAM, xlab=..., ylab=..... font.lab= ...shade=....)But when I running that command the result is not so good. I mean, the scale on the y-axis is very weird. How do I set the scale on the y-axis and x-axis in 1 and 5 interval (for instance) respectively? 解决方案 Since you didn't include any test data, I will use the test data in the gam package to calculate AUC and plot an ROC curve.library(gam)library(ROCR)#sample binomial regression data(kyphosis)GAM<-gam(Kyphosis ~ poly(Age,2) + s(Start), data=kyphosis, family=binomial)#get the predicted probabilities for each samplegampred <- predict(GAM, type="response")#make a ROCR prediction object using the predicted values from# our model and the true values from the real datarp <- prediction(gampred, kyphosis$Kyphosis) #now calculate AUCauc <- performance( rp, "auc")@y.values[[1]]auc#not plot ROC curveroc <- performance( rp, "tpr", "fpr")plot( roc ) 这篇关于计算AUC和GAM并在R中设定一个比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-21 11:39