def test_dimension_unit(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, save=False, dimension_unit='stim') #obs.saveRcommands() obs.run()
def test_readobjectresults(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=True, keepfiles=False) obs.Rdatafile = abspath('output_test.MLDS') obs.readobjectresults() self.compare(obs)
def test_bootstrap(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=True, save=False) obs.parallel = False obs.nsamples = 1000 obs.initcommands() obs.run() self.compare(obs)
def test_dimension_unit_Rdatafilename(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, save=False, dimension_unit='stim') obs.getRdatafilename() assert (obs.Rdatafile == abspath('test_stim_norm_probit.MLDS'))
def test_readdiags(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, keepfiles=False) obs.Rdatafile = abspath('output_test.MLDS') obs.readdiags() self.assertAlmostEqual(obs.AIC, aic, places=d) self.assertAlmostEqual(obs.DAF, daf, places=d)
def test_readcsv(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=True, keepfiles=True) obs.mldsfile = abspath('output_mldsfile.csv') obs.returncode = 0 obs.readresults() self.compare(obs)
def test_Rdatafilename4(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, save=False, standardscale=False) obs.getRdatafilename(force_refit=True) assert (obs.Rdatafile == abspath('test_unnorm_probit_refit.MLDS'))
def test_simple_othernamecols2(self): obs = mlds.MLDSObject(abspath('test_cols.csv'), boot=False, save=False) obs.colnames = { 'stim': ['stim1', 'stim2', 'stim3'], 'response': 'resp' } obs.load() np.testing.assert_almost_equal(obs.scale, scale, decimal=d)
def test_rundiags_nosave(self, saveresiduals=False): obs = mlds.MLDSObject(abspath('test.csv'), boot=True, keepfiles=False) obs.parallel = False obs.nsamples = 250 obs.run() obs.rundiagnostics(saveresiduals=saveresiduals) self.assertAlmostEqual(obs.prob, prob, places=1) os.remove(obs.Rdatafile)
def test_Rdatafilename3(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, save=False, standardscale=False) obs.linktype = 'cauchit' obs.getRdatafilename() assert (obs.Rdatafile == abspath('test_unnorm_cauchit.MLDS'))
def test_bootstrap_correctedCI(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=True, save=False) obs.correctedCI = True obs.parallel = False obs.nsamples = 1000 obs.run() np.testing.assert_almost_equal(obs.ci95, ci95_corrected, decimal=d) np.testing.assert_almost_equal(obs.sigmaci95, sigmaci95_corrected, decimal=d)
res = 0.000015 # interpolation resolution. decrease if needed. # Standards: at which stimulus levels you want to predict thresholds? sts = np.array([0.25, 0.5, 0.75]) # d' : thresholds will be derived to the following d' performance dp = [-2, -1, -0.5, 0.5, 1, 2] # d' around the standard at which we will read out thresholds # (negative values indicate comparisons below the standard, positive values for # comparisons above the standard) # type of confidence interval. citype = 'BCa' # bias-corrected and accelerated CIs # citype = 'percentile' # raw percentile CI # %% Estimating scale calling MLDS ml = mlds.MLDSObject(name, boot=True, standardscale=False, verbose=False) ml.nsamples = nsamples ml.load() # plotting plt.figure(figsize=(5, 5)) plt.plot(ml.stim, ml.scale, c='k') yerr = abs(ml.ci95 - ml.mns) plt.errorbar(ml.stim, ml.mns, yerr=yerr, fmt="none", c='k') sns.despine() plt.xlabel('Stimulus') plt.ylabel('Perceptual scale') plt.show() # runs GoF diagnostics # ml.rundiagnostics()
def test_simple(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, save=False) obs.run() np.testing.assert_almost_equal(obs.scale, scale, decimal=d)
def test_Rdatafilename(self): obs = mlds.MLDSObject(abspath('test.csv'), boot=False, save=False) print(obs.rootname, obs.filename) obs.getRdatafilename() assert (obs.Rdatafile == abspath('test_norm_probit.MLDS'))
# -*- coding: utf-8 -*- """ Example use of MLDS class data.csv was created by simulation. """ import matplotlib.pyplot as plt import mlds ## creating MLDS object and running analysis obs = mlds.MLDSObject('data.csv', standardscale=False, boot=True, verbose=True) obs.nsamples = 1000 print("Running analysis...") # obs.run() # always runs the analysis, overwrites the .MLDS file if exists. obs.load() # loads results from .MLDS file; runs the analysis if doesn't exist ## plotting print("plotting...") plt.figure() plt.errorbar(obs.stim, obs.mns, yerr=abs(obs.ci95 - obs.mns), color='#4C72B0', linewidth=2, elinewidth=2) plt.xlabel('Stimulus') plt.ylabel('Difference Scale') plt.xlim((-0.1, 1.1)) plt.show()