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 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 估計器尊敬的先生
我使用 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 運行(liu 回歸)到 R 的腳本。
不跑?!
#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();