What is the method to specify nu=4.0 (or any desired value) when utilizing the StudentsT() distribution in arch_model within Python?

How can I set nu=4.0 in this situation?

model = arch_model(data)
from arch.univariate import StudentsT
model.distribution = StudentsT()

Answer №1

If you want to pass a specific degree of freedom to the function StudentsT, use the method _ord_t_partial_moment:

StudentsT._ord_t_partial_moment(n, z, nu)

Found in: arch univariate distribution

@staticmethod
    def _ord_t_partial_moment(n: int, z: float, nu: float) -> float:
        r"""
        Partial moment calculation for ordinary parameterization of Students t with degrees of freedom=nu

        Parameters
        ----------
        n : int
            Order of the partial moment
        z : float
            Upper limit for the partial moment integral
        nu : float
            Degrees of freedom

        Returns
        -------
        float
            Calculated moment

        References
        ----------
        .. [1] Winkler et al. (1972) "The Determination of Partial Moments"
               *Management Science* Vol. 19 No. 3

        Notes
        -----
        The lower partial moment of order n for variable x up to z is defined by:

        .. math::

            \int_{-\infty}^{z}x^{n}f(x)dx

        For more information, refer to [1]_.
        """
        if n < 0 or n >= nu:
            return nan
        elif n == 0:
            moment = stats.t.cdf(z, nu)
        elif n == 1:
            c = gamma(0.5 * (nu + 1)) / (sqrt(nu * pi) * gamma(0.5 * nu))
            e = 0.5 * (nu + 1)
            moment = (0.5 * (c * nu) / (1 - e)) * ((1 + (z ** 2) / nu) ** (1 - e))
        else:
            t1 = (z ** (n - 1)) * (nu + z ** 2) * stats.t.pdf(z, nu)
            t2 = (n - 1) * nu * StudentsT._ord_t_partial_moment(n - 2, z, nu)
            moment = (1 / (n - nu)) * (t1 - t2)
        return moment

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I use Selenium to open a webpage without pausing the script?

I am facing an issue where all the code execution after driver.get(url) is halted until the page finishes loading. I want to avoid this behavior, so I am looking for alternative methods or perhaps a way to make the get method non-blocking. Is there any s ...

Instructions for accessing Jupyter notebook's console rather than the webpage post-version 4.1.1

With the release of version 4.1.0, logging to console/terminal is possible with the following code snippet: import logging r = logging.getLogger() r.setLevel(logging.DEBUG) logging.debug("debug") Additionally, a default StreamHandler can be obtained by u ...

Determine the likelihood of achieving the desired sum through various lottery drawings

If I were to participate in multiple lotteries with varying prize amounts and different odds of winning, how can I determine the likelihood of winning at least a specified value if I play each lottery simultaneously and only once? Lottery A: Has a 50% cha ...

Tips for setting up my ajax/views method to output a dictionary

Here's the HTML snippet I have along with an AJAX request: <script> $("#search_button").on("click", function(){ var start_date = $("input[name=\"startdate\"]").val(); var end_date = $("input[name=\"end ...

Exploring a JSON file with Python using regular expressions or the Whoosh library

I have extracted data from over 5 e-commerce websites and stored it in a large JSON file as a collection of dictionaries, such as: { "url": "https://www.amazon.com/category/product_1", "price": 539, "product_code": ["x123"], "page_title": "Smar ...

How to extract and display data in Python using JSON parsing techniques

In search of the right syntax for extracting and displaying specific JSON data using Python Check out this example JSON file: Sample JSON Response from Play Information: { "id": 111, "age": 22, "Hobby": [ { "List": 1, "Sev": "medium", "name": "play 1" ...

Enable editing on QTableView when using a pandas dataframe as the model

Within my gui file, I create a QTableView using the code generated by Qt Designer: self.pnl_results = QtGui.QTableView(self.tab_3) font = QtGui.QFont() font.setPointSize(7) self.pnl_results.setFont(font) self.pnl_results.setFrameShape(QtGui.QFrame.StyledP ...

Utilizing Python and CV2 for Iterative Horizontal Image Stacking in a Loop

I am trying to vertically stack a series of images in Python using a loop. The goal is to add the images one by one vertically, starting with an image outside of the loop. Desired Output Format, Actual Output I'm Getting image = cv2.imread(os.path. ...

What could be causing my multi-process queue to exhibit un-threadsafe behavior?

I am currently developing a watchdog timer that is responsible for monitoring another Python program. If the watchdog timer fails to receive a check-in signal from any of the threads, it will shut down the entire program. This functionality is essential fo ...

Sending checkbox value with jquery.ajax in Bootstrap modal: a step-by-step guide

Currently I am facing a challenge with a form that includes a checkbox on a webpage pop-up modal using flask/bootstrap/jquery. My goal is to submit the form without refreshing the page, which is why I'm utilizing jquery.ajax for this task. Despite the ...

Select a particular email within a Gmail inbox using Python

Looking to extract a specific email from a Gmail account based on the subject. I have opted for selenium as I am unable to utilize imaplib with this particular Gmail account. Stuck at this point: driver.find_element_by_id("identifierId").send_keys('M ...

What is the method for embedding the creation date of a page within a paragraph on Wagtail?

Whenever a page is created in the admin panel of Wagtail, it automatically displays how much time has elapsed since its creation. https://i.stack.imgur.com/6InSV.png I am looking to include the timestamp of the page's creation within a paragraph in ...

Iterating over a dataframe to generate additional columns while preventing fragmentation alerts

Currently, I have an extended version of this coding to iterate through a large dataset and generate new columns: categories = ['All Industries, All firms', 'All Industries, Large firms'] for category in categories: sa[ ...

Python script for removing .nc files with a 'bad flag' attribute

I have a directory with a large number of nc files (4663 in total) and I need to delete certain files based on a specific attribute. The attribute in question is called 'bad'. If bad=0 (with 0 being a string type), it indicates that the nc file ...

Extracting the text content of a specific tag while ignoring the text within other tags nested inside the initial one

I am trying to extract only the text inside the <a> tags from the first <td> element of each <tr>. I have provided examples of the necessary text as "yyy" and examples of unnecessary text as "zzz". <table> <tbody> <tr ...

I'm having trouble adding a background image, even though I have set it to static. What could be

I attempted to add a background image to my Django website, but unfortunately, it was not successful. I followed the steps provided in this Stack Overflow answer here, however, it did not work. I even made changes to the database by migrating them, but s ...

Divide the row according to the value in the column

After pondering over this issue for quite some time and feeling somewhat frustrated, I am seeking assistance. In a dataframe, I have aggregated data structured as follows, CLASS_ID,ACH_MONTH(MM format),ACH_YEAR(YYYY format),FEES,PAY_TYPE 862424,06,2020,100 ...

Exploring DataFrames with interrows() and writing them out as CSV files with .to_csv:

I am using the following script to perform the following actions: Apply a function to a column in each row of a DataFrame Write the returns from that function into two new columns of a DataFrame Continuously write the DataFrame into a *.csv I am interes ...

For loop not functioning correctly due to if statement

I'm just starting out and I've been working on an iterative calculation in Python that looks like this: for i in range(30): if i<10: p = 1 if 10<=i<20: p = 2 else: p = 3 But when I run the code, for the ...

Repeatedly apply multiplication to a numpy array by scalar values

I am currently working with a 3D NumPy array of size (9,9,200) and a 2D array of size (200,200). My goal is to take each channel of shape (9,9,1), multiply it by 200 scalars in a single row, and then average the result to obtain an array of shape (9,9,1). ...