Page 1 of 1

Difficulty extracting p-values from PySDTest objects via EViews xrun

Posted: Mon Apr 13, 2026 8:55 am
by papel
I am working on a research project involving Stochastic Dominance tests using EViews 13 (64-bit) integrated with Python 3.9.
I have successfully set up the Python environment and installed the PySDTest package (by Kyung-ho Lee and Yoon-Jae Whang). My goal is to extract the p-values from the test objects generated by pysdtest.test_sd() and store them in EViews scalars/tables for further analysis.

My workflow is as follows:
I use xput to send my series (a_vals, b_vals) to Python.
I execute the test:
xrun my_test_ssd = pysdtest.test_sd(a_vals, b_vals, s=2, resampling='paired_bootstrap', nboot=1000, quiet=False)
I run the testing procedure:
xrun res_ssd = my_test_ssd.testing()

The issue:
While the testing() method correctly prints the results to the EViews Python Output log, I am unable to programmatically access the p-value result to bring it back to EViews. When I attempt to access the attribute via xrun my_pval = my_test_ssd.pvalue or res_ssd.pvalue, I receive an AttributeError or NoneType error, despite the output being clearly visible in the Python console log.

My questions:
Is there a documented way to access the p-value attribute from the test_sd object directly through xrun?
What is the recommended best practice for capturing and importing Python output (log) back into an EViews table when the standard xget fails to resolve the specific object attributes?

Best Regards,
Timotheos

Re: Difficulty extracting p-values from PySDTest objects via EViews xrun

Posted: Mon Apr 13, 2026 9:44 am
by EViews Gareth
If you're stuck in EV13 (and can't use 14), the only thing you can do is create a new page and try to use xget. Hard to be of more advice without having access to the exact situation you're in.

Re: Difficulty extracting p-values from PySDTest objects via EViews xrun

Posted: Mon Apr 13, 2026 9:57 am
by papel
Dear Gareth,
Below you can find the programm that I am using. The programm generates the following results in the Log: Python Output. I need a way to bring the pvalue back in Eviews. I also attach the Eviews workfile that I am using
Kind regards,
Timotheos

______________________
Log: Python Output

#--- Testing for Stochastic Dominance -----#

* H0 : sample1 first order SD sample2

#-------------------------------------------#

*** Test Setting ***
* Resampling method = paired_bootstrap
* SD order = 1
* # of (sample1) = 2000
* # of (sample2) = 2000
* # of bootstrapping = 100
* # of grid points = 200

#-------------------------------------------#

*** Test Result ***
* Test statistic = 0.2846
* Significance level = 0.05
* Critical-value = 0.6174
* P-value = 0.8500
* Time elapsed = 2.35 Sec



'______________________________________
xopen(p)

xrun import pysdtest

' Send the data
xput data_a data_b

' 3. Load Libraries
xrun import numpy as np
xrun import pandas as pd

xrun import pysdtest.pysdtest as sd

' 1-dimensional NumPy arrays
xrun a_vals = np.array(data_a).flatten()
xrun b_vals = np.array(data_b).flatten()

' 4. Run LMW (2005) TEST

%kind_test = "'paired_bootstrap'"

' --- ΕΛΕΓΧΟΣ 1ης ΤΑΞΗΣ (FSD) ---
xrun my_test_fsd = pysdtest.test_sd(a_vals, b_vals, ngrid=200, s=1, resampling={%kind_test}, nboot=100, quiet=False)

xrun print("--- RUNNING 1st ORDER TEST (A Dominates B) ---")
xrun res_fsd = my_test_fsd.testing()
'________________________________________________

Re: Difficulty extracting p-values from PySDTest objects via EViews xrun

Posted: Mon Apr 13, 2026 4:46 pm
by EViews Gareth
Not really EViews, but...

Code: Select all

xrun pval = my_test_fsd.result["p_val"].item() xget pval

Re: Difficulty extracting p-values from PySDTest objects via EViews xrun

Posted: Mon Apr 13, 2026 9:51 pm
by papel
Thank you!