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 ~✍
1 ACCEPTED SOLUTION

Accepted Solutions

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();

View solution in original post

21 REPLIES 21

Re: Lui estimators

I cannot find this statistic in the Statistics Index in JMP. I am not familiar with this estimator. Please provide a reference for it. Thanks!

Raaed
Level IV

Re: Lui estimators

Liu's method is a method similar to ridge regression method, used to estimate the parameters of a Poisson regression model in case of data suffering from a multicollinearity problem.

 

doi:10.1016/j.jspi.2010.05.030

 

https://doi.org/10.1080%2F03610929508831585

 

The Comprehensive R Archive Network (r-project.org)

 

Řaëd ~✍

Re: Lui estimators

Thank you for the background!

 

In the meantime, you can run R code from JMP, if that would help.

Raaed
Level IV

Re: Lui estimators

Dear Mr. markbailey

I don't know how to run R program codes through JMP pro.
(I tried once and couldn't do it)
Please, if you know, help me

 

Regards

Řaëd ~✍

Re: Lui estimators

Did you read the JMP documentation that I cited above? You might find this white paper useful, too.

 

Here is an example of using R with JMP in a recent project of mine. I show two versions. The first uses matrices to transfer data between JMP and R.

 

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" );

// use Big Class from JMP Sample Data Folder
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
x = :height << Get As Matrix;
y = :weight << Get As Matrix;
Close( dt, No Save );

// connect to R session
R Init( );

// send JMP data as vectors
R Send( x );
R Send( y );

// use mcreg function in mcr package with entire data set
R Submit("
library( mcr )
mc <- mcreg( x, y, alpha = 0.05, method.reg = \!"PaBa\!", method.ci = \!"analytical\!", slope.measure = \!"tangent\!" )
print( mc )
parms <- getCoefficients( mc )
pred <- parms[1] + parms[2]*x
print( pred )
resid <- y - pred
print( resid )
");

// close R connection
R Term();

// select View > Log (Windows) or Windows > Log (macOS) to see results

The second versions uses the JMP data table instead. It becomes a data frame in R.

 

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" );

// use Big Class from JMP Sample Data Folder
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
x = :height << Get As Matrix;
y = :weight << Get As Matrix;
Close( dt, No Save );

// connect to R session
R Init( );

// send JMP data as vectors
R Send( x );
R Send( y );

// use mcreg function in mcr package with entire data set
R Submit("
library( mcr )
mc <- mcreg( x, y, alpha = 0.05, method.reg = \!"PaBa\!", method.ci = \!"analytical\!", slope.measure = \!"tangent\!" )
print( mc )
parms <- getCoefficients( mc )
pred <- parms[1] + parms[2]*x
print( pred )
resid <- y - pred
print( resid )
");

// close R connection
R Term();

// select View > Log (Windows) or Windows > Log (macOS) to see results

You can send individual commands to R or, as I illustrated, an entire R script as a character string. You can use all the JSL features for strings and expressions to create custom R scripts 'on the fly.'

Raaed
Level IV

Re: Lui estimators

Dear Sir

JMP does not connect with R, has read and applied the feedback you sent.
But I did not succeed!

Regards

Řaëd ~✍
txnelson
Super User

Re: Lui estimators

what version of JMP Pro are you running and on what Operating System?

Do you have R installed on your computer or do you run it on a separate computer?

If it is installed on the same computer as JMP is installed on, what messages are printed out when you run the following script?

Names Default To Here( 1 );
R Init();
R Term();

 

Jim
Raaed
Level IV

Re: Lui estimators

Dear Sir
I use JMPPro version 16 as well as R version 4.1.3
The two programs are installed on the same computer that is running Windows Pro 11

 

and i read the notes in this link:

wp-jmp-synergies-python-r.pdf

 

But I did not succeed!

Ř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 ~✍