Edit nls or nlsLM function for waste calculation

2

I need to set a nonlinear function through the routines nls  or nlsLM , however, my data generate heteroscedastic residues when calculated with these routines, which does not allow me to adjust directly through the sum of the squares of the residues

I already have the equation that makes the residues homocedastic, but I do not know how to make the routine use this form to calculate the residuals instead of the direct calculation of (observed-expected) ^ 2

    
asked by anonymous 10.02.2015 / 16:43

1 answer

1

I've done an example that should help you:

# dados do modelo
DNase1 <- subset(DNase, Run == 1)

# ajuste do mdoelo
fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1)

# definicao de a e b
a <- 1
b <- 2

# cálculo do resíduo
residuo <- (DNase1$density - predict(fm1DNase1))/((a*DNase1$density)^b)

In the last part of the code, I put the response variable in place of your x , but I do not know if that's exactly what you wanted.

    
11.02.2015 / 21:43