为什么 p.summary() 在运行 pyprocessmacro 时导致我的脚本崩溃(我使用模型 1 和 4)

发布于 2025-01-10 01:56:51 字数 2650 浏览 0 评论 0原文

我正在使用 pyprocessmacro 运行中介分析,但出现了问题。 运行 p.summary() 时脚本崩溃。

我使用输入文本字段来获取变量(来自 PySimpleGUI)。

在我的脚本中,我运行

from PyProcessMacro import Process

iv=valMediation['iv']
dv=valMediation['dv']
m1=valMediation['m']
m_list=[m1]

#Output included variables for control:
print('IV: ' + iv)
print('M: ' + m1)
print('DV: ' + dv)
print('M_list: ' + m_list)

Output dataframe for control:
print(data)
                                       
p = Process(data=data, model=4, x=iv, y=dv, m=m_list)
print('Full summary: ')
p.summary()

我的输出如下:


IV: q0044 
M: q0068 
DV: q0046 
M_list: ['q0068']

     q0044  q0068  q0046 0        2      1      5 1        2      1      5 2        2      1      5 3        3      1      5 4        3      1 
4 ..     ...    ...    ... 201      2      1      4 202      2      1 
5 203      1      1      3 204      3      2      4 205      2      4 
4

[206 rows x 3 columns] 

C:\Users\ChristianOttoRuge\Telia Sky\Christian\CORals\Scripts\CORals-Analytics\Corals-Analytics_3.9.9\3.9.9_venv\lib\site-packages\pyprocessmacro\utils.py:33:
DeprecationWarning: the `interpolation=` argument to percentile was renamed to `method=`, which has additional options. 
Users of the modes 'nearest', 'lower', 'higher', or 'midpoint' are encouraged to review the method they. (Deprecated NumPy 1.22)   
llci = np.percentile(samples, plow * 100, interpolation="lower")

C:\Users\ChristianOttoRuge\Telia Sky\Christian\CORals\Scripts\CORals-Analytics\Corals-Analytics_3.9.9\3.9.9_venv\lib\site-packages\pyprocessmacro\utils.py:34:
DeprecationWarning: the `interpolation=` argument to percentile was renamed to `method=`, which has additional options. 
Users of the modes 'nearest', 'lower', 'higher', or 'midpoint' are encouraged to review the method they. (Deprecated NumPy 1.22)   
ulci = np.percentile(samples, phigh * 100, interpolation="higher") 

Process successfully initialized. 
Based on the Process Macro by Andrew F. Hayes, Ph.D. (www.afhayes.com)

****************************** SPECIFICATION ****************************

Model = 4

Variables:
    Cons = Cons
    x = q0044
    y = q0046
    m1 = q0068

Sample size: 206

Bootstrapping information for indirect effects: Final number of
bootstrap samples: 5000 Number of samples discarded due to convergence
issues: 0 

Full summary:

正如您所看到的,它在到达时中断

p.summary()

它看起来 p 有问题,但所有变量都经过检查和验证。

在输出中,变量可能看起来不是字符串,因为输出中缺少引号,但我尝试向变量添加引号:

dv = "'" + dv + "'"

但没有成功。这甚至会更早地停止该过程。

我还检查了数据框中的空值或非数字值,但看起来不错。

如果有人能在这里帮助我,我将非常感激!

亲切的问候

I'm using pyprocessmacro to run mediation analysis, but an issue has occured.
When running p.summary() the script crashes.

I use input textfields to get the variables (from PySimpleGUI).

In my script, I run

from PyProcessMacro import Process

iv=valMediation['iv']
dv=valMediation['dv']
m1=valMediation['m']
m_list=[m1]

#Output included variables for control:
print('IV: ' + iv)
print('M: ' + m1)
print('DV: ' + dv)
print('M_list: ' + m_list)

Output dataframe for control:
print(data)
                                       
p = Process(data=data, model=4, x=iv, y=dv, m=m_list)
print('Full summary: ')
p.summary()

My output is like this:


IV: q0044 
M: q0068 
DV: q0046 
M_list: ['q0068']

     q0044  q0068  q0046 0        2      1      5 1        2      1      5 2        2      1      5 3        3      1      5 4        3      1 
4 ..     ...    ...    ... 201      2      1      4 202      2      1 
5 203      1      1      3 204      3      2      4 205      2      4 
4

[206 rows x 3 columns] 

C:\Users\ChristianOttoRuge\Telia Sky\Christian\CORals\Scripts\CORals-Analytics\Corals-Analytics_3.9.9\3.9.9_venv\lib\site-packages\pyprocessmacro\utils.py:33:
DeprecationWarning: the `interpolation=` argument to percentile was renamed to `method=`, which has additional options. 
Users of the modes 'nearest', 'lower', 'higher', or 'midpoint' are encouraged to review the method they. (Deprecated NumPy 1.22)   
llci = np.percentile(samples, plow * 100, interpolation="lower")

C:\Users\ChristianOttoRuge\Telia Sky\Christian\CORals\Scripts\CORals-Analytics\Corals-Analytics_3.9.9\3.9.9_venv\lib\site-packages\pyprocessmacro\utils.py:34:
DeprecationWarning: the `interpolation=` argument to percentile was renamed to `method=`, which has additional options. 
Users of the modes 'nearest', 'lower', 'higher', or 'midpoint' are encouraged to review the method they. (Deprecated NumPy 1.22)   
ulci = np.percentile(samples, phigh * 100, interpolation="higher") 

Process successfully initialized. 
Based on the Process Macro by Andrew F. Hayes, Ph.D. (www.afhayes.com)

****************************** SPECIFICATION ****************************

Model = 4

Variables:
    Cons = Cons
    x = q0044
    y = q0046
    m1 = q0068

Sample size: 206

Bootstrapping information for indirect effects: Final number of
bootstrap samples: 5000 Number of samples discarded due to convergence
issues: 0 

Full summary:

As you can see it breaks when reaching

p.summary()

It looks like there's something wrong with p, but all variables are checked and validated.

In the output it could look like the variables are not strings, since quotation marks are missing in the output, but I have tried adding quotationmarks to the variables:

dv = "'" + dv + "'"

without sucsess. This even stops the process earlier.

I've also checked for empty, or non-numerical values in the dataframe, but it looks fine.

If someone can help me out here I'd be extremely greatful!!

Kind regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可遇━不可求 2025-01-17 01:56:51

升级 pyprocessmacro 就完成了这项工作!

pip install pyprocessmacro==1.0.12

非常感谢 GitHub 上的@QuentinAndre 提供解决方案。

Upgrading pyprocessmacro did the job!

pip install pyprocessmacro==1.0.12

Thanks a lot to @QuentinAndre at GitHub for reaching out with the solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文