Message Boards Message Boards

[?] Manipulate of a 2-D plot?

Posted 7 years ago

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
3 Replies
Posted 7 years ago

Hans,

Thanks so much. You solution was very helpful!

POSTED BY: Terry Ackerman

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

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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract