0

I am trying to get the nonlinear formula of y0, a, and b for my curve so I cam plot it on my graph. the summary(nls.mod) output does not show the y0 that I will need to plot the curve and I am not sure why as I have tried everything. The code is below:

# BH this version of plot is used for diagnostic plots for
# BH residuals of a linear model, i.e. using lm.
plot(mdl3 <- lm(ETR ~ wp_Mpa + I(wp_Mpa^2) + I(wp_Mpa^3), data = dat3))
prd <- data.frame(x = seq(-4, 0, by = 0.5))
result <- prd
result$mdl3 <- predict(mdl3, newdat3 = prd)

# BH use nls to fit this model y0+a*exp(b*x)
nls.mod <- nls(ETR ~ y0 + a*exp(b*wp_Mpa), start=c(a = -4, b = 0), data=dat3.no_na)
summary(nls.mod)

and here is the output:

Formula: ETR ~ y0 + a * exp(b * wp_Mpa)

Parameters:
  Estimate Std. Error t value Pr(>|t|)    
a 85.85515    8.62005   9.960   <2e-16 ***
b  0.14157    0.07444   1.902   0.0593 .  
---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Residual standard error: 58.49 on 134 degrees of freedom

Number of iterations to convergence: 8 
Achieved convergence tolerance: 1.515e-06

as you can see for some reason only the a and b show up but the y0 is supposed to be above that

I tried to reassign the variables and that just continued to give me the same output contacted a stats consultant and they just said I needed to change the variables but it still didnt work

jay.sf
  • 60,139
  • 8
  • 53
  • 110
Abby
  • 1
  • 1
  • You did not specify that y0 was an adjustable parameter. Add y0 to start=c(a = -4, b = 0) and that should work – Dave2e Nov 19 '22 at 17:13
  • thank you I've added that but I am getting this error: Error in start[[i]] : subscript out of bounds nls.mod=nls(ETR~y0+a*exp(b*wp_Mpa),start=c(y0, a = -4, b = 0),data=dat3.no_na) – Abby Nov 19 '22 at 20:05
  • You will need to define a starting value for y0, like "y0=1" – Dave2e Nov 19 '22 at 20:11

0 Answers0