Description Usage Format Details Source Examples

Monthly data on physician detailing (sales calls). 23 months of data for each of 1000 physicians; includes physician covariates.

1 |

The `detailing`

object is a list containing two data frames, `counts`

and `demo`

.

In the `counts`

data frame:

...`$id ` | identifies the physician |

...`$scrips ` | the number of new presectiptions ordered by the physician for the drug detailed |

...`$detailing ` | the number of sales called made to each physician per month |

...`$lagged_scripts` | scrips value for prior month |

In the `demo`

data frame:

...`$$id ` | identifies the physician |

...`$generalphys ` | dummy for if doctor is a "general practitioner" |

...`$specialist ` | dummy for if the physician is a specialist in the theraputic class for which the drug is intended |

...`$mean_samples` | the mean number of free drug samples given the doctor over the sample period |

Manchanda, Puneet, Pradeep Chintagunta, and Peter Rossi (2004), "Response Modeling with Non-Random Marketing Mix Variables," *Journal of Marketing Research* 41, 467–478.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | ```
data(detailing)
cat(" table of Counts Dep Var", fill=TRUE)
print(table(detailing$counts[,2]))
cat(" means of Demographic Variables",fill=TRUE)
mat = apply(as.matrix(detailing$demo[,2:4]), 2, mean)
print(mat)
## example of processing for use with 'rhierNegbinRw'
if(0) {
data(detailing)
counts = detailing$counts
Z = detailing$demo
# Construct the Z matrix
Z[,1] = 1
Z[,2] = Z[,2] - mean(Z[,2])
Z[,3] = Z[,3] - mean(Z[,3])
Z[,4] = Z[,4] - mean(Z[,4])
Z = as.matrix(Z)
id = levels(factor(counts$id))
nreg = length(id)
nobs = nrow(counts$id)
regdata = NULL
for (i in 1:nreg) {
X = counts[counts[,1] == id[i], c(3:4)]
X = cbind(rep(1, nrow(X)), X)
y = counts[counts[,1] == id[i], 2]
X = as.matrix(X)
regdata[[i]] = list(X=X, y=y)
}
rm(detailing, counts)
cat("Finished reading data", fill=TRUE)
fsh()
Data = list(regdata=regdata, Z=Z)
nvar = ncol(X) # Number of X variables
nz = ncol(Z) # Number of Z variables
deltabar = matrix(rep(0,nvar*nz), nrow=nz)
Vdelta = 0.01*diag(nz)
nu = nvar+3
V = 0.01*diag(nvar)
a = 0.5
b = 0.1
Prior = list(deltabar=deltabar, Vdelta=Vdelta, nu=nu, V=V, a=a, b=b)
R = 10000
keep = 1
s_beta = 2.93/sqrt(nvar)
s_alpha = 2.93
c = 2
Mcmc = list(R=R, keep=keep, s_beta=s_beta, s_alpha=s_alpha, c=c)
out = rhierNegbinRw(Data, Prior, Mcmc)
## Unit level mean beta parameters
Mbeta = matrix(rep(0,nreg*nvar), nrow=nreg)
ndraws = length(out$alphadraw)
for (i in 1:nreg) { Mbeta[i,] = rowSums(out$Betadraw[i,,])/ndraws }
cat(" Deltadraws ", fill=TRUE)
summary(out$Deltadraw)
cat(" Vbetadraws ", fill=TRUE)
summary(out$Vbetadraw)
cat(" alphadraws ", fill=TRUE)
summary(out$alphadraw)
## plotting examples
if(0){
plot(out$betadraw)
plot(out$alphadraw)
plot(out$Deltadraw)
}
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.