cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
Raaed
Level IV

Lui estimators

How can Liu's estimations be calculated using JMP pro?!

 

Attached
Real data obtained from the Central Child Hospital in Baghdad - Iraq, representing the number of cases of congenital defects of children in the heart and circulatory system for the period (2006-2011).

 

regards

Řaëd ~✍
21 REPLIES 21

Re: Lui estimators

I have two comments that might help.

 

First of all, I showed how you can make sure that JMP finds R after you install it. Here is the JSL code for that purpose. Does the path that I use match the path that you should use? Please make sure that the location is correct.

 

// make sure JMP can find the desired installed version of R
Set Environment Variable( "R_HOME", "C:\Program Files\R\R-4.1.3" );

Your R script refers to a dta data frame, but that is a JMP data table that that you did not send. You sent JMP data columns as individual vectors to R instead. So you must either create the data frame in R from the vectors that you sent, or send the data table instead of the vectors and use it in R. JMP creates a data frame for R automatically, so the latter approach seems easier and more efficient. See my second example above.

 

Also, be sure to call this function at the end of your script:

R Term();
Raaed
Level IV

Re: Lui estimators

dear sir

dta = Open( "/D:/Rdata/fatima data.jmp" );

the location is correct.

I don't know how to convert a table to data frame using JMP pro.

My main target is to implement (Liu Regression) through JmpPro, even if the data is hypothetical from a simulation.

 

Řaëd ~✍
txnelson
Super User

Re: Lui estimators

The R extension to JMP is documented in the Scripting Guide, available in the JMP Documentation Library, under the Help Pull Down Menu.  Here is a copy of the mapping of JMP data structures to R structures, followed by an example of Sending a JMP data table to a Data Frame in R.

txnelson_0-1650331109768.png

Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );
R Init();
R Send( dt );
R Submit( "print(dt)" );
R Term();
Jim
Raaed
Level IV

Re: Lui estimators

Dear Sir

The code you sent has been executed successfully.
But I am trying to implement Leo regression on my data
attachments:
A picture of the output, and I don't know where the error is?!

Names Default to Here( 1 );

// make sure JMP can find the desired installed version of R
Set Environment Variable( "R_HOME", "C:\Program Files\R\R-4.1.3" );

// Open Data Table: PoiReg.jmp
dta = Open( "/D:/Rdata/PoiReg.jmp" );
x1 = :x1 << Get As Matrix;
x2 = :x2 << Get As Matrix;
x3 = :x3 << Get As Matrix;
x4 = :x4 << Get As Matrix;
x5 = :x5 << Get As Matrix;
x6 = :x6 << Get As Matrix;
x7 = :x7 << Get As Matrix;
y = :y << Get As Matrix;

Close( dta, No Save );

// connect to R session
R Init( );

// send JMP data as vectors
R Send( x1 );
R Send( x2 );
R Send( x3 );
R Send( x4 );
R Send( x5 );
R Send( x6 );
R Send( x7 );
R Send( y );

// use centered function in liureg package with entire data set
R Submit("
library(Matrix)
library(glmnet)
library(liureg)
library (readxl)
## liu regression

lu.reg <- liu(y~., data=as.data.frame(dta), d=seq(0, 0.1, 0.1), scaling= \!"centered\!")
print(lu.reg)
");

// close R connection
R Term();
Řaëd ~✍
txnelson
Super User

Re: Lui estimators

Your error message is coming from R.  The code is looking for a data frame called DTE. From my examination of your code, you did not Send the data table to R from JMP.

Jim
Raaed
Level IV

Re: Lui estimators

Dear Sir

i don't know how to do that?!
the data is opened in jmp correctly

Řaëd ~✍
txnelson
Super User

Re: Lui estimators

How to move a data table from JMP to R was previously detailed in a response I made on Monday.  An example illustrating rhe openinf of a table in JMP, Sending it to R, and then finally printing the table in R was provided.  All of this is also detailed in a specific section in the Scripting Guide on Extending JMP with R.  I strongly suggest you read and study that section. 

Jim

Re: Lui estimators

You send the individual vectors but then you refer to the data table in the liureg function call. You didn't send the data table as a data frame. You didn't make a data frame in R from the vectors. There are several approaches but it seems to me that the easiest way is to send the JMP data table as a data frame instead of individual vectors. I should you how to do it both ways but you mixed them together and left out the important parts in the process.

 

Try this script:

 

Names Default to Here( 1 );

// make sure JMP can find the desired installed version of R
Set Environment Variable( "R_HOME", "C:\Program Files\R\R-4.1.3" );

// Open Data Table: PoiReg.jmp
dta = Open( "/D:/Rdata/PoiReg.jmp" );

// connect to R session
R Init( );

// send JMP data as vectors
R Send( dta );

// use centered function in liureg package with entire data set
R Submit("
library(Matrix)
library(glmnet)
library(liureg)
library (readxl)
## liu regression

lu.reg <- liu(y~., data=dta, d=seq(0, 0.1, 0.1), scaling= \!"centered\!")
print(lu.reg)
");

// close R connection
R Term();
Raaed
Level IV

Re: Lui estimators

 

Yes, great job!!. R codes were run and executed through the JMPpro script. I just added the summary function: summary(lu.reg)
In the next step I will try to ask the developers of JMPpro, to convert the Liu regression method into a plugin.

 

Thank you very much to everyone who helped me
Thank you very much Mr.markbailey

 

regards

Řaëd ~✍
Raaed
Level IV

Re: Lui estimators

Names Default to Here( 1 );

// make sure JMP can find the desired installed version of R
Set Environment Variable( "R_HOME", "C:\Program Files\R\R-4.1.3" );

// Open Data Table: fatima data.jmp
dta = Open( "/D:/Rdata/fatima data.jmp" );
x1 = :the totals of the children weights << Get As Matrix;
x2 = :age sums of children parents << Get As Matrix;
x3 = :age sums of the mothers of the children << Get As Matrix;
x4 = :number of infected male children << Get As Matrix;
x5 = :number of infected female children << Get As Matrix;
x6 = :number of infected children born from consanguineous marriages << Get As Matrix;
x7 = :children whose mothers were exposed to radiation during pregnancy << Get As Matrix;
y = :total children with congenital heart defects << Get As Matrix;

Close( dta, No Save );

// connect to R session
R Init( );

// send JMP data as vectors
R Send( x1 );
R Send( x2 );
R Send( x3 );
R Send( x4 );
R Send( x5 );
R Send( x6 );
R Send( x7 );
R Send( y );

// use mcreg function in mcr package with entire data set
R Submit("
library(liureg)
mod <-liu(y~., data = as.data.frame(dta), d = seq(0, 0.1, 0.01), scaling = "centered")
print( mod )
## Liu Var-Cov matrix
vcov(mod)
## Liu biasing parameters by researchers
dest(mod)
## Liu related statistics
lstats(mod)
");

this is my script to run (liu regression) from jmp to R.

 

not run?!

 

#note: the data attached in below

Řaëd ~✍