performance - R: Speed up multiple lm() -
i want estimate parameters of non linear model. the model equation z = * exp(- * x) + b * exp(- b * y) + c x , y predictors a, b, a, b parameters estimate what did transform model linear problem doing exponential transformation before doing linear regression: for a , b between 0 , 1, compute exp_x = exp(- * x) , exp_y = exp(- b * y) i linear regression z ~ exp_x + exp_y it works can see in simulation x = 1:10 y = 1:10 combination = expand.grid(x = x, y = y) df = data.frame( x = combination$x, y = combination$y, z = 2 * exp(-0.3 * combination$x) + 5 * exp(-0.6 * combination$y) + rnorm(n = 100, mean = 0, sd = 0.1 ) ) a_hat = 0 b_hat = 0 best_ols = null best_rsquared = 0 (a in seq(0.01, 1, 0.01)){ (b in seq(0.01, 1, 0.01)){ df$exp_x = exp(- * df$x) df$exp_y = exp(- b *df$y) ols = lm(data = df, formula = z ~ exp_x + exp_y) r_squared = summary(ols)$r.squared if (r_squared > best_rsquared){ best_rsquared =...