Graph 计算AUC和GAM,并在R中设置刻度

Graph 计算AUC和GAM,并在R中设置刻度,graph,r,Graph,R,我的数据表如下: x y chla sst ssha eke tuna : : : : : : : : : : : : : : 我使用GAM模型如下: GAM由于您没有包含任何测试数据,我将使用GAM包中的测试数据来计算AUC并绘制ROC曲线 library(gam) library(ROCR) #sample binomial regression data(k

我的数据表如下:

x    y   chla   sst   ssha   eke  tuna
:    :     :     :      :     :     : 
:    :     :     :      :     :     :
我使用GAM模型如下:


GAM由于您没有包含任何测试数据,我将使用
GAM
包中的测试数据来计算AUC并绘制ROC曲线

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 sample
gampred <- predict(GAM, type="response")

#make a ROCR prediction object using the predicted values from
#    our model and the true values from the real data
rp <- prediction(gampred, kyphosis$Kyphosis) 

#now calculate AUC
auc <- performance( rp, "auc")@y.values[[1]]
auc

#not plot ROC curve
roc <- performance( rp, "tpr", "fpr")
plot( roc )
库(gam)
图书馆(ROCR)
#样本二项回归
数据(脊柱后凸)

GAMGAM表示广义加法模型我不知道R,但我怀疑添加“不太正确”图形的屏幕截图可能会有所帮助。你能将
str(非线性)
的输出添加到你的问题中吗。以及
dput(名称(非线性))
如果“eke”的字符不好或与其他向量不同,我正在工作。对不起,Flick先生,我不明白你的意思。你能帮我解释一下示例语法吗?实际上,我想画出Chl-a vs s(Chl-a),SST vs s(SST)等等。我该怎么做?@ahmad我不知道你的符号是什么意思。从你的回答来看,我认为你的数据名是脊柱后凸。这是真的吗?我的输入数据是.txt(例如2005.txt)。当我用2005或2005.txt更改脊柱后凸时,R程序说“错误:在”rp@ahmad中意外输入,因为您没有提供任何数据,我使用了来自GAM包的示例数据集脊柱后凸。数据框名为“脊柱后凸”,用于GAM回归的data.frame中的响应变量名为“脊柱后凸”(大写)如我所知,gam模型对每个模型协变量都有一个平滑函数。我在这里也使用了mgcv包。这就是为什么我要绘制Chl-a与s(Chl-a)、SST与s(SST)、SSHA与s(SSHA)以及EKE与s(EKE)。
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 sample
gampred <- predict(GAM, type="response")

#make a ROCR prediction object using the predicted values from
#    our model and the true values from the real data
rp <- prediction(gampred, kyphosis$Kyphosis) 

#now calculate AUC
auc <- performance( rp, "auc")@y.values[[1]]
auc

#not plot ROC curve
roc <- performance( rp, "tpr", "fpr")
plot( roc )