## --- Example: Real data (E-Cigarettes, id = 1) ---
dat <- structure(list(
id = c(1, 1, 1, 1, 1, 1),
x = c(2, 4, 8, 16, 32, 64),
y = c(3, 5, 5, 16, 17, 13),
target = c("alt", "alt", "alt", "alt", "alt", "alt"),
group = c("E-Cigarettes", "E-Cigarettes", "E-Cigarettes",
"E-Cigarettes", "E-Cigarettes", "E-Cigarettes")
), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
## Fit the default (exponentiated) cross-price form
fit_ecig <- fit_cp_nls(dat, equation = "exponentiated", return_all = TRUE)
summary(fit_ecig) # model summary
fit_ecig$method # backend actually used (e.g., "nls_multstart")
coef(fit_ecig$model) # parameter estimates: log10_qalone, I, log10_beta
Run the code above in your browser using DataLab