{"word_count": 424, "character_count": 3241}
On http://www.bakadesuyo.com, there was recently an interesting discussion about infidelity, the key question being "at what ages are men and women most likely to have affairs?" The discussion is based on some graphs, e.g.The source is a paper by Donald Cox. Based on a sample of 36 men and 22 women 3,432 respondent (NHSLS dataset) . And to be honest, I have been surprised by the shape of the curves. Especially for men... In order to compare, it is possible to use another dataset that can be found in R,&#62; library(Ecdat)&#62; data(Fair)&#62; tail(Fair)sex age   ym child religious education occupation596   male  47 15.0   yes         3        16          4597   male  22  1.5   yes         1        12          2598 female  32 10.0   yes         2        18          5599   male  32 10.0   yes         2        17          6600   male  22  7.0   yes         3        18          6601 female  32 15.0   yes         3        14          1rate nbaffairs596    2         7597    5         1598    4         7599    5         2600    2         2601    5         1with 601 observations (from Fair (1977)). It is possible to run a Poisson regression to describe the number of affairs in the past year. E.g for men&#62; library(splines)&#62; regM=glm(nbaffairs~bs(age),family=poisson,+ data=Fair[Fair$sex=="male",])&#62; a=seq(20,60)&#62; N=predict(regM,newdata=data.frame(age=a),type="response")&#62; plot(a,N,type="l",lwd=2,col="red")or for women,&#62; regF=glm(nbaffairs~bs(age),family=poisson,+ data=Fair[Fair$sex=="female",])&#62; N=predict(regF,newdata=data.frame(age=a),type="response")&#62; plot(a,N,type="l",lwd=2,col="red",lty=2)On that (larger) dataset, we obtain curves that are more intuitive... But maybe the Poisson distribution is not an appropriate model. For instance, having no affairs do not mean that the person did not want to... So perhaps, a more interesting model would be a Poisson model with a zero-inflation, i.e. some people are honest and do not want to have affairs (and appear as 0), while some do want to have some affairs, and the number of affairs is Poisson distributed (and can take the value 0). If we focus on people wo do not want to have affairs, the model (and the prediction) is the following, where we plot the probability of not being interested in having an affair,&#62; library(pscl)&#62; regM0=zeroinfl(nbaffairs~bs(age)|bs(age),family=poisson,+ link="logit",data=Fair[Fair$sex=="male",])&#62; N0=predict(regM0,newdata=data.frame(age=a),type="zero")&#62; plot(a,N0,type="l",lwd=2,col="blue")For those willing to have an affair, here is the parameter of the Poisson distribution of the number of affairs,&#62; Nc=predict(regM0,newdata=data.frame(age=a),type="count")&#62; plot(a,Nc,type="l",lwd=2,col="purple")The same can be done for women, with the probability of no-willing to have an affair,and to Poisson rate for women willing to have an affair,If we focus on people willing to have an affair, the curves are the following,i.e. men below 40 have more interested, but after 40, the probability drops, while women are still more and more likely to be willing to have an affair. On the other hand, young women having affairs might be less, but they usually have much more affairs than men...