0

I am trying to use a logistic model of the form

Y = exp(ao + a1fi1....)/(1 + exp(a0 + a1fi1 ....)

for multiple non linear regression in R, The dependent variable Y is a row consisting of about 500 values and there are 33 independent variables X1, X2, X3.....X33

I am reading my data from an EXCEL file:

data1<-read.csv(file.choose(), header=TRUE)

which populates R with my data. I performed linear regression with the lm() function using input:

results<- lm(Y~ X1 + X2....X33, data = data1)

which worked perfectly fine and now I am trying to use the self starting logistic function of the form:

 nls(Y ~ SSlogis(x, Asym, xmid, scal), data1) 

for non linear regression; however, I do not seem to be applying the function properly. Thus my question is how would I use this function to perform multiple non linear regression analysis for my dataset?? Thank you for any help you can provide.

Matt Sandgren
  • 476
  • 1
  • 4
  • 10
MC2016
  • 1
  • 1
  • "*I do not seem to be applying the function properly*"... makes you say that? Do you get an error? A warning? If so, what do they say? Does your R session crash? Does your computer freeze? Do you get a result but it just doesn't seem right? – Gregor Thomas Aug 12 '16 at 16:34
  • Also, let's be sure you need `nls` with `SSlogis`. Do you have binary data (Y takes two distinct values)? If so, use `glm` with `family = binomial`, not `nls` with `SSlogis`. – Gregor Thomas Aug 12 '16 at 16:36
  • Your question is a bit unclear. The gnls function from package nlme allows you to model the parameters of a nonlinear model with linear relationships to covariates. – Roland Aug 12 '16 at 18:23
  • Yes My Y function is 1 and 0. Thus I used the function: glm(formula = Y ~ X1 + X2, family = binomial, data = data1) . The estimated coefficients matched those in a published paper that were calculated with SAS – MC2016 Aug 15 '16 at 13:17
  • Thank you everyone for the help!! the glm() function was what I should have been using!! – MC2016 Aug 15 '16 at 13:27

1 Answers1

0

You simply choose the type of the model when doing regression. The codes following should help. (I used a online dataset for example)

    mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
    model <- glm(admit ~ .,
    family=binomial(link='logit'),
    data= my data)

Then you can use following code to get more info about your model

    fit
    fit$resample
    fit$results
    fit$finalModel
CSV
  • 759
  • 5
  • 4