I have a regression that looks like this:
fit <- nls (data$y ~ (data$v1 + data$v2 + data$v3 + data$v4) *(1 + exp(theta1 - theta2*data$v5 - theta3*data$v6)^-1),
data = data,
start = c (theta1 =0, theta2= 0, theta3= 0))
summary(fit)
In the first part the variables follow a linear relationship but they are weighted by a non-linear expression (second part). The model runs, but the summary only shows the information for the parameters on the non-linear part (theta1, theta2, and theta3). Does anybody know how to get the information about the intercept and the coefficient of the non-linear part? Or my formulation wrong and R is not estimating these coefficients?
While lm
will assume you want coefficients in front of every data column, nls
makes no such assumption; you must tell it.
fit <- nls (y ~ (b0 + b1 * v1 + b2 * v2 + b3 * v3 + b4 * v4) *
(1 + exp(theta1 - theta2 * v5 - theta3 * v6) ^ -1),
data = data,
start = c (b0 = 0, b1 = 1, b2 = 2, b3 = 3, b4 = 4,
theta1 =0, theta2= 0, theta3= 0))
You may want to initially fit the lm
to the first part, and then use the estimated coefficients as the starting values in nls
.