Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

In R I'm setting up a dataset to run a logistic regression on. I have two question regarding the selection of independent variables.

I will first briefly explain the dataset: The dataset contains of visits to a website. Some of these visits will eventually lead to a sale. Some will not. Each visit shows the time the user spend on the website and the number of pages they have viewed. If a user eventually buys the data entry also gets field called relevance and a field called recency (how long it takes until the order is made). Visits can come from multiple parties and several visits can lead to one sale (e.g. customer enters yesterday via an channel, and does not buy, next day customer enters via another channel and buys). I have the following questions:

  • the time spend on the website and the number of pages viewed are available for all visits (thus visits that turn into a visit that assisted to a sale (1) and visits that don’t (0). Visits that do not turn into a sale have no relevance and thus would get a value appointed of 0. Recency however is only measured for visits that eventually lead to a sale, thus only when the dependent variable has a value of 1. How to incorporate this?
  • Furthermore there are also some general measures which are channel specific and thus not row specific. (for instance: the conversion rate of visits to visits that contribute to a sale). I suppose it is not right to put this variable in on a per row basis, since these variables are not row specific. How to incorporate these in the model?
share|improve this question

1 Answer

up vote 3 down vote accepted

As far as the problem with recency goes, there is no way around it given your current system of assigning values. Recency is a simple function of purchase: no purchase, no value assigned for recency. Thus the variable is of no use in predicting purchase. Relevance has a similar problem, being the other side of the coin. One could make a single variable out of the recency and relevance values (if purchase, call this new variable 1; if no purchase, call it 0) and still this would contribute nothing to prediction of purchasing behavior.

In your last paragraph you ask about

the conversion rate of visits to visits that contribute to a sale.

This can be treated just like time spent or pages viewed--in other words, analyzed at the level of each individual. If you include it in a logistic regression with multiple predictors, you might want to use each individual's a) number of visits b) mean time spent per visit c) mean number of pages viewed per visit. Or you might substitute median for mean. Each of these can be included as main effects. You may also want to interact number of visits with the other two.

share|improve this answer
Thank you for your reply. The first part regarding the recency and relevance is clear. Regarding the last paragraph I do not completely understand what you mean. The records in the datafile are like this (simplified): image Thus tos and pageviews here are row specific. For Assist rate: this would be 100% for channel 1 (both involved in sale) and 50% for channel 2, these are not row specific. How to incorporate them? Can I just add them on a per row basis? So every row with channel 1 gets Ratio=100 and every row with channel 2 gets Ratio=50? – Max van der Heijden Jul 31 '12 at 13:09
I'm only partially understanding your problem, I fear, so I hope someone else chimes in. But you may need to look into more ways of dealing with person-record data sets (1 row per person) and data sets with multiple rows per person. You may end up wanting to convert the latter to the former, using as your predictors each person's average across rows on several variables, but assigning each person a single value when it comes to sale or no sale. I.e., if any of that person's rows resulted in a sale, Sale = 1. – rolando2 Jul 31 '12 at 23:46
Yes that would make sense, but the goal of this research is to find connections on a visit base level. So in this case I can at least use tos and pageviews since these are unique for every 'row' (i.e. visit) in the datafile. My final question is: can more general variables (i.e. assist rate which is number of visits that turn into assist per channel / total number of assists per channel) which are thus not unique per row be taken into account on a per row basis, so as an extra variable to run the logistic regression with? – Max van der Heijden Aug 1 '12 at 7:15
@Max In general, yes - but you need to make sure that that information isn't already contained in the regression. E.g., if you add the channel to each visit, the regression model adjust its estimates to account for each channel's proportion of visits that result in purchases. I put together a little example to help clarify. Similarly, I don't think that adding a variable like "average tos of visits from this channel" would add any new information if tos and channel were already in the model. – Matt Parker Aug 1 '12 at 20:29
But if you get into more complex efforts to model this, you ought to look into generalized multilevel models. That's a big step in complexity, but also in flexibility. You could nest visits within channels, or perhaps nest visits within users within channels. A good book for that is "Data Analysis Using Regression and Multilevel/Hierarchical Models" by Gelman and Hill - the first few pages of Chapter 11 lay out the point of multilevel models and when to use them pretty succinctly. – Matt Parker Aug 1 '12 at 20:36
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.