2017-10-18 47 views
1

J'ai des problèmes avec mon code R pour faire l'optimisation en utilisant le paquet de désirabilité, je base mon travail sur this document.R analyse de désirabilité

Mon code est le suivant:

library(desirability) 

#Desirability function 
##Function creation 
Aldeh_ther<-function(x) ((1/(-0.4349834+(0.0150467*x[1])+(0.0086295*x[2])-(0.0000392*(x[1]^2))-(0.0000484*(x[1]*x[2]))))^(1/3))-1 
Alcoh_ther<-function(x) ((0.00000251*x[1]^3)-(0.00162503*x[1]^2)+0.35051446*x[1]-24.3342493)^(1/15.625)-1+0*x[2] 
Dim01_ther<-function(x) 0.084274-0.001068*x[1]+0.000003*x[1]^2+0*x[2] 
Dim02_ther<-function(x) 0.074642-0.000942*x[1]+0.000003*x[1]^2+0*x[2] 
Cim03_ther<-function(x) 0.131254852-(0.001122297*x[1])-(0.001068577*x[2])+(0.0000031092*x[1]*x[2])+(0.00000299178*(x[1]^2))+(0.00000534403*(x[2]^2)) 
LigAr_ther<-function(x) (1/(40041891907.4231*x[1]^(-1.375863404)-17274906.5300496))^(1/4.68)+0*x[2] 
ArAld_ther<-function(x) 0.07063708-0.00072373*x[1]+0.0000023217*x[1]^2+0.0000015008*x[2]^2 
ArVin_ther<-function(x) 0.04855352-0.00034407*x[1]+0.0004283*x[2]+0.0000013*x[1]^2+0.00000503*x[2]^2 
Iso01_ther<-function(x) (1/(42.800123-0.108827*x[1]-0.468667*x[2]+0.002539*x[1]*x[2]))^(1/0.8) 
Iso02_ther<-function(x) (1/(120151935.1-402916.2*x[1]-114490.7*x[2]))^(1/5)+0*x[2] 
Ester_oxid<-function(x) 0.00501805*x[1]-0.000015595*x[1]^2-0.27959773+0*x[2] 
Aldeh_oxid<-function(x) 0.00717424*x[1]+0.00455026*x[2]-0.000021871*x[1]*x[2]-0.000015255*x[1]^2-0.68899457 
FFA_target<-function(x) 0.58079701-0.00573986*x[1]-0.00596008*x[2]+0.000019772*x[1]*x[2]+0.000015716*x[1]^2+0.000025474*x[2]^2 
##Optimization algorithm 
FFA_targetD<-dMax(0.0314, 0.3000) 
Aldeh_therD<-dTarget(0, 0.021, 0.4) 
Alcoh_therD<-dTarget(0, 0.013, 0.02) 
Dim01_therD<-dTarget(0, 0.011, 0.02) 
Dim02_therD<-dTarget(0, 0.009, 0.05) 
Cim03_therD<-dTarget(0, 0.027, 0.07) 
LigAr_therD<-dTarget(0, 0.044, 0.065) 
ArAld_therD<-dTarget(0, 0.039, 0.06) 
ArVin_therD<-dTarget(0, 0.034, 0.05) 
Iso01_therD<-dMin(0, 0.03) 
Iso02_therD<-dTarget(0, 0.056, 0.085) 
Ester_oxidD<-dMin(0, 0.191435) 
Aldeh_oxidD<-dMin(0, 0.07) 
##Calculation of center point projected absorbances 
predOutcomes<-c(FFA_target(c(212.5,50)), Aldeh_ther(c(212.5,50)), Alcoh_ther(c(212.5,50)), Dim01_ther(c(212.5,50)), 
       Dim02_ther(c(212.5,50)), Cim03_ther(c(212.5,50)), LigAr_ther(c(212.5,50)), ArAld_ther(c(212.5,50)), 
       ArVin_ther(c(212.5,50)), Iso01_ther(c(212.5,50)), Iso02_ther(c(212.5,50)), Ester_oxid(c(212.5,50)), 
       Aldeh_oxid(c(212.5,50))) 
print(predOutcomes) 

predict(FFA_targetD, predOutcomes[1]) 
predict(Aldeh_therD, predOutcomes[2]) 
predict(Alcoh_therD, predOutcomes[3]) 
predict(Dim01_therD, predOutcomes[4]) 
predict(Dim02_therD, predOutcomes[5]) 
predict(Cim03_therD, predOutcomes[6]) 
predict(LigAr_therD, predOutcomes[7]) 
predict(ArAld_therD, predOutcomes[8]) 
predict(ArVin_therD, predOutcomes[9]) 
predict(Iso01_therD, predOutcomes[10]) 
predict(Iso02_therD, predOutcomes[11]) 
predict(Ester_oxidD, predOutcomes[12]) 
predict(Aldeh_oxidD, predOutcomes[13]) 

overallD<-dOverall(FFA_targetD, Aldeh_therD, Alcoh_therD, Dim01_therD, Dim02_therD, Cim03_therD, LigAr_therD, ArAld_therD, 
        ArVin_therD, Iso01_therD, Iso02_therD, Ester_oxidD, Aldeh_oxidD) 
print(overallD) 

predict(overallD, predOutcomes) 

quand je lance la commande finale prédire l'erreur suivante apparaît:

prédisent (overallD, predOutcomes) Erreur dans predict.dOverall (overallD, predOutcomes) : le nombre de colonnes dans newdata doit correspondre au nombre de fonctions de désirabilité

Je suis un peu nouveau dans R et j'ai été capable de faire des ANOVA à réponse unique et de la régression, mais j'en ai besoin pour déterminer ma région de travail expérimentale.

Espérons que quelqu'un peut me aider

Répondre

1

Merci à Max Kuhn j'ai pu résoudre ce problème, en changeant la ligne suivante:

(overallD, prédisent as.data.frame (matrice (predOutcomes, nrow = 1)))