Using logged variable for prediction - help!

Hi all,

Super new to R and finding it fairly daunting since I was an SPSS girl many years ago. My current stats assignment had us fit a model for some data about avocados. Total.Volume (sales), AveragePrice and Type (organic versus regular). We had to log the model (AveragePriceType) as the data was fairly skewed which was fine. However when I come to try and insert some figures for prediction I run into trouble with the R code.

Inserting $0.8 US as an average price to predict total sales by each type was fine but I'm struggling to find the right code to quantify the effect of $0.10 US increase in average price on sales - help!

AveragePriceType.fit2 = lm(log(Total.Volume) ~ AveragePrice + Type, data = avocado.df)
summary(AveragePriceType.fit2)

NewAveragePrice = data.frame(AveragePrice = c(0.8), Type = c("Organic"))

predict(AveragePriceType.fit2, newdata = NewAveragePrice)

predict(AveragePriceType.fit2, newdata = NewAveragePrice, interval = "confidence")

NewAveragePrice = data.frame(AveragePrice = c(0.8), Type = c("Regular"))

predict(AveragePriceType.fit2, newdata = NewAveragePrice)

predict(AveragePriceType.fit2, newdata = NewAveragePrice, interval = "confidence")

I do not see a problem with your code. What happens when you set the AveragePrice in NewAveragePrice to 0.1 and run it through the predict() function?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.