[R] how to predict X given Y using logit regresion in R?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Sat Oct 2 22:36:57 CEST 2021


Hello,
I also tried with
```
library(MASS)
> dose.p(model,p=.95)
               Dose       SE
p = 0.95: 1.70912 96.26511
```
which is closer to the expected 1.72 but with a very large error (I
expected 1.10-2.34). Is this regression correct?

On Sat, Oct 2, 2021 at 10:14 AM Luigi Marongiu <marongiu.luigi using gmail.com> wrote:
>
> Hello,
> I have set a glm model using probit. I would like to use it to predict
> X given Y. I have followed this example:
> ```
> f2<-data.frame(age=c(10,20,30),weight=c(100,200,300))
> f3<-data.frame(age=c(15,25))
> f4<-data.frame(age=18)
> mod<-lm(weight~age,data=f2)
> > predict(mod,f3)
> 1
> 150
> > predict(mod,f4)
> 1
> 180
> ```
>
> I have set the following:
> ```
> df <- data.frame(concentration = c(1, 10, 100, 1000, 10000),
> positivity = c(0.86, 1, 1, 1, 1))
> model <- glm(positivity~concentration,family = binomial(link =
> "logit"), data=df)
> > e3<-data.frame(concentration=c(11, 101), positivity=c(1, 1))
> > predict(model, e3)
> 1               2
> 5.645045 46.727573
> ```
> but:
> ```
> > e4<-data.frame(positivity=0.95)
> > e4
> positivity
> 1       0.95
> > predict(model, e4)
> Error in eval(predvars, data, env) : object 'concentration' not found
> ```
> Why did the thing worked for f4 but not e4? How do I get X given Y?
> Do I need to find the inverse function of logit (which one?) and apply
> this to the regression or is there a simpler method?
> Also, is it possible to plot the model to get a smooter line than
> `plot(positivity ~ concentration, data = df, log = "x", type="o")`?
> Thanks
> --
> Best regards,
> Luigi



-- 
Best regards,
Luigi



More information about the R-help mailing list