R Bass Diffusion Using nls() with predictors
up vote
0
down vote
favorite
How do researchers include additional predictors/independent variables when estimating the bass curve? I've read that Bass diffusion does not accept additional predictors, but yet I see papers claiming that they do. With that said, is this possible with the nls() function in R? I have created some toy data and an example without the extra predictor, advert.
TIA
library(data.table)
options(scipen=999)
rm(list=ls())
df <- data.table(
year = seq(1979, 1988, by=1),
T = 1:10,
sales = c(840, 1470, 2110, 4000, 7590, 10950, 10530, 9470, 7790, 5890),
advert = c(100,100,100,100,100,75,75,50,50,25))
df[, sales_cumulative := cumsum(sales)]
est_bass <- nls(sales ~ M*(((P+Q)^2/P)*exp(-(P+Q)*T))/(1+(Q/P)*exp(-(P+Q)*T))^2,
# add P and Q below
start=c(list(M = 60630, P = 0.03, Q = 0.38)),
data = df)
coef(est_bass)
# P, Q, M parameters
m = coef(est_bass)[1]
p = coef(est_bass)[2]
q = coef(est_bass)[3]
Tdelt <- (1:100)/10
ngete <- exp(-(p+q)*Tdelt)
# plot pdf
par(mfrow=c(1,2))
Bpdf <- m*((p+q)^2/p)*ngete/(1+(q/p)*ngete)^2
plot(Tdelt, Bpdf, xlab = "Year from 1979", ylab = "Sales per year", type = "l")
points(df$T, df$sales) # compare to original
# plot cdf
Bcdf <- m*(1-ngete)/(1+(q/p)*ngete)
plot(Tdelt, Bcdf, xlab = "Year from 1979", ylab = "Cumulative sales", type = "l")
points(df$T, df$sales_cumulative)
r nls
add a comment |
up vote
0
down vote
favorite
How do researchers include additional predictors/independent variables when estimating the bass curve? I've read that Bass diffusion does not accept additional predictors, but yet I see papers claiming that they do. With that said, is this possible with the nls() function in R? I have created some toy data and an example without the extra predictor, advert.
TIA
library(data.table)
options(scipen=999)
rm(list=ls())
df <- data.table(
year = seq(1979, 1988, by=1),
T = 1:10,
sales = c(840, 1470, 2110, 4000, 7590, 10950, 10530, 9470, 7790, 5890),
advert = c(100,100,100,100,100,75,75,50,50,25))
df[, sales_cumulative := cumsum(sales)]
est_bass <- nls(sales ~ M*(((P+Q)^2/P)*exp(-(P+Q)*T))/(1+(Q/P)*exp(-(P+Q)*T))^2,
# add P and Q below
start=c(list(M = 60630, P = 0.03, Q = 0.38)),
data = df)
coef(est_bass)
# P, Q, M parameters
m = coef(est_bass)[1]
p = coef(est_bass)[2]
q = coef(est_bass)[3]
Tdelt <- (1:100)/10
ngete <- exp(-(p+q)*Tdelt)
# plot pdf
par(mfrow=c(1,2))
Bpdf <- m*((p+q)^2/p)*ngete/(1+(q/p)*ngete)^2
plot(Tdelt, Bpdf, xlab = "Year from 1979", ylab = "Sales per year", type = "l")
points(df$T, df$sales) # compare to original
# plot cdf
Bcdf <- m*(1-ngete)/(1+(q/p)*ngete)
plot(Tdelt, Bcdf, xlab = "Year from 1979", ylab = "Cumulative sales", type = "l")
points(df$T, df$sales_cumulative)
r nls
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How do researchers include additional predictors/independent variables when estimating the bass curve? I've read that Bass diffusion does not accept additional predictors, but yet I see papers claiming that they do. With that said, is this possible with the nls() function in R? I have created some toy data and an example without the extra predictor, advert.
TIA
library(data.table)
options(scipen=999)
rm(list=ls())
df <- data.table(
year = seq(1979, 1988, by=1),
T = 1:10,
sales = c(840, 1470, 2110, 4000, 7590, 10950, 10530, 9470, 7790, 5890),
advert = c(100,100,100,100,100,75,75,50,50,25))
df[, sales_cumulative := cumsum(sales)]
est_bass <- nls(sales ~ M*(((P+Q)^2/P)*exp(-(P+Q)*T))/(1+(Q/P)*exp(-(P+Q)*T))^2,
# add P and Q below
start=c(list(M = 60630, P = 0.03, Q = 0.38)),
data = df)
coef(est_bass)
# P, Q, M parameters
m = coef(est_bass)[1]
p = coef(est_bass)[2]
q = coef(est_bass)[3]
Tdelt <- (1:100)/10
ngete <- exp(-(p+q)*Tdelt)
# plot pdf
par(mfrow=c(1,2))
Bpdf <- m*((p+q)^2/p)*ngete/(1+(q/p)*ngete)^2
plot(Tdelt, Bpdf, xlab = "Year from 1979", ylab = "Sales per year", type = "l")
points(df$T, df$sales) # compare to original
# plot cdf
Bcdf <- m*(1-ngete)/(1+(q/p)*ngete)
plot(Tdelt, Bcdf, xlab = "Year from 1979", ylab = "Cumulative sales", type = "l")
points(df$T, df$sales_cumulative)
r nls
How do researchers include additional predictors/independent variables when estimating the bass curve? I've read that Bass diffusion does not accept additional predictors, but yet I see papers claiming that they do. With that said, is this possible with the nls() function in R? I have created some toy data and an example without the extra predictor, advert.
TIA
library(data.table)
options(scipen=999)
rm(list=ls())
df <- data.table(
year = seq(1979, 1988, by=1),
T = 1:10,
sales = c(840, 1470, 2110, 4000, 7590, 10950, 10530, 9470, 7790, 5890),
advert = c(100,100,100,100,100,75,75,50,50,25))
df[, sales_cumulative := cumsum(sales)]
est_bass <- nls(sales ~ M*(((P+Q)^2/P)*exp(-(P+Q)*T))/(1+(Q/P)*exp(-(P+Q)*T))^2,
# add P and Q below
start=c(list(M = 60630, P = 0.03, Q = 0.38)),
data = df)
coef(est_bass)
# P, Q, M parameters
m = coef(est_bass)[1]
p = coef(est_bass)[2]
q = coef(est_bass)[3]
Tdelt <- (1:100)/10
ngete <- exp(-(p+q)*Tdelt)
# plot pdf
par(mfrow=c(1,2))
Bpdf <- m*((p+q)^2/p)*ngete/(1+(q/p)*ngete)^2
plot(Tdelt, Bpdf, xlab = "Year from 1979", ylab = "Sales per year", type = "l")
points(df$T, df$sales) # compare to original
# plot cdf
Bcdf <- m*(1-ngete)/(1+(q/p)*ngete)
plot(Tdelt, Bcdf, xlab = "Year from 1979", ylab = "Cumulative sales", type = "l")
points(df$T, df$sales_cumulative)
r nls
r nls
asked Nov 10 at 2:47
yokota
591520
591520
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235606%2fr-bass-diffusion-using-nls-with-predictors%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown