-4

I was asking to find best fit values for two unknown parameters using the lm() function in r, I have used the lm function before but I am unsure of how to do this for unknown parameters?

I need to use the lm function on this formula

log⁡(C)~ log⁡(A)+ D log⁡(B)

Based off of this model

log(C)~ N(log⁡(A)+ D log⁡(B),σ^2 )

I already have the starting values for C and B in vectors, and I need to estimate A and D? I am not how to do this in r using the lm function.

Thank you!

  • Apply `summary` function on your model and you shall get your estimates. – liuminzhao May 04 '19 at 21:11
  • Since I don't have a starting value for A and D I am getting errors. It says "non-numeric argument to mathematical function." When using nls you can input suggested starting values, but I don't believe you could do this with lm()? – Michael Lee May 04 '19 at 21:14
  • Are C and B vectors? Then it is as simple as summary(lm(log(C) ~ log(B))). Make sure that C and B are of class "numeric" (e.g. by using a correct data import). – Roland May 04 '19 at 21:42

1 Answers1

0

To minimize the residual sum of squares, just use the lm function. Your output will contain an intercept and a coefficient associated with any predictor variables. Thus:

lm(log(C) ~ log(B), data = my_data) 

You will predict log(C) as a linear combination of two parameters: the estimate of the "intercept" and the regression coefficient of log(B). For your purposes, this is log(A) and D respectively.

Dij
  • 1,318
  • 1
  • 7
  • 13