Message Boards Message Boards

[✓] Manipulate of a 2-D plot?

GROUPS:
mathematics dynamic interactivity graphics and visualization wolfram language

I am trying to create a plot of a logistic function with parameters AHAT and MDIF. The values of these parameters depend up underlying parameters A and DIF and an underlying ability distribution with a covariance omega and mean vector mu. I have to go through several steps to determine AHAT and MDIF. I would like to create a plot where I can manipulate sigma, mu1 and mu2 to see how it affects the logistic curve. I can't figure out how to create the plot. Leaving the variable sigma and mu1 and mu2 in the expressions at the outside will not work. I have attached a MSWord document with the code. Does any have suggestions?

A={{1.2,.4},{.8,.5},{.9,1.0},{1.3,.5},{.6,.9}};u={{μ1,μ2}};
 DIF={{.5},{.7},{1.0},{-1.},{2.0}};
 Ω={{σ,1},{1,σ}}
L=CholeskyDecomposition[Ω]
W=Eigenvectors[Transpose[L].Transpose[A].A.L]
AM=List[A[[1]]]
W1M=List[W[[1]]]
W2M=List[W[[2]]]
AHAT=AM.Transpose[W1M]/Sqrt[2.89+AM.Transpose[W2M].W2M.Transpose[AM]]
MDIF=(DIF[[1]]-AM.Transpose[u])/AM.Transpose[W1M]
Manipulate[Plot[{(1/(1+Exp[-1.7*AHAT*(θ-MDIF)])),},{θ,-3,3},AxesLabel->{θ,p}],{σ,1,3},{μ1,-2,2},{μ2,-2,2}]
Attachments:
POSTED BY: Terry Ackerman
Answer
8 days ago

The problem seems to be to give the parameters to the plot instruction. Try this

A = {{1.2, .4}, {.8, .5}, {.9,        1.0}, {1.3, .5}, {.6, .9}}; u = {{\[Mu]1, \[Mu]2}};
DIF = {{.5}, {.7}, {1.0}, {-1.}, {2.0}};
\[CapitalOmega] = {{\[Sigma], 1}, {1, \[Sigma]}};
L = CholeskyDecomposition[\[CapitalOmega]];

Manipulate[
 W = Eigenvectors[
   Transpose[L].Transpose[A].A.L /. {\[Sigma] -> s, \[Mu]1 -> 
      m1, \[Mu]2 -> m2}];
 AM = List[A[[1]]];
 W1M = List[W[[1]]];
 W2M = List[W[[2]]] /. {\[Sigma] -> s, \[Mu]1 -> m1, \[Mu]2 -> m2};
 AHAT = AM.Transpose[W1M]/
   Sqrt[2.89 + AM.Transpose[W2M].W2M.Transpose[AM]];
 MDIF = (DIF[[1]] - AM.Transpose[u])/
    AM.Transpose[W1M] /. {\[Sigma] -> s, \[Mu]1 -> m1, \[Mu]2 -> m2};
 Plot[{(1/(1 + Exp[-1.7*AHAT*(\[Theta] - MDIF)]))}, {\[Theta], -3, 3},
   AxesLabel -> {\[Theta], p}, PlotRange -> {0, 1}]
 , {s, 1, 3}, {m1, -2, 2}, {m2, -2, 2}]
POSTED BY: Hans Dolhaine
Answer
7 days ago

Hans,

Thanks so much. You solution was very helpful!

POSTED BY: Terry Ackerman
Answer
5 days ago

You are welcome.

Perhaps you will find the following modification of the code more handsome (see Notebook). First I define the function to be displayed, then the constant items and then comes the plot.

Regards, Hans

Attachments:
POSTED BY: Hans Dolhaine
Answer
4 days ago

Group Abstract Group Abstract