maurizio-manuguerra / ordinalCont

Ordinal regression analysis for continuous scales
0 stars 1 forks source link

Predict new data fails #1

Open dnacombo opened 3 years ago

dnacombo commented 3 years ago

Hi, I'd be happy to use your package but I'm having the following difficulty:

I'm using ocm on a dataset where I try to predict a VAS [0-100] in different sessions. My model is as simple as Passage_of_Time ~ ClockDuration with the following df test.csv

m <- ocm(Passage_of_Time ~ ClockDuration, data = testtostat)
Ext.iters   Int.iters   lambda      Convergence (<0.01)
1        19          0.0001882339        1.0002          
2        8       0.0003580664        0.9022          
3        8       0.0004971071        0.3883          
4        6       0.000593285         0.1935          
5        5       0.0006608927        0.114       
6        4       0.0006956968        0.0527          
7        3       0.000735787         0.0576          
8        12          0.0009614459        0.3067          
9        13          0.001160391         0.2069          
10       4       0.001281713         0.1046          
11       4       0.001365607         0.0655          
12       4       0.001421852         0.0412          
13       2       0.001459035         0.0262          
14       1       0.001495745         0.0252          
15       1       0.001518871         0.0155          
16       1       0.001538802         0.0131          
17       1       0.001547643         0.0057          
Warning message:
In ocm(Passage_of_Time ~ ClockDuration, data = testtostat) :
  The range of the data [0, 100] is used to scale data to the interval (0,1).

Now

g <- expand_grid(ClockDuration = seq(0,300,by = 10))
em <- predict(m, newdata = g)
Error in `[<-.data.frame`(`*tmp*`, internames, value = list(ClockDuration = c(0,  : 
  replacement element 1 has 31 rows, need 100

It seems like this is not implemented. Can you help?

maurizio-manuguerra commented 3 years ago

Hi,

Yes I can. There is an unpublished version of the package that solves the problems with the predict method. I will publish it asap, but it stil requires some work to be acceptable on the CRAN. I’m attaching the package to this email, please be sure to load this instead of the one from CRAN. Verify with:

packageVersion("ordinalCont") [1] ‘2.0.5’

For reasons, currently the predict method needs a data frame with the same variables as in the one used in the fit. You will need to add the variable Passage_of_Time to g (pls note, it won’t be used to predict values of the response variable, so you can use any value, eg 50):

g$Passage_of_Time = rep(50,31)

After this, your command works:

em <- predict(m, newdata = g)

Kind regards, Maurizio

On 21 Sep 2021, at 2:03 pm, Maximilien Chaumon @.***> wrote:

em <- predict(m, newdata = g)

ls-dewberry commented 1 month ago

Did this fix the issue? If so, can I also have the unpublished version of the package? I am on 2.0.2 right now.

maurizio-manuguerra-mq commented 1 month ago

Hi, I haven't published the new version yet. If you contact me privately, I can send a copy to you. My email should be visible on github.