Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

function to perform pairs bootstrap estimates on linear regression parameters

def draw_bs_pairs_linreg(x, y, size=1):
    """Perform pairs bootstrap for linear regression."""

    # Set up array of indices to sample from: inds
    inds = np.arange(len(x))

    # Initialize replicates: bs_slope_reps, bs_intercept_reps
    bs_slope_reps = np.empty(size)
    bs_intercept_reps = np.empty(size)

    # Generate replicates
    for i in range(size):
        bs_inds = np.random.choice(inds, size=len(inds))
        bs_x, bs_y = x[bs_inds], y[bs_inds]
        bs_slope_reps[i], bs_intercept_reps[i] = np.polyfit(bs_x, bs_y, 1)

    return bs_slope_reps, bs_intercept_reps
Comment

PREVIOUS NEXT
Code Example
Python :: Install Pip 2 on ubuntu linux 
Python :: journalctl not showing all python prints 
Python :: symmetrical sum python 
Python :: API curl python pandas 
Python :: how to hide button in tkinter 
Python :: python replace string with int in list 
Python :: create frequency tables in pandas 
Python :: how to add numbers into a list python 
Python :: python remove item from list 
Python :: python linux command 
Python :: dont truncate dataframe jupyter pd display options 
Python :: python open aspx file 
Python :: change gles3 to gles2 
Python :: Convert Int to String Using str() function 
Python :: python wheel 
Python :: for loop in python array 
Python :: python submatrix 
Python :: cv2 and PIL BRG to RGB 
Python :: python string lowercase 
Python :: dense in keras 
Python :: symbolic variables python 
Python :: python os path safe string 
Python :: dictionary python 
Python :: django trigger when an instance od data is deleted from model 
Python :: cv2 remove black borders on images 
Python :: python defaultdict default value 
Python :: threshold meaning in pandas dropna 
Python :: how to split a dataframe into train and test 
Python :: Plot kdeplot, lineplot, scatterplot in seaborn 
Python :: print 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =