Question: Error, (in Statistics:-Fit) invalid input: Fit expects its 4th argument, v, to be of type {name, list(name)}

Dear All, I hope this message finds you well. I am currently facing some issues and would appreciate your support or guidance in resolving them. Nusselt_RSM_Model.mw

 

restart;

with(Statistics): with(LinearAlgebra): with(plots):

local A, B, C, D;

Digits := 10:

 

# Step 1: Define the variables

vars := [A, B, C, D];

 

# Step 2: Generate Central Composite Design (CCD) coded matrix

coded := Matrix([

    [ 1,  1,  1,  1],

    [ 1,  1,  1, -1],

    [ 1,  1, -1,  1],

    [ 1,  1, -1, -1],

    [ 1, -1,  1,  1],

    [ 1, -1,  1, -1],

    [ 1, -1, -1,  1],

    [ 1, -1, -1, -1],

    [-1,  1,  1,  1],

    [-1,  1,  1, -1],

    [-1,  1, -1,  1],

    [-1,  1, -1, -1],

    [-1, -1,  1,  1],

    [-1, -1,  1, -1],

    [-1, -1, -1,  1],

    [-1, -1, -1, -1],

    [ 0,  0,  0,  0],

    [ 0,  0,  0,  0],

    [ 0,  0,  0,  0],

    [ 0,  0,  0,  0]

]):

 

# Step 3: Define uncoded variable ranges

rangeA := [0.1, 0.5]:

rangeB := [0.1, 0.5]:

rangeC := [0.1, 0.5]:

rangeD := [0.1, 0.5]:

 

decode := (val, r) -> r[1] + (val + 1)*(r[2] - r[1])/2:

 

# Step 4: Create actual values matrix

actual := Matrix(20, 4):

for i from 1 to 20 do

    for j from 1 to 4 do

        r := eval(cat("range", vars[j])):

        actual[i, j] := evalf(decode(coded[i, j], r));

    end do;

end do:

 

# Step 5: Define model coefficients (for simulation purposes)

beta := [1.5, 0.8, 0.6, 0.5, 0.3,  # Linear terms

         0.1, 0.2, 0.15, 0.18,  # Square terms

         0.05, 0.04, 0.03, 0.02, 0.01, 0.025]; # Interaction terms

 

# Step 6: Simulate Response (Nusselt number)

Nu := Vector(20):

for i from 1 to 20 do

    A := actual[i,1]; B := actual[i,2]; C := actual[i,3]; D := actual[i,4];

    Nu[i] := evalf(

        beta[1] + beta[2]*A + beta[3]*B + beta[4]*C + beta[5]*D +

        beta[6]*A^2 + beta[7]*B^2 + beta[8]*C^2 + beta[9]*D^2 +

        beta[10]*A*B + beta[11]*A*C + beta[12]*A*D +

        beta[13]*B*C + beta[14]*B*D + beta[15]*C*D

    );

end do:

 

# Step 7: Create data frame for ANOVA

X := Matrix(actual):

Y := convert(Nu, list):

 

# Step 8: Fit quadratic model

model := Fit(

    A + B + C + D + A^2 + B^2 + C^2 + D^2 + A*B + A*C + A*D + B*C + B*D + C*D,

    X,

    Y,

    vars

):

 

# Step 9: ANOVA table

anovaTable := ANOVA(model, significancelevel=0.05):

 

# Step 10: Display results with 8 decimal places

printf("RSM Model for Nu (Nusselt number):\n");

print(evalf[8](model));

printf("\nANOVA Table:\n");

print(anovaTable);

 

# Optional: Plotting

pointplot([seq([i, Nu[i]], i = 1..20)], style=point, symbol=circle,

          color=red, title="Nusselt Number vs Run Index",

          labels=["Run", "Nusselt Number"]);

[A, B, C, D]

 

[1.5, .8, .6, .5, .3, .1, .2, .15, .18, 0.5e-1, 0.4e-1, 0.3e-1, 0.2e-1, 0.1e-1, 0.25e-1]

 

Error, (in Statistics:-Fit) invalid input: Fit expects its 4th argument, v, to be of type {name, list(name)}, but received [1.5+2.2*"a"+.805*"a"^2, 1.5+1.9*"a"+.3*"r"+.56*"a"^2+.18*"r"^2+0.65e-1*"a"*"r", 1.5+1.7*"a"+.5*"r"+.57*"a"^2+.15*"r"^2+0.85e-1*"a"*"r", 1.5+1.4*"a"+.8*"r"+.35*"a"^2+.355*"r"^2+.10*"a"*"r", 1.5+1.6*"a"+.6*"r"+.525*"a"^2+.2*"r"^2+0.8e-1*"a"*"r", 1.5+1.3*"a"+.9*"r"+.29*"a"^2+.39*"r"^2+.125*"a"*"r", 1.5+1.1*"a"+1.1*"r"+.31*"a"^2+.37*"r"^2+.125*"a"*"r", 1.5+.8*"a"+1.4*"r"+.1*"a"^2+.585*"r"^2+.12*"a"*"r", 1.5+.8*"r"+1.4*"a"+.1*"r"^2+.585*"a"^2+.12*"a"*"r", 1.5+1.1*"r"+1.1*"a"+.31*"r"^2+.37*"a"^2+.125*"a"*"r", 1.5+1.3*"r"+.9*"...

 

RSM Model for Nu (Nusselt number):

 

model

 


ANOVA Table:

 

ANOVA(model, significancelevel = 0.5e-1)

 

Error, (in plots:-pointplot) incorrect specification of points data

 
 

``

Download Nusselt_RSM_Model.mw

Please Wait...