Multiple variables with different relationships in nls() in R

528 views Asked by At

I would like to build a model to predict Y based on several variables. First, I have a look on scatterplot and correlation map on R (see below)

enter image description here

It appears that Y has a exponential relationship with X1, a logistics growth with X2, and linear relationiships with X3 and X4. So, I was wondering that if it is possible to use nls() to build a model that may cover above relationship. Below is my try:

modelling Y~X2 solely in nls() to get phi parameters :

fit <- nls(Y~ c1*(exp(-k1*X1))+ SSlogis(Y, phi1, phi2, phi3) + X3+ X4,
               start=list(c1=Y[1], k1=0, phi1=15.07, phi2=1082.67,phi3=55.47))

Error:minFactor

Then try it differently:

fit <- nls(Y~ c1*(exp(-k1*X1))+ c2/(1+b2*exp(-k2*X2)) + X3+ X4,
               start=list(c1=Y[1], k1=0, c2 = 1, b2 = 0, k2 = 111))

Error: singularity

Q1: can I mix variables like above,if so, any thoughts how to fix errors

Q2: any thoughts on model selection(other models)

0

There are 0 answers