我通过RPy与nlme和lme4r函数接口,我想从python控制台访问输出摘要。在
我运行以下代码:
test1=nlme.lme(r.formula('Pupil~CoI*Time'), random=r.formula('~1|ID'),data=dfr)
test2=nlme.lme(r.formula('Pupil~CoI*measurement'),random=r.formula('~1|ID'),data=dfr)
test1_sum= r.summary(test1)
test2_sum= r.summary(test2)
print test1_sum
print test2_sum
对于nlme,对于lme4:
^{pr2}$要获取包含数据和显式导入的代码段,请参考此IPython notebook。在
在所有情况下,我都会得到大量的打印输出,其中包括一个非常长的部分,看起来像:
Data: structure(list(CoI = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ......
我想进一步总结一下:
Random effects:
Formula: ~1 | ID
(Intercept) Residual
StdDev: 0.2201214 0.1199874
Fixed effects: Pupil ~ CoI * measurement
Value Std.Error DF t-value p-value
(Intercept) 1.2068660 0.06369911 5769 18.946357 0
CoIhard -0.0394413 0.00629117 5769 -6.269306 0
measurement -0.0002743 0.00003207 5769 -8.554287 0
CoIhard:measurement 0.0005227 0.00004536 5769 11.524511 0
Correlation:
(Intr) CoIhrd msrmnt
CoIhard -0.049
measurement -0.060 0.612
CoIhard:measurement 0.043 -0.865 -0.707
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-9.86773055 -0.37638950 0.02085029 0.43203795 4.97364143
Number of Observations: 5784
Number of Groups: 12
(包括在我得到的信息中,但在上面的后面只有数千个条目) 我怎样才能做到呢?在
正确的方法是使用
.rx2()
方法,有多种不同的使用方法:通过跳过
^{pr2}$calls
和residuals
,您将摆脱大多数问题,请尝试:附加编辑:
我认为访问
lme4
结果的tTable
(使用rpy2
)的最佳方法是将其转换为pandas
DataFrame
:print
输出与R
打印输出不完全匹配,但很容易做到:相关问题 更多 >
编程相关推荐