0

I am trying to predict a continuous variable using the code I made to predict binary variables. I don't understand if there is something else in the code that I am suppose to change, but this is where I get an error.

osmos is the continuous variable that has real values from (0-40.435).

I usually use binary values (0 or 1) for this specific code but I don't know what to change to apply the same concept to predict osmos.

The excel sheet is set up with osmos in the first column and variable that will be used to predict in the second column. Both columns contain continuous variables. The expected output is r squared and p values for the prediction.

# logistic regression model
library(nnet)
mymodel <- multinom(variable, na.action=na.omit, data=newdata)


# misclassification rate
p <- predict(mymodel, newdata)
tab <- table(p, newdata$osmos)
tab

sum(diag(tab))/sum(tab)
table(newdata$osmos)

# model performance evaluation
library(ROCR)
pred <- predict(mymodel, newdata, type = 'prob')
head(pred)
head(newdata)
hist(pred)

pred <- prediction(pred, newdata$osmos)
eval <- performance(pred, "acc")
plot(eval)

But I keep getting the error

Error in prediction(pred, newdata$osmos) : 
Number of cross-validation runs must be equal for predictions and labels.
person
  • 1
  • 1
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. We don't know what your data looks like. Remove whatever code is not relevant to your specific question. And if you need help choosing the appropriate model for your data, that's really a statistical question which would get better answers on [stats.se]. You seem to make your continuous `fit` model with `lm()` but then never actually use it. – MrFlick Jun 04 '18 at 17:49
  • @MrFlick I revised the description. Does it make more sense? The input osmos and variable are from a data set in an excel sheet, they are both continuous variables – person Jun 04 '18 at 20:10
  • Most of this doesn't make sense for a continuous value. Like what would the `table()` look like for a continuous value? That only makes sense for discrete. Same goes for the ROC. That doesn't make much sense for a continuous value. I suggest you consult a statistician about what your goals for such an analysis even are. – MrFlick Jun 04 '18 at 20:14

0 Answers0