I have put toghether the following piece of code to do a dotplot displaying the coefficients and 95% CI from a fitted Logistic Regression model. Is uses the errbar() function in the 'Hmisc' package.

I am wondering if there is a way to display the actual coefficient value on top (or near) each corresponding dot in the returned chart.

Thank you in advance for any hint.

Best

Gm

Code:

`library(Hmisc)`

#get some data to work on

mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")

mydata$rank <- factor(mydata$rank)

fit <- glm(mydata, data=mydata, family=binomial(logit))

coeff <- cbind(coef = coef(fit), confint(fit))

df.coeff <- data.frame(names =dimnames(coeff)[[1]], cf=coeff[,1], lcl=coeff[,2], ucl=coeff[,3])

errbar(df.coeff$names, df.coeff$cf, df.coeff$ucl, df.coeff$lcl, main="Logistic regression: coefficients and 95% CI") #requires 'Hmisc' package

abline(v=0, lty=2)

You elicit experts to give their 95% confidence interval estimates for the random variables representing savings(materials, labor, and production) and production level:

Maintenance savings (MS): $10 to $20 per unit

Labor savings (LS): -$2 to $8 per unit

Raw materials savings (RMS): $3 to $9 per unit

Production level (PL): 15,000 to 35,000 units per year

Thus, your annual savings will be random variable that is equal to:

(MS + LS + RMS) × PL - $400,000.

Use R to create a representative sample (n = 100,000) of savings outcomes (you should use normal distributions when modeling the experts opinions). What is your estimate for the 5% "Value at Risk" estimate (i.e. use the quantile function with probs = 0.05)? This represents the amount of savings that you expect to exceed 95% of the time. Round your answer to the nearest whole dollar (note: if your answer is negative, be sure to include the negative sign).

Thanks! ]]>

I am fairly at a beginners level in R Studio and I wonder if someone can help me out. I have created this simple dataframe to explain my intention.

(see attachment DATAFRAME)

So what I want to know is what kind of combinations of favorite animals exist in the rows and create a matrix of this. F.e. Bird and Horse are called twice, one time in subject 2 and one time in subject 4. Blank lines exist in the dataframe, because some animals do not 'count' and have been erased.

I want to create this matrix.

(see attachment MATRIX)

Anyone can help me out a little?