【发布时间】:2011-09-13 16:20:15
【问题描述】:
我有 9 个数据集,每个数据集有 115 行和 742 列,每个数据集都包含光谱仪在特定条件下的结果。
我想分析这 9 个数据集的所有组合以确定最佳条件。
编辑:
数据是在 10 个不同温度下进行的光谱测量(行 = 样本,列 = 波长)。
我想获取 9 个数据集的所有组合,并将函数 cpr2 应用于每个组合。 cpr2 获取一个数据集并制作一个 plsr 模型,预测 9 个测试集(单个集),并返回预测偏差。
我的目的是找出哪个组合给出了最小的预测偏差,即需要多少温度条件才能给出可接受的偏差。
根据建议:
我想做这样的事情
g<-c("g11","g12","g13,g21","g22","g23","g31","g32","g33")
cbn<-combn(g,3) # making combinations of 3
comb<-lapply(cbn,cpr2(cbn))
供参考cpr2是
cpr2<-function(data){
data.pls<-plsr(protein~.,8,data=data,validation="LOO") #make plsr model
gag11p.pred<-predict(data.pls,8,newdata=gag11p) #predict each test set
gag12p.pred<-predict(data.pls,8,newdata=gag12p)
gag13p.pred<-predict(data.pls,8,newdata=gag13p)
gag21p.pred<-predict(data.pls,8,newdata=gag21p)
gag22p.pred<-predict(data.pls,8,newdata=gag22p)
gag23p.pred<-predict(data.pls,8,newdata=gag23p)
gag31p.pred<-predict(data.pls,8,newdata=gag31p)
gag32p.pred<-predict(data.pls,8,newdata=gag32p)
gag33p.pred<-predict(data.pls,8,newdata=gag33p)
pred.bias1<-mean(gag11p.pred-gag11p[742]) #calculate prediction bias
pred.bias2<-mean(gag12p.pred-gag12p[742])
pred.bias3<-mean(gag13p.pred-gag13p[742])
pred.bias4<-mean(gag21p.pred-gag21p[742])
pred.bias5<-mean(gag22p.pred-gag22p[742])
pred.bias6<-mean(gag23p.pred-gag23p[742])
pred.bias7<-mean(gag31p.pred-gag31p[742])
pred.bias8<-mean(gag32p.pred-gag32p[742])
pred.bias9<-mean(gag33p.pred-gag33p[742])
r<-signif(c(pred.bias1,pred.bias2,pred.bias3,pred.bias4,pred.bias5,
pred.bias6,pred.bias7,pred.bias8,pred.bias9),2)
out<-c(R2(data.pls,"train",ncomp=8),RMSEP(data.pls,"train",ncomp=8),r)
return(out)
}
任何解决此问题的见解将不胜感激。
【问题讨论】:
-
单个数据集的行和列指的是什么?它们是实验结果吗(cols 是波长/质量,而行是样本?) 10 个数据集是 10 个设置组合?如果不是,什么代表组合?如果这个问题的答案是有 10 * 115 * 750 个条件并且你想评估它们的所有个组合,我希望你已经准备好等待漫长的等待!
-
“这些数据集的所有组合”是什么意思?如果您的每个数据框具有相同的列名,您可以使用
rbind()将它们组合成一个数据框:g <- rbind(g11,g12,g13,g21,g22,g23,g31,g32,g33,g2) -
您必须向我们提供有关您的数据的更多信息。我知道你有 10 个矩阵,但我不明白你想如何组合这些矩阵。保存例如你组合
g11和g12,这个组合矩阵是什么样的?一个有 230 行的矩阵? -
@Gavin 数据集是光谱测量,其中列是波长 (750),行是样本 (115)。十个数据集是指进行测量的十个不同温度。我想评估这十个条件的所有组合。所有数据集的列名(波长)都相同,因此 g11 和 g12 的组合将按照 Andrie 的建议进行。
-
@adamleerich
rbind()会给我一个单一的数据集,however i want to assess how individual conditions interact, eg. g11,g31 and g33 or g11, g21,g22 and g33。我一直在手动进行选择,但我希望有更简单的方法。
标签: r