Lui 估计器如何使用 JMP pro 计算 Liu 的估计?!
随附的
从伊拉克巴格达中央儿童医院获得的真实数据,代表该时期(2006-2011 年)儿童心脏和循环系统先天性缺陷的病例数。
问候
分析数据表脚本回复:Lui 估计器我在 JMP 的统计索引中找不到这个统计数据。 我不熟悉这个估计器。 请提供参考。 谢谢!
回复:Lui 估计器Liu的方法是一种类似于岭回归方法的方法,用于在数据存在多重共线性问题的情况下估计泊松回归模型的参数。
doi:10.1016/j.jspi.2010.05.030
https://doi.org/10.1080%2F03610929508831585
综合 R 档案网络 (r-project.org)
回复:Lui 估计器谢谢你的背景!
同时,您可以从 JMP 运行 R 代码,如果这会有所帮助。
回复:Lui 估计器亲爱的马克贝利先生
我不知道如何通过 JMP pro 运行 R 程序代码。
(我试过一次,做不到)
请,如果你知道,请帮助我
问候
回复:Lui 估计器您是否阅读了我上面引用的 JMP 文档? 你可能会发现这个白纸也有用。
这是在我最近的一个项目中使用 R 和 JMP 的示例。 我展示了两个版本。 第一个使用矩阵在 JMP 和 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
第二个版本使用 JMP 数据表。 它成为 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
您可以将单个命令发送到 R,或者如我所说明的,将整个 R 脚本作为字符串发送。 您可以使用字符串和表达式的所有 JSL 功能“即时”创建自定义 R 脚本。
回复:Lui 估计器尊敬的先生
JMP 未与 R 连接,已阅读并应用您发送的反馈。
但是我没有成功!
问候
回复:Lui 估计器您正在运行什么版本的 JMP Pro 以及在什么操作系统上运行?
您的计算机上安装了 R 还是在单独的计算机上运行它?
如果它与安装 JMP 的计算机安装在同一台计算机上,则在运行以下脚本时会打印出哪些消息?
Names Default To Here( 1 );
R Init();
R Term();
回复:Lui 估计器尊敬的先生
我使用 JMPPro 版本 16 以及 R 版本 4.1.3
这两个程序安装在运行 Windows Pro 11 的同一台计算机上
我阅读了此链接中的注释:
wp-jmp-synergies-python-r.pdf
但是我没有成功!
回复:Lui 估计器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)
");这是我从 jmp 到 R 运行(liu 回归)的脚本。
不跑?!
#note:下面附上的数据
回复:Lui 估计器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)
");这是我从 jmp 运行(liu 回归)到 R 的脚本。
不跑?!
#note:下面附上的数据
回复:Lui 估计器我修改了您的 JSL 以匹配包含的数据表中的列名。我还添加了一个 Send() 来将 dta 数据移动到 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" );
// Open Data Table: fatima data.jmp
//dta = Open( "/D:/Rdata/fatima data.jmp" );
dta=current data table();
x1 = :"the totals of the children's weights 109 75.4 69.5 36.2 6.9"n << Get As Matrix;
x2 = :"Age sums of children's parents 1260 811 735 201 82"n << Get As Matrix;
x3 = :"Age sums of the mothers of the children 915 619 503 168 61"n << Get As Matrix;
x4 = :"The number of infected male children 29 18 11 3 2"n << Get As Matrix;
x5 = :"Number of infected female children 10 3 7 2 0"n << Get As Matrix;
x6 = :"Number of infected children born from consanguineous marriages 9 5 3 1 0"n << Get As Matrix;
x7 = :"Number of infected children whose mothers were exposed to radiation during pregnancy 11 3 1 1 0"n << Get As Matrix;
y = :"Total children with congenital heart defects 39 21 18 5 2"n << 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 );
R Send(dta);
// 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)
");
r term();
r 的结果是
TKIntRJMP.R version 14.0
Call:
liu.default(formula = y ~ ., data = as.data.frame(dta), d = seq(0,
0.1, 0.01), scaling = "centered")
Intercept no.1.2.3.4.5
d=0 NA NA
d=0.01 NA NA
d=0.02 NA NA
d=0.03 NA NA
d=0.04 NA NA
d=0.05 NA NA
d=0.06 NA NA
d=0.07 NA NA
d=0.08 NA NA
d=0.09 NA NA
d=0.1 NA NA
Total.children.with.congenital.heart.defects.39.21.18.5.2
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
the.totals.of.the.children.s.weights.109.75.4.69.5.36.2.6.9
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
Age.sums.of.children.s.parents.1260.811.735.201.82
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
Age.sums.of.the.mothers.of.the.children.915.619.503.168.61
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
The.number.of.infected.male.children.29.18.11.3.2
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
Number.of.infected.female.children.10.3.7.2.0
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
Number.of.infected.children.born.from.consanguineous.marriages.9.5.3.1.0
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
Number.of.infected.children.whose.mothers.were.exposed.to.radiation.during.pregnancy.11.3.1.1.0
d=0 NA
d=0.01 NA
d=0.02 NA
d=0.03 NA
d=0.04 NA
d=0.05 NA
d=0.06 NA
d=0.07 NA
d=0.08 NA
d=0.09 NA
d=0.1 NA
Error: Error in solve.default(t(x) %*% x) :
system is computationally singular: reciprocal condition number = 1.28204e-20
0
界面似乎工作正常,似乎存在数据问题。
回复:他的估算员我有两点建议或许会有帮助。
首先,我演示了如何确保 JMP 在安装 R 后能够找到它。以下是实现此目的的 JSL 代码。我使用的路径与您应该使用的路径是否一致?请确保路径正确。
// make sure JMP can find the desired installed version of R
Set Environment Variable( "R_HOME", "C:\Program Files\R\R-4.1.3" );
你的 R 脚本引用了一个 dta 数据框,但那实际上是一个 JMP 数据表,你并没有发送它。你把 JMP 数据列作为单独的向量发送给了 R。因此,你必须要么在 R 中根据你发送的向量创建数据框,要么发送数据表而不是向量,然后在 R 中使用它。JMP 会自动为 R 创建数据框,所以后一种方法似乎更简单高效。请参阅我上面的第二个示例。
另外,请务必在脚本末尾调用此函数:
R Term();