0
$\begingroup$

I am trying to run a simple logistic regression (response ~ stimulus, where responses are "f" or "s" and stimulus goes from 1 to 11). My main objective is to calculate the turning point of the function (-alpha/beta). I have to use JavaScript to do it. For that, I am using js-regression package. However, the js-regression returns theta, a pair of numbers different from the alpha and beta I need. Does someone know how to calculate alpha and beta (or the turning point) from theta?

For example, consider the following data:

response<-c(rep("f",35),rep("s",75))
stimulus<-sort(c(rep(1:11,10)))
response[c(10,15,21,25,30)]<-"s"
response[c(40,45,50,60,65,70)]<-"f"
data<-as.data.frame(cbind(response,stimulus))

JavaScript:

var jsregression = require('js-regression')
var logistic = new jsregression.LogisticRegression();
var dados = require('data_simulated.json')
logistic.fit(dados)

Output: theta: [ 0.5397380297076451, 0.46554794170958247 ], threshold: 0.7320965934732375, cost: -4.387012914910967, config: { alpha: 0.001, lambda: 0, iterations: 100 }

The R output, using glm(family = "binomial"), is intercept = -3.5744; beta = 0.8816. Using js-regression, the output is theta= [0.5397380297076451, 0.46554794170958247].

$\endgroup$
2
  • $\begingroup$ Hi, could you please provide the js code you have used? $\endgroup$ – Spätzle Jul 22 at 4:36
  • $\begingroup$ Hi, I just added it. Thank you. $\endgroup$ – marceletras Jul 22 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.