Subscribe Bookmark RSS Feed

How to save a column of values from a report for later use

abdulj

Community Trekker

Joined:

Jul 12, 2011

Hello,

I'm trying to develop a script to automate several data analysis tasks. One of them is to automatically find the distribution of a data set and then run a simulation with that distribution's parameters.

I have most pieces in place except I am not sure how to use the parameters I saved from the distribution in the Profiler simulation.

After the distribution code, I save the parameters as follows:

parameterOne=distReport["Overall Y-A-P20"][outlinebox("? " || distNameOne)]["Parameter Estimates"][NumberColBox(1)];

will this save all the values for the entire column?? I know if I use ...[NumberColBox(1)][1]; it will save the 1st row, how do you save the values for an unknown number of rows?

Second question: Can I simply use this variable "parameterOne" in the profiler as such...

Eval(Parse(EvalInsert("\[

Profiler(

          Y( Column(3) ),

          Profiler(

                    1,

                    Term Value(

                              Name( "Overall Y-A-P20" )(227.01),

                              Name( "Overall X-B-P2" )(324.6375)

                    ),

                    Simulator(

                              1,

                              Factors(

                                        Name( "Overall Y-A-P20" ) << Random(

                                                  ^distNameOne^( parameterOne )

                                        ),

                                        Name( "Overall X-B-P2" ) << Random(

                                                  ^distNameTwo^( parameterTwo )

                                        )

                              ),

                              Responses( Combined << No Noise )

                    )

          )

)

]\")));

I have tried doing this with no success. No error codes, but the profiler isn't using the correct parameters.

Thanks for your help and patience with my amature jsl skills.


1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham

Super User

Joined:

Jul 13, 2011

Solution

OK, I understand the problem.  You can use the following code to create a string representation of the parameter list:

mat = colBox << Get As Matrix;

strValues = "";

For (i=1,i<=NRows(mat),i++,

    strValues = strValues || Char(mat) || ","

);

and then insert this variable into the command:

...

   Factors( height << Random( ^dist^( ^strValues^ ) ) ),

...

Technically the strValues variable results in an additional comma at the end of the list.  This could be stripped off, but JMP is forgiving of redundant commas and the code works fine as-is.

-Dave
6 REPLIES
David_Burnham

Super User

Joined:

Jul 13, 2011

Regarding saving the parameters; you can create a reference to the display box and then send messages to it, for example:

Open("$SAMPLE_DATA/Big Class.jmp");

dist = Distribution(

          Continuous Distribution( Column( :height ), Fit Distribution( Normal ) )

);

distR = dist << report;

colBox = distR[NumberColBox(1)];

mat = colBox << Get As Matrix;

show(mat)

For the second question, to substitute variables into the evaluation you use the notation ^name^ in the same way as you have for the distribution name e.g.

     Name( "Overall Y-A-P20" ) << Random(

          ^distNameOne^( ^parameterOne^ )

      ),

-Dave

-Dave
abdulj

Community Trekker

Joined:

Jul 12, 2011

Thanks for the help.

I am now saving the data properly as a matrix, however when I try using it in the profiler it is using the wrong numbers still...

matrixParameterOne = parameterOne << Get As Matrix;

matrixParameterTwo = parameterTwo << Get As Matrix;

//Run simulation

Eval(Parse(EvalInsert("\[

Profiler(

          Y( Column(3) ),

          Profiler(

                    1,

                    Term Value(

                              Name( "Overall Y-A-P20" )(227.01),

                              Name( "Overall X-B-P2" )(324.6375)

                    ),

                    Simulator(

                              1,

                              Factors(

                                        Name( "Overall Y-A-P20" ) << Random(

                                                  ^distNameOne^( ^matrixParameterOne^ )

                                        ),

                                        Name( "Overall X-B-P2" ) << Random(

                                                  ^distNameTwo^( ^matrixParameterTwo^ )

                                        )

                              ),

                              Responses( Combined << No Noise )

                    )

          )

)

]\")));

Any thoughts on this??

David_Burnham

Super User

Joined:

Jul 13, 2011

The parameter estimates are contained in the display box named NumColBox(1).  You only need to reference this once.  The Get As Matrix message retrieves all the parameter estimates as a single collection.  You then need to reference specific items within this matrix:

Open("$SAMPLE_DATA/Big Class.jmp");

dist = Distribution(

    Continuous Distribution(

        Column( :height ),

        Fit Distribution( Weibull )

    )

);

distR = dist << report;

parameterEstimates = distR[NumberColBox(1)];

matParameters = parameterEstimates << Get As Matrix;

parameter1 = matParameters[1];

parameter2 = matParameters[2];

show(matParameters,parameter1,parameter2);

-Dave
abdulj

Community Trekker

Joined:

Jul 12, 2011

Hi Dave

I understand that all parameters are stored in NumColBox(1), but the reason I reference it twice because I am referencing the parameters of 2 different distribution reports.

My main problem is that the number of parameters changes depending on the type of distribution. So I could have 1, 2 or more parameters depending on the data (normal, Weibull, etc...). So I cannot use the code you provided above because that assumes I will always have 2 parameters. Is there any way to use the items within the matrix of an unknown size??

David_Burnham

Super User

Joined:

Jul 13, 2011

Solution

OK, I understand the problem.  You can use the following code to create a string representation of the parameter list:

mat = colBox << Get As Matrix;

strValues = "";

For (i=1,i<=NRows(mat),i++,

    strValues = strValues || Char(mat) || ","

);

and then insert this variable into the command:

...

   Factors( height << Random( ^dist^( ^strValues^ ) ) ),

...

Technically the strValues variable results in an additional comma at the end of the list.  This could be stripped off, but JMP is forgiving of redundant commas and the code works fine as-is.

-Dave
abdulj

Community Trekker

Joined:

Jul 12, 2011

Awesome, Thanks! Everything worked.